Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Gives more control over implicit intents creation and the way it is presented to users.

License

NotificationsYou must be signed in to change notification settings

KingsMentor/IntentManip

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.

LicenseAndroid Arsenal

Lib Sample

Adding to your project.

step 1

Add it in your root build.gradle at the end of repositories:

repositories {...maven { url "https://jitpack.io" }}

step 2

Add the dependency

dependencies {        compile 'com.github.KingsMentor:IntentManip:v1.0'}

Usage :

There are a couple of operations you can do with the library. It includes:

  1. Merging
  2. Categorizing Intent
  3. Appending Intent
  4. Ignoring Component
  5. Lookup Component
  6. Target Component
  7. Component Preference

Snippets :

Merging - merging components of different intents

List<ResolveIntent>resolveIntentList =mergeIntents(this,MediaIntents.newSelectPictureIntent(),GeoIntents.newNavigationIntent(""));LaunchIntent.withButtomSheetAsList(this,resolveIntentList,"launch using",newResolvedIntentListener<ResolveIntent>() {@OverridepublicvoidonIntentSelected(ResolveIntentresolveIntent) {            }        });
Note

launchingintentfromresolveIntent

startActivity(ManipUtils.getLaunchableIntent(resolveIntent));

implementResolvedIntentListener to get the item the user selected from the list

Categorising Components

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));            }        });

Appending Explicit Intents.

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));            }        });

Ignore Components

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) {            }        });

LookingUp Components

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) {            }        });

Target a Component

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));        }

Component Preference

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);

Contributing

Contributions are welcome.

Credits

android-intents andBottom Sheet upon which this library is based.

License

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp