mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-19 04:16:27 -04:00
Fixed Invasive access photos and media permission request at start
This commit is contained in:
parent
7df79cdd46
commit
3c510b60f3
@ -1199,6 +1199,10 @@ abstract class CoreReaderFragment :
|
|||||||
isPermissionGranted = true
|
isPermissionGranted = true
|
||||||
} else {
|
} else {
|
||||||
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||||
|
requestPermissions(
|
||||||
|
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
||||||
|
REQUEST_WRITE_STORAGE_PERMISSION_ADD_NOTE
|
||||||
|
)
|
||||||
/* shouldShowRequestPermissionRationale() returns false when:
|
/* shouldShowRequestPermissionRationale() returns false when:
|
||||||
* 1) User has previously checked on "Don't ask me again", and/or
|
* 1) User has previously checked on "Don't ask me again", and/or
|
||||||
* 2) Permission has been disabled on device
|
* 2) Permission has been disabled on device
|
||||||
@ -1207,12 +1211,13 @@ abstract class CoreReaderFragment :
|
|||||||
R.string.ext_storage_permission_rationale_add_note,
|
R.string.ext_storage_permission_rationale_add_note,
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
)
|
)
|
||||||
}
|
} else {
|
||||||
requestPermissions(
|
alertDialogShower?.show(
|
||||||
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
|
KiwixDialog.ReadPermissionRequired,
|
||||||
REQUEST_WRITE_STORAGE_PERMISSION_ADD_NOTE
|
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
|
||||||
}
|
}
|
||||||
@ -1269,8 +1274,8 @@ abstract class CoreReaderFragment :
|
|||||||
externalLinkOpener?.openExternalUrl(intent)
|
externalLinkOpener?.openExternalUrl(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun openZimFile(file: File) {
|
protected fun openZimFile(file: File, isCustomApp: Boolean = false) {
|
||||||
if (hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
if (hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE) || isCustomApp) {
|
||||||
if (file.isFileExist()) {
|
if (file.isFileExist()) {
|
||||||
openAndSetInContainer(file)
|
openAndSetInContainer(file)
|
||||||
updateTitle()
|
updateTitle()
|
||||||
|
@ -151,10 +151,10 @@ class CustomReaderFragment : CoreReaderFragment() {
|
|||||||
customFileValidator.validate(
|
customFileValidator.validate(
|
||||||
onFilesFound = {
|
onFilesFound = {
|
||||||
when (it) {
|
when (it) {
|
||||||
is ValidationState.HasFile -> openZimFile(it.file)
|
is ValidationState.HasFile -> openZimFile(it.file, true)
|
||||||
is ValidationState.HasBothFiles -> {
|
is ValidationState.HasBothFiles -> {
|
||||||
it.zimFile.delete()
|
it.zimFile.delete()
|
||||||
openZimFile(it.obbFile)
|
openZimFile(it.obbFile, true)
|
||||||
}
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user