mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Merge pull request #10924 from nextcloud/fix/storage-permission-background
PermissionUtil: ensure fragment result is listened to on activity thread
This commit is contained in:
commit
aab8fcfe2d
1 changed files with 10 additions and 4 deletions
|
@ -31,6 +31,7 @@ import android.content.pm.PackageManager
|
|||
import android.content.pm.ResolveInfo
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.RequiresApi
|
||||
|
@ -213,10 +214,7 @@ object PermissionUtil {
|
|||
if (shouldRequestPermission &&
|
||||
activity.supportFragmentManager.findFragmentByTag(PERMISSION_CHOICE_DIALOG_TAG) == null
|
||||
) {
|
||||
activity.supportFragmentManager.setFragmentResultListener(
|
||||
StoragePermissionDialogFragment.REQUEST_KEY,
|
||||
activity
|
||||
) { _, resultBundle ->
|
||||
val listener: (requestKey: String, result: Bundle) -> Unit = { _, resultBundle ->
|
||||
val result: StoragePermissionDialogFragment.Result? =
|
||||
resultBundle.getParcelable(StoragePermissionDialogFragment.RESULT_KEY)
|
||||
if (result != null) {
|
||||
|
@ -238,6 +236,14 @@ object PermissionUtil {
|
|||
}
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
activity.supportFragmentManager.setFragmentResultListener(
|
||||
StoragePermissionDialogFragment.REQUEST_KEY,
|
||||
activity,
|
||||
listener
|
||||
)
|
||||
}
|
||||
|
||||
val dialogFragment = StoragePermissionDialogFragment.newInstance(permissionRequired)
|
||||
dialogFragment.show(activity.supportFragmentManager, PERMISSION_CHOICE_DIALOG_TAG)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue