Skip to content

Commit

Permalink
Cleanups after SDK bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiascode committed Jan 31, 2024
1 parent 866c72f commit 360bb98
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,17 @@ private void initializeThemeSettings(final SharedPreferences preferences) {
theme.setEntryValues(new CharSequence[]{"light", "dark", "auto"});

switch (getCurrentTheme) {
case MODE_NIGHT_NO:
theme.setValue("light");
break;
case MODE_NIGHT_YES:
theme.setValue("dark");
break;
default:
theme.setValue("auto");
break;
case MODE_NIGHT_NO -> theme.setValue("light");
case MODE_NIGHT_YES -> theme.setValue("dark");
default -> theme.setValue("auto");
}

theme.setOnPreferenceChangeListener((preference, newValue) -> {
int newTheme;

switch (newValue.toString()) {
case "light":
newTheme = MODE_NIGHT_NO;
break;
case "dark":
newTheme = MODE_NIGHT_YES;
break;
default:
newTheme = MODE_NIGHT_FOLLOW_SYSTEM;
break;
}
int newTheme = switch (newValue.toString()) {
case "light" -> MODE_NIGHT_NO;
case "dark" -> MODE_NIGHT_YES;
default -> MODE_NIGHT_FOLLOW_SYSTEM;
};

AppCompatDelegate.setDefaultNightMode(newTheme);
SharedPreferences.Editor editor = preferences.edit();
Expand All @@ -137,9 +123,7 @@ private void initializeStartupSettings(final SharedPreferences preferences) {
// SD Card-related methods

private void initializeSDCardSettings(final SharedPreferences preferences) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& requireContext().getExternalFilesDirs(null).length > 1
&& requireContext().getExternalFilesDirs(null)[1] != null) {
if (requireContext().getExternalFilesDirs(null).length > 1 && requireContext().getExternalFilesDirs(null)[1] != null) {
final String PUBLIC_DIR = Environment.getExternalStorageDirectory().getAbsolutePath();
final SwitchPreferenceCompat toggleSD = findPreference("saveToSDToggle");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ProgressReceiver(Context context, Handler handler) {
public void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
switch (resultCode) {
case PROGRESS_START_INDETERMINATE: {
case PROGRESS_START_INDETERMINATE -> {
String title = resultData.getString("title");
progressDialog = new ProgressDialog(cont);
progressDialog.setTitle(title);
Expand All @@ -35,10 +35,8 @@ public void onReceiveResult(int resultCode, Bundle resultData) {

progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
break;
}

case PROGRESS_START: {
case PROGRESS_START -> {
String title = resultData.getString("title");
progressDialog = new ProgressDialog(cont);
progressDialog.setTitle(title);
Expand All @@ -48,21 +46,16 @@ public void onReceiveResult(int resultCode, Bundle resultData) {

progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(false);
break;
}

case PROGRESS_NEW_DATA: {
case PROGRESS_NEW_DATA -> {
int progress = resultData.getInt("progress");
int max = resultData.getInt("max");
progressDialog.setIndeterminate(false);
progressDialog.setProgress(progress);
progressDialog.setMax(max);
break;
}

case PROGRESS_END: {
case PROGRESS_END -> {
progressDialog.dismiss();
break;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/fragment_console.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
android:padding="12dp"
android:hint="@string/inputLine_hint"
android:layout_toStartOf="@+id/executeLine"
android:layout_toLeftOf="@+id/executeLine"
android:singleLine="true"
tools:ignore="Autofill"
android:inputType="textNoSuggestions" />
Expand All @@ -48,7 +47,6 @@
android:layout_height="wrap_content"
android:contentDescription="@string/do_execute_line"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
app:srcCompat="@drawable/ic_execute" />
</RelativeLayout>
</RelativeLayout>

0 comments on commit 360bb98

Please sign in to comment.