Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Oct 21, 2024
1 parent 575b76e commit 4542208
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions app/src/main/java/org/blitzortung/android/app/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
if (requiresPermission) {
val locationText = this.resources.getString(R.string.location_permission_background_disclosure)
AlertDialog.Builder(this).setMessage(locationText).setCancelable(false)
.setNeutralButton(android.R.string.ok) { dialog, count ->
.setPositiveButton(android.R.string.ok) { dialog, count ->
requestPermission(
permission, requestCode,
R.string.location_permission_required
Expand All @@ -667,13 +667,13 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
@TargetApi(Build.VERSION_CODES.M)
private fun requestPermission(permission: String, requestCode: Int, permissionRequiredStringId: Int) {
val shouldShowPermissionRationale = shouldShowRequestPermissionRationale(permission)
val permissionStatus = checkSelfPermission(permission)
val permissionIsGranted = checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED
Log.v(
LOG_TAG,
"Main.requestPermission() permission: $permission, status: $permissionStatus, shouldRequest: ${!shouldShowPermissionRationale}"
"Main.requestPermission() permission: $permission, isGranted: $permissionIsGranted, shouldShowRationale: ${!shouldShowPermissionRationale}"
)

if (permissionStatus != PackageManager.PERMISSION_GRANTED) {
if (!permissionIsGranted) {
if (shouldShowPermissionRationale) {
requestPermissionsAfterDialog(permissionRequiredStringId, permission, requestCode)
} else {
Expand All @@ -688,10 +688,17 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener {
permission: String,
requestCode: Int,
) {
Log.v(
LOG_TAG,
"Main.requestPermissionsAfterDialog() permission: $permission, dialogResource: $dialogTextResource, requestCode: $requestCode"
)

val locationText = resources.getString(dialogTextResource)
AlertDialog.Builder(this).setMessage(locationText).setCancelable(false)
.setNeutralButton(android.R.string.ok) { dialog, count ->
requestPermissions( arrayOf(permission), requestCode )
.setPositiveButton(android.R.string.ok) { dialog, count ->
Log.v(LOG_TAG, "Main.requestPermissionsAfterDialog() clicked OK, before request")
requestPermissions(arrayOf(permission), requestCode)
Log.v(LOG_TAG, "Main.requestPermissionsAfterDialog() clicked OK, after request")
}.show()
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Ivan Karev (karev.ivan@gmail.com)\nTschechisch: Jakub Mareček (jakubmarecek715@
<string name="location_permission_required">Für die Ortsbestimmung über den Gerätestandort ist die Berechtigung erforderlich.</string>
<string name="location_permission_background_required">Für die Ortsbestimmung über den Gerätestandort im Hintergrund ist die Berechtigung erforderlich.</string>
<string name="changelog">Änderungsprotokoll</string>
<string name="location_permission_background_disclosure">Diese App verwendet Standortdaten, auch wenn die App geschlossen ist oder nicht verwendet wird, wenn Warnungen im Hintergrund mit einer Gerätestandortquelle verwendet werden.</string>
<string name="location_permission_background_disclosure">Diese App verwendet Standortdaten, auch wenn die App geschlossen ist oder nicht verwendet wird, <b>sofern Warnungen im Hintergrund aktiviert wurden</b> und eine <b>Gerätestandortquelle ausgewählt</b> ist.</string>
<string name="menu">Menü öffnen</string>
<string name="slider_current">jetzt</string>
<string name="slider_past">Vergangenheit</string>
Expand Down

0 comments on commit 4542208

Please sign in to comment.