Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to android 11 #225

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion FishBun/src/main/res/layout/header_item.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
Expand All @@ -9,7 +10,9 @@
android:id="@+id/rel_header_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d9d9d9">
android:background="#d9d9d9"
android:foreground="?attr/selectableItemBackground"
tools:targetApi="m">

<ImageView
android:layout_width="wrap_content"
Expand Down
7 changes: 6 additions & 1 deletion FishBunDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>

<application
android:name="com.sangcomz.fishbundemo.CommonApplication"
android:allowBackup="true"
Expand All @@ -23,5 +29,4 @@
</activity>
<activity android:name="com.sangcomz.fishbundemo.WithFragmentActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ and to allow the following permissions in your `Manifest`:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

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):

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>

## How to Use

Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)