- Notifications
You must be signed in to change notification settings - Fork4
Gives more control over implicit intents creation and the way it is presented to users.
License
KingsMentor/IntentManip
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Gives more controls over implicit intents creation and the way it is presented to users.See this for a more detailed explanation on why you should consider using this library.
Add it in your root build.gradle at the end of repositories:
repositories {...maven { url "https://jitpack.io" }}
Add the dependency
dependencies { compile 'com.github.KingsMentor:IntentManip:v1.0'}
There are a couple of operations you can do with the library. It includes:
- Merging
- Categorizing Intent
- Appending Intent
- Ignoring Component
- Lookup Component
- Target Component
- Component Preference
List<ResolveIntent>resolveIntentList =mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));LaunchIntent.withButtomSheetAsList(this,resolveIntentList,"launch using",newResolvedIntentListener<ResolveIntent>() {@OverridepublicvoidonIntentSelected(ResolveIntentresolveIntent) { } });
launchingintentfromresolveIntent
startActivity(ManipUtils.getLaunchableIntent(resolveIntent));
implementResolvedIntentListener
to get the item the user selected from the list
for presenting merged intents in a categorised format
ResolveCategorypixResolveCategory =CategorisedIntent.categorized(this,MediaIntents.newSelectPictureIntent(),"picture",1);List<ResolveIntent>merge =newMergeIntent().mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));ResolveCategorymergeResolveCategory =CategorisedIntent.categorized(merge,"Geo and Media",2);List<ResolveCategory>resolveCategories =newArrayList<>();resolveCategories.add(pixResolveCategory);resolveCategories.add(mergeResolveCategory);LaunchIntent.categorised(this,resolveCategories,"Share With",newResolvedIntentListener<ResolveIntent>() {@OverridepublicvoidonIntentSelected(ResolveIntentresolveIntent) {startActivity(ManipUtils.getLaunchableIntent(resolveIntent)); } });
for adding explicit intent ( probably activities from your project ) to implicit components.
PreparedIntentpreparedIntent =newPreparedIntent(newIntent(this,Sample.class),R.string.sample,R.mipmap.ic_launcher);List<ResolveIntent>resolveIntentList =IntentAppend.appendCustomIntent(this,MediaIntents.newSelectPictureIntent(),preparedIntent);LaunchIntent.withButtomSheetAsList(this,resolveIntentList,"launch using",newResolvedIntentListener<ResolveIntent>() {@OverridepublicvoidonIntentSelected(ResolveIntentresolveIntent) {startActivity(ManipUtils.getLaunchableIntent(resolveIntent)); } });
to ignore or skip or remove components that matches a defined naming pattern from the list
List<ResolveIntent>resolveIntentList =mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));IntentIgnore.IgnoreIntentWithName(this,resolveIntentList,newArrayList<String>(Arrays.asList(newString[]{"Maps"})));LaunchIntent.withButtomSheetAsList(this,resolveIntentList,"launch using",newResolvedIntentListener() {@OverridepublicvoidonIntentSelected(ObjectresolveIntent) { } });
to find and return components that matches a defined naming pattern
List<ResolveIntent>resolveIntentList =mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));IntentLookUp.lookUpAppsByAppName(this,resolveIntentList,"Maps");LaunchIntent.withButtomSheetAsList(this,resolveIntentList,"launch using",newResolvedIntentListener() {@OverridepublicvoidonIntentSelected(ObjectresolveIntent) { } });
to target a particular component from a list of component.returnsnull
if not found or return the first item if more than 1 item is found.
List<ResolveIntent>resolveIntentList =mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));ResolveIntentresolveIntent =TargetIntent.targetByAppName(this,resolveIntentList,"Photo");if (resolveIntent !=null) {startActivity(ManipUtils.getLaunchableIntent(resolveIntent)); }
This involves using aPreferenceType
which could be
- ASCENDING - to arange components in an alphabetical order by appname
- DECENDING - to arange components in a decending alphabetical order by app name
- CUSTOM_PACKAGENAME - arrange the list, placing components with supplied package names aboved others.
- CUSTOM_APPNAME - arrange the list, placing components with supplied app names aboved others.
- CUSTOM_REGEX_APPNAME - arrange the list, placing components with app names matching regEx supplied aboved others.
- CUSTOM_REGEX_PACKAGE_NAME - arrange the list, placing components with package names matching regEx supplied aboved others.
Alsonote that CUSTOM Preference type sort the component in same manage the list was provided.
List<ResolveIntent>resolveIntentList =mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));PreferenceIntent.preferredIntent(this,PreferenceType.CUSTOM_APPNAME,newArrayList<String>(Arrays.asList(newString[]{"Maps","Photo"})),resolveIntentList);LaunchIntent.withButtomSheetAsList(this,resolveIntentList,"launch using",newResolvedIntentListener() {@OverridepublicvoidonIntentSelected(ObjectresolveIntent) { } });
The snippet above will sort the merge component ofMediaIntents
andGeoIntents
but would place Maps and Photo above the entire list.Maps will be above Photos because if was provided that way. To bring Photos above Maps, it has to be this way:
PreferenceIntent.preferredIntent(this,PreferenceType.CUSTOM_APPNAME,newArrayList<String>(Arrays.asList(newString[]{"Photo","Maps"})),resolveIntentList);
Contributions are welcome.
android-intents andBottom Sheet upon which this library is based.
Copyright (C) 2016 MarvinLabs Copyright (C) 2011, 2015 Kai LiaoLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
About
Gives more control over implicit intents creation and the way it is presented to users.