mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Merge pull request #3439 from kiwix/Fixes#3370
Improved the permission asking scenario for custom apps
This commit is contained in:
commit
8469e18e23
@ -342,10 +342,25 @@ abstract class CoreReaderFragment :
|
|||||||
// Successfully granted permission, so opening the note keeper
|
// Successfully granted permission, so opening the note keeper
|
||||||
showAddNoteDialog()
|
showAddNoteDialog()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||||
requireActivity().applicationContext,
|
/* shouldShowRequestPermissionRationale() returns false when:
|
||||||
getString(R.string.ext_storage_write_permission_denied_add_note), Toast.LENGTH_LONG
|
* 1) User has previously checked on "Don't ask me again", and/or
|
||||||
).show()
|
* 2) Permission has been disabled on device
|
||||||
|
*/
|
||||||
|
requireActivity().toast(
|
||||||
|
R.string.ext_storage_permission_rationale_add_note,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
requireActivity().toast(
|
||||||
|
R.string.ext_storage_write_permission_denied_add_note,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
)
|
||||||
|
alertDialogShower?.show(
|
||||||
|
KiwixDialog.ReadPermissionRequired,
|
||||||
|
requireActivity()::navigateToAppSettings
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1306,22 +1321,7 @@ abstract class CoreReaderFragment :
|
|||||||
) {
|
) {
|
||||||
isPermissionGranted = true
|
isPermissionGranted = true
|
||||||
} else {
|
} else {
|
||||||
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
storagePermissionForNotesLauncher?.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
storagePermissionForNotesLauncher?.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
||||||
/* shouldShowRequestPermissionRationale() returns false when:
|
|
||||||
* 1) User has previously checked on "Don't ask me again", and/or
|
|
||||||
* 2) Permission has been disabled on device
|
|
||||||
*/
|
|
||||||
requireActivity().toast(
|
|
||||||
R.string.ext_storage_permission_rationale_add_note,
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
alertDialogShower?.show(
|
|
||||||
KiwixDialog.ReadPermissionRequired,
|
|
||||||
requireActivity()::navigateToAppSettings
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else { // For Android versions below Marshmallow 6.0 (API 23)
|
} else { // For Android versions below Marshmallow 6.0 (API 23)
|
||||||
isPermissionGranted = true // As already requested at install time
|
isPermissionGranted = true // As already requested at install time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user