Git Product home page Git Product logo

multiapppicker's Introduction

MultiAppPicker

API

A simple, material design multi-app picker using RecyclerView and Alphabetical Fast Scrolling (based on MultiContactPicker )! The picker will read the device applications and allow you to select 1-1 or 1-many and return them in a convenient list.

Note: In the code you can see some comments relative to the icon of the application selected; if you need the icon of the selected application you can uncomments the code (recommended for single choise mode); it's not recommended for multi choise mode because the icons (bitmaps) are also serialised into an internal bundle. Unfortunately this bundle has a very small size limit.

Screenshot

Install

Add this to your project build.gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Add this to your module build.gradle

    dependencies {
        compile 'com.github.biagiopietro:MultiAppPicker:1.0'
    }

Usage

Open the picker in your activity/fragment:

new MultiAppPicker.Builder(MainActivity.this) //Activity/fragment context
                        .theme(R.style.MyCustomPickerTheme) //Optional - default: MultiAppPicker.Azure
                        .hideScrollbar(false) //Optional - default: false
                        .showTrack(true) //Optional - default: true
                        .searchIconColor(Color.WHITE) // Optional - default: White
                        .setSelectOnlyOneItem(singleChoiseMode) // Optional -  default: false
                        .showBackButton(true) // Optional - default: true
                        .handleColor(ContextCompat.getColor(MainActivity.this, R.color.colorPrimary)) //Optional - default: Azure Blue
                        .bubbleColor(ContextCompat.getColor(MainActivity.this, R.color.colorPrimary)) //Optional - default: Azure Blue
                        .bubbleTextColor(Color.WHITE) //Optional - default: White
                        .showPickerForResult(APP_PICKER_REQUEST);

Then listen for results:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == APP_PICKER_REQUEST){
            if(resultCode == RESULT_OK) {
                List<ApplicationResult> results = MultiAppPicker.obtainResult(data);
                if (singleChoiseMode == true) {
                    Log.d("MyTag", results.get(results.size() - 1).getApplicationPackageName());
                } else {
                    printSelectedItemsOnConsole(results);
                }
            } else if(resultCode == RESULT_CANCELED){
                System.out.println("User closed the picker without selecting items.");
            }
        }
    }

    private void printSelectedItemsOnConsole(List<ApplicationResult> results) {
        for(ApplicationResult result: results) {
            Log.d("MyTag", result.getApplicationTitle() + " -> " + result.getApplicationPackageName());
        }
    }

Themeing

MultiAppPicker has a default theme called Azure, however you can use a custom theme if you wish by using both the builder calls above and using styles:

    <style name="MyCustomPickerTheme" parent="MultiAppPicker.Azure">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="mapToolbarTheme">@style/MyCustomToolbarTheme</item>
        <item name="mapListPopupWindowStyleTheme">@style/MyCustomToolbarTheme</item>
    </style>

    <style name="MyCustomToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:textColorPrimary">@color/colorAccent</item>
        <item name="android:textColorSecondary">@color/colorAccent</item>
    </style>

This can then be set in the builder above using .theme(int)

Language

  • English;
  • Italian.

Thanks

MultiAppPicker utilises code from these great libraries:

License

Copyright 2018 biagiopietro

Licensed 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 at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.

multiapppicker's People

Contributors

biagiopietro avatar

Stargazers

่Œถ avatar uso avatar Bakyt Itigulov avatar Abhishek Nair avatar Motonari Tsuzuki avatar Edgar Ceballos avatar Andrea Colombo avatar alphaDroid89 avatar sovereign avatar Dzhunet Hasan avatar Lalit Pawar avatar Alessandro avatar

Watchers

James Cloos avatar uso avatar

multiapppicker's Issues

preselect apps in list

is there a way to provide a list of package names to have the list pre-tick those apps.
eg. The user opens the app list, selects a few apps and submits.
On the next use those previously selected apps should be still ticked.

In single 'singleChoiseMode' the app select wrong app

Open the app picker intent in 'singleChoiseMode' mode.
From the list of apps shown, pick one app but do not click on 'Select' button yet.
Now click on some other app from the list, which means I want to pick the new app now.
Click on Select button.

Expected behaviour-
The app should pick the last selected app, which is the recent most selection.

Actual behaviour-
The app picks the first clicked app. It might happen that user might select the wrong app first and then corrects. But it doesn't reflect and on the app list UI actual selection shown is the new app but old app selection is saved instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.