-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android: more user-friendly way of granting permissions in call (#3945)
* android: more user-friendly way of granting permissions in call * changes * ask permissions without click at first * changes in logic and UI * enhancements * show alert only when non in PiP * change --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
- Loading branch information
1 parent
b64ae90
commit 3d20465
Showing
7 changed files
with
244 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/helpers/Permissions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package chat.simplex.common.helpers | ||
|
||
import android.content.* | ||
import android.net.Uri | ||
import android.provider.Settings | ||
import chat.simplex.common.platform.* | ||
import chat.simplex.common.views.helpers.AlertManager | ||
import chat.simplex.common.views.helpers.generalGetString | ||
import chat.simplex.res.MR | ||
|
||
fun Context.openAppSettingsInSystem() { | ||
Intent().apply { | ||
action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS | ||
data = Uri.parse("package:${androidAppContext.packageName}") | ||
try { | ||
startActivity(this) | ||
} catch (e: ActivityNotFoundException) { | ||
Log.e(TAG, e.stackTraceToString()) | ||
} | ||
} | ||
} | ||
|
||
fun Context.showAllowPermissionInSettingsAlert(action: () -> Unit = ::openAppSettingsInSystem) { | ||
AlertManager.shared.showAlertMsg( | ||
title = generalGetString(MR.strings.permissions_grant_in_settings), | ||
text = generalGetString(MR.strings.permissions_find_in_settings_and_grant), | ||
confirmText = generalGetString(MR.strings.permissions_open_settings), | ||
onConfirm = action, | ||
) | ||
} |
Oops, something went wrong.