mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 11:09:49 +08:00
Added: Add multi process support in TermuxAppSharedPreferences
since plugin apps may need to read values modified by termux app process
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user