88import android .graphics .drawable .BitmapDrawable ;
99import android .net .Uri ;
1010import androidx .annotation .NonNull ;
11+
12+ import android .text .TextUtils ;
1113import android .view .View ;
1214
15+ import androidx .annotation .Nullable ;
1316import androidx .cardview .widget .CardView ;
1417
1518import com .vansuita .materialabout .R ;
@@ -1120,6 +1123,7 @@ public AboutBuilder addSkypeLink(String phone) {
11201123 * @return the same {@link AboutBuilder} instance
11211124 */
11221125 @ NonNull
1126+ @ Deprecated
11231127 public AboutBuilder addWhatsappLink (int name , int phone ) {
11241128 return addWhatsappLink (context .getString (name ), context .getString (phone ));
11251129 }
@@ -1131,10 +1135,65 @@ public AboutBuilder addWhatsappLink(int name, int phone) {
11311135 * @return the same {@link AboutBuilder} instance
11321136 */
11331137 @ NonNull
1138+ @ Deprecated
11341139 public AboutBuilder addWhatsappLink (String name , String phone ) {
11351140 return addLink (R .mipmap .whatsapp , R .string .whastapp , util .openAddContact (name , phone ));
11361141 }
11371142
1143+ /**
1144+ * Starts a new direct Whatsapp chat
1145+ *
1146+ * @param phone any phone number
1147+ * @return the same {@link AboutBuilder} instance
1148+ */
1149+ @ NonNull
1150+ public AboutBuilder addWhatsAppDirectChat (int phone ) {
1151+ return addWhatsAppDirectChat (context .getString (phone ));
1152+ }
1153+
1154+ /**
1155+ * Starts a new direct Whatsapp chat
1156+ *
1157+ * @param phone any phone number
1158+ * @return the same {@link AboutBuilder} instance
1159+ *
1160+ */
1161+ @ NonNull
1162+ public AboutBuilder addWhatsAppDirectChat (@ NonNull String phone ) {
1163+ return addWhatsAppDirectChat (phone , null );
1164+ }
1165+
1166+ /**
1167+ * Starts a new direct Whatsapp chat with a default message
1168+ *
1169+ * @param phone any phone number
1170+ * @param message the message to pre-fill
1171+ * @return the same {@link AboutBuilder} instance
1172+ */
1173+ @ NonNull
1174+ public AboutBuilder addWhatsAppDirectChat (int phone , int message ) {
1175+ return addWhatsAppDirectChat (context .getString (phone ), context .getString (message ));
1176+ }
1177+
1178+ /**
1179+ * Starts a new direct Whatsapp chat with a default message
1180+ *
1181+ * @link https://faq.whatsapp.com/general/chats/how-to-use-click-to-chat
1182+ * @param phone any phone number
1183+ * @param message the message to pre-fill
1184+ * @throws IllegalArgumentException Phone number should be in international format and not contain any brackets, leading zeroes, or dashes.
1185+ * @return the same {@link AboutBuilder} instance
1186+ *
1187+ */
1188+ @ NonNull
1189+ public AboutBuilder addWhatsAppDirectChat (@ NonNull String phone , @ Nullable String message ) {
1190+ if (!TextUtils .isDigitsOnly (phone ) || phone .startsWith ("0" )){
1191+ throw new IllegalArgumentException ("Phone number should be in international format and not contain any brackets, leading zeroes, or dashes." );
1192+ }
1193+
1194+ return addLink (R .mipmap .whatsapp , R .string .whastapp , context .getString (R .string .uri_whatsapp , phone , message == null ? "" : message ));
1195+ }
1196+
11381197 /**
11391198 * Adds a Android link on the links section
11401199 *
0 commit comments