├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── xyz
│ │ └── belvi
│ │ └── intentmanipsample
│ │ ├── MainActivity.java
│ │ └── Sample.java
│ └── res
│ ├── layout
│ ├── activity_intent_manip_sample.xml
│ └── activity_main__intent_manip_sample.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── intentmanip
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── xyz
│ │ └── belvi
│ │ └── intentmanip
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── xyz
│ │ │ └── belvi
│ │ │ └── intentmanip
│ │ │ ├── IntentUtils
│ │ │ ├── CategorisedIntent.java
│ │ │ ├── IntentAppend.java
│ │ │ ├── IntentCallBack
│ │ │ │ └── ResolvedIntentListener.java
│ │ │ ├── IntentIgnore.java
│ │ │ ├── IntentLookUp.java
│ │ │ ├── ManipUtils.java
│ │ │ ├── MergeIntent.java
│ │ │ ├── Models
│ │ │ │ ├── PreferenceType.java
│ │ │ │ ├── PreparedIntent.java
│ │ │ │ ├── ResolveCategory.java
│ │ │ │ └── ResolveIntent.java
│ │ │ ├── PreferenceIntent.java
│ │ │ └── TargetIntent.java
│ │ │ └── LaunchIntent.java
│ └── res
│ │ ├── menu
│ │ └── category_menu.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── xyz
│ └── belvi
│ └── intentmanip
│ └── ExampleUnitTest.java
├── license
├── projectFilesBackup
└── .idea
│ └── workspace.xml
├── sample.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | IntentManip
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
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 |
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 |
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 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 |
1100 |
1101 |
1102 |
1103 |
1104 |
1105 |
1106 |
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
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 | Android
39 |
40 |
41 | Android > Lint > Correctness
42 |
43 |
44 | Android > Lint > Performance
45 |
46 |
47 | Android > Lint > Security
48 |
49 |
50 | Code maturity issuesJava
51 |
52 |
53 | Code style issuesJava
54 |
55 |
56 | Data flow issuesJava
57 |
58 |
59 | Error handlingGroovy
60 |
61 |
62 | Error handlingJava
63 |
64 |
65 | Groovy
66 |
67 |
68 | Java
69 |
70 |
71 | Logging issuesJava
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 | 1.8
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IntentManip
2 | Gives more controls over implicit intents creation and the way it is presented to users. [See this](http://belvi.xyz/posts/Handling-Intents) for a more detailed explanation on why you should consider using this library.
3 |
4 | [](https://jitpack.io/#KingsMentor/IntentManip)
5 | [](http://www.apache.org/licenses/LICENSE-2.0)
6 | [](http://android-arsenal.com/details/1/4490)
7 |
8 | 
9 |
10 | # Adding to your project.
11 |
12 | ### step 1
13 | Add it in your root build.gradle at the end of repositories:
14 | ```
15 | repositories {
16 | ...
17 | maven { url "https://jitpack.io" }
18 | }
19 | ```
20 |
21 | ### step 2
22 | Add the dependency
23 | ```
24 | dependencies {
25 | compile 'com.github.KingsMentor:IntentManip:v1.0'
26 | }
27 | ```
28 | # Usage :
29 | There are a couple of operations you can do with the library. It includes:
30 |
31 | 1. Merging
32 | 2. Categorizing Intent
33 | 3. Appending Intent
34 | 4. Ignoring Component
35 | 5. Lookup Component
36 | 6. Target Component
37 | 7. Component Preference
38 |
39 | # Snippets :
40 |
41 | #### Merging - merging components of different intents
42 | ```java
43 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
44 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
45 | @Override
46 | public void onIntentSelected(ResolveIntent resolveIntent) {
47 |
48 | }
49 | });
50 | ```
51 | ##### Note
52 |
53 | *launching* *intent* *from* *resolveIntent*
54 |
55 | ```java
56 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
57 | ```
58 |
59 | implement `ResolvedIntentListener` to get the item the user selected from the list
60 |
61 | #### Categorising Components
62 |
63 | for presenting merged intents in a categorised format
64 |
65 | ```java
66 | ResolveCategory pixResolveCategory = CategorisedIntent.categorized(this, MediaIntents.newSelectPictureIntent(), "picture", 1);
67 | List merge = new MergeIntent().mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
68 | ResolveCategory mergeResolveCategory = CategorisedIntent.categorized(merge, "Geo and Media", 2);
69 | List resolveCategories = new ArrayList<>();
70 | resolveCategories.add(pixResolveCategory);
71 | resolveCategories.add(mergeResolveCategory);
72 | LaunchIntent.categorised(this, resolveCategories, "Share With", new ResolvedIntentListener() {
73 | @Override
74 | public void onIntentSelected(ResolveIntent resolveIntent) {
75 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
76 | }
77 | });
78 |
79 | ```
80 |
81 | #### Appending Explicit Intents.
82 | for adding explicit intent ( probably activities from your project ) to implicit components.
83 |
84 | ```java
85 | PreparedIntent preparedIntent = new PreparedIntent(new Intent(this, Sample.class), R.string.sample, R.mipmap.ic_launcher);
86 | List resolveIntentList = IntentAppend.appendCustomIntent(this, MediaIntents.newSelectPictureIntent(), preparedIntent);
87 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
88 | @Override
89 | public void onIntentSelected(ResolveIntent resolveIntent) {
90 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
91 | }
92 | });
93 | ```
94 | #### Ignore Components
95 | to ignore or skip or remove components that matches a defined naming pattern from the list
96 |
97 | ```java
98 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
99 | IntentIgnore.IgnoreIntentWithName(this, resolveIntentList, new ArrayList(Arrays.asList(new String[]{"Maps"})));
100 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
101 | @Override
102 | public void onIntentSelected(Object resolveIntent) {
103 |
104 | }
105 | });
106 | ```
107 |
108 | #### LookingUp Components
109 | to find and return components that matches a defined naming pattern
110 | ```java
111 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
112 | IntentLookUp.lookUpAppsByAppName(this, resolveIntentList, "Maps");
113 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
114 | @Override
115 | public void onIntentSelected(Object resolveIntent) {
116 |
117 | }
118 | });
119 | ```
120 |
121 | #### Target a Component
122 | to target a particular component from a list of component.
123 | returns `null` if not found or return the first item if more than 1 item is found.
124 | ```java
125 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
126 | ResolveIntent resolveIntent = TargetIntent.targetByAppName(this, resolveIntentList, "Photo");
127 | if (resolveIntent != null) {
128 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
129 | }
130 | ```
131 |
132 | #### Component Preference
133 | This involves using a `PreferenceType` which could be
134 |
135 | * ASCENDING - to arange components in an alphabetical order by appname
136 | * DECENDING - to arange components in a decending alphabetical order by app name
137 | * CUSTOM_PACKAGENAME - arrange the list, placing components with supplied package names aboved others.
138 | * CUSTOM_APPNAME - arrange the list, placing components with supplied app names aboved others.
139 | * CUSTOM_REGEX_APPNAME - arrange the list, placing components with app names matching regEx supplied aboved others.
140 | * CUSTOM_REGEX_PACKAGE_NAME - arrange the list, placing components with package names matching regEx supplied aboved others.
141 |
142 | Also **note** that CUSTOM Preference type sort the component in same manage the list was provided.
143 |
144 | ```java
145 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
146 | PreferenceIntent.preferredIntent(this, PreferenceType.CUSTOM_APPNAME, new ArrayList(Arrays.asList(new String[]{"Maps","Photo"})), resolveIntentList);
147 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
148 | @Override
149 | public void onIntentSelected(Object resolveIntent) {
150 |
151 | }
152 | });
153 | ```
154 |
155 | The snippet above will sort the merge component of `MediaIntents` and `GeoIntents` but would place Maps and Photo above the entire list.
156 | Maps will be above Photos because if was provided that way. To bring Photos above Maps, it has to be this way:
157 |
158 | ```java
159 | PreferenceIntent.preferredIntent(this, PreferenceType.CUSTOM_APPNAME, new ArrayList(Arrays.asList(new String[]{"Photo","Maps"})), resolveIntentList);
160 | ```
161 |
162 | ## Contributing
163 | Contributions are welcome.
164 |
165 |
166 |
167 | ## Credits
168 | [android-intents](https://github.com/marvinlabs/android-intents) and
169 | [Bottom Sheet](https://github.com/soarcn/BottomSheet) upon which this library is based.
170 |
171 | ## License
172 |
173 | ```
174 | Copyright (C) 2016 MarvinLabs
175 | Copyright (C) 2011, 2015 Kai Liao
176 |
177 | Licensed under the Apache License, Version 2.0 (the "License");
178 | you may not use this file except in compliance with the License.
179 | You may obtain a copy of the License at
180 |
181 | http://www.apache.org/licenses/LICENSE-2.0
182 |
183 | Unless required by applicable law or agreed to in writing, software
184 | distributed under the License is distributed on an "AS IS" BASIS,
185 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186 | See the License for the specific language governing permissions and
187 | limitations under the License.
188 | ```
189 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | applicationId "xyz.belvi.intentmanip"
9 | minSdkVersion 15
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 | repositories {
22 | maven { url "https://jitpack.io" }
23 | }
24 |
25 |
26 | dependencies {
27 | compile fileTree(include: ['*.jar'], dir: 'libs')
28 | compile 'com.android.support:appcompat-v7:24.2.1'
29 | compile 'com.android.support:design:24.2.1'
30 | testCompile 'junit:junit:4.12'
31 | // compile 'com.github.KingsMentor:intentmanip:v1.0'
32 | compile project(':intentmanip')
33 | }
34 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zone2/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/belvi/intentmanipsample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanipsample;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.ArrayAdapter;
9 | import android.widget.ListView;
10 |
11 | import com.marvinlabs.intents.GeoIntents;
12 | import com.marvinlabs.intents.MediaIntents;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Arrays;
16 | import java.util.List;
17 |
18 | import xyz.belvi.intentmanip.IntentUtils.CategorisedIntent;
19 | import xyz.belvi.intentmanip.IntentUtils.IntentAppend;
20 | import xyz.belvi.intentmanip.IntentUtils.IntentCallBack.ResolvedIntentListener;
21 | import xyz.belvi.intentmanip.IntentUtils.IntentIgnore;
22 | import xyz.belvi.intentmanip.IntentUtils.IntentLookUp;
23 | import xyz.belvi.intentmanip.IntentUtils.ManipUtils;
24 | import xyz.belvi.intentmanip.IntentUtils.MergeIntent;
25 | import xyz.belvi.intentmanip.IntentUtils.Models.PreferenceType;
26 | import xyz.belvi.intentmanip.IntentUtils.Models.PreparedIntent;
27 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveCategory;
28 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
29 | import xyz.belvi.intentmanip.IntentUtils.PreferenceIntent;
30 | import xyz.belvi.intentmanip.IntentUtils.TargetIntent;
31 | import xyz.belvi.intentmanip.LaunchIntent;
32 |
33 | import static xyz.belvi.intentmanip.IntentUtils.MergeIntent.mergeIntents;
34 |
35 |
36 | public class MainActivity extends AppCompatActivity {
37 |
38 | private final int MERGE = 0;
39 | private final int CATEGORISE = 1;
40 | private final int APPENDING = 2;
41 | private final int IGNORE = 3;
42 | private final int LOOKUP = 4;
43 | private final int PREF = 5;
44 | private final int TARGET = 6;
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.activity_main__intent_manip_sample);
50 | ListView listView = (ListView) findViewById(R.id.intent_list);
51 | listView.setAdapter(ArrayAdapter.createFromResource(this, R.array.manip_list, android.R.layout.simple_list_item_1));
52 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
53 | @Override
54 | public void onItemClick(AdapterView> adapterView, View view, int position, long l) {
55 | switch (position) {
56 | case MERGE:
57 | runMerge();
58 | break;
59 | case CATEGORISE:
60 | categorised();
61 | break;
62 | case APPENDING:
63 | appendIntent();
64 | break;
65 | case IGNORE:
66 | ignore();
67 | break;
68 | case LOOKUP:
69 | lookUp();
70 | break;
71 | case PREF:
72 | arrangeInPreference();
73 | break;
74 | case TARGET:
75 | target();
76 |
77 | }
78 | }
79 | });
80 | }
81 |
82 |
83 | private void runMerge() {
84 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
85 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
86 | @Override
87 | public void onIntentSelected(Object resolveIntent) {
88 |
89 | }
90 | });
91 | }
92 |
93 |
94 | private void categorised() {
95 | ResolveCategory pixResolveCategory = CategorisedIntent.categorized(this, MediaIntents.newSelectPictureIntent(), "picture", 1);
96 | List merge = new MergeIntent().mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
97 | ResolveCategory mergeResolveCategory = CategorisedIntent.categorized(merge, "Geo and Media", 2);
98 | List resolveCategories = new ArrayList<>();
99 | resolveCategories.add(pixResolveCategory);
100 | resolveCategories.add(mergeResolveCategory);
101 | LaunchIntent.categorised(this, resolveCategories, "Share With", new ResolvedIntentListener() {
102 | @Override
103 | public void onIntentSelected(ResolveIntent resolveIntent) {
104 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
105 | }
106 | });
107 | }
108 |
109 | private void appendIntent() {
110 | PreparedIntent preparedIntent = new PreparedIntent(new Intent(this, Sample.class), R.string.sample, R.mipmap.ic_launcher);
111 | List resolveIntentList = IntentAppend.appendCustomIntent(this, MediaIntents.newSelectPictureIntent(), preparedIntent);
112 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
113 | @Override
114 | public void onIntentSelected(ResolveIntent resolveIntent) {
115 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
116 | }
117 | });
118 | }
119 |
120 |
121 | private void ignore() {
122 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
123 | IntentIgnore.IgnoreIntentWithName(this, resolveIntentList, new ArrayList(Arrays.asList(new String[]{"Maps"})));
124 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
125 | @Override
126 | public void onIntentSelected(Object resolveIntent) {
127 |
128 | }
129 | });
130 | }
131 |
132 |
133 | private void lookUp() {
134 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
135 | IntentLookUp.lookUpAppsByAppName(this, resolveIntentList, new ArrayList(Arrays.asList("Maps")));
136 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
137 | @Override
138 | public void onIntentSelected(Object resolveIntent) {
139 |
140 | }
141 | });
142 | }
143 |
144 |
145 | private void arrangeInPreference() {
146 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
147 | PreferenceIntent.preferredIntent(this, PreferenceType.CUSTOM_APPNAME, new ArrayList(Arrays.asList(new String[]{"Maps", "Photo"})), resolveIntentList);
148 | LaunchIntent.withButtomSheetAsList(this, resolveIntentList, "launch using", new ResolvedIntentListener() {
149 | @Override
150 | public void onIntentSelected(Object resolveIntent) {
151 |
152 | }
153 | });
154 | }
155 |
156 |
157 | private void target() {
158 | List resolveIntentList = mergeIntents(this, MediaIntents.newSelectPictureIntent(), GeoIntents.newNavigationIntent(""));
159 | ResolveIntent resolveIntent = TargetIntent.targetByAppName(this, resolveIntentList, "Photo");
160 | if (resolveIntent != null) {
161 | startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
162 | }
163 |
164 | }
165 |
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/app/src/main/java/xyz/belvi/intentmanipsample/Sample.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanipsample;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.annotation.TargetApi;
6 | import android.app.LoaderManager.LoaderCallbacks;
7 | import android.content.CursorLoader;
8 | import android.content.Loader;
9 | import android.content.pm.PackageManager;
10 | import android.database.Cursor;
11 | import android.net.Uri;
12 | import android.os.AsyncTask;
13 | import android.os.Build;
14 | import android.os.Bundle;
15 | import android.provider.ContactsContract;
16 | import android.support.annotation.NonNull;
17 | import android.support.design.widget.Snackbar;
18 | import android.support.v7.app.AppCompatActivity;
19 | import android.text.TextUtils;
20 | import android.view.KeyEvent;
21 | import android.view.View;
22 | import android.view.View.OnClickListener;
23 | import android.view.inputmethod.EditorInfo;
24 | import android.widget.ArrayAdapter;
25 | import android.widget.AutoCompleteTextView;
26 | import android.widget.Button;
27 | import android.widget.EditText;
28 | import android.widget.TextView;
29 |
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | import static android.Manifest.permission.READ_CONTACTS;
34 |
35 | /**
36 | * A login screen that offers login via email/password.
37 | */
38 | public class Sample extends AppCompatActivity implements LoaderCallbacks {
39 |
40 | /**
41 | * Id to identity READ_CONTACTS permission request.
42 | */
43 | private static final int REQUEST_READ_CONTACTS = 0;
44 |
45 | /**
46 | * A dummy authentication store containing known user names and passwords.
47 | * TODO: remove after connecting to a real authentication system.
48 | */
49 | private static final String[] DUMMY_CREDENTIALS = new String[]{
50 | "foo@example.com:hello", "bar@example.com:world"
51 | };
52 | /**
53 | * Keep track of the login task to ensure we can cancel it if requested.
54 | */
55 | private UserLoginTask mAuthTask = null;
56 |
57 | // UI references.
58 | private AutoCompleteTextView mEmailView;
59 | private EditText mPasswordView;
60 | private View mProgressView;
61 | private View mLoginFormView;
62 |
63 | @Override
64 | protected void onCreate(Bundle savedInstanceState) {
65 | super.onCreate(savedInstanceState);
66 | setContentView(R.layout.activity_intent_manip_sample);
67 | // Set up the login form.
68 | mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
69 | populateAutoComplete();
70 |
71 | mPasswordView = (EditText) findViewById(R.id.password);
72 | mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
73 | @Override
74 | public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
75 | if (id == R.id.login || id == EditorInfo.IME_NULL) {
76 | attemptLogin();
77 | return true;
78 | }
79 | return false;
80 | }
81 | });
82 |
83 | Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
84 | mEmailSignInButton.setOnClickListener(new OnClickListener() {
85 | @Override
86 | public void onClick(View view) {
87 | attemptLogin();
88 | }
89 | });
90 |
91 | mLoginFormView = findViewById(R.id.login_form);
92 | mProgressView = findViewById(R.id.login_progress);
93 | }
94 |
95 | private void populateAutoComplete() {
96 | if (!mayRequestContacts()) {
97 | return;
98 | }
99 |
100 | getLoaderManager().initLoader(0, null, this);
101 | }
102 |
103 | private boolean mayRequestContacts() {
104 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
105 | return true;
106 | }
107 | if (checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
108 | return true;
109 | }
110 | if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
111 | Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)
112 | .setAction(android.R.string.ok, new View.OnClickListener() {
113 | @Override
114 | @TargetApi(Build.VERSION_CODES.M)
115 | public void onClick(View v) {
116 | requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
117 | }
118 | });
119 | } else {
120 | requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
121 | }
122 | return false;
123 | }
124 |
125 | /**
126 | * Callback received when a permissions request has been completed.
127 | */
128 | @Override
129 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
130 | @NonNull int[] grantResults) {
131 | if (requestCode == REQUEST_READ_CONTACTS) {
132 | if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
133 | populateAutoComplete();
134 | }
135 | }
136 | }
137 |
138 |
139 | /**
140 | * Attempts to sign in or register the account specified by the login form.
141 | * If there are form errors (invalid email, missing fields, etc.), the
142 | * errors are presented and no actual login attempt is made.
143 | */
144 | private void attemptLogin() {
145 | if (mAuthTask != null) {
146 | return;
147 | }
148 |
149 | // Reset errors.
150 | mEmailView.setError(null);
151 | mPasswordView.setError(null);
152 |
153 | // Store values at the time of the login attempt.
154 | String email = mEmailView.getText().toString();
155 | String password = mPasswordView.getText().toString();
156 |
157 | boolean cancel = false;
158 | View focusView = null;
159 |
160 | // Check for a valid password, if the user entered one.
161 | if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
162 | mPasswordView.setError(getString(R.string.error_invalid_password));
163 | focusView = mPasswordView;
164 | cancel = true;
165 | }
166 |
167 | // Check for a valid email address.
168 | if (TextUtils.isEmpty(email)) {
169 | mEmailView.setError(getString(R.string.error_field_required));
170 | focusView = mEmailView;
171 | cancel = true;
172 | } else if (!isEmailValid(email)) {
173 | mEmailView.setError(getString(R.string.error_invalid_email));
174 | focusView = mEmailView;
175 | cancel = true;
176 | }
177 |
178 | if (cancel) {
179 | // There was an error; don't attempt login and focus the first
180 | // form field with an error.
181 | focusView.requestFocus();
182 | } else {
183 | // Show a progress spinner, and kick off a background task to
184 | // perform the user login attempt.
185 | showProgress(true);
186 | mAuthTask = new UserLoginTask(email, password);
187 | mAuthTask.execute((Void) null);
188 | }
189 | }
190 |
191 | private boolean isEmailValid(String email) {
192 | //TODO: Replace this with your own logic
193 | return email.contains("@");
194 | }
195 |
196 | private boolean isPasswordValid(String password) {
197 | //TODO: Replace this with your own logic
198 | return password.length() > 4;
199 | }
200 |
201 | /**
202 | * Shows the progress UI and hides the login form.
203 | */
204 | @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
205 | private void showProgress(final boolean show) {
206 | // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
207 | // for very easy animations. If available, use these APIs to fade-in
208 | // the progress spinner.
209 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
210 | int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
211 |
212 | mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
213 | mLoginFormView.animate().setDuration(shortAnimTime).alpha(
214 | show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
215 | @Override
216 | public void onAnimationEnd(Animator animation) {
217 | mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
218 | }
219 | });
220 |
221 | mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
222 | mProgressView.animate().setDuration(shortAnimTime).alpha(
223 | show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
224 | @Override
225 | public void onAnimationEnd(Animator animation) {
226 | mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
227 | }
228 | });
229 | } else {
230 | // The ViewPropertyAnimator APIs are not available, so simply show
231 | // and hide the relevant UI components.
232 | mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
233 | mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
234 | }
235 | }
236 |
237 | @Override
238 | public Loader onCreateLoader(int i, Bundle bundle) {
239 | return new CursorLoader(this,
240 | // Retrieve data rows for the device user's 'profile' contact.
241 | Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
242 | ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,
243 |
244 | // Select only email addresses.
245 | ContactsContract.Contacts.Data.MIMETYPE +
246 | " = ?", new String[]{ContactsContract.CommonDataKinds.Email
247 | .CONTENT_ITEM_TYPE},
248 |
249 | // Show primary email addresses first. Note that there won't be
250 | // a primary email address if the user hasn't specified one.
251 | ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
252 | }
253 |
254 | @Override
255 | public void onLoadFinished(Loader cursorLoader, Cursor cursor) {
256 | List emails = new ArrayList<>();
257 | cursor.moveToFirst();
258 | while (!cursor.isAfterLast()) {
259 | emails.add(cursor.getString(ProfileQuery.ADDRESS));
260 | cursor.moveToNext();
261 | }
262 |
263 | addEmailsToAutoComplete(emails);
264 | }
265 |
266 | @Override
267 | public void onLoaderReset(Loader cursorLoader) {
268 |
269 | }
270 |
271 | private void addEmailsToAutoComplete(List emailAddressCollection) {
272 | //Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
273 | ArrayAdapter adapter =
274 | new ArrayAdapter<>(Sample.this,
275 | android.R.layout.simple_dropdown_item_1line, emailAddressCollection);
276 |
277 | mEmailView.setAdapter(adapter);
278 | }
279 |
280 |
281 | private interface ProfileQuery {
282 | String[] PROJECTION = {
283 | ContactsContract.CommonDataKinds.Email.ADDRESS,
284 | ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
285 | };
286 |
287 | int ADDRESS = 0;
288 | int IS_PRIMARY = 1;
289 | }
290 |
291 | /**
292 | * Represents an asynchronous login/registration task used to authenticate
293 | * the user.
294 | */
295 | public class UserLoginTask extends AsyncTask {
296 |
297 | private final String mEmail;
298 | private final String mPassword;
299 |
300 | UserLoginTask(String email, String password) {
301 | mEmail = email;
302 | mPassword = password;
303 | }
304 |
305 | @Override
306 | protected Boolean doInBackground(Void... params) {
307 | // TODO: attempt authentication against a network service.
308 |
309 | try {
310 | // Simulate network access.
311 | Thread.sleep(2000);
312 | } catch (InterruptedException e) {
313 | return false;
314 | }
315 |
316 | for (String credential : DUMMY_CREDENTIALS) {
317 | String[] pieces = credential.split(":");
318 | if (pieces[0].equals(mEmail)) {
319 | // Account exists, return true if the password matches.
320 | return pieces[1].equals(mPassword);
321 | }
322 | }
323 |
324 | // TODO: register the new account here.
325 | return true;
326 | }
327 |
328 | @Override
329 | protected void onPostExecute(final Boolean success) {
330 | mAuthTask = null;
331 | showProgress(false);
332 |
333 | if (success) {
334 | finish();
335 | } else {
336 | mPasswordView.setError(getString(R.string.error_incorrect_password));
337 | mPasswordView.requestFocus();
338 | }
339 | }
340 |
341 | @Override
342 | protected void onCancelled() {
343 | mAuthTask = null;
344 | showProgress(false);
345 | }
346 | }
347 | }
348 |
349 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_intent_manip_sample.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
21 |
22 |
26 |
27 |
32 |
33 |
36 |
37 |
45 |
46 |
47 |
48 |
51 |
52 |
63 |
64 |
65 |
66 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main__intent_manip_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | IntentManip
3 | Sample
4 |
5 |
6 | - Merge Sample
7 | - Categorised Intent
8 | - Appending Intent
9 | - Igonore Intent
10 | - Lookup Intent
11 | - Preference Intent
12 | - Target Intent
13 |
14 |
15 | Sign in
16 |
17 |
18 | Email
19 | Password (optional)
20 | Sign in or register
21 | Sign in
22 | This email address is invalid
23 | This password is too short
24 | This password is incorrect
25 | This field is required
26 | "Contacts permissions are needed for providing email
27 | completions."
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Oct 02 20:18:51 WAT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/intentmanip/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/intentmanip/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:24.2.1'
30 | testCompile 'junit:junit:4.12'
31 | compile 'com.cocosw:bottomsheet:1.+@aar'
32 | compile 'com.marvinlabs:android-intents:1.5.1@aar'
33 | }
34 |
--------------------------------------------------------------------------------
/intentmanip/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zone2/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/intentmanip/src/androidTest/java/xyz/belvi/intentmanip/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("xyz.belvi.intentmanip.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/intentmanip/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/CategorisedIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import java.util.List;
7 |
8 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveCategory;
9 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
10 |
11 | /**
12 | * Created by zone2 on 10/3/16.
13 | */
14 |
15 | public class CategorisedIntent extends ManipUtils {
16 |
17 | public static ResolveCategory categorized(Context context, Intent intent, String name, int order) {
18 | List resolveIntents = lookUp(context, intent);
19 |
20 | return new ResolveCategory(resolveIntents, name, order);
21 | }
22 |
23 | public static ResolveCategory categorized(List resolveIntents, String name, int order) {
24 | return new ResolveCategory(resolveIntents, name, order);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/IntentAppend.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import java.util.List;
7 |
8 | import xyz.belvi.intentmanip.IntentUtils.Models.PreparedIntent;
9 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
10 |
11 | /**
12 | * Created by zone2 on 10/3/16.
13 | */
14 |
15 | public class IntentAppend extends ManipUtils {
16 |
17 | public static List appendCustomIntent(Context context, Intent launchItent, PreparedIntent... customIntent) {
18 | List resolveIntents = lookUp(context, launchItent);
19 | for (PreparedIntent preparedIntent : customIntent) {
20 | for (ResolveIntent resolveIntent : lookUp(context, preparedIntent.getIntent())) {
21 | resolveIntent.getResolveInfo().labelRes = preparedIntent.getNameRes();
22 | resolveIntent.getResolveInfo().icon = preparedIntent.getIconRes();
23 | resolveIntents.add(resolveIntent);
24 | }
25 | }
26 | return resolveIntents;
27 | }
28 |
29 | public static void appendCustomIntent(Context context, List launchResolveIntents, PreparedIntent... customIntent) {
30 | for (PreparedIntent preparedIntent : customIntent) {
31 | for (ResolveIntent resolveIntent : lookUp(context, preparedIntent.getIntent())) {
32 | resolveIntent.getResolveInfo().labelRes = preparedIntent.getNameRes();
33 | resolveIntent.getResolveInfo().icon = preparedIntent.getIconRes();
34 | launchResolveIntents.add(resolveIntent);
35 | }
36 | }
37 | }
38 |
39 | public static List appendToIntent(Context context, Intent launchItent, Intent... customIntent) {
40 | List resolveIntents = lookUp(context, launchItent);
41 | for (Intent intent : customIntent) {
42 | resolveIntents.addAll(lookUp(context, intent));
43 | }
44 | return resolveIntents;
45 | }
46 |
47 | public static void appendToIntent(Context context, List launchResolveIntents, Intent... customIntent) {
48 | for (Intent intent : customIntent) {
49 | launchResolveIntents.addAll(lookUp(context, intent));
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/IntentCallBack/ResolvedIntentListener.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils.IntentCallBack;
2 |
3 | /**
4 | * Created by zone2 on 10/3/16.
5 | */
6 |
7 | public interface ResolvedIntentListener {
8 | void onIntentSelected(T resolveIntent);
9 | }
10 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/IntentIgnore.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
10 |
11 | /**
12 | * Created by zone2 on 10/3/16.
13 | */
14 |
15 | public class IntentIgnore extends ManipUtils {
16 |
17 |
18 | public static List IgnoreIntentWithName(Context context, Intent intent, ArrayList skipList) {
19 | List resolveIntents = lookUp(context, intent);
20 | for (ResolveIntent resolveIntent : resolveIntents) {
21 | if (skipList.contains(getName(context, resolveIntent.getResolveInfo())))
22 | resolveIntents.remove(resolveIntent);
23 | }
24 | return resolveIntents;
25 | }
26 |
27 | public static void IgnoreIntentWithName(Context context, List resolveIntents, ArrayList skipList) {
28 | List resultingIntent = new ArrayList<>();
29 | for (ResolveIntent resolveIntent : resolveIntents) {
30 | if (!skipList.contains(getName(context, resolveIntent.getResolveInfo())))
31 | resultingIntent.add(resolveIntent);
32 | }
33 | resolveIntents.clear();
34 | resolveIntents.addAll(resultingIntent);
35 |
36 | }
37 |
38 |
39 | public static List IgnoreIntentWithPackageName(Context context, Intent intent, ArrayList skipList) {
40 | List resolveIntents = lookUp(context, intent);
41 | for (ResolveIntent resolveIntent : resolveIntents) {
42 | if (skipList.contains(getPackageName(resolveIntent.getResolveInfo())))
43 | resolveIntents.remove(resolveIntent);
44 | }
45 | return resolveIntents;
46 | }
47 |
48 | public static void IgnoreIntentWithPackageName(List resolveIntents, ArrayList skipList) {
49 | List resultingIntent = new ArrayList<>();
50 | for (ResolveIntent resolveIntent : resolveIntents) {
51 | if (!skipList.contains(getPackageName(resolveIntent.getResolveInfo())))
52 | resultingIntent.add(resolveIntent);
53 | }
54 | resolveIntents.clear();
55 | resolveIntents.addAll(resultingIntent);
56 |
57 | }
58 |
59 | public static List IgnoreIntentsWithAppNameMatching(Context context, Intent intent, String regEx) {
60 | List resolveIntents = lookUp(context, intent);
61 | for (ResolveIntent resolveIntent : resolveIntents) {
62 | if (getName(context, resolveIntent.getResolveInfo()).matches(regEx))
63 | resolveIntents.remove(resolveIntent);
64 | }
65 | return resolveIntents;
66 | }
67 |
68 | public static void IgnoreIntentsWithAppNameMatching(Context context, List resolveIntents, String regEx) {
69 | List resultingIntent = new ArrayList<>();
70 | for (ResolveIntent resolveIntent : resolveIntents) {
71 | if (!getName(context, resolveIntent.getResolveInfo()).matches(regEx))
72 | resultingIntent.add(resolveIntent);
73 | }
74 | resolveIntents.clear();
75 | resolveIntents.addAll(resultingIntent);
76 | }
77 |
78 | public static List IgnoreIntentsWithPackageNameMatching(Context context, Intent intent, String regEx) {
79 | List resolveIntents = lookUp(context, intent);
80 | for (ResolveIntent resolveIntent : resolveIntents) {
81 | if (getPackageName(resolveIntent.getResolveInfo()).matches(regEx))
82 | resolveIntents.remove(resolveIntent);
83 | }
84 | return resolveIntents;
85 | }
86 |
87 | public static void IgnoreIntentsWithPacjageNameMatching(List resolveIntents, String regEx) {
88 | List resultingIntent = new ArrayList<>();
89 |
90 | for (ResolveIntent resolveIntent : resolveIntents) {
91 | if (!getPackageName(resolveIntent.getResolveInfo()).matches(regEx))
92 | resultingIntent.add(resolveIntent);
93 | }
94 | resolveIntents.clear();
95 | resolveIntents.addAll(resultingIntent);
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/IntentLookUp.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
10 |
11 | /**
12 | * Created by zone2 on 10/3/16.
13 | */
14 |
15 | public class IntentLookUp extends ManipUtils {
16 |
17 |
18 | public static List lookUpByAppName(Context context, Intent intent, ArrayList appName) {
19 | List resolveIntentList = new ArrayList<>();
20 | for (ResolveIntent resolveIntent : lookUp(context, intent)) {
21 | if (appName.contains(getName(context, resolveIntent.getResolveInfo())))
22 | resolveIntentList.add(resolveIntent);
23 | }
24 | return resolveIntentList;
25 | }
26 |
27 | public static void lookUpByAppName(Context context, List resolveIntents, ArrayList appName) {
28 | List resolveIntentList = new ArrayList<>();
29 | for (ResolveIntent resolveIntent : resolveIntents) {
30 | if (appName.contains(getName(context, resolveIntent.getResolveInfo())))
31 | resolveIntentList.add(resolveIntent);
32 | }
33 | resolveIntents.clear();
34 | resolveIntents.addAll(resolveIntentList);
35 | }
36 |
37 | public static List lookUpByPackageName(Context context, Intent intent, ArrayList packageName) {
38 | List resolveIntentList = new ArrayList<>();
39 | for (ResolveIntent resolveIntent : lookUp(context, intent)) {
40 | if (packageName.contains(getPackageName(resolveIntent.getResolveInfo())))
41 | resolveIntentList.add(resolveIntent);
42 | }
43 | return resolveIntentList;
44 | }
45 |
46 | public static void lookUpByPackageName(List resolveIntents, ArrayList packageName) {
47 | List resolveIntentList = new ArrayList<>();
48 | for (ResolveIntent resolveIntent : resolveIntents) {
49 | if (packageName.contains(getPackageName(resolveIntent.getResolveInfo())))
50 | resolveIntentList.add(resolveIntent);
51 | }
52 | resolveIntentList.clear();
53 | resolveIntents.addAll(resolveIntentList);
54 | }
55 |
56 | public static List lookUpAppsByAppName(Context context, Intent intent, ArrayList appName) {
57 | List resolveIntents = new ArrayList<>();
58 | for (ResolveIntent resolveIntent : lookUp(context, intent)) {
59 | if (appName.contains(getName(context, resolveIntent.getResolveInfo())))
60 | resolveIntents.add(resolveIntent);
61 | }
62 | return resolveIntents;
63 | }
64 |
65 | public static void lookUpAppsByAppName(Context context, List resolveIntents, ArrayList appName) {
66 | List resultResolveIntentList = new ArrayList<>();
67 | for (ResolveIntent resolveIntent : resolveIntents) {
68 | if (appName.contains(getName(context, resolveIntent.getResolveInfo())))
69 | resultResolveIntentList.add(resolveIntent);
70 | }
71 | resolveIntents.clear();
72 | resolveIntents.addAll(resultResolveIntentList);
73 | }
74 |
75 |
76 | public static List lookUpAppsByPackageName(Context context, Intent intent, ArrayList packageName) {
77 | List resolveIntents = new ArrayList<>();
78 | for (ResolveIntent resolveIntent : lookUp(context, intent)) {
79 | if (packageName.contains(getPackageName(resolveIntent.getResolveInfo())))
80 | resolveIntents.add(resolveIntent);
81 | }
82 | return resolveIntents;
83 | }
84 |
85 | public static void lookUpAppsByPackageName(List resolveIntents, ArrayList packageName) {
86 | List resultResolveIntentList = new ArrayList<>();
87 | for (ResolveIntent resolveIntent : resolveIntents) {
88 | if (packageName.contains(getPackageName(resolveIntent.getResolveInfo())))
89 | resultResolveIntentList.add(resolveIntent);
90 | }
91 | resolveIntents.clear();
92 | resolveIntents.addAll(resultResolveIntentList);
93 | }
94 |
95 | public static List lookUpAppsByRegEx(Context context, Intent intent, String regEx) {
96 | List resolveIntents = new ArrayList<>();
97 | for (ResolveIntent resolveIntent : lookUp(context, intent)) {
98 | if (getPackageName(resolveIntent.getResolveInfo()).matches(regEx))
99 | resolveIntents.add(resolveIntent);
100 | }
101 | return resolveIntents;
102 | }
103 |
104 | public static void lookUpAppsByRegEx(List resolveIntents, String regEx) {
105 | List resultResolveIntentList = new ArrayList<>();
106 | for (ResolveIntent resolveIntent : resolveIntents) {
107 | if (getPackageName(resolveIntent.getResolveInfo()).matches(regEx))
108 | resultResolveIntentList.add(resolveIntent);
109 | }
110 | resolveIntents.clear();
111 | resolveIntents.addAll(resultResolveIntentList);
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/ManipUtils.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.content.pm.ResolveInfo;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
13 |
14 | /**
15 | * Created by zone2 on 10/5/16.
16 | */
17 |
18 | public class ManipUtils {
19 |
20 |
21 | protected static List lookUp(Context context, Intent intent) {
22 | List resolveIntents = new ArrayList<>();
23 | PackageManager packageManager = context.getPackageManager();
24 | List listCam = packageManager.queryIntentActivities(intent, 0);
25 | for (ResolveInfo res : listCam) {
26 | resolveIntents.add(new ResolveIntent(res, intent));
27 | }
28 | return resolveIntents;
29 | }
30 |
31 | public static String getName(Context context, ResolveInfo resolveInfo) {
32 | return String.valueOf(resolveInfo.loadLabel(context.getPackageManager()));
33 | }
34 |
35 | protected static String getPackageName(ResolveInfo resolveInfo) {
36 | return String.valueOf(resolveInfo.activityInfo.packageName);
37 | }
38 |
39 | public List getInstalledAppList(Context context) {
40 | List resolveIntents = new ArrayList<>();
41 | Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
42 | mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
43 | List pkgAppsList = context.getPackageManager().queryIntentActivities(mainIntent, 0);
44 | for (ResolveInfo res : pkgAppsList) {
45 | resolveIntents.add(new ResolveIntent(res, mainIntent));
46 | }
47 |
48 | return resolveIntents;
49 | }
50 |
51 | public static Intent getLaunchableIntent(ResolveIntent resolveIntent) {
52 |
53 | resolveIntent.getIntent().setComponent(new ComponentName(resolveIntent.getResolveInfo().activityInfo.packageName, resolveIntent.getResolveInfo().activityInfo.name));
54 | return resolveIntent.getIntent();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/MergeIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.content.pm.ResolveInfo;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
12 |
13 | /**
14 | * Created by zone2 on 10/2/16.
15 | */
16 |
17 | public class MergeIntent extends ManipUtils {
18 |
19 | public static List mergeIntents(Context context, Intent... intents) {
20 |
21 | PackageManager packageManager = context.getPackageManager();
22 |
23 |
24 | List resolveIntents = new ArrayList<>();
25 | for (Intent intent : intents) {
26 | List listCam = packageManager.queryIntentActivities(intent, 0);
27 | for (ResolveInfo res : listCam) {
28 | resolveIntents.add(new ResolveIntent(res, intent));
29 | }
30 | }
31 | return resolveIntents;
32 | }
33 |
34 | public static List distinctMerge(Context context, Intent... intents) {
35 |
36 | PackageManager packageManager = context.getPackageManager();
37 |
38 |
39 | ArrayList intentsNameLog = new ArrayList<>();
40 | List resolveIntents = new ArrayList<>();
41 | for (Intent intent : intents) {
42 | List listCam = packageManager.queryIntentActivities(intent, 0);
43 | for (ResolveInfo res : listCam) {
44 | if (!intentsNameLog.contains(getPackageName(res))) {
45 | intentsNameLog.add(getPackageName(res));
46 | resolveIntents.add(new ResolveIntent(res, intent));
47 | }
48 | }
49 | }
50 | intentsNameLog.clear();
51 | return resolveIntents;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/Models/PreferenceType.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils.Models;
2 |
3 | /**
4 | * Created by zone2 on 10/3/16.
5 | */
6 |
7 | public enum PreferenceType {
8 | ASCENDING, DECENDING, CUSTOM_PACKAGENAME, CUSTOM_APPNAME, CUSTOM_REGEX_APPNAME, CUSTOM_REGEX_PACKAGE_NAME;
9 | }
10 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/Models/PreparedIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils.Models;
2 |
3 | import android.content.Intent;
4 |
5 | /**
6 | * Created by zone2 on 10/5/16.
7 | */
8 |
9 | public class PreparedIntent {
10 |
11 | private Intent intent;
12 | private int nameRes, iconRes;
13 |
14 | public PreparedIntent(Intent intent, int nameRes, int iconRes) {
15 | this.intent = intent;
16 | this.nameRes = nameRes;
17 | this.iconRes = iconRes;
18 | }
19 |
20 | public Intent getIntent() {
21 | return this.intent;
22 | }
23 |
24 | public void setIntent(Intent intent) {
25 | this.intent = intent;
26 | }
27 |
28 | public int getNameRes() {
29 | return this.nameRes;
30 | }
31 |
32 | public void setNameRes(int nameRes) {
33 | this.nameRes = nameRes;
34 | }
35 |
36 | public int getIconRes() {
37 | return this.iconRes;
38 | }
39 |
40 | public void setIconRes(int iconRes) {
41 | this.iconRes = iconRes;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/Models/ResolveCategory.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils.Models;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by zone2 on 10/3/16.
7 | */
8 |
9 | public class ResolveCategory {
10 | List resolveIntents;
11 | String categoryName;
12 | int orderId;
13 |
14 | public ResolveCategory(List resolveIntents, String categoryName, int orderId) {
15 | this.resolveIntents = resolveIntents;
16 | this.categoryName = categoryName;
17 | this.orderId = orderId;
18 |
19 | }
20 |
21 | public List getResolveIntents() {
22 | return this.resolveIntents;
23 | }
24 |
25 |
26 |
27 | public void setResolveIntents(List resolveIntents) {
28 | this.resolveIntents = resolveIntents;
29 | }
30 |
31 | public String getCategoryName() {
32 | return this.categoryName;
33 | }
34 |
35 | public void setCategoryName(String categoryName) {
36 | this.categoryName = categoryName;
37 | }
38 |
39 | public int getOrderId() {
40 | return this.orderId;
41 | }
42 |
43 | public void setOrderId(int orderId) {
44 | this.orderId = orderId;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/Models/ResolveIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils.Models;
2 |
3 | import android.content.Intent;
4 | import android.content.pm.ResolveInfo;
5 |
6 | /**
7 | * Created by zone2 on 10/3/16.
8 | */
9 |
10 | public class ResolveIntent {
11 |
12 | ResolveInfo resolveInfo;
13 | Intent intent;
14 |
15 |
16 | public ResolveIntent(ResolveInfo resolveInfo, Intent intent) {
17 | this.resolveInfo = resolveInfo;
18 | this.intent = intent;
19 | }
20 |
21 | public ResolveInfo getResolveInfo() {
22 | return this.resolveInfo;
23 | }
24 |
25 | public void setResolveInfo(ResolveInfo resolveInfo) {
26 | this.resolveInfo = resolveInfo;
27 | }
28 |
29 | public Intent getIntent() {
30 | return this.intent;
31 | }
32 |
33 | public void setIntent(Intent intent) {
34 | this.intent = intent;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/PreferenceIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.content.pm.ResolveInfo;
8 | import android.util.Log;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Collections;
12 | import java.util.Comparator;
13 | import java.util.List;
14 |
15 | import xyz.belvi.intentmanip.IntentUtils.Models.PreferenceType;
16 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
17 |
18 | /**
19 | * Created by zone2 on 10/3/16.
20 | */
21 |
22 | public class PreferenceIntent extends ManipUtils {
23 |
24 | Context mContext;
25 |
26 | public PreferenceIntent(Context context) {
27 | mContext = context;
28 | }
29 |
30 | public static List preferredIntent(Context context, Intent intents) {
31 |
32 | return preferredIntent(context, PreferenceType.ASCENDING, intents);
33 | }
34 |
35 | private static List getResolveIntents(Context context, Intent intent) {
36 | List resolveIntents = new ArrayList<>();
37 | PackageManager packageManager = context.getPackageManager();
38 | List listCam = packageManager.queryIntentActivities(intent, 0);
39 | for (ResolveInfo res : listCam) {
40 | final Intent finalIntent = new Intent(intent);
41 | finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
42 | resolveIntents.add(new ResolveIntent(res, intent));
43 |
44 | }
45 | return resolveIntents;
46 | }
47 |
48 | public static List preferredIntent(Context context, PreferenceType preferenceType, Intent intent) {
49 |
50 | List resolveIntents = getResolveIntents(context, intent);
51 | Collections.sort(resolveIntents, new IntentComparator(context, preferenceType));
52 | return resolveIntents;
53 |
54 | }
55 |
56 | public static List preferredIntent(Context context, PreferenceType preferenceType, ArrayList orderingPackageName, Intent intent) {
57 | List resolveIntents = getResolveIntents(context, intent);
58 | Collections.sort(resolveIntents, new IntentComparator(context, preferenceType, orderingPackageName));
59 | return resolveIntents;
60 |
61 | }
62 |
63 | public static List preferredIntent(Context context, PreferenceType preferenceType, String regEx, Intent intent) {
64 | List resolveIntents = getResolveIntents(context, intent);
65 | Collections.sort(resolveIntents, new IntentComparator(context, preferenceType, regEx));
66 | return resolveIntents;
67 |
68 | }
69 |
70 | public static void preferredIntent(Context context, List resolveIntents) {
71 | preferredIntent(context, PreferenceType.ASCENDING, resolveIntents);
72 |
73 | }
74 |
75 | public static void preferredIntent(Context context, PreferenceType preferenceType, List resolveIntents) {
76 |
77 | Collections.sort(resolveIntents, new IntentComparator(context, preferenceType));
78 |
79 | }
80 |
81 | public static void preferredIntent(Context context, PreferenceType preferenceType, ArrayList orderingPackageName, List resolveIntents) {
82 | Collections.sort(resolveIntents, new IntentComparator(context, preferenceType, orderingPackageName));
83 |
84 | }
85 |
86 | public static void preferredIntent(Context context, PreferenceType preferenceType, String regEx, List resolveIntents) {
87 | Collections.sort(resolveIntents, new IntentComparator(context, preferenceType, regEx));
88 |
89 | }
90 |
91 |
92 | public static class IntentComparator implements Comparator {
93 | private PreferenceType preferenceType;
94 | private ArrayList preferencesList;
95 | private Context mContext;
96 | private String regEx;
97 |
98 | public IntentComparator(Context context, PreferenceType preferenceType) {
99 | this.preferenceType = preferenceType;
100 | mContext = context;
101 | }
102 |
103 | public IntentComparator(Context context, PreferenceType preferenceType, ArrayList preferenceList) {
104 | this.preferenceType = preferenceType;
105 | this.preferencesList = preferenceList;
106 | mContext = context;
107 | }
108 |
109 | public IntentComparator(Context context, PreferenceType preferenceType, String regEx) {
110 | this.preferenceType = preferenceType;
111 | this.regEx = regEx;
112 | mContext = context;
113 | }
114 |
115 |
116 | @Override
117 | public int compare(ResolveIntent resolveIntent, ResolveIntent t1) {
118 | switch (preferenceType) {
119 | case ASCENDING:
120 | return getName(mContext, resolveIntent.getResolveInfo()).compareTo(getName(mContext, t1.getResolveInfo()));
121 | case DECENDING:
122 | return getName(mContext, t1.getResolveInfo()).compareTo(getName(mContext, resolveIntent.getResolveInfo()));
123 | case CUSTOM_APPNAME:
124 | return compare(getName(mContext, resolveIntent.getResolveInfo()), getName(mContext, t1.getResolveInfo()));
125 | case CUSTOM_PACKAGENAME:
126 | return compare(getPackageName(resolveIntent.getResolveInfo()), getPackageName(t1.getResolveInfo()));
127 | case CUSTOM_REGEX_APPNAME:
128 | return compareRegEx(getName(mContext, resolveIntent.getResolveInfo()), getName(mContext, t1.getResolveInfo()));
129 | case CUSTOM_REGEX_PACKAGE_NAME:
130 | return compareRegEx(getPackageName(resolveIntent.getResolveInfo()), getPackageName(t1.getResolveInfo()));
131 |
132 | }
133 | return 0;
134 | }
135 |
136 | private int compare(String resolveIntentName, String t1Name) {
137 | if (preferencesList.contains(resolveIntentName) && preferencesList.contains(t1Name)) {
138 | int resolveIntentIndex = preferencesList.indexOf(resolveIntentName);
139 | int t1Index = preferencesList.indexOf(t1Name);
140 | if (resolveIntentIndex > t1Index) {
141 | return 1;
142 | }
143 | return -1;
144 | } else if (preferencesList.contains(resolveIntentName)) {
145 | Log.e("arrang", "jdf");
146 | return -1;
147 | } else if (preferencesList.contains(t1Name)) {
148 | Log.e("arrang", "jdf");
149 | return 1;
150 | }
151 | return resolveIntentName.compareTo(t1Name);
152 | }
153 |
154 | private int compareRegEx(String resolveIntentName, String t1Name) {
155 | if (resolveIntentName.matches(regEx) && !t1Name.matches(regEx)) {
156 | return -1;
157 | } else if (t1Name.matches(regEx) && !resolveIntentName.matches(regEx)) {
158 | return 1;
159 | }
160 | return resolveIntentName.compareTo(t1Name);
161 | }
162 |
163 |
164 | }
165 |
166 | }
167 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/TargetIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip.IntentUtils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Arrays;
8 | import java.util.List;
9 |
10 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
11 |
12 | /**
13 | * Created by zone2 on 10/7/16.
14 | */
15 |
16 | public class TargetIntent extends IntentLookUp {
17 |
18 |
19 | public static List getAllMainActionApps(Context context) {
20 | return lookUp(context, new Intent().setAction("android.intent.action.MAIN"));
21 | }
22 |
23 | public static List getAllApps(Context context) {
24 | return lookUp(context, new Intent().setAction("android.intent.action.MAIN").addCategory(Intent.CATEGORY_LAUNCHER));
25 | }
26 |
27 | public static ResolveIntent targetByAppName(Context context, List resolveIntents, String appName) {
28 | lookUpAppsByAppName(context, resolveIntents, new ArrayList(Arrays.asList(appName)));
29 | if (resolveIntents.size() > 0) {
30 | return resolveIntents.get(0);
31 | }
32 | return null;
33 | }
34 |
35 | public static ResolveIntent targetByPackageName(Context context, List resolveIntents, String packageName) {
36 | lookUpAppsByPackageName(resolveIntents, new ArrayList(Arrays.asList(packageName)));
37 | if (resolveIntents.size() > 0) {
38 | return resolveIntents.get(0);
39 | }
40 | return null;
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/intentmanip/src/main/java/xyz/belvi/intentmanip/LaunchIntent.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip;
2 |
3 | import android.app.Activity;
4 | import android.content.DialogInterface;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 |
8 | import com.cocosw.bottomsheet.BottomSheet;
9 |
10 | import java.util.Collections;
11 | import java.util.Comparator;
12 | import java.util.List;
13 |
14 | import xyz.belvi.intentmanip.IntentUtils.IntentCallBack.ResolvedIntentListener;
15 | import xyz.belvi.intentmanip.IntentUtils.ManipUtils;
16 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveCategory;
17 | import xyz.belvi.intentmanip.IntentUtils.Models.ResolveIntent;
18 |
19 | /**
20 | * Created by zone2 on 10/2/16.
21 | */
22 |
23 | public class LaunchIntent {
24 |
25 |
26 | private static BottomSheet.Builder builder(Activity context, List resolveIntents, String title) {
27 | BottomSheet.Builder bottomSheet = new BottomSheet.Builder(context);
28 | bottomSheet.title(title);
29 | int index = 0;
30 | for (ResolveIntent resolveIntent : resolveIntents) {
31 |
32 | bottomSheet.sheet(index, resolveIntent.getResolveInfo().loadIcon(context.getPackageManager()), resolveIntent.getResolveInfo().loadLabel(context.getPackageManager()));
33 | index++;
34 | }
35 |
36 | return bottomSheet;
37 | }
38 |
39 | private static BottomSheet.Builder categoryBuilder(Activity context, String title) {
40 | return new BottomSheet.Builder(context)
41 | .title(title).sheet(R.menu.category_menu);
42 |
43 | }
44 |
45 |
46 | public static void withButtomSheetAsList(Activity context, final List resolveIntents, String title, final ResolvedIntentListener resolvedIntentListener) {
47 | builder(context, resolveIntents, title).listener(new DialogInterface.OnClickListener() {
48 | @Override
49 | public void onClick(DialogInterface dialogInterface, int i) {
50 | resolvedIntentListener.onIntentSelected(resolveIntents.get(i));
51 | }
52 | }).show();
53 | }
54 |
55 | public static void withButtomSheetGrid(Activity context, final List resolveIntents, String title, final ResolvedIntentListener resolvedIntentListener) {
56 | builder(context, resolveIntents, title).grid().listener(new DialogInterface.OnClickListener() {
57 | @Override
58 | public void onClick(DialogInterface dialogInterface, int i) {
59 | resolvedIntentListener.onIntentSelected(resolveIntents.get(i));
60 | }
61 | }).grid().show();
62 | }
63 |
64 |
65 | public static void categorised(Activity context, final List resolveCategories, String title, final ResolvedIntentListener resolvedIntentListener) {
66 | BottomSheet sheet = categoryBuilder(context, "Complete action using").listener(new MenuItem.OnMenuItemClickListener() {
67 | @Override
68 | public boolean onMenuItemClick(MenuItem menuItem) {
69 | ResolveIntent resolveIntent = findResolveIntentFromIndex(resolveCategories, menuItem.getItemId());
70 | resolvedIntentListener.onIntentSelected(resolveIntent);
71 | return false;
72 | }
73 | }).build();
74 | Menu menu = sheet.getMenu();
75 | Collections.sort(resolveCategories, new IntentCategoryOrdering());
76 | int id = 0;
77 | for (ResolveCategory resolveCategory : resolveCategories) {
78 | int index = 0;
79 | for (ResolveIntent resolveIntent : resolveCategory.getResolveIntents()) {
80 | if (index == 0) {
81 | menu.add(0, fakeID(id), resolveCategory.getOrderId(), resolveCategory.getCategoryName());
82 | menu.findItem(fakeID(id)).setEnabled(false);
83 | }
84 | menu.add(0, id, resolveCategory.getOrderId(), new ManipUtils().getName(context, resolveIntent.getResolveInfo()));
85 | menu.findItem(id).setIcon(resolveIntent.getResolveInfo().loadIcon(context.getPackageManager()));
86 | index++;
87 | id++;
88 | }
89 |
90 | }
91 | sheet.show();
92 |
93 |
94 | }
95 |
96 | private static ResolveIntent findResolveIntentFromIndex(List resolveCategories, int index) {
97 | int currentIndex = index;
98 | for (ResolveCategory resolveCategory : resolveCategories) {
99 | int size = resolveCategory.getResolveIntents().size();
100 | if (currentIndex < size) {
101 | return resolveCategory.getResolveIntents().get(currentIndex);
102 | } else {
103 | currentIndex -= size;
104 | }
105 | }
106 | return null;
107 | }
108 |
109 | private static int fakeID(int index) {
110 | return 200 * (index + 1);
111 | }
112 |
113 | public static boolean checkByAppNAme(ResolveIntent resolveIntent, String appName) {
114 | return false;
115 | }
116 |
117 | public static boolean checkByPackageName(ResolveIntent resolveIntent, String appName) {
118 | return false;
119 | }
120 |
121 | public static boolean matchesAppName(ResolveIntent resolveIntent, String regEx) {
122 | return false;
123 | }
124 |
125 | public static boolean matchesPackageName(ResolveIntent resolveIntent, String regEx) {
126 | return false;
127 | }
128 |
129 | private static class IntentCategoryOrdering implements Comparator {
130 |
131 |
132 | @Override
133 | public int compare(ResolveCategory resolveCategory, ResolveCategory t1) {
134 | if (t1.getOrderId() > resolveCategory.getOrderId()) {
135 | return -1;
136 | } else if (t1.getOrderId() > resolveCategory.getOrderId()) {
137 | return 1;
138 | }
139 | return 0;
140 | }
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/intentmanip/src/main/res/menu/category_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/intentmanip/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | IntentManip
3 |
4 |
--------------------------------------------------------------------------------
/intentmanip/src/test/java/xyz/belvi/intentmanip/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package xyz.belvi.intentmanip;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/sample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KingsMentor/IntentManip/95baa371b6bb0f5f7ed3c388b12092ef47e66d8c/sample.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':intentmanip'
2 |
--------------------------------------------------------------------------------