GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ParthLotia/FilePicker: File Picker (Image, VIdeo, Audio , Doc and PDF) Demo with till Android 16 support

BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
.gradle
.gradle
 
 
.idea
.idea
 
 
app
app
 
 
art
art
 
 
build/reports/problems
build/reports/problems
 
 
gradle/wrapper
gradle/wrapper
 
 
photoPicker
photoPicker
 
 
.gitattributes
.gitattributes
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
jitpack.yml
jitpack.yml
 
 
local.properties
local.properties
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

PhotoPicker

Here is the Demo for the PhotoPicker in All Android Versions

I have added other pickers as well(pdf,doc,video,pictures).

There is no need to add any kind of permission and any library to select File from gallery .

I have tested with multiple scenarios , here is the scenario list

  1. Android 8 to 16 versions
  2. Also Add the Single Photo and Multiple Photo Selection
  3. Single Photo Selection Working on All Android Versions
  4. Multiple Photo Selection will work from Android 11 to Android 16.
  5. Multiple Photo Selection below Android 11 we have to use clipdata the old way.

Here how to use library in your project follow below steps .

Currently Tag version is 1.0.9

  1. In your gradle(app) add below line
    dependencies{
         implementation 'com.github.ParthLotia:FilePicker:Tag'
    }

Replace your Tag with current version 1.0.9

  1. In your project level gradle add below line
    repositories {
        google()
        mavenCentral()
        maven { url "https://www.jitpack.io" }
    }
  1. Add below code in your activity/fragment
    In on create add below lines
    
    btn_upload_pick.setOnClickListener {
            val mimeType = "*/*"
            /*Single Document Picker*/
            // Image , Video , PDF , DOC , DOCX
            pickMedia.launch(
                arrayOf(mimeType)
            )
        }
        
        
    Out side on create add below lines of code
    
        private val pickMedia =
        registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
            if (uri != null) {
                val file = FileUriUtils.getRealPath(this, uri)?.let { File(it) }
                if (FileUriUtils.checkExtensionFile(file)) {
                    img_pick.setImageURI(uri)
                } else {
                    img_pick.setImageBitmap(
                        FileUtil.getThumbnail(
                            file,
                            uri,
                            context = applicationContext
                        )
                    )
                }
            } else {
                Log.d("PhotoPicker", "No media selected")
            }
        }
        
    Here img_pick is an Imageview to display the file you have selected .
        
    
    For Jetpack Compose    
         
         Button(onClick = {
                            singleFilePickerLauncher.launch(arrayOf("*/*"))
                        }) {
                            Text(text = "Choose File")
                        }
         
         val singleFilePickerLauncher = rememberLauncherForActivityResult(
                    contract = ActivityResultContracts.OpenDocument(),
                    onResult = { uri ->

                        if (uri != null) {
                            file = FileUriUtils.getRealPath(this, uri)?.let { File(it) }
                            if (FileUriUtils.checkExtensionFile(file)) {
                                selectedSingleImageUri.value = uri
                                selectedSingleImageUriThumbnail.value = null
                            } else {
                                selectedSingleImageUri.value = null
                                Log.e("uri", "PLAndroid" + uri)
                                selectedSingleImageUriThumbnail.value = uri

                            }
                        }
                    }
                )
                
                 selectedSingleImageUri.value.let {
                        if (it != null) {
                            AsyncImage(model = it, contentDescription = "")
                        }
                    }
        
    Here AsyncImage is an ImageView to display the file you have selected .

About

File Picker (Image, VIdeo, Audio , Doc and PDF) Demo with till Android 16 support

Topics

androidandroid13android13-supportandroid14android15android16galleryimage-pickerimagesjetpackjetpack-androidjetpack-composekotlinmultiple-image-uploadpermissionsphotopickersingle-imagevideo

Resources

Readme
Activity

Stars

24 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.