diff --git a/app/src/main/java/com/termux/app/TermuxService.java b/app/src/main/java/com/termux/app/TermuxService.java index 5caa3ebb..3e60a2c8 100644 --- a/app/src/main/java/com/termux/app/TermuxService.java +++ b/app/src/main/java/com/termux/app/TermuxService.java @@ -648,7 +648,7 @@ public final class TermuxService extends Service implements AppShell.AppShellCli } else { TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences.build(this); if (preferences == null) return; - if (preferences.arePluginErrorNotificationsEnabled()) + if (preferences.arePluginErrorNotificationsEnabled(false)) Logger.showToast(this, this.getString(R.string.error_display_over_other_apps_permission_not_granted), true); } } diff --git a/app/src/main/java/com/termux/app/fragments/settings/termux/DebuggingPreferencesFragment.java b/app/src/main/java/com/termux/app/fragments/settings/termux/DebuggingPreferencesFragment.java index 059dccbe..8afd568f 100644 --- a/app/src/main/java/com/termux/app/fragments/settings/termux/DebuggingPreferencesFragment.java +++ b/app/src/main/java/com/termux/app/fragments/settings/termux/DebuggingPreferencesFragment.java @@ -144,9 +144,9 @@ class DebuggingPreferencesDataStore extends PreferenceDataStore { case "terminal_view_key_logging_enabled": return mPreferences.isTerminalViewKeyLoggingEnabled(); case "plugin_error_notifications_enabled": - return mPreferences.arePluginErrorNotificationsEnabled(); + return mPreferences.arePluginErrorNotificationsEnabled(false); case "crash_report_notifications_enabled": - return mPreferences.areCrashReportNotificationsEnabled(); + return mPreferences.areCrashReportNotificationsEnabled(false); default: return false; } diff --git a/app/src/main/java/com/termux/app/utils/PluginUtils.java b/app/src/main/java/com/termux/app/utils/PluginUtils.java index 37493d01..a407747f 100644 --- a/app/src/main/java/com/termux/app/utils/PluginUtils.java +++ b/app/src/main/java/com/termux/app/utils/PluginUtils.java @@ -241,7 +241,7 @@ public class PluginUtils { if (preferences == null) return; // If user has disabled notifications for plugin commands, then just return - if (!preferences.arePluginErrorNotificationsEnabled() && !forceNotification) + if (!preferences.arePluginErrorNotificationsEnabled(true) && !forceNotification) return; logTag = DataUtils.getDefaultIfNull(logTag, LOG_TAG); diff --git a/termux-shared/src/main/java/com/termux/shared/termux/settings/preferences/TermuxAppSharedPreferences.java b/termux-shared/src/main/java/com/termux/shared/termux/settings/preferences/TermuxAppSharedPreferences.java index 3e10ca70..876546a4 100644 --- a/termux-shared/src/main/java/com/termux/shared/termux/settings/preferences/TermuxAppSharedPreferences.java +++ b/termux-shared/src/main/java/com/termux/shared/termux/settings/preferences/TermuxAppSharedPreferences.java @@ -20,6 +20,7 @@ public class TermuxAppSharedPreferences { private final Context mContext; private final SharedPreferences mSharedPreferences; + private final SharedPreferences mMultiProcessSharedPreferences; private int MIN_FONTSIZE; private int MAX_FONTSIZE; @@ -30,6 +31,8 @@ public class TermuxAppSharedPreferences { private TermuxAppSharedPreferences(@NonNull Context context) { mContext = context; mSharedPreferences = getPrivateSharedPreferences(mContext); + mMultiProcessSharedPreferences = getPrivateAndMultiProcessSharedPreferences(mContext); + setFontVariables(context); } @@ -73,6 +76,12 @@ public class TermuxAppSharedPreferences { } + private static SharedPreferences getPrivateAndMultiProcessSharedPreferences(Context context) { + if (context == null) return null; + return SharedPreferenceUtils.getPrivateAndMultiProcessSharedPreferences(context, TermuxConstants.TERMUX_DEFAULT_PREFERENCES_FILE_BASENAME_WITHOUT_EXTENSION); + } + + public boolean shouldShowTerminalToolbar() { return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_SHOW_TERMINAL_TOOLBAR, TERMUX_APP.DEFAULT_VALUE_SHOW_TERMINAL_TOOLBAR); @@ -218,8 +227,11 @@ public class TermuxAppSharedPreferences { - public boolean arePluginErrorNotificationsEnabled() { - return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED); + public boolean arePluginErrorNotificationsEnabled(boolean readFromFile) { + if (readFromFile) + return SharedPreferenceUtils.getBoolean(mMultiProcessSharedPreferences, TERMUX_APP.KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED); + else + return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED); } public void setPluginErrorNotificationsEnabled(boolean value) { @@ -228,8 +240,11 @@ public class TermuxAppSharedPreferences { - public boolean areCrashReportNotificationsEnabled() { - return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_CRASH_REPORT_NOTIFICATIONS_ENABLED); + public boolean areCrashReportNotificationsEnabled(boolean readFromFile) { + if (readFromFile) + return SharedPreferenceUtils.getBoolean(mMultiProcessSharedPreferences, TERMUX_APP.KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_CRASH_REPORT_NOTIFICATIONS_ENABLED); + else + return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_CRASH_REPORT_NOTIFICATIONS_ENABLED); } public void setCrashReportNotificationsEnabled(boolean value) {