Site icon Android Tutorial Online

A Kotlin Library help you to pick photos

A Kotlin Library help you to pick photos

PickPhotoView

A Library help u to pick photos.

Click to download lastest demo ⬇️ or select Release Version

Last Update (2019.1.2)

v0.4.8

  1. update third part lib version
  2. fix some bug
  3. add proguard

Screenshot

Dependency

the last-version is releases-version

Gradle

   implementation 'com.github.AnonymousBoiz:ImagePicker:1.0'  // Last Version

repositories

    maven { url 'https://jitpack.io' } 
    // Last Version

some Library already dependency

If you don’t want to dependency this Library version , you can replace it just like

  compile ('com.werb.pickphotoview:pickphotoview:last-version',{
        exclude group: 'com.google.code.gson'
  })
  compile 'com.google.code.gson:gson:XXXX'

New Version 0.3.6+ build with Kotlin new feature LayoutContainer , so you must add this command in your module build.gradle

apply plugin: 'kotlin-android-extensions'

and config this command in android{}

androidExtensions {
    experimental = true
}

when new feature published in kotlin release version it will built-in code and no need for config

Usage

Make sure you have permissions about CAMERA and WRITE/READ_EXTERNAL_STORAGE before use

PermissionsChecker : A Library help u to check permissions on Android M.

Register Provider in your app AndroidManifest.xml

    <provider
        android:name="com.werb.pickphotoview.provider.PickProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/pick_file_paths"/>
    </provider>

Initialize PickPhotoView

 new PickPhotoView.Builder(MainActivity.this)
    .setPickPhotoSize(1)                  // select image size
    .setClickSelectable(true)             // click one image immediately close and return image
    .setShowCamera(true)                  // is show camera
    .setSpanCount(3)                      // span count
    .setLightStatusBar(true)              // lightStatusBar used in Android M or higher
    .setStatusBarColor(R.color.white)     // statusBar color
    .setToolbarColor(R.color.white)       // toolbar color
    .setToolbarTextColor(R.color.black)   // toolbar text color
    .setSelectIconColor(R.color.pink)     // select icon color
    .setShowGif(false)                    // is show gif
    .start();

onActivityResult

  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == 0){
            return;
        }
        if(data == null){
            return;
        }
        if (requestCode == PickConfig.PICK_PHOTO_DATA) {
            ArrayList<String> selectPaths = (ArrayList<String>) data.getSerializableExtra(PickConfig.INTENT_IMG_LIST_SELECT);
            // do something u want
        }
    }

proguard

proguard-rules.pro

License

Apache2.0

GitHub

View Github

Exit mobile version