Refactoring

This commit is contained in:
M66B 2022-04-16 17:50:47 +02:00
parent bd8cff9ccd
commit d2283c5e58
2 changed files with 29 additions and 29 deletions

View File

@ -121,7 +121,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvExperimentsHint;
private SwitchCompat swCrashReports;
private TextView tvUuid;
private SwitchCompat swCanary;
private Button btnReset;
private SwitchCompat swCleanupAttachments;
private Button btnCleanup;
@ -129,6 +128,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swProtocol;
private SwitchCompat swLogInfo;
private SwitchCompat swDebug;
private SwitchCompat swCanary;
private SwitchCompat swTest1;
private SwitchCompat swTest2;
private SwitchCompat swTest3;
@ -204,8 +204,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"classification", "class_min_probability", "class_min_difference",
"language", "deepl_enabled", "watchdog",
"updates", "weekly", "show_changelog",
"experiments", "crash_reports", "leak_canary", "cleanup_attachments",
"protocol", "debug", "log_level", "test1", "test2", "test3", "test4", "test5",
"experiments", "crash_reports", "cleanup_attachments",
"protocol", "log_level", "debug", "leak_canary", "test1", "test2", "test3", "test4", "test5",
"work_manager", // "external_storage",
"query_threads", "wal", "sqlite_checkpoints", "sqlite_analyze", "sqlite_cache",
"chunk_size", "thread_range", "undo_manager", "webview_legacy", "browser_zoom",
@ -288,7 +288,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
swCrashReports = view.findViewById(R.id.swCrashReports);
tvUuid = view.findViewById(R.id.tvUuid);
swCanary = view.findViewById(R.id.swCanary);
btnReset = view.findViewById(R.id.btnReset);
swCleanupAttachments = view.findViewById(R.id.swCleanupAttachments);
btnCleanup = view.findViewById(R.id.btnCleanup);
@ -296,6 +295,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swProtocol = view.findViewById(R.id.swProtocol);
swLogInfo = view.findViewById(R.id.swLogInfo);
swDebug = view.findViewById(R.id.swDebug);
swCanary = view.findViewById(R.id.swCanary);
swTest1 = view.findViewById(R.id.swTest1);
swTest2 = view.findViewById(R.id.swTest2);
swTest3 = view.findViewById(R.id.swTest3);
@ -667,15 +667,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swCanary.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
swCanary.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("leak_canary", checked).apply();
CoalMine.setup(checked);
}
});
btnReset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -734,6 +725,15 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swCanary.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
swCanary.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("leak_canary", checked).apply();
CoalMine.setup(checked);
}
});
swTest1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1685,12 +1685,12 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swExperiments.setChecked(prefs.getBoolean("experiments", false));
swCrashReports.setChecked(prefs.getBoolean("crash_reports", false));
tvUuid.setText(prefs.getString("uuid", null));
swCanary.setChecked(prefs.getBoolean("leak_canary", false));
swCleanupAttachments.setChecked(prefs.getBoolean("cleanup_attachments", false));
swProtocol.setChecked(prefs.getBoolean("protocol", false));
swLogInfo.setChecked(prefs.getInt("log_level", Log.getDefaultLogLevel()) <= android.util.Log.INFO);
swDebug.setChecked(prefs.getBoolean("debug", false));
swCanary.setChecked(prefs.getBoolean("leak_canary", false));
swTest1.setChecked(prefs.getBoolean("test1", false));
swTest2.setChecked(prefs.getBoolean("test2", false));
swTest3.setChecked(prefs.getBoolean("test3", false));

View File

@ -453,19 +453,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCrashReports" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCanary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/leakcanary"
android:drawablePadding="6dp"
android:text="@string/title_advanced_canary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUuid"
app:switchPadding="12dp" />
<Button
android:id="@+id/btnReset"
style="?android:attr/buttonStyleSmall"
@ -476,7 +463,7 @@
android:drawablePadding="6dp"
android:text="@string/title_setup_reset_questions"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCanary" />
app:layout_constraintTop_toBottomOf="@id/tvUuid" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCleanupAttachments"
@ -638,6 +625,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDebug" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCanary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableStart="@drawable/leakcanary"
android:drawablePadding="6dp"
android:text="@string/title_advanced_canary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDebugHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swTest1"
android:layout_width="0dp"
@ -647,7 +647,7 @@
android:text="@string/title_advanced_test1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDebugHint"
app:layout_constraintTop_toBottomOf="@id/swCanary"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat