Skip to content

Commit cf5bb69

Browse files
Add crash_report_notifications_enabled shared preferences
This will allow users to control if a notification should be shown with the crash info when app is restarted after a crash The `TermuxPreferenceConstants` classes has been updated to `v0.8.0`. Check its Changelog section for info on changes.
1 parent 18b004a commit cf5bb69

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ public void putBoolean(String key, boolean value) {
111111
case "plugin_error_notifications_enabled":
112112
mPreferences.setPluginErrorNotificationsEnabled(value);
113113
break;
114+
case "crash_report_notifications_enabled":
115+
mPreferences.setCrashReportNotificationsEnabled(value);
116+
break;
114117
default:
115118
break;
116119
}
@@ -123,6 +126,8 @@ public boolean getBoolean(String key, boolean defValue) {
123126
return mPreferences.getTerminalViewKeyLoggingEnabled();
124127
case "plugin_error_notifications_enabled":
125128
return mPreferences.getPluginErrorNotificationsEnabled();
129+
case "crash_report_notifications_enabled":
130+
return mPreferences.getCrashReportNotificationsEnabled();
126131
default:
127132
return false;
128133
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,14 @@ public void setPluginErrorNotificationsEnabled(boolean value) {
161161
SharedPreferenceUtils.setBoolean(mSharedPreferences, TERMUX_APP.KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED, value, false);
162162
}
163163

164+
165+
166+
public boolean getCrashReportNotificationsEnabled() {
167+
return SharedPreferenceUtils.getBoolean(mSharedPreferences, TERMUX_APP.KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED, TERMUX_APP.DEFAULT_VALUE_CRASH_REPORT_NOTIFICATIONS_ENABLED);
168+
}
169+
170+
public void setCrashReportNotificationsEnabled(boolean value) {
171+
SharedPreferenceUtils.setBoolean(mSharedPreferences, TERMUX_APP.KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED, value, false);
172+
}
173+
164174
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.termux.app.settings.preferences;
22

33
/*
4-
* Version: v0.7.0
4+
* Version: v0.8.0
55
*
66
* Changelog
77
*
@@ -33,6 +33,10 @@
3333
* - 0.7.0 (2021-03-27)
3434
* - Added following to `TERMUX_APP`:
3535
* `KEY_SOFT_KEYBOARD_ENABLED` and `DEFAULT_VALUE_KEY_SOFT_KEYBOARD_ENABLED`.
36+
*
37+
* - 0.8.0 (2021-04-06)
38+
* - Added following to `TERMUX_APP`:
39+
* `KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED` and `DEFAULT_VALUE_CRASH_REPORT_NOTIFICATIONS_ENABLED`.
3640
*/
3741

3842
/**
@@ -108,6 +112,12 @@ public static final class TERMUX_APP {
108112
public static final String KEY_PLUGIN_ERROR_NOTIFICATIONS_ENABLED = "plugin_error_notifications_enabled";
109113
public static final boolean DEFAULT_VALUE_PLUGIN_ERROR_NOTIFICATIONS_ENABLED = true;
110114

115+
/**
116+
* Defines the key for whether notifications for crash reports are enabled or not.
117+
*/
118+
public static final String KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED = "crash_report_notifications_enabled";
119+
public static final boolean DEFAULT_VALUE_CRASH_REPORT_NOTIFICATIONS_ENABLED = true;
120+
111121
}
112122

113123
/**

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@
201201
<string name="plugin_error_notifications_off">Disable flashes and notifications for plugin errors.</string>
202202
<string name="plugin_error_notifications_on">Show flashes and notifications for plugin errors. (Default)</string>
203203

204+
<!-- Crash Report Notifications -->
205+
<string name="crash_report_notifications_title">Crash Report Notifications</string>
206+
<string name="crash_report_notifications_off">Disable notifications for crash reports.</string>
207+
<string name="crash_report_notifications_on">Show notifications for crash reports. (Default)</string>
208+
204209

205210
<!-- Terminal IO Preferences -->
206211
<string name="terminal_io_preferences">Terminal I/O</string>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
app:summaryOn="@string/plugin_error_notifications_on"
2323
app:title="@string/plugin_error_notifications_title" />
2424

25+
<SwitchPreferenceCompat
26+
app:key="crash_report_notifications_enabled"
27+
app:summaryOff="@string/crash_report_notifications_off"
28+
app:summaryOn="@string/crash_report_notifications_on"
29+
app:title="@string/crash_report_notifications_title" />
30+
2531
</PreferenceCategory>
2632

2733
</PreferenceScreen>

0 commit comments

Comments
 (0)