Skip to content

Ready to use library that allows people to select pictures from their device and Facebook account.

License

Notifications You must be signed in to change notification settings

lovoo/android-pickpic

Repository files navigation

android-pickpic (Pick a Picture)

Description

Ready to use library that allows people to select pictures from their device and Facebook account. It's designed to unify multiple picture sources in one flow. PickPic can be configured for different use cases:

  • select one profile picture

  • select multiple pictures as attachment

  • select a minimum of 2 pictures to finish an onboarding

  • ...

It is also possible to configure title, subtitle and the call to action (text or icon). If you want to communicate a rule set for your guidelines you can pass an FAQ url.

PickPic will handle all permissions for storage, camera and Facebook.

What PickPic will not handle are animated pictures and videos.

Screenshot

Screenshot

Screenshot

Import

We have to find a new host. Since Bintray shuts down we do not deploy to any repository since 1.4.0. We are sorry and try to find time to setup a new repository as host soon.

PickPic was hosted on Jcenter. Add this to your project's build.gradle.

repositories {
    jcenter()
}

Then add this to your app's build.gradle and replace <tag> with the version you want to use:

pickpic_version = "<tag>"

dependencies {
    implementation "com.lovoo.android:pickapp:$pickpic_version"
}
pickpic_version = "<tag>"

dependencies {
    implementation ("com.lovoo.android:pickapp:$pickpic_version") {
        exclude group: 'com.lovoo.android', module: 'pickfacebook'
        exclude group: 'com.lovoo.android', module: 'pickcam'
    }
}

Depending on the function you need you could also leave out some modules like com.lovoo.android:pickfacebook (see chapter Modules).

Usage

Start the PickPicActivity for result and pass a PickPicConfig that fits your needs.

    private fun startPicker() {
        val config = PickPicConfig(
            style = R.style.AppTheme_NoActionbar,           // your app theme
            minCount = 2,                                   // button will be active when 2 pictures are selected
            maxCount = 10,                                  // limit selection count to 10
            sendIcon = R.drawable.ic_upload,                // provide icon for the button
            header = "Please choose 2 or more pictures",    // provide text for the title
            title = "My Activity Title",
            faqUrl = "https://www.myDomain.com/myPictureGuidelines"
        )

        Intent(this, PickPicActivity::class.java).let {
            PickPicActivity.applyConfig(it, config)
            startActivityForResult(it, 101)
        }
    }

Wait and handle the Activity result to fetch the selected pictures

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (requestCode == 101) {
            val result = PickPicActivity.getResult(data)
            
            // handle the selected Uri's for your use case
            
            return
        }

        super.onActivityResult(requestCode, resultCode, data)
    }

You are free to call the provided PickPickActivity or do your own implementation and use the Fragments and Adapter that are provided by the modules.

Facebook implementation

You have to set up your app as described in Facebook docs. Overwrite these strings with your own Facebook app id and protocol scheme:

    <string name="facebook_app_id">your_app_id</string>
    <string name="fb_login_protocol_scheme">your_protocol_scheme</string>

Do not forget to apply your APK for Facebook review to unlock picture permission.

Customization

Design can be changed easily by overwriting the style attributes and resources. It's also possible to overwrite whole layouts, but keep in mind that some view ids and classes may be mandatory. So please don't change an AndroidX RecyclerView to a SupportRecyclerView or worse GridLayout :) When changing the style attributes, please keep in mind that you need to copy the whole theme

Example: styles.xml

Or extend your app theme from PickPic <style name="ExampleAppTheme" parent="PickPicAppTheme">

PickPic provides only English as translation, so that you can decide which languages you offer on top. To localize PickPic in your languages just provide translations for all PickPic strings.

Example: strings.xml

Modules

PickPick is divided in different modules:

Module Description Dependency Path External Dependencies Documentation
PickCore The base of PickPick com.lovoo.android:pickcore:$pickpic_version androidx.exifinterface:exifinterface
androidx.appcompat:appcompat
androidx.recyclerview:recyclerview
androidx.lifecycle:lifecycle-livedata
link
PickUI The basic UI implementation com.lovoo.android:pickui:$pickpic_version pickcore
androidx.vectordrawable:vectordrawable
androidx.constraintlayout:constraintlayout
link
PickCam The camera capture implementation com.lovoo.android:pickcam:$pickpic_version pickcore
androidx.appcompat:appcompat
androidx.constraintlayout:constraintlayout
android.arch.work:work-runtime
android.arch.work:work-runtime-ktx
android.arch.work:work-rxjava2
link
PickFacebook Facebook module for PickPic com.lovoo.android:pickfacebook:$pickpic_version pickui
com.google.code.gson:gson
com.facebook.android:facebook-android-sdk
link
PickApp A ready to use PickPicActivity that can be configured com.lovoo.android:pickapp:$pickpic_version pickfacebook (alternative pickui)
pickcam (optional)
com.google.android.material:material
io.reactivex.rxjava2:rxjava
io.reactivex.rxjava2:rxandroid
com.github.bumptech.glide:compiler
androidx.lifecycle:lifecycle-compiler
link

For PickApp: The Facebook Tab will only appear if PickFacebook is packed within your dependencies. For PickApp: The Camera Capture will only appear if PickCam is packed within your dependencies.

Permissions, such as storage and camera, are handled by PickPic. Camera permission will be only requested when using the camera functionality and when your manifest declares this permission.

License

Copyright 2018 LOVOO GmbH

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.`