16
16
import android .widget .ImageView ;
17
17
import android .widget .Switch ;
18
18
import android .widget .TextView ;
19
+ import android .widget .Toast ;
19
20
20
21
import com .google .firebase .messaging .FirebaseMessaging ;
21
22
22
23
import ca .pkay .rcloneexplorer .Dialogs .ColorPickerDialog ;
24
+ import es .dmoral .toasty .Toasty ;
23
25
24
26
public class SettingsActivity extends AppCompatActivity {
25
27
@@ -36,6 +38,8 @@ public class SettingsActivity extends AppCompatActivity {
36
38
private Switch useLogsSwitch ;
37
39
private View useLogsElement ;
38
40
private Switch appUpdatesSwitch ;
41
+ private View crashReportsElement ;
42
+ private Switch crashReportsSwitch ;
39
43
private boolean isDarkTheme ;
40
44
private boolean themeHasChanged ;
41
45
@@ -105,17 +109,21 @@ private void getViews() {
105
109
appUpdatesSwitch = findViewById (R .id .app_updates_switch );
106
110
useLogsSwitch = findViewById (R .id .use_logs_switch );
107
111
useLogsElement = findViewById (R .id .use_logs );
112
+ crashReportsElement = findViewById (R .id .crash_reporting );
113
+ crashReportsSwitch = findViewById (R .id .crash_reporting_switch );
108
114
}
109
115
110
116
private void setDefaultStates () {
111
117
SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences (this );
112
118
boolean isDarkTheme = sharedPreferences .getBoolean (getString (R .string .pref_key_dark_theme ), false );
113
119
boolean useLogs = sharedPreferences .getBoolean (getString (R .string .pref_key_logs ), false );
114
120
boolean appUpdates = sharedPreferences .getBoolean (getString (R .string .pref_key_app_updates ), true );
121
+ boolean crashReports = sharedPreferences .getBoolean (getString (R .string .pref_key_crash_reports ), true );
115
122
116
123
darkThemeSwitch .setChecked (isDarkTheme );
117
124
useLogsSwitch .setChecked (useLogs );
118
125
appUpdatesSwitch .setChecked (appUpdates );
126
+ crashReportsSwitch .setChecked (crashReports );
119
127
}
120
128
121
129
private void setClickListeners () {
@@ -147,16 +155,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
147
155
onDarkThemeClicked (isChecked );
148
156
}
149
157
});
150
- useLogsElement .setOnClickListener (new View .OnClickListener () {
151
- @ Override
152
- public void onClick (View v ) {
153
- if (useLogsSwitch .isChecked ()) {
154
- useLogsSwitch .setChecked (false );
155
- } else {
156
- useLogsSwitch .setChecked (true );
157
- }
158
- }
159
- });
160
158
notificationsElement .setOnClickListener (new View .OnClickListener () {
161
159
@ Override
162
160
public void onClick (View v ) {
@@ -179,12 +177,38 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
179
177
onAppUpdatesClicked (isChecked );
180
178
}
181
179
});
180
+ useLogsElement .setOnClickListener (new View .OnClickListener () {
181
+ @ Override
182
+ public void onClick (View v ) {
183
+ if (useLogsSwitch .isChecked ()) {
184
+ useLogsSwitch .setChecked (false );
185
+ } else {
186
+ useLogsSwitch .setChecked (true );
187
+ }
188
+ }
189
+ });
182
190
useLogsSwitch .setOnCheckedChangeListener (new CompoundButton .OnCheckedChangeListener () {
183
191
@ Override
184
192
public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
185
193
onUseLogsClicked (isChecked );
186
194
}
187
195
});
196
+ crashReportsElement .setOnClickListener (new View .OnClickListener () {
197
+ @ Override
198
+ public void onClick (View v ) {
199
+ if (crashReportsSwitch .isChecked ()) {
200
+ crashReportsSwitch .setChecked (false );
201
+ } else {
202
+ crashReportsSwitch .setChecked (true );
203
+ }
204
+ }
205
+ });
206
+ crashReportsSwitch .setOnCheckedChangeListener (new CompoundButton .OnCheckedChangeListener () {
207
+ @ Override
208
+ public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
209
+ crashReportsClicked (isChecked );
210
+ }
211
+ });
188
212
}
189
213
190
214
private void showPrimaryColorPicker () {
@@ -294,4 +318,13 @@ private void onUseLogsClicked(boolean isChecked) {
294
318
editor .putBoolean (getString (R .string .pref_key_logs ), isChecked );
295
319
editor .apply ();
296
320
}
321
+
322
+ private void crashReportsClicked (boolean isChecked ) {
323
+ SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences (this );
324
+ SharedPreferences .Editor editor = sharedPreferences .edit ();
325
+ editor .putBoolean (getString (R .string .pref_key_crash_reports ), isChecked );
326
+ editor .apply ();
327
+
328
+ Toasty .info (this , getString (R .string .restart_required ), Toast .LENGTH_SHORT , true ).show ();
329
+ }
297
330
}
0 commit comments