mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 09:13:39 +00:00
Utilise dialog dsl in SettingsDialog
This commit is contained in:
parent
4641512644
commit
033eabbc53
@ -255,7 +255,7 @@ public class Permissions {
|
||||
resultListener.onResult(permissions, grantResults, shouldShowRationaleDialog);
|
||||
}
|
||||
|
||||
private static Intent getApplicationSettingsIntent(@NonNull Context context) {
|
||||
static Intent getApplicationSettingsIntent(@NonNull Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", context.getPackageName(), null);
|
||||
@ -352,20 +352,8 @@ public class Permissions {
|
||||
@Override
|
||||
public void run() {
|
||||
Context context = this.context.get();
|
||||
|
||||
if (context != null) {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(context, R.style.ThemeOverlay_Session_AlertDialog)
|
||||
.setTitle(R.string.Permissions_permission_required)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.Permissions_continue, (dialog, which) -> context.startActivity(getApplicationSettingsIntent(context)))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (positiveButton != null) {
|
||||
positiveButton.setContentDescription(context.getString(R.string.AccessibilityId_continue));
|
||||
}
|
||||
alertDialog.show();
|
||||
}
|
||||
if (context == null) return;
|
||||
SettingsDialog.show(context, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package org.thoughtcrime.securesms.permissions
|
||||
|
||||
import android.content.Context
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.showSessionDialog
|
||||
|
||||
class SettingsDialog {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(context: Context, message: String) {
|
||||
context.showSessionDialog {
|
||||
title(R.string.Permissions_permission_required)
|
||||
text(message)
|
||||
button(R.string.Permissions_continue, R.string.AccessibilityId_continue) {
|
||||
context.startActivity(Permissions.getApplicationSettingsIntent(context))
|
||||
}
|
||||
cancelButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user