Skip to content

Android image picker and camera app based on PixImagePixer library version 1.5.2 by Akshay Sharma.

Notifications You must be signed in to change notification settings

yzzzd/PixProject

Repository files navigation

PixProject

Release

Android image picker and camera app based on PixImagePixer library version 1.5.2 by Akshay Sharma.

Mod

  1. CameraX implementation
  2. ActivityResultContracts replace ActivityResult

Download

Add it to your build.gradle with:

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

and:

dependencies {
    implementation 'com.github.yzzzd:PixProject:{latest version}'
}

Usage

val options = Options.init()
  .setType(Options.Mode.Both) //Options.Mode.Camera or Options.Mode.Gallery
  .setCount(3)                //Number of images to restict selection count

Pix.open(this, options, activityResultLauncher)

or just use with minimal config

Pix.open(this, Options.Mode.Both, activityResultLauncher)

for fetching only a single picture.

Use ActivityResultContracts to get results

private var activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
  if (result.resultCode == Activity.RESULT_OK) {
    val returnValue = result.data?.getStringArrayListExtra(Pix.IMAGE_RESULTS)
    if (returnValue?.isNotEmpty() == true) {
      val imageFile = File(returnValue[0])
      binding.imageView.setImageURI(imageFile.toUri())
    }
  }
}

License

Licensed under the Apache License, Version 2.0,

About

Android image picker and camera app based on PixImagePixer library version 1.5.2 by Akshay Sharma.

Resources

Stars

Watchers

Forks

Packages

No packages published