From 6c397e41c48713c69197c99ad110186732d038cd Mon Sep 17 00:00:00 2001 From: Xtr126 <80520774+Xtr126@users.noreply.github.com> Date: Fri, 20 Sep 2024 23:02:22 +0530 Subject: [PATCH] fix: apply shared prefs --- .../java/xtr/keymapper/activity/MainActivity.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/xtr/keymapper/activity/MainActivity.java b/app/src/main/java/xtr/keymapper/activity/MainActivity.java index 5fa600a2..53122598 100644 --- a/app/src/main/java/xtr/keymapper/activity/MainActivity.java +++ b/app/src/main/java/xtr/keymapper/activity/MainActivity.java @@ -5,7 +5,6 @@ import android.content.ComponentName; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageManager; @@ -64,20 +63,20 @@ protected void onCreate(Bundle savedInstanceState) { RemoteServiceHelper.useShizuku = keymapConfig.useShizuku; Server.setupServer(this, mCallback); - if(!RemoteServiceHelper.useShizuku) + if(!RemoteServiceHelper.useShizuku) { Shell.getShell(shell -> { RemoteServiceHelper.getInstance(this, null); - if (Shizuku.pingBinder() || getPackageManager().getLaunchIntentForPackage("moe.shizuku.privileged.api") != null) + if (Shizuku.pingBinder() || getPackageManager().getLaunchIntentForPackage("moe.shizuku.privileged.api") != null) { showAlertDialog(R.string.detected_shizuku, R.string.use_shizuku_for_activation, (dialog, which) -> { - keymapConfig.useShizuku = true; + RemoteServiceHelper.useShizuku = keymapConfig.useShizuku = true; + keymapConfig.applySharedPrefs(); alertShizukuNotAuthorized(); }); - else - if (!RemoteServiceHelper.isRootService) { + } else if (!RemoteServiceHelper.isRootService) { alertRootAccessNotFound(); } }); - else if (!(Shizuku.pingBinder() && Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED)) { + } else if (!(Shizuku.pingBinder() && Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED)) { alertShizukuNotAuthorized(); } setupButtons();