Skip to content

Commit 8612a1d

Browse files
Added plugin_error_notifications_enabled preference
This will allow user to control whether flashes and notifications for plugin errors are enabled or not. The `TermuxPreferenceConstants` classes has been updated to `v0.4.0`. Check its Changelog sections for info on changes.
1 parent 7d53a14 commit 8612a1d

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

app/src/main/java/com/termux/app/settings/DebuggingPreferencesFragment.java

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ public void putBoolean(String key, boolean value) {
108108
case "terminal_view_key_logging_enabled":
109109
mPreferences.setTerminalViewKeyLoggingEnabled(value);
110110
break;
111+
case "plugin_error_notifications_enabled":
112+
mPreferences.setPluginErrorNotificationsEnabled(value);
113+
break;
111114
default:
112115
break;
113116
}
@@ -118,6 +121,8 @@ public boolean getBoolean(String key, boolean defValue) {
118121
switch (key) {
119122
case "terminal_view_key_logging_enabled":
120123
return mPreferences.getTerminalViewKeyLoggingEnabled();
124+
case "plugin_error_notifications_enabled":
125+
return mPreferences.getPluginErrorNotificationsEnabled();
121126
default:
122127
return false;
123128
}

app/src/main/java/com/termux/app/settings/preferences/TermuxAppSharedPreferences.java

+10
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,14 @@ public void setTerminalViewKeyLoggingEnabled(boolean value) {
130130
SharedPreferenceUtils.setBoolean(mSharedPreferences, TERMUX_APP.KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED, value, false);
131131
}
132132

133+
134+
135+
public boolean getPluginErrorNotificationsEnabled() {
136+
return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED);
137+
}
138+
139+
public void setPluginErrorNotificationsEnabled(boolean value) {
140+
SharedPreferenceUtils.setBoolean(mSharedPreferences, TERMUX_APP.KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED, value, false);
141+
}
142+
133143
}

app/src/main/java/com/termux/app/settings/preferences/TermuxPreferenceConstants.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.termux.app.settings.preferences;
22

33
/*
4-
* Version: v0.3.0
4+
* Version: v0.4.0
55
*
66
* Changelog
77
*
@@ -16,7 +16,12 @@
1616
* Termux app and its plugins. This will allow {@link com.termux.app.TermuxSettings} to
1717
* manage preferences of plugins as well if they don't have launcher activity themselves
1818
* and also allow plugin apps to make changes to preferences from background.
19-
* - Added `KEY_LOG_LEVEL` to `TERMUX_TASKER_APP` scope.
19+
* - Added following to `TERMUX_TASKER_APP`:
20+
* `KEY_LOG_LEVEL`.
21+
*
22+
* - 0.4.0 (2021-03-13)
23+
* - Added following to `TERMUX_APP`:
24+
* `KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED` and `DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED`.
2025
*/
2126

2227
/**
@@ -71,6 +76,12 @@ public static final class TERMUX_APP {
7176
public static final String KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED = "terminal_view_key_logging_enabled";
7277
public static final boolean DEFAULT_VALUE_TERMINAL_VIEW_KEY_LOGGING_ENABLED = false;
7378

79+
/**
80+
* Defines the key for whether flashes and notifications for plugin errors are enabled or not
81+
*/
82+
public static final String KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED = "plugin_error_notifications_enabled";
83+
public static final boolean DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED = true;
84+
7485
}
7586

7687
/**

app/src/main/res/values/strings.xml

+6
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,10 @@
118118
<string name="terminal_view_key_logging_off">Logs will not have entries for terminal view keys. (Default)</string>
119119
<string name="terminal_view_key_logging_on">Logcat logs will have entries for terminal view keys. These are very verbose and should be disabled under normal circumstances or will cause performance issues.</string>
120120

121+
122+
<!-- Plugin Error Notifications -->
123+
<string name="plugin_error_notifications_title">Plugin Error Notifications</string>
124+
<string name="plugin_error_notifications_off">Disable flashes and notifications for plugin errors.</string>
125+
<string name="plugin_error_notifications_on">Show flashes and notifications for plugin errors. (Default)</string>
126+
121127
</resources>

app/src/main/res/xml/debugging_preferences.xml

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
app:summaryOn="@string/terminal_view_key_logging_on"
1717
app:title="@string/terminal_view_key_logging_title" />
1818

19+
<SwitchPreferenceCompat
20+
app:key="plugin_error_notifications_enabled"
21+
app:summaryOff="@string/plugin_error_notifications_off"
22+
app:summaryOn="@string/plugin_error_notifications_on"
23+
app:title="@string/plugin_error_notifications_title" />
24+
1925
</PreferenceCategory>
2026

2127
</PreferenceScreen>

0 commit comments

Comments
 (0)