-
Notifications
You must be signed in to change notification settings - Fork 208
/
AboutBuilder.java
2171 lines (1952 loc) · 63.5 KB
/
AboutBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package com.vansuita.materialabout.builder;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.cardview.widget.CardView;
import androidx.core.text.HtmlCompat;
import com.vansuita.materialabout.R;
import com.vansuita.materialabout.util.ColorUtil;
import com.vansuita.materialabout.util.IconUtil;
import com.vansuita.materialabout.util.IntentUtil;
import com.vansuita.materialabout.views.AboutView;
import java.util.LinkedList;
import static com.vansuita.materialabout.R.mipmap.share;
/**
* Used to build an {@link AboutView}.
*/
@SuppressWarnings({"WeakerAccess", "unused"})
public final class AboutBuilder {
private Context context;
private IntentUtil util;
private CharSequence name;
private CharSequence subTitle;
private CharSequence brief;
private CharSequence appName;
private CharSequence appTitle;
private Bitmap photo;
private Bitmap cover;
private Bitmap appIcon;
private int nameColor;
private int subTitleColor;
private int briefColor;
private int iconColor;
private int backgroundColor;
private boolean showDivider = true;
private int dividerColor = 0;
private int dividerHeight = 4;
private int dividerDashWidth = 15;
private int dividerDashGap = 15;
private boolean linksAnimated = true;
private int linksColumnsCount = 5;
private int actionsColumnsCount = 2;
private boolean wrapScrollView = false;
private boolean showAsCard = true;
private LinkedList<Item> links = new LinkedList<>();
private LinkedList<Item> actions = new LinkedList<>();
/**
* @deprecated Used {@link #with(Context)} instead.
*/
@Deprecated
AboutBuilder(@NonNull Context context) {
this.context = context;
this.util = new IntentUtil(context);
}
@NonNull
public static AboutBuilder with(@NonNull Context context) {
//noinspection deprecation
return new AboutBuilder(context);
}
@NonNull
private String getApplicationID() {
return context.getPackageName();
}
@NonNull
private PackageInfo getPackageInfo() throws PackageManager.NameNotFoundException {
return context.getPackageManager().getPackageInfo(getApplicationID(), 0);
}
/**
* Gets the id of the last action added
*/
public int getLastActionId() {
return getLastAction().getId();
}
/**
* Gets the last action item added
*/
@NonNull
public Item getLastAction() {
return actions.getLast();
}
/**
* Gets the id of the last link added
*/
public int getLastLinkId() {
return getLastLink().getId();
}
/**
* Gets the last link item added
*/
@NonNull
public Item getLastLink() {
return links.getLast();
}
/**
* Sets the developer name
*
* @param text the name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setName(@Nullable CharSequence text) {
this.name = text;
return this;
}
/**
* Sets the developer name
*
* @param text the name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setName(@StringRes int text) {
return setName(context.getString(text));
}
/**
* Sets the sub title. It will be place below the developer name
*
* @param text the sub title
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setSubTitle(@Nullable CharSequence text) {
this.subTitle = text;
return this;
}
/**
* Sets the sub title. It will be place below the developer name
*
* @param text the sub title
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setSubTitle(@StringRes int text) {
return setSubTitle(context.getString(text));
}
/**
* Sets a personal brief
*
* @param text the brief
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setBrief(@Nullable CharSequence text) {
this.brief = text;
return this;
}
/**
* Sets a personal brief
*
* @param text the brief
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setBrief(@StringRes int text) {
return setBrief(context.getString(text));
}
/**
* Sets the app name
*
* @param text the app name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppName(@Nullable CharSequence text) {
this.appName = text;
return this;
}
/**
* Sets the app name
*
* @param text the app name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppName(@StringRes int text) {
return setAppName(context.getString(text));
}
/**
* Sets the app title
*
* @param text the title
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppTitle(@Nullable CharSequence text) {
this.appTitle = text;
return this;
}
/**
* Sets the app title
*
* @param text the title
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppTitle(@StringRes int text) {
return setAppTitle(context.getString(text));
}
/**
* Displays the app version below the app name
*
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setVersionNameAsAppSubTitle() {
try {
return setAppTitle(context.getString(com.vansuita.materialabout.R.string.version, getPackageInfo().versionName));
} catch (PackageManager.NameNotFoundException e) {
return setAppTitle(R.string.error);
}
}
/**
* Sets the developer photo
*
* @param photo the image
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setPhoto(@Nullable Bitmap photo) {
this.photo = photo;
return this;
}
/**
* Sets the developer photo
*
* @param photo the image
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setPhoto(@DrawableRes int photo) {
return setPhoto(IconUtil.getBitmap(context, photo));
}
/**
* Sets the developer photo
*
* @param photo the image
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setPhoto(@Nullable BitmapDrawable photo) {
return setPhoto(IconUtil.getBitmap(photo));
}
/**
* Sets a about cover
*
* @param cover the image
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setCover(@Nullable Bitmap cover) {
this.cover = cover;
return this;
}
/**
* Sets a about cover
*
* @param cover the image
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setCover(@DrawableRes int cover) {
return setCover(IconUtil.getBitmap(context, cover));
}
/**
* Sets a about cover
*
* @param cover the image
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setCover(@Nullable BitmapDrawable cover) {
return setCover(IconUtil.getBitmap(cover));
}
/**
* Sets an icon to display as app icon
*
* @param icon the app icon
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppIcon(@Nullable Bitmap icon) {
this.appIcon = icon;
return this;
}
/**
* Sets an icon to display as app icon
*
* @param icon the app icon
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppIcon(@DrawableRes int icon) {
return setAppIcon(IconUtil.getBitmap(context, icon));
}
/**
* Sets an icon to display as app icon
*
* @param icon the app icon
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setAppIcon(@Nullable BitmapDrawable icon) {
return setAppIcon(IconUtil.getBitmap(icon));
}
/**
* Sets the name text color
*
* @param color the color resource or the real color.
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setNameColor(@ColorRes int color) {
this.nameColor = ColorUtil.get(context, color);
return this;
}
/**
* Sets the sub title text color
*
* @param color the color resource or the real color.
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setSubTitleColor(@ColorRes int color) {
this.subTitleColor = ColorUtil.get(context, color);
return this;
}
/**
* Sets the brief text color
*
* @param color the color resource or the real color.
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setBriefColor(@ColorRes int color) {
this.briefColor = ColorUtil.get(context, color);
return this;
}
/**
* Sets the divider color
*
* @param color the color resource or the real color.
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setDividerColor(@ColorRes int color) {
this.dividerColor = ColorUtil.get(context, color);
return this;
}
/**
* Sets the icons color
*
* @param color the color resource or the real color.
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setIconColor(@ColorRes int color) {
this.iconColor = ColorUtil.get(context, color);
return this;
}
/**
* Sets the about view background color
*
* @param color the color resource or the real color.
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setBackgroundColor(@ColorRes int color) {
this.backgroundColor = ColorUtil.get(context, color);
return this;
}
/**
* Sets the maximum number of columns for the actions section
*
* @param count number of columns
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setActionsColumnsCount(@IntRange(from = 0) int count) {
this.actionsColumnsCount = count;
return this;
}
/**
* Sets the maximum number of columns for the links section
*
* @param count number of columns
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setLinksColumnsCount(@IntRange(from = 0) int count) {
this.linksColumnsCount = count;
return this;
}
/**
* Sets an animation when displaying the actions
*
* @param animate true if you want it
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setLinksAnimated(boolean animate) {
this.linksAnimated = animate;
return this;
}
/**
* Sets the divider height
*
* @param dividerHeight size of the height
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setDividerHeight(int dividerHeight) {
this.dividerHeight = dividerHeight;
return this;
}
/**
* Sets the divider dash width
*
* @param dividerDashWidth size of the width
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setDividerDashWidth(int dividerDashWidth) {
this.dividerDashWidth = dividerDashWidth;
return this;
}
/**
* Sets the divider dash gap
*
* @param dividerDashGap size of the gap
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setDividerDashGap(int dividerDashGap) {
this.dividerDashGap = dividerDashGap;
return this;
}
/**
* Displays a divider line between the about sections
*
* @param showDivider true if you want it
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setShowDivider(boolean showDivider) {
this.showDivider = showDivider;
return this;
}
/**
* Places the about view inside a {@link android.widget.ScrollView}
*
* @param wrapScrollView true if you want to wrap
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder setWrapScrollView(boolean wrapScrollView) {
this.wrapScrollView = wrapScrollView;
return this;
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param onClickListener the click callback
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@Nullable CharSequence label,@Nullable View.OnClickListener onClickListener) {
links.add(new Item(icon, label, onClickListener));
return this;
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param intent the action intent
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@Nullable CharSequence label,@Nullable Intent intent) {
return addLink(icon, label, util.clickIntent(intent));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param uri the action uri
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@Nullable CharSequence label,@NonNull Uri uri) {
return addLink(icon, label, util.clickUri(uri));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@Nullable CharSequence label,@NonNull String url) {
return addLink(icon, label, Uri.parse(url));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param onClickListener the click callback
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@StringRes int label,@Nullable View.OnClickListener onClickListener) {
return addLink(icon, context.getString(label), onClickListener);
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param intent the action intent
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@StringRes int label,@Nullable Intent intent) {
return addLink(icon, label, util.clickIntent(intent));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param uri the action uri
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@StringRes int label,@NonNull Uri uri) {
return addLink(icon, label, util.clickUri(uri));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable Bitmap icon,@StringRes int label,@NonNull String url) {
return addLink(icon, label, Uri.parse(url));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param onClickListener the click callback
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@StringRes int label,@Nullable View.OnClickListener onClickListener) {
return addLink(IconUtil.getBitmap(context, icon), context.getString(label), onClickListener);
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param intent the action intent
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@StringRes int label,@Nullable Intent intent) {
return addLink(icon, label, util.clickIntent(intent));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param uri the action uri
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@StringRes int label,@NonNull Uri uri) {
return addLink(icon, label, util.clickUri(uri));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@StringRes int label,@NonNull String url) {
return addLink(icon, label, Uri.parse(url));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param onClickListener the click callback
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@Nullable CharSequence label,@Nullable View.OnClickListener onClickListener) {
return addLink(IconUtil.getBitmap(context, icon), label, onClickListener);
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param intent the action intent
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@Nullable CharSequence label,@Nullable Intent intent) {
return addLink(icon, label, util.clickIntent(intent));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param uri the action uri
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@Nullable CharSequence label,@NonNull Uri uri) {
return addLink(icon, label, util.clickUri(uri));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@DrawableRes int icon,@Nullable CharSequence label,@NonNull String url) {
return addLink(icon, label, Uri.parse(url));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param onClickListener the click callback
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@StringRes int label,@Nullable View.OnClickListener onClickListener) {
return addLink(IconUtil.getBitmap(icon), context.getString(label), onClickListener);
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param intent the action intent
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@StringRes int label,@Nullable Intent intent) {
return addLink(icon, label, util.clickIntent(intent));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param uri the action uri
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@StringRes int label,@NonNull Uri uri) {
return addLink(icon, label, util.clickUri(uri));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@StringRes int label,@NonNull String url) {
return addLink(icon, label, Uri.parse(url));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param onClickListener the click callback
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@Nullable CharSequence label,@Nullable View.OnClickListener onClickListener) {
return addLink(IconUtil.getBitmap(icon), label, onClickListener);
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param intent the action intent
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@Nullable CharSequence label,@Nullable Intent intent) {
return addLink(icon, label, util.clickIntent(intent));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param uri the action uri
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@Nullable CharSequence label,@NonNull Uri uri) {
return addLink(icon, label, util.clickUri(uri));
}
/**
* Adds an link on the links section.
*
* @param icon the action icon
* @param label the action title
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addLink(@Nullable BitmapDrawable icon,@Nullable String label,@NonNull String url) {
return addLink(icon, label, Uri.parse(url));
}
/**
* Adds a GitHub profile link on the links section
*
* @param user a GitHub user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addGitHubLink(@StringRes int user) {
return addGitHubLink(context.getString(user));
}
/**
* Adds a GitHub profile link on the links section
*
* @param user a GitHub user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addGitHubLink(@NonNull String user) {
return addLink(R.mipmap.github, R.string.github, util.uri(R.string.url_github, user));
}
/**
* Adds a Bitbucket profile link on the links section
*
* @param user a Bitbucket user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addBitbucketLink(@StringRes int user) {
return addBitbucketLink(context.getString(user));
}
/**
* Adds a Bitbucket profile link on the links section
*
* @param user a Bitbucket user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addBitbucketLink(@NonNull String user) {
return addLink(R.mipmap.bitbucket, R.string.bitbucket, util.uri(R.string.url_bitbucket, user));
}
/**
* Adds a Facebook profile link on the links section
*
* @param user a Facebook user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addFacebookLink(@StringRes int user) {
return addFacebookLink(context.getString(user));
}
/**
* Adds a Facebook profile link on the links section
*
* @param user a Facebook user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addFacebookLink(@NonNull String user) {
return addLink(R.mipmap.facebook, R.string.facebook, util.openFacebook(user));
}
/**
* Adds a Instagram profile link on the links section
*
* @param user a Instagram user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addInstagramLink(@StringRes int user) {
return addInstagramLink(context.getString(user));
}
/**
* Adds a Instagram profile link on the links section
*
* @param user a Instagram user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addInstagramLink(@NonNull String user) {
return addLink(R.mipmap.instagram, R.string.instagram, util.openInstagram(user));
}
/**
* Adds a Twitter profile link on the links section
*
* @param user a Twitter user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addTwitterLink(@StringRes int user) {
return addTwitterLink(context.getString(user));
}
/**
* Adds a Twitter profile link on the links section
*
* @param user a Twitter user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addTwitterLink(@NonNull String user) {
return addLink(R.mipmap.twitter, R.string.twitter, util.openTwitter(user));
}
/**
* Adds a Google link on the links section
*
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addGoogleLink(@StringRes int url) {
return addGoogleLink(context.getString(url));
}
/**
* Adds a Google link on the links section
*
* @param url any url
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addGoogleLink(@Nullable String url) {
return addLink(R.mipmap.google, R.string.google, url);
}
/**
* Adds a Google Play Store profile link on the links section
*
* @param user a Google Play Store user name or id
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addGooglePlayStoreLink(@StringRes int user) {
return addGooglePlayStoreLink(context.getString(user));
}
/**
* Adds a Google Play Store profile link on the links section
*
* @param user a Google Play Store user name
* @return the same {@link AboutBuilder} instance
*/
@NonNull
public AboutBuilder addGooglePlayStoreLink(@NonNull String user) {
return addLink(R.mipmap.google_play_store, R.string.google_play_store, util.openGooglePlayDev(user));
}
/**
* Adds a Google Games link on the links section
*