├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ ├── list_item_selected_media.xml │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── ic_launcher-playstore.png │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── geeksmediapickerdemo │ │ │ ├── SelectedMediaAdapter.kt │ │ │ └── MainActivity.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── geeksmediapickerdemo │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── geeksmediapickerdemo │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── .idea ├── .name ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── compiler.xml ├── kotlinc.xml ├── vcs.xml ├── gradle.xml ├── misc.xml └── jarRepositories.xml ├── GeeksArts ├── empty.md ├── art1.jpg ├── art2.jpg ├── art3.jpg ├── art4.jpg ├── art5.jpg ├── art6.jpg └── art7.jpg ├── geeksmediapicker ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── res │ │ │ ├── font │ │ │ │ ├── poppins_bold.otf │ │ │ │ ├── poppins_light.otf │ │ │ │ ├── poppins_medium.otf │ │ │ │ ├── poppins_regular.otf │ │ │ │ ├── poppins_bold_italic.otf │ │ │ │ ├── poppins_light_italic.otf │ │ │ │ └── poppins_medium_italic.otf │ │ │ ├── drawable │ │ │ │ ├── check_box.png │ │ │ │ ├── check_box_tick.png │ │ │ │ ├── shadow_top_bottom.png │ │ │ │ ├── ic_arrow_back.xml │ │ │ │ └── ic_video_white.xml │ │ │ ├── xml │ │ │ │ └── provider_paths.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── layout │ │ │ │ ├── activity_camera.xml │ │ │ │ ├── my_custom_toast.xml │ │ │ │ ├── list_item_album.xml │ │ │ │ ├── list_item_media.xml │ │ │ │ └── activity_picker.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── geeksmediapicker │ │ │ │ ├── GeeksMediaType.kt │ │ │ │ ├── utils │ │ │ │ ├── AppConstants.kt │ │ │ │ ├── ViewExtensions.kt │ │ │ │ ├── ActivityExtensions.kt │ │ │ │ ├── FileUtils.kt │ │ │ │ └── ImageCompressor.kt │ │ │ │ ├── interfaces │ │ │ │ ├── ItemClickListener.kt │ │ │ │ └── MediaPickerListener.kt │ │ │ │ ├── models │ │ │ │ ├── MediaStoreAlbum.kt │ │ │ │ └── MediaStoreData.kt │ │ │ │ ├── databinding │ │ │ │ └── BindingAdapters.kt │ │ │ │ ├── adapters │ │ │ │ ├── AlbumAdapter.kt │ │ │ │ ├── MediaAdapter.kt │ │ │ │ └── GridSpacingItemDecoration.kt │ │ │ │ ├── GeeksMediaPicker.kt │ │ │ │ └── ui │ │ │ │ ├── CameraActivity.kt │ │ │ │ ├── PickerActivity.kt │ │ │ │ └── PickerActivityVM.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── geeksmediapicker │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── geeksmediapicker │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── geeksmediapicker.zip ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── LICENSE ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | GeeksMediaPickerDemo -------------------------------------------------------------------------------- /GeeksArts/empty.md: -------------------------------------------------------------------------------- 1 | empty file 2 | -------------------------------------------------------------------------------- /geeksmediapicker/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /geeksmediapicker/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /GeeksArts/art1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art1.jpg -------------------------------------------------------------------------------- /GeeksArts/art2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art2.jpg -------------------------------------------------------------------------------- /GeeksArts/art3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art3.jpg -------------------------------------------------------------------------------- /GeeksArts/art4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art4.jpg -------------------------------------------------------------------------------- /GeeksArts/art5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art5.jpg -------------------------------------------------------------------------------- /GeeksArts/art6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art6.jpg -------------------------------------------------------------------------------- /GeeksArts/art7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/GeeksArts/art7.jpg -------------------------------------------------------------------------------- /geeksmediapicker.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker.zip -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GeeksMediaPickerDemo 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_bold.otf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/drawable/check_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/drawable/check_box.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_light.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_light.otf -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_medium.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_medium.otf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_regular.otf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/drawable/check_box_tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/drawable/check_box_tick.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_bold_italic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_bold_italic.otf -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/drawable/shadow_top_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/drawable/shadow_top_bottom.png -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_light_italic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_light_italic.otf -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/font/poppins_medium_italic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/im-manisharma/GeeksMediaPicker/HEAD/geeksmediapicker/src/main/res/font/poppins_medium_italic.otf -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/xml/provider_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/GeeksMediaType.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker 2 | 3 | object GeeksMediaType { 4 | const val IMAGE = "IMAGE" 5 | const val VIDEO = "VIDEO" 6 | } -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/utils/AppConstants.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.utils 2 | 3 | internal const val REQ_EXTERNAL_STORAGE = 0x1045 4 | internal const val REQ_CODE_CAPTURE_IMAGE = 0x1046 -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/interfaces/ItemClickListener.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.interfaces 2 | 3 | interface ItemClickListener { 4 | fun onClick(position: Int, event: Any? = null) 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Apr 12 02:52:52 IST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/interfaces/MediaPickerListener.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.interfaces 2 | 3 | import com.geeksmediapicker.models.MediaStoreData 4 | 5 | interface MediaPickerListener { 6 | fun onMediaPicked(selectedMediaList: ArrayList = ArrayList(), mediaStoreData: MediaStoreData = MediaStoreData()) 7 | } 8 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | #0071BC 5 | #6200EE 6 | #3700B3 7 | #03DAC5 8 | 9 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/drawable/ic_arrow_back.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | contentDescription 4 | Select Album 5 | Ok 6 | Selected 7 | Please select a media 8 | Compressing Image... 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | jcenter() 13 | mavenCentral() 14 | } 15 | } 16 | rootProject.name='GeeksMediaPickerDemo' 17 | include ':app' 18 | include ':geeksmediapicker' 19 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/test/java/com/geeksmediapickerdemo/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapickerdemo 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /geeksmediapicker/src/test/java/com/geeksmediapicker/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/layout/activity_camera.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/drawable/ic_video_white.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/models/MediaStoreAlbum.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.models 2 | 3 | import android.net.Uri 4 | 5 | /** 6 | * Simple data class to hold information about an Album included in the device's MediaStore. 7 | */ 8 | data class MediaStoreAlbum( 9 | val bucket_id: Long, 10 | val bucket_name: String?, 11 | val imageUri: Uri?, 12 | val medias: List 13 | ){ 14 | fun getTotalImages(): String{ 15 | return medias.size.toString() 16 | } 17 | } -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/databinding/BindingAdapters.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.databinding 2 | 3 | import android.net.Uri 4 | import android.widget.ImageView 5 | import androidx.databinding.BindingAdapter 6 | import com.bumptech.glide.Glide 7 | 8 | 9 | @BindingAdapter("bind:loadImageUri") 10 | internal fun loadImageUri(imageView: ImageView, uri: Uri?) { 11 | if (uri == null) 12 | return 13 | 14 | Glide.with(imageView.context) 15 | .load(uri) 16 | .thumbnail(0.3f) 17 | .into(imageView) 18 | } 19 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/models/MediaStoreData.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.models 2 | 3 | import android.net.Uri 4 | import android.os.Parcelable 5 | import kotlinx.parcelize.Parcelize 6 | import java.util.* 7 | 8 | /** 9 | * Simple data class to hold information about an image or a video included in the device's MediaStore. 10 | */ 11 | 12 | @Parcelize 13 | data class MediaStoreData( 14 | var media_id: Long = 0, 15 | var bucket_id: Long = 0, 16 | var media_name: String = "", 17 | var media_type: String = "", 18 | var bucket_name: String? = "", 19 | var date_added: Date? = null, 20 | var content_uri: Uri? = null, 21 | var media_path: String = "", 22 | var media_duration: Long = 0, 23 | var isSelected: Boolean = false 24 | ): Parcelable -------------------------------------------------------------------------------- /app/src/androidTest/java/com/geeksmediapickerdemo/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapickerdemo 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.geeksmediapickerdemo", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /geeksmediapicker/src/androidTest/java/com/geeksmediapicker/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.geeksmediapicker.test", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /geeksmediapicker/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 1.8 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/layout/my_custom_toast.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/utils/ViewExtensions.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.utils 2 | 3 | import android.content.Context 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.widget.TextView 7 | import android.widget.Toast 8 | import com.geeksmediapicker.R 9 | 10 | 11 | internal fun View.visible() { 12 | visibility = View.VISIBLE 13 | } 14 | 15 | internal fun View.gone() { 16 | visibility = View.GONE 17 | } 18 | 19 | internal fun View.invisible() { 20 | visibility = View.INVISIBLE 21 | } 22 | 23 | internal fun View.isVisible(): Boolean = visibility == View.VISIBLE 24 | 25 | internal fun Context.showToast(message: String) { 26 | val myInflater = LayoutInflater.from(this) 27 | val view = myInflater.inflate(R.layout.my_custom_toast, null) 28 | val myToast = Toast(this) 29 | myToast.duration = Toast.LENGTH_SHORT 30 | myToast.view = view 31 | view.findViewById(R.id.tvMsg).text = message 32 | myToast.show() 33 | } 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/utils/ActivityExtensions.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.utils 2 | 3 | import android.app.Activity 4 | import android.app.AlertDialog 5 | import android.content.Intent 6 | import android.net.Uri 7 | import android.provider.Settings 8 | 9 | internal fun Activity.showPermissionSettingDialog() { 10 | val alertDialogBuilder: AlertDialog.Builder = AlertDialog.Builder(this) 11 | alertDialogBuilder.setTitle("Permission needed") 12 | alertDialogBuilder.setMessage("Location permission needed to access location") 13 | alertDialogBuilder.setPositiveButton("Open Setting") { _, _ -> 14 | startActivity(Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { 15 | data = Uri.fromParts("package", packageName, null) 16 | }) 17 | finish() 18 | } 19 | alertDialogBuilder.setNegativeButton("Cancel") { dialogInterface, i -> 20 | dialogInterface.dismiss() 21 | finish() 22 | } 23 | val dialog: AlertDialog = alertDialogBuilder.create() 24 | dialog.show() 25 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Manish Sharma 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 23 | 24 | 29 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/adapters/AlbumAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.adapters 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import androidx.recyclerview.widget.RecyclerView 6 | import com.geeksmediapicker.databinding.ListItemAlbumBinding 7 | import com.geeksmediapicker.interfaces.ItemClickListener 8 | import com.geeksmediapicker.models.MediaStoreAlbum 9 | import java.util.* 10 | 11 | class AlbumAdapter( 12 | private val list: ArrayList, 13 | private val itemClickListener: ItemClickListener 14 | ) : RecyclerView.Adapter() { 15 | 16 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 17 | val inflater = LayoutInflater.from(parent.context) 18 | return MyViewHolder(ListItemAlbumBinding.inflate(inflater)) 19 | } 20 | 21 | override fun getItemCount(): Int { 22 | return list.size 23 | } 24 | 25 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) = holder.bind(position) 26 | 27 | inner class MyViewHolder(private val binding: ListItemAlbumBinding) : RecyclerView.ViewHolder(binding.root) { 28 | fun bind(position: Int) { 29 | val model = list[position] 30 | binding.albumData = model 31 | binding.itemPosition = position 32 | binding.clickListener = itemClickListener 33 | binding.executePendingBindings() 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-parcelize' 4 | apply plugin: 'kotlin-kapt' 5 | 6 | android { 7 | compileSdk 33 8 | namespace 'com.geeksmediapickerdemo' 9 | defaultConfig { 10 | applicationId "com.geeksmediapickerdemo" 11 | minSdk 16 12 | targetSdk 33 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | dataBinding { 27 | enabled = true 28 | } 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_17 32 | targetCompatibility JavaVersion.VERSION_17 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = "${JavaVersion.VERSION_17}" 37 | } 38 | 39 | } 40 | 41 | dependencies { 42 | implementation 'androidx.core:core-ktx:1.10.1' 43 | implementation 'androidx.appcompat:appcompat:1.6.1' 44 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 45 | 46 | implementation project(':geeksmediapicker') 47 | 48 | //RecyclerView 49 | implementation 'androidx.recyclerview:recyclerview:1.3.0' 50 | 51 | //Material Library 52 | implementation 'com.google.android.material:material:1.9.0' 53 | 54 | //Glide Library 55 | implementation 'com.github.bumptech.glide:glide:4.15.1' 56 | } 57 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/adapters/MediaAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.adapters 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import androidx.recyclerview.widget.RecyclerView 6 | import com.geeksmediapicker.databinding.ListItemMediaBinding 7 | import com.geeksmediapicker.interfaces.ItemClickListener 8 | import com.geeksmediapicker.models.MediaStoreData 9 | import java.util.* 10 | import java.util.concurrent.TimeUnit 11 | 12 | class MediaAdapter( 13 | private val list: ArrayList, 14 | private val itemClickListener: ItemClickListener 15 | ) : RecyclerView.Adapter() { 16 | 17 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 18 | val inflater = LayoutInflater.from(parent.context) 19 | return MyViewHolder(ListItemMediaBinding.inflate(inflater)) 20 | } 21 | 22 | override fun getItemCount(): Int { 23 | return list.size 24 | } 25 | 26 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) = holder.bind(position) 27 | 28 | inner class MyViewHolder(private val binding: ListItemMediaBinding) : RecyclerView.ViewHolder(binding.root) { 29 | fun bind(position: Int) { 30 | val model = list[position] 31 | binding.mediaData = model 32 | binding.itemPosition = position 33 | binding.clickListener = itemClickListener 34 | 35 | val minutes = TimeUnit.MILLISECONDS.toMinutes(model.media_duration) 36 | val seconds = TimeUnit.MILLISECONDS.toSeconds(model.media_duration) 37 | binding.tvMediaDuration.text = String.format("%d:%d s", minutes, seconds) 38 | binding.executePendingBindings() 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/geeksmediapickerdemo/SelectedMediaAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapickerdemo 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import androidx.recyclerview.widget.RecyclerView 7 | import com.bumptech.glide.Glide 8 | import com.geeksmediapicker.models.MediaStoreData 9 | import com.geeksmediapickerdemo.databinding.ListItemSelectedMediaBinding 10 | import java.util.* 11 | 12 | class SelectedMediaAdapter( 13 | private val list: ArrayList 14 | ) : RecyclerView.Adapter() { 15 | 16 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { 17 | val inflater = LayoutInflater.from(parent.context) 18 | return MyViewHolder(ListItemSelectedMediaBinding.inflate(inflater)) 19 | } 20 | 21 | override fun getItemCount(): Int { 22 | return list.size 23 | } 24 | 25 | override fun onBindViewHolder(holder: MyViewHolder, position: Int) = holder.bind(position) 26 | 27 | inner class MyViewHolder(val binding: ListItemSelectedMediaBinding) : RecyclerView.ViewHolder(binding.root) { 28 | fun bind(position: Int) { 29 | val model = list[position] 30 | 31 | with(itemView){ 32 | Glide.with(binding.ivProductImage.context) 33 | .load(model.content_uri) 34 | .thumbnail(0.3f) 35 | .into(binding.ivProductImage) 36 | //ivProductImage.setImageURI(model.content_uri) 37 | binding.tvMediaName.text = "Name: ${model.media_name}" 38 | binding.tvMediaMimeType.text = "Type: ${model.media_type}" 39 | binding.tvMediaUri.text = "Uri: ${model.content_uri}" 40 | binding.tvMediaPath.text = "Path: ${model.media_path}" 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/adapters/GridSpacingItemDecoration.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.adapters 2 | 3 | import android.graphics.Rect 4 | import android.view.View 5 | import androidx.recyclerview.widget.RecyclerView 6 | 7 | class GridSpacingItemDecoration( 8 | private val spanCount: Int, 9 | private val spacing: Int, 10 | private val includeEdge: Boolean = false 11 | ) : RecyclerView.ItemDecoration() { 12 | 13 | override fun getItemOffsets( 14 | outRect: Rect, 15 | view: View, 16 | parent: RecyclerView, 17 | state: RecyclerView.State 18 | ) { 19 | val position = parent.getChildAdapterPosition(view) // item position 20 | 21 | if (position >= 0) { 22 | val column = position % spanCount // item column 23 | 24 | if (includeEdge) { 25 | outRect.left = 26 | spacing - column * spacing / spanCount // spacing - column * ((1f / spanCount) * spacing) 27 | outRect.right = 28 | (column + 1) * spacing / spanCount // (column + 1) * ((1f / spanCount) * spacing) 29 | 30 | if (position < spanCount) { // top edge 31 | outRect.top = spacing 32 | } 33 | outRect.bottom = spacing // item bottom 34 | } else { 35 | outRect.left = column * spacing / spanCount // column * ((1f / spanCount) * spacing) 36 | outRect.right = 37 | spacing - (column + 1) * spacing / spanCount // spacing - (column + 1) * ((1f / spanCount) * spacing) 38 | if (position >= spanCount) { 39 | outRect.top = spacing // item top 40 | } 41 | } 42 | } else { 43 | outRect.left = 0 44 | outRect.right = 0 45 | outRect.top = 0 46 | outRect.bottom = 0 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /geeksmediapicker/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-parcelize' 4 | apply plugin: 'kotlin-kapt' 5 | 6 | android { 7 | compileSdk 33 8 | namespace 'com.geeksmediapicker' 9 | defaultConfig { 10 | minSdk 16 11 | targetSdkVersion 33 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | consumerProguardFiles 'consumer-rules.pro' 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | dataBinding { 27 | enabled = true 28 | } 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_17 32 | targetCompatibility JavaVersion.VERSION_17 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = "${JavaVersion.VERSION_17}" 37 | } 38 | 39 | } 40 | 41 | dependencies { 42 | implementation 'androidx.core:core-ktx:1.10.1' 43 | implementation 'androidx.appcompat:appcompat:1.6.1' 44 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 45 | 46 | //RecyclerView 47 | implementation 'androidx.recyclerview:recyclerview:1.3.0' 48 | 49 | //Material Library 50 | implementation 'com.google.android.material:material:1.9.0' 51 | 52 | //AndroidX Lifecycle Components with coroutines 53 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1" 54 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' 55 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' 56 | 57 | //Glide Library 58 | implementation 'com.github.bumptech.glide:glide:4.15.1' 59 | 60 | // SDP and SSP 61 | implementation 'com.intuit.sdp:sdp-android:1.0.6' 62 | implementation 'com.intuit.ssp:ssp-android:1.0.6' 63 | } 64 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item_selected_media.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 16 | 17 | 24 | 25 | 34 | 35 | 41 | 42 | 49 | 50 | 57 | 58 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/layout/list_item_album.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 21 | 25 | 26 | 30 | 31 | 38 | 39 | 44 | 45 | 59 | 60 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/geeksmediapickerdemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapickerdemo 2 | 3 | import android.os.Bundle 4 | import android.widget.Toast 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.databinding.DataBindingUtil 7 | import com.geeksmediapicker.GeeksMediaPicker 8 | import com.geeksmediapicker.GeeksMediaType 9 | import com.geeksmediapicker.models.MediaStoreData 10 | import com.geeksmediapickerdemo.databinding.ActivityMainBinding 11 | 12 | class MainActivity : AppCompatActivity() { 13 | 14 | 15 | private lateinit var binding : ActivityMainBinding 16 | private val mediaList = ArrayList() 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | binding = DataBindingUtil.setContentView(this, R.layout.activity_main) 21 | inItAdapter() 22 | inItListener() 23 | } 24 | 25 | private fun inItAdapter(){ 26 | binding.rvSelectedMedia.adapter = SelectedMediaAdapter(mediaList) 27 | } 28 | 29 | private fun inItListener() { 30 | binding.startPickerBtn.setOnClickListener { 31 | 32 | val includesFilePath = binding.cbIncludesPath.isChecked 33 | val isCompressionEnable = binding.cbEnableImageCompression.isChecked 34 | 35 | val mediaType = if (binding.rbImage.isChecked) { 36 | GeeksMediaType.IMAGE 37 | } else { 38 | GeeksMediaType.VIDEO 39 | } 40 | 41 | if (binding.rbSingle.isChecked) { 42 | GeeksMediaPicker.with(this) 43 | .setMediaType(mediaType) 44 | .setIncludesFilePath(includesFilePath) 45 | .setEnableCompression(isCompressionEnable) 46 | .startSingle { data -> 47 | mediaList.clear() 48 | mediaList.add(data) 49 | binding.rvSelectedMedia.adapter?.notifyDataSetChanged() 50 | //Log.e("My TAG", "${data}") 51 | } 52 | } else { 53 | GeeksMediaPicker.with(this) 54 | .setMediaType(mediaType) 55 | .setIncludesFilePath(includesFilePath) 56 | .setEnableCompression(isCompressionEnable) 57 | .startMultiple { dataList -> 58 | mediaList.clear() 59 | mediaList.addAll(dataList) 60 | binding.rvSelectedMedia.adapter?.notifyDataSetChanged() 61 | //Log.e("My TAG", "${dataList}") 62 | } 63 | } 64 | } 65 | 66 | binding.startCameraBtn.setOnClickListener { 67 | val isCompressionEnable = binding.cbEnableImageCompression.isChecked 68 | if (binding.rbVideo.isChecked) { 69 | Toast.makeText(this, "Under Development", Toast.LENGTH_SHORT).show() 70 | }else { 71 | GeeksMediaPicker.with(this) 72 | .setEnableCompression(isCompressionEnable) 73 | .startCamera { mediaStoreData -> 74 | mediaList.clear() 75 | mediaList.add(mediaStoreData) 76 | binding.rvSelectedMedia.adapter?.notifyDataSetChanged() 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/layout/list_item_media.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 18 | 19 | 22 | 23 | 24 | 28 | 29 | 33 | 34 | 41 | 42 | 46 | 47 | 57 | 58 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/utils/FileUtils.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.utils 2 | 3 | import android.content.ContentResolver 4 | import android.content.Context 5 | import android.content.pm.PackageManager 6 | import android.graphics.Bitmap 7 | import android.media.MediaMetadataRetriever 8 | import android.net.Uri 9 | import android.os.Build 10 | import android.provider.OpenableColumns 11 | import android.util.Log 12 | import android.util.Size 13 | import java.io.File 14 | import java.io.FileOutputStream 15 | 16 | object FileUtils { 17 | 18 | private const val TAG = "FileUtil" 19 | 20 | fun getFilePath(context: Context, uri: Uri): String { 21 | var filePath = "" 22 | val contentResolver = context.contentResolver 23 | val fileName = getFileName(contentResolver, uri) 24 | //Log.e(TAG, "file name: $fileName") 25 | if (fileName.isNotEmpty()) { 26 | contentResolver.openInputStream(uri)?.use { inputStream -> 27 | val file = File(context.getExternalFilesDir(null), fileName) 28 | Log.e(TAG, "file path: ${file.absolutePath}") 29 | val outputStream = FileOutputStream(file) 30 | inputStream.copyTo(outputStream) 31 | filePath = file.absolutePath 32 | } 33 | } 34 | return filePath 35 | } 36 | 37 | fun getFileName(contentResolver: ContentResolver, uri: Uri): String { 38 | var name = "Image_${System.currentTimeMillis()}.jpeg" 39 | contentResolver.query(uri, null, null, null, null)?.use { 40 | val nameIndex = it.getColumnIndex(OpenableColumns.DISPLAY_NAME) 41 | if (it.moveToFirst()) { 42 | name = it.getString(nameIndex) 43 | } 44 | } 45 | return name 46 | } 47 | 48 | fun getVideoThumb(context: Context, videoUri: Uri): String { 49 | val bitmapList = getVideoThumbBitmaps(context, videoUri) 50 | if (bitmapList.isNotEmpty()){ 51 | val filePath = File(context.getExternalFilesDir(null), "Thumbnails") 52 | 53 | //Log.e("Check", "cache file path : ${filePath.absolutePath}") 54 | 55 | if (!filePath.exists()) { 56 | filePath.mkdirs() 57 | //Log.e("Check", "File path created") 58 | } 59 | 60 | val outFile = File(filePath, "thumb_${System.currentTimeMillis()}.jpg") 61 | val fileOutputStream = FileOutputStream(outFile) 62 | bitmapList[0].compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream) 63 | 64 | fileOutputStream.flush() 65 | fileOutputStream.close() 66 | 67 | return outFile.absolutePath 68 | } 69 | 70 | return "" 71 | } 72 | 73 | private fun getVideoThumbBitmaps(context: Context, videoUri: Uri): ArrayList { 74 | val thumbnailList = ArrayList() 75 | try { 76 | val mdr = MediaMetadataRetriever() 77 | mdr.setDataSource(context, videoUri) 78 | 79 | // Retrieve media data 80 | val videoLengthInMs = mdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong()?:0 * 1000 81 | 82 | // Set thumbnail properties (Thumbs are squares) 83 | val thumbWidth = 512 84 | val thumbHeight = 512 85 | 86 | val numThumbs = 10 87 | 88 | val interval = videoLengthInMs / numThumbs 89 | 90 | for (i in 0 until numThumbs) { 91 | try { 92 | var bitmap = mdr.getFrameAtTime(i * interval, MediaMetadataRetriever.OPTION_CLOSEST_SYNC) 93 | bitmap = Bitmap.createScaledBitmap(bitmap!!, thumbWidth, thumbHeight, false) 94 | thumbnailList.add(bitmap) 95 | } catch (e: Exception) { 96 | e.printStackTrace() 97 | } 98 | } 99 | mdr.release() 100 | }catch (e: Exception) { 101 | e.printStackTrace() 102 | } 103 | return thumbnailList 104 | } 105 | } -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 13 | 14 | 15 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | xmlns:android 24 | 25 | ^$ 26 | 27 | 28 | 29 |
30 |
31 | 32 | 33 | 34 | xmlns:.* 35 | 36 | ^$ 37 | 38 | 39 | BY_NAME 40 | 41 |
42 |
43 | 44 | 45 | 46 | .*:id 47 | 48 | http://schemas.android.com/apk/res/android 49 | 50 | 51 | 52 |
53 |
54 | 55 | 56 | 57 | .*:name 58 | 59 | http://schemas.android.com/apk/res/android 60 | 61 | 62 | 63 |
64 |
65 | 66 | 67 | 68 | name 69 | 70 | ^$ 71 | 72 | 73 | 74 |
75 |
76 | 77 | 78 | 79 | style 80 | 81 | ^$ 82 | 83 | 84 | 85 |
86 |
87 | 88 | 89 | 90 | .* 91 | 92 | ^$ 93 | 94 | 95 | BY_NAME 96 | 97 |
98 |
99 | 100 | 101 | 102 | .* 103 | 104 | http://schemas.android.com/apk/res/android 105 | 106 | 107 | ANDROID_ATTRIBUTE_ORDER 108 | 109 |
110 |
111 | 112 | 113 | 114 | .* 115 | 116 | .* 117 | 118 | 119 | BY_NAME 120 | 121 |
122 |
123 |
124 |
125 | 126 | 128 |
129 |
-------------------------------------------------------------------------------- /geeksmediapicker/src/main/res/layout/activity_picker.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 15 | 16 | 21 | 22 | 30 | 31 | 44 | 45 | 59 | 60 | 61 | 67 | 68 | 75 | 76 | 77 | 78 | 87 | 88 | 91 | 92 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/GeeksMediaPicker.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.content.Intent 6 | import androidx.fragment.app.Fragment 7 | import com.geeksmediapicker.interfaces.MediaPickerListener 8 | import com.geeksmediapicker.models.MediaStoreData 9 | import com.geeksmediapicker.ui.CameraActivity 10 | import com.geeksmediapicker.ui.PickerActivity 11 | import java.lang.ref.WeakReference 12 | import java.util.* 13 | 14 | class GeeksMediaPicker private constructor(activity: Activity?, fragment: Fragment?) { 15 | 16 | private val activityWeakRef: WeakReference = WeakReference(activity) 17 | private val fragmentWeakRef: WeakReference = WeakReference(fragment) 18 | 19 | companion object { 20 | const val EXTRA_MEDIA_TYPE = "MEDIA_TYPE" 21 | const val EXTRA_MULTI_SELECTION = "MULTI_SELECTION" 22 | const val EXTRA_INCLUDES_FILE_PATH = "INCLUDES_FILE_PATH" 23 | const val EXTRA_ENABLE_COMPRESSION = "ENABLE_COMPRESSION" 24 | const val EXTRA_TOOLBAR_COLOR = "TOOLBAR_COLOR" 25 | const val EXTRA_MAX_COUNT = "MAX_COUNT" 26 | 27 | @JvmStatic 28 | fun with(activity: Activity) = GeeksMediaPicker(activity, null) 29 | 30 | @JvmStatic 31 | fun with(fragment: Fragment) = GeeksMediaPicker(null, fragment) 32 | 33 | @JvmStatic 34 | val listenerDeque: Deque = ArrayDeque() 35 | } 36 | 37 | private var maxCount: Int = -1 38 | private var toolBarColor: Int = -1 39 | private var mediaType: String = GeeksMediaType.IMAGE 40 | private var isMultiSelection: Boolean = false 41 | private var includesFilePath: Boolean = false 42 | private var isCompressionEnable: Boolean = false 43 | 44 | fun setMediaType(mediaType: String): GeeksMediaPicker { 45 | this.mediaType = mediaType 46 | return this 47 | } 48 | 49 | fun setToolbarColor(toolBarColor: Int): GeeksMediaPicker { 50 | this.toolBarColor = toolBarColor 51 | return this 52 | } 53 | 54 | fun setIncludesFilePath(includesFilePath: Boolean): GeeksMediaPicker { 55 | this.includesFilePath = includesFilePath 56 | return this 57 | } 58 | 59 | fun setEnableCompression(isCompressionEnable: Boolean): GeeksMediaPicker { 60 | this.isCompressionEnable = isCompressionEnable 61 | return this 62 | } 63 | 64 | fun startSingle(action: (MediaStoreData) -> Unit) { 65 | listenerDeque.clear() 66 | listenerDeque.push(object : MediaPickerListener { 67 | override fun onMediaPicked(selectedMediaList: ArrayList, mediaStoreData: MediaStoreData) { 68 | action(selectedMediaList[0]) 69 | } 70 | }) 71 | 72 | isMultiSelection = false 73 | startPicker() 74 | } 75 | 76 | fun startMultiple(maxCount: Int = -1, action: (ArrayList) -> Unit) { 77 | this.maxCount = maxCount 78 | listenerDeque.clear() 79 | listenerDeque.push(object : MediaPickerListener { 80 | override fun onMediaPicked(selectedMediaList: ArrayList, mediaStoreData: MediaStoreData) { 81 | action(selectedMediaList) 82 | } 83 | }) 84 | 85 | isMultiSelection = true 86 | startPicker() 87 | } 88 | 89 | fun startCamera(action: (MediaStoreData) -> Unit) { 90 | listenerDeque.clear() 91 | listenerDeque.push(object : MediaPickerListener { 92 | override fun onMediaPicked(selectedMediaList: ArrayList, mediaStoreData: MediaStoreData) { 93 | action(mediaStoreData) 94 | } 95 | }) 96 | 97 | val activity = activityWeakRef.get() 98 | val fragment = fragmentWeakRef.get() 99 | 100 | when { 101 | activity != null -> openCamera(activity) 102 | fragment != null -> openCamera(fragment.requireActivity()) 103 | else -> { 104 | listenerDeque.clear() 105 | throw NullPointerException("activity or fragment can't be null.") 106 | } 107 | } 108 | } 109 | 110 | private fun openCamera(activity: Activity) { 111 | with(activity) { 112 | startActivity(Intent(this, CameraActivity::class.java).apply { 113 | putExtra(EXTRA_ENABLE_COMPRESSION, isCompressionEnable) 114 | }) 115 | } 116 | } 117 | 118 | private fun startPicker() { 119 | val activity = activityWeakRef.get() 120 | val fragment = fragmentWeakRef.get() 121 | 122 | when { 123 | activity != null -> activity.startActivity(getIntentWithData(activity)) 124 | fragment != null -> fragment.startActivity(getIntentWithData(fragment.requireContext())) 125 | else -> { 126 | listenerDeque.clear() 127 | throw NullPointerException("activity or fragment can't be null.") 128 | } 129 | } 130 | } 131 | 132 | private fun getIntentWithData(context: Context?): Intent { 133 | return Intent(context, PickerActivity::class.java).apply { 134 | putExtra(EXTRA_MEDIA_TYPE, mediaType) 135 | putExtra(EXTRA_MULTI_SELECTION, isMultiSelection) 136 | putExtra(EXTRA_INCLUDES_FILE_PATH, includesFilePath) 137 | putExtra(EXTRA_ENABLE_COMPRESSION, isCompressionEnable) 138 | putExtra(EXTRA_TOOLBAR_COLOR, toolBarColor) 139 | putExtra(EXTRA_MAX_COUNT, maxCount) 140 | } 141 | } 142 | } -------------------------------------------------------------------------------- /geeksmediapicker/src/main/java/com/geeksmediapicker/utils/ImageCompressor.kt: -------------------------------------------------------------------------------- 1 | package com.geeksmediapicker.utils 2 | 3 | import android.content.Context 4 | import android.graphics.Bitmap 5 | import android.graphics.BitmapFactory 6 | import android.graphics.Matrix 7 | import android.net.Uri 8 | import android.util.Log 9 | import androidx.exifinterface.media.ExifInterface 10 | import kotlinx.coroutines.Dispatchers 11 | import kotlinx.coroutines.withContext 12 | import java.io.File 13 | import java.io.FileOutputStream 14 | import java.io.IOException 15 | import java.io.InputStream 16 | 17 | object ImageCompressor { 18 | 19 | private const val MAX_WIDTH = 612 20 | private const val MAX_HEIGHT = 816 21 | private const val IMAGE_QUALITY = 80 22 | 23 | 24 | suspend fun getCompressedImage(context: Context, uri: Uri?, success: (String) -> Unit) { 25 | if (uri == null) { 26 | throw NullPointerException("uri can't be null.") 27 | } 28 | 29 | try { 30 | val compressedFilePath = compressImageFromUri(context, uri) 31 | success(compressedFilePath) 32 | } catch (e: Exception) { 33 | Log.e("ImageCompressor", "error --> ${e.localizedMessage}") 34 | } 35 | } 36 | 37 | private suspend fun compressImageFromUri(context: Context, uri: Uri): String { 38 | var filePath = "" 39 | 40 | withContext(Dispatchers.IO){ 41 | val options = BitmapFactory.Options() 42 | // Here true means that we don’t want to load bitmap into memory. 43 | // We just want to get information(width, height, etc.) about image. So we can calculate scale factor with that information. 44 | options.inJustDecodeBounds = true 45 | 46 | 47 | val fileName = FileUtils.getFileName(context.contentResolver, uri) 48 | 49 | 50 | context.contentResolver.openInputStream(uri)?.use {inputStream1-> 51 | BitmapFactory.decodeStream(inputStream1, null, options) 52 | 53 | // Calculate and set inSampleSize 54 | options.inSampleSize = calculateInSampleSize( 55 | options, 56 | MAX_WIDTH, 57 | MAX_HEIGHT 58 | ) 59 | // Decode bitmap with inSampleSize set 60 | options.inJustDecodeBounds = false 61 | 62 | context.contentResolver.openInputStream(uri)?.use {inputStream2 -> 63 | BitmapFactory.decodeStream(inputStream2, null, options)?.also {bitmap -> 64 | 65 | //Log.e("Check", "scaled bitmap size : ${bitmap.byteCount}") 66 | 67 | context.contentResolver.openInputStream(uri)?.use { 68 | val scaledBitmap = rotateImageIfRequired(bitmap, it) 69 | val newFile = File(context.getExternalFilesDir(null), "compressed_$fileName") 70 | //Log.e("Check", "cache file path : ${newFile.absolutePath}") 71 | 72 | if (newFile.exists()) { 73 | newFile.delete() 74 | //Log.e("Check", "File deleted") 75 | } 76 | 77 | val fileOutputStream = FileOutputStream(newFile) 78 | scaledBitmap?.compress(Bitmap.CompressFormat.JPEG, IMAGE_QUALITY, fileOutputStream) 79 | 80 | //Log.e("Check", "Is bitmap compressed: $bitmapCompressed") 81 | //Log.e("ImageCompressor", "resize scaled bitmap size : ${scaledBitmap?.byteCount}") 82 | 83 | fileOutputStream.flush() 84 | fileOutputStream.close() 85 | 86 | filePath = newFile.absolutePath 87 | } 88 | } 89 | } 90 | 91 | } 92 | 93 | } 94 | return filePath 95 | } 96 | 97 | private fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int { 98 | // Raw height and width of image 99 | val (height: Int, width: Int) = options.run { outHeight to outWidth } 100 | var inSampleSize = 1 101 | 102 | if (height > reqHeight || width > reqWidth) { 103 | 104 | val halfHeight: Int = height / 2 105 | val halfWidth: Int = width / 2 106 | 107 | // Calculate the largest inSampleSize value that is a power of 2 and keeps both 108 | // height and width larger than the requested height and width. 109 | while (halfHeight / inSampleSize >= reqHeight && halfWidth / inSampleSize >= reqWidth) { 110 | inSampleSize *= 2 111 | } 112 | } 113 | 114 | return inSampleSize 115 | } 116 | 117 | /** 118 | * Rotate an image if required. 119 | * 120 | * @param bitmap The image bitmap 121 | * @param inputStream Image InputStream 122 | * @return The resulted Bitmap after manipulation 123 | */ 124 | @Throws(IOException::class) 125 | private fun rotateImageIfRequired(bitmap: Bitmap, inputStream: InputStream): Bitmap? { 126 | return when (ExifInterface(inputStream).getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)) { 127 | ExifInterface.ORIENTATION_ROTATE_90 -> rotateImage(bitmap, 90) 128 | ExifInterface.ORIENTATION_ROTATE_180 -> rotateImage(bitmap, 180) 129 | ExifInterface.ORIENTATION_ROTATE_270 -> rotateImage(bitmap, 270) 130 | else -> bitmap 131 | } 132 | } 133 | 134 | private fun rotateImage(img: Bitmap, degree: Int): Bitmap? { 135 | val matrix = Matrix() 136 | matrix.postRotate(degree.toFloat()) 137 | val rotatedImg = Bitmap.createBitmap(img, 0, 0, img.width, img.height, matrix, true) 138 | img.recycle() 139 | return rotatedImg 140 | } 141 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 19 | 20 | 26 | 27 | 33 | 34 | 40 | 41 | 48 | 49 | 50 | 51 | 58 | 59 | 65 | 66 | 72 | 73 | 79 | 80 | 87 | 88 | 89 | 90 | 98 | 99 | 107 | 108 | 114 | 115 |