From e22ad71fad6c4b1ed05dfab7f9e0f347d88060b1 Mon Sep 17 00:00:00 2001 From: DrDisagree Date: Tue, 12 Sep 2023 17:41:16 +0600 Subject: [PATCH] QS Row Column: Rework on methods and slider values (Closes #259) --- .../iconify/common/Preferences.java | 1 + .../drdisagree/iconify/common/References.java | 10 +-- .../iconify/ui/activities/QsRowColumn.java | 84 ++++++++----------- .../res/layout/activity_qs_row_column.xml | 16 ++-- 4 files changed, 50 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/com/drdisagree/iconify/common/Preferences.java b/app/src/main/java/com/drdisagree/iconify/common/Preferences.java index cd10c65bc..dedc8c54e 100644 --- a/app/src/main/java/com/drdisagree/iconify/common/Preferences.java +++ b/app/src/main/java/com/drdisagree/iconify/common/Preferences.java @@ -150,4 +150,5 @@ public class Preferences { public static final String BOOT_ID = "boot_id"; public static final String VER_CODE = "versionCode"; public static final String EASTER_EGG = "iconify_easter_egg"; + public static final String ALERT_DIALOG_QSROWCOL = "alertDialogQsRowCol"; } diff --git a/app/src/main/java/com/drdisagree/iconify/common/References.java b/app/src/main/java/com/drdisagree/iconify/common/References.java index a6f08eaee..4b1d3e216 100644 --- a/app/src/main/java/com/drdisagree/iconify/common/References.java +++ b/app/src/main/java/com/drdisagree/iconify/common/References.java @@ -8,11 +8,11 @@ public class References { public static final String FABRICATED_COLORED_BATTERY = "coloredBattery"; public static final String FABRICATED_BATTERY_COLOR_BG = "batteryColorBackground"; public static final String FABRICATED_BATTERY_COLOR_FG = "batteryColorFilled"; - public static final String FABRICATED_QS_ROW = "qsRow"; - public static final String FABRICATED_QQS_ROW = "qqsRow"; - public static final String FABRICATED_QS_COLUMN = "qsColumn"; - public static final String FABRICATED_QQS_TILE = "qqsTile"; - public static final String FABRICATED_QS_TILE = "qsTile"; + public static final String FABRICATED_QS_ROW = "qsRowCount"; + public static final String FABRICATED_QQS_ROW = "qqsRowCount"; + public static final String FABRICATED_QS_COLUMN = "qsColumnCount"; + public static final String FABRICATED_QQS_TILE = "qqsTileCount"; + public static final String FABRICATED_QS_TILE = "qsTileCount"; public static final String FABRICATED_QS_TEXT_SIZE = "qsTextSize"; public static final String FABRICATED_QS_ICON_SIZE = "qsIconSize"; public static final String FABRICATED_QS_MOVE_ICON = "qsMoveIcon"; diff --git a/app/src/main/java/com/drdisagree/iconify/ui/activities/QsRowColumn.java b/app/src/main/java/com/drdisagree/iconify/ui/activities/QsRowColumn.java index 64252266c..cd73b0a09 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/activities/QsRowColumn.java +++ b/app/src/main/java/com/drdisagree/iconify/ui/activities/QsRowColumn.java @@ -1,8 +1,8 @@ package com.drdisagree.iconify.ui.activities; import static com.drdisagree.iconify.common.Const.SYSTEMUI_PACKAGE; +import static com.drdisagree.iconify.common.Preferences.ALERT_DIALOG_QSROWCOL; import static com.drdisagree.iconify.common.Preferences.QS_ROW_COLUMN_SWITCH; -import static com.drdisagree.iconify.common.Preferences.STR_NULL; import static com.drdisagree.iconify.common.References.FABRICATED_QQS_ROW; import static com.drdisagree.iconify.common.References.FABRICATED_QQS_TILE; import static com.drdisagree.iconify.common.References.FABRICATED_QS_COLUMN; @@ -34,11 +34,11 @@ public class QsRowColumn extends BaseActivity { public static void applyRowColumn() { FabricatedUtil.buildAndEnableOverlays( - new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QQS_ROW, "integer", "quick_qs_panel_max_rows", String.valueOf(Integer.parseInt(Prefs.getString(FABRICATED_QQS_ROW)) + 1)}, - new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QS_ROW, "integer", "quick_settings_max_rows", String.valueOf(Integer.parseInt(Prefs.getString(FABRICATED_QS_ROW)) + 1)}, - new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QS_COLUMN, "integer", "quick_settings_num_columns", String.valueOf(Integer.parseInt(Prefs.getString(FABRICATED_QS_COLUMN)) + 1)}, - new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QQS_TILE, "integer", "quick_qs_panel_max_tiles", String.valueOf((Integer.parseInt(Prefs.getString(FABRICATED_QQS_ROW)) + 1) * (Integer.parseInt(Prefs.getString(FABRICATED_QS_COLUMN)) + 1))}, - new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QS_TILE, "integer", "quick_settings_min_num_tiles", String.valueOf((Integer.parseInt(Prefs.getString(FABRICATED_QS_COLUMN)) + 1) * (Integer.parseInt(Prefs.getString(FABRICATED_QS_ROW)) + 1))} + new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QQS_ROW, "integer", "quick_qs_panel_max_rows", String.valueOf(Prefs.getInt(FABRICATED_QQS_ROW, 2))}, + new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QS_ROW, "integer", "quick_settings_max_rows", String.valueOf(Prefs.getInt(FABRICATED_QS_ROW, 4))}, + new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QS_COLUMN, "integer", "quick_settings_num_columns", String.valueOf(Prefs.getInt(FABRICATED_QS_COLUMN, 2))}, + new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QQS_TILE, "integer", "quick_qs_panel_max_tiles", String.valueOf((Prefs.getInt(FABRICATED_QQS_ROW, 2) * Prefs.getInt(FABRICATED_QS_COLUMN, 2)))}, + new Object[]{SYSTEMUI_PACKAGE, FABRICATED_QS_TILE, "integer", "quick_settings_min_num_tiles", String.valueOf((Prefs.getInt(FABRICATED_QS_COLUMN, 2) * Prefs.getInt(FABRICATED_QS_ROW, 4)))} ); } @@ -60,14 +60,9 @@ protected void onCreate(Bundle savedInstanceState) { loadingDialog = new LoadingDialog(this); // Quick QsPanel Row - final int[] finalQqsRow = {1}; - - if (!Prefs.getString(FABRICATED_QQS_ROW).equals(STR_NULL)) { - binding.qqsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + (Integer.parseInt(Prefs.getString(FABRICATED_QQS_ROW)) + 1)); - finalQqsRow[0] = Integer.parseInt(Prefs.getString(FABRICATED_QQS_ROW)); - binding.qqsRowSeekbar.setValue(finalQqsRow[0]); - } else binding.qqsRowOutput.setText(getResources().getString(R.string.opt_selected) + " 2"); - + final int[] finalQqsRow = {Prefs.getInt(FABRICATED_QQS_ROW, 2)}; + binding.qqsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + finalQqsRow[0]); + binding.qqsRowSeekbar.setValue(finalQqsRow[0]); binding.qqsRowSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() { @Override public void onStartTrackingTouch(@NonNull Slider slider) { @@ -76,19 +71,14 @@ public void onStartTrackingTouch(@NonNull Slider slider) { @Override public void onStopTrackingTouch(@NonNull Slider slider) { finalQqsRow[0] = (int) slider.getValue(); - binding.qqsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + (finalQqsRow[0] + 1)); + binding.qqsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + finalQqsRow[0]); } }); // QsPanel Row - final int[] finalQsRow = {3}; - - if (!Prefs.getString(FABRICATED_QS_ROW).equals(STR_NULL)) { - binding.qsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + (Integer.parseInt(Prefs.getString(FABRICATED_QS_ROW)) + 1)); - finalQsRow[0] = Integer.parseInt(Prefs.getString(FABRICATED_QS_ROW)); - binding.qsRowSeekbar.setValue(finalQsRow[0]); - } else binding.qsRowOutput.setText(getResources().getString(R.string.opt_selected) + " 4"); - + final int[] finalQsRow = {Prefs.getInt(FABRICATED_QS_ROW, 4)}; + binding.qsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + finalQsRow[0]); + binding.qsRowSeekbar.setValue(finalQsRow[0]); binding.qsRowSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() { @Override public void onStartTrackingTouch(@NonNull Slider slider) { @@ -97,20 +87,14 @@ public void onStartTrackingTouch(@NonNull Slider slider) { @Override public void onStopTrackingTouch(@NonNull Slider slider) { finalQsRow[0] = (int) slider.getValue(); - binding.qsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + (finalQsRow[0] + 1)); + binding.qsRowOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + finalQsRow[0]); } }); // QsPanel Column - final int[] finalQsColumn = {1}; - - if (!Prefs.getString(FABRICATED_QS_COLUMN).equals(STR_NULL)) { - binding.qsColumnOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + (Integer.parseInt(Prefs.getString(FABRICATED_QS_COLUMN)) + 1)); - finalQsColumn[0] = Integer.parseInt(Prefs.getString(FABRICATED_QS_COLUMN)); - binding.qsColumnSeekbar.setValue(finalQsColumn[0]); - } else - binding.qsColumnOutput.setText(getResources().getString(R.string.opt_selected) + " 2"); - + final int[] finalQsColumn = {Prefs.getInt(FABRICATED_QS_COLUMN, 2)}; + binding.qsColumnOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + finalQsColumn[0]); + binding.qsColumnSeekbar.setValue(finalQsColumn[0]); binding.qsColumnSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() { @Override public void onStartTrackingTouch(@NonNull Slider slider) { @@ -119,7 +103,7 @@ public void onStartTrackingTouch(@NonNull Slider slider) { @Override public void onStopTrackingTouch(@NonNull Slider slider) { finalQsColumn[0] = (int) slider.getValue(); - binding.qsColumnOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + (finalQsColumn[0] + 1)); + binding.qsColumnOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + finalQsColumn[0]); } }); @@ -131,11 +115,11 @@ public void onStopTrackingTouch(@NonNull Slider slider) { Runnable runnable = () -> { Prefs.putBoolean(QS_ROW_COLUMN_SWITCH, true); - Prefs.putString(FABRICATED_QQS_ROW, String.valueOf(finalQqsRow[0])); - Prefs.putString(FABRICATED_QS_ROW, String.valueOf(finalQsRow[0])); - Prefs.putString(FABRICATED_QS_COLUMN, String.valueOf(finalQsColumn[0])); - Prefs.putString(FABRICATED_QQS_TILE, String.valueOf((finalQqsRow[0] + 1) * (finalQsColumn[0] + 1))); - Prefs.putString(FABRICATED_QS_TILE, String.valueOf((finalQsColumn[0] + 1) * (finalQsRow[0] + 1))); + Prefs.putInt(FABRICATED_QQS_ROW, finalQqsRow[0]); + Prefs.putInt(FABRICATED_QS_ROW, finalQsRow[0]); + Prefs.putInt(FABRICATED_QS_COLUMN, finalQsColumn[0]); + Prefs.putInt(FABRICATED_QQS_TILE, (finalQqsRow[0] * finalQsColumn[0])); + Prefs.putInt(FABRICATED_QS_TILE, (finalQsColumn[0] * finalQsRow[0])); applyRowColumn(); @@ -157,9 +141,7 @@ public void onStopTrackingTouch(@NonNull Slider slider) { }); // Reset button - if (Prefs.getBoolean(QS_ROW_COLUMN_SWITCH)) - binding.qsRowColumnReset.setVisibility(View.VISIBLE); - else binding.qsRowColumnReset.setVisibility(View.GONE); + binding.qsRowColumnReset.setVisibility(Prefs.getBoolean(QS_ROW_COLUMN_SWITCH) ? View.VISIBLE : View.GONE); binding.qsRowColumnReset.setOnClickListener(v -> { // Show loading dialog @@ -186,12 +168,18 @@ public void onStopTrackingTouch(@NonNull Slider slider) { thread.start(); }); - new MaterialAlertDialogBuilder(this, R.style.MaterialComponents_MaterialAlertDialog) - .setTitle(getResources().getString(R.string.hey_there)) - .setMessage(getResources().getString(R.string.qs_row_column_warn_desc)) - .setPositiveButton(getResources().getString(R.string.understood), (dialog, which) -> dialog.dismiss()) - .setCancelable(true) - .show(); + if (Prefs.getBoolean(ALERT_DIALOG_QSROWCOL, true)) { + new MaterialAlertDialogBuilder(this, R.style.MaterialComponents_MaterialAlertDialog) + .setTitle(getResources().getString(R.string.hey_there)) + .setMessage(getResources().getString(R.string.qs_row_column_warn_desc)) + .setPositiveButton(getResources().getString(R.string.understood), (dialog, which) -> dialog.dismiss()) + .setNegativeButton(getString(R.string.dont_show_again), (dialog, which) -> { + dialog.dismiss(); + Prefs.putBoolean(ALERT_DIALOG_QSROWCOL, false); + }) + .setCancelable(true) + .show(); + } } @Override diff --git a/app/src/main/res/layout/activity_qs_row_column.xml b/app/src/main/res/layout/activity_qs_row_column.xml index 71e3e60fe..86b1a7efb 100644 --- a/app/src/main/res/layout/activity_qs_row_column.xml +++ b/app/src/main/res/layout/activity_qs_row_column.xml @@ -52,9 +52,9 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="4dp" android:stepSize="1" - android:value="1" + android:value="2" android:valueFrom="0" - android:valueTo="1" /> + android:valueTo="3" /> @@ -89,9 +89,9 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="4dp" android:stepSize="1" - android:value="3" - android:valueFrom="0" - android:valueTo="5" /> + android:value="4" + android:valueFrom="1" + android:valueTo="8" /> @@ -126,9 +126,9 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="4dp" android:stepSize="1" - android:value="1" - android:valueFrom="0" - android:valueTo="4" /> + android:value="2" + android:valueFrom="1" + android:valueTo="5" />