From 91b46f5993a9d334b4c68d34d5b080c949e88861 Mon Sep 17 00:00:00 2001 From: Nick Bradshaw Date: Mon, 26 Oct 2020 16:38:32 -0700 Subject: [PATCH 1/2] Add manifest query to allow camera to launch properly on API 30 * Fix some runtime nullability errors with arrayLists * Update README * Add ripple to camera button --- .../fishbun/datasource/PickerIntentDataSourceImpl.kt | 12 +++++++----- FishBun/src/main/res/layout/header_item.xml | 5 ++++- FishBunDemo/src/main/AndroidManifest.xml | 7 ++++++- .../java/com/sangcomz/fishbundemo/SubFragment.kt | 3 ++- .../com/sangcomz/fishbundemo/WithActivityActivity.kt | 11 ++++++----- README.md | 6 ++++++ settings.gradle | 4 ++-- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt b/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt index 851c9f62..1f942630 100644 --- a/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt +++ b/FishBun/src/main/java/com/sangcomz/fishbun/datasource/PickerIntentDataSourceImpl.kt @@ -9,11 +9,13 @@ class PickerIntentDataSourceImpl(private val intent: Intent) : PickerIntentDataS && intent.hasExtra(ARG_ALBUM_ID) && intent.hasExtra(ARG_ALBUM_POSITION) ) - AlbumData( - intent.getLongExtra(ARG_ALBUM_ID, -1), - intent.getStringExtra(ARG_ALBUM_NAME), - intent.getIntExtra(ARG_ALBUM_POSITION, -1) - ) + intent.getStringExtra(ARG_ALBUM_NAME)?.let { + AlbumData( + intent.getLongExtra(ARG_ALBUM_ID, -1), + it, + intent.getIntExtra(ARG_ALBUM_POSITION, -1) + ) + } else null } diff --git a/FishBun/src/main/res/layout/header_item.xml b/FishBun/src/main/res/layout/header_item.xml index de2108dd..88d8a5d2 100644 --- a/FishBun/src/main/res/layout/header_item.xml +++ b/FishBun/src/main/res/layout/header_item.xml @@ -1,5 +1,6 @@ + android:background="#d9d9d9" + android:foreground="?attr/selectableItemBackground" + tools:targetApi="m"> + + + + + + - \ No newline at end of file diff --git a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt index b0c2bcf8..f168dca7 100644 --- a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt +++ b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/SubFragment.kt @@ -14,6 +14,7 @@ import com.sangcomz.fishbun.FishBun import com.sangcomz.fishbun.adapter.image.impl.CoilAdapter import kotlinx.android.synthetic.main.fragment_sub.* import java.util.* +import kotlin.collections.ArrayList /** * A simple [Fragment] subclass. @@ -52,7 +53,7 @@ class SubFragment : Fragment() { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { FishBun.FISHBUN_REQUEST_CODE -> if (resultCode == Activity.RESULT_OK) { - path = data!!.getParcelableArrayListExtra(FishBun.INTENT_PATH) + path = data?.getParcelableArrayListExtra(FishBun.INTENT_PATH) ?: arrayListOf() imageAdapter.changePath(path) } } diff --git a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt index 6aa3590b..9dc88f0b 100644 --- a/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt +++ b/FishBunDemo/src/main/java/com/sangcomz/fishbundemo/WithActivityActivity.kt @@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.recyclerview.widget.LinearLayoutManager import com.sangcomz.fishbun.FishBun +import com.sangcomz.fishbun.MimeType import com.sangcomz.fishbun.adapter.image.impl.GlideAdapter import com.sangcomz.fishbun.adapter.image.impl.CoilAdapter import kotlinx.android.synthetic.main.activity_withactivity.* @@ -46,7 +47,7 @@ class WithActivityActivity : AppCompatActivity() { super.onActivityResult(requestCode, resultCode, imageData) if (requestCode == FishBun.FISHBUN_REQUEST_CODE && resultCode == RESULT_OK) { - path = imageData!!.getParcelableArrayListExtra(FishBun.INTENT_PATH) + path = imageData?.getParcelableArrayListExtra(FishBun.INTENT_PATH) ?: arrayListOf() imageAdapter.changePath(path) } } @@ -84,8 +85,8 @@ class WithActivityActivity : AppCompatActivity() { .setSelectedImages(path) .setAlbumSpanCount(2, 3) .setButtonInAlbumActivity(false) - .setCamera(true) - .exceptGif(true) + .hasCameraInPickerPage(true) + .exceptMimeType(arrayListOf(MimeType.GIF)) .setReachLimitAutomaticClose(true) .setHomeAsUpIndicatorDrawable( ContextCompat.getDrawable( @@ -119,8 +120,8 @@ class WithActivityActivity : AppCompatActivity() { .setSelectedImages(path) .setAlbumSpanCount(1, 2) .setButtonInAlbumActivity(true) - .setCamera(false) - .exceptGif(true) + .hasCameraInPickerPage(false) + .exceptMimeType(arrayListOf(MimeType.GIF)) .setReachLimitAutomaticClose(false) .setHomeAsUpIndicatorDrawable( ContextCompat.getDrawable( diff --git a/README.md b/README.md index c50ac058..822ce4e4 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,12 @@ and to allow the following permissions in your `Manifest`: +If your app targets Android 11 with compileSdk/targetSdk >= 30 then you will need to add this to the manifest (outside of the application block) in order to capture pictures with the device camera. [Android documentation here](https://developer.android.com/about/versions/11/privacy/package-visibility) + + + + + ## How to Use diff --git a/settings.gradle b/settings.gradle index 49d29e71..521f407f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,5 +4,5 @@ gradle.ext.versionCode = 31 gradle.ext.versionName = '1.0.0-alpha03' gradle.ext.set('minSdk', 15) -gradle.ext.set('targetSdk', 29) -gradle.ext.set('compileSdk', 29) +gradle.ext.set('targetSdk', 30) +gradle.ext.set('compileSdk', 30) From eb96bd5852782e4f9cfa27f2307886a28bc68b2d Mon Sep 17 00:00:00 2001 From: Nick Bradshaw Date: Mon, 26 Oct 2020 16:52:19 -0700 Subject: [PATCH 2/2] just adding a line break --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 822ce4e4..82e0f3be 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,8 @@ and to allow the following permissions in your `Manifest`: -If your app targets Android 11 with compileSdk/targetSdk >= 30 then you will need to add this to the manifest (outside of the application block) in order to capture pictures with the device camera. [Android documentation here](https://developer.android.com/about/versions/11/privacy/package-visibility) +If your app targets Android 11 with compileSdk/targetSdk >= 30 then you will need to add this to the manifest (outside of the application block) in order to capture pictures with the device camera. [Android documentation here](https://developer.android.com/about/versions/11/privacy/package-visibility): +