Skip to content

Commit

Permalink
add COLOR_HISTORY_ENABLED option to setting
Browse files Browse the repository at this point in the history
  • Loading branch information
FazziCLAY committed Nov 4, 2023
1 parent 0f919ce commit 1594613
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class SettingsManager {
public static final StringOption PLUGINS = registerOption(new StringOption("plugins", true, "")); // empty string is default
public static final BooleanOption TOOLBAR_AUTOMATICALLY_CLOSE = registerOption(new BooleanOption("toolbar.auto_close", false, true));
public static final EnumOption<ActionBarPosition> ACTIONBAR_POSITION = registerOption(new EnumOption<>("actionbar.position", false, ActionBarPosition.TOP));
public static final BooleanOption COLOR_HISTORY_ENABLED = registerOption(new BooleanOption("color_history.enabled", false, true));


// object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import androidx.appcompat.app.AlertDialog;

import com.fazziclay.opentoday.app.App;
import com.fazziclay.opentoday.app.ColorHistoryManager;
import com.fazziclay.opentoday.app.settings.SettingsManager;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
Expand All @@ -16,6 +18,7 @@
public class ColorPicker {
private final Context context;
private int startColor;
private SettingsManager settingsManager;
private ColorHistoryManager colorHistoryManager;
private int colorHistoryMax = 5;
private boolean showHex;
Expand All @@ -31,6 +34,7 @@ public ColorPicker(Context context) {
public ColorPicker(Context context, int startColor) {
this.context = context;
this.startColor = startColor;
this.settingsManager = App.get(context).getSettingsManager();
}

public ColorPicker setting(boolean showHex, boolean showPreview, boolean showAlpha) {
Expand Down Expand Up @@ -95,7 +99,9 @@ public ColorPicker setStartColor(int color) {
}

public ColorPicker setColorHistoryManager(ColorHistoryManager colorHistoryManager) {
this.colorHistoryManager = colorHistoryManager;
if (SettingsManager.COLOR_HISTORY_ENABLED.get(settingsManager)) {
this.colorHistoryManager = colorHistoryManager;
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,15 @@ class SettingsFragment : Fragment() {


// Lock color history
binding.colorHistoryEnabled.isChecked = SettingsManager.COLOR_HISTORY_ENABLED[sm]
viewClick(binding.colorHistoryEnabled, Runnable {
binding.colorHistoryLocked.isEnabled = binding.colorHistoryEnabled.isChecked
SettingsManager.COLOR_HISTORY_ENABLED[sm] = binding.colorHistoryEnabled.isChecked
sm.save()
})

binding.colorHistoryLocked.isChecked = colorHistoryManager.isLocked
binding.colorHistoryLocked.isEnabled = binding.colorHistoryEnabled.isChecked
viewClick(binding.colorHistoryLocked, Runnable {
colorHistoryManager.isLocked = binding.colorHistoryLocked.isChecked
})
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,17 @@


<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/colorHistoryLocked"
android:id="@+id/colorHistoryEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/itemInternalBackgroundFromItem"
android:text="@string/settings_colorHistoryEnabled" />

<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/colorHistoryLocked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/colorHistoryEnabled"
android:text="@string/settings_colorHistoryLocked" />

<com.google.android.material.checkbox.MaterialCheckBox
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,5 @@
<string name="transform_selectTypeDialog_message" />
<string name="transform_selectTypeDialog_title">Выберите тип результата</string>
<string name="fragment_developer_resetUpdateCheckerTimeout">Сбросить таймаут АпдейтЧекера</string>
<string name="settings_colorHistoryEnabled">Сохранять историю выбранных цветов</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,5 @@
<string name="transform_selectTypeDialog_message" translatable="false" />
<string name="transform_selectTypeDialog_title">Select result type</string>
<string name="fragment_developer_resetUpdateCheckerTimeout">Reset UpdateChecker timeout</string>
<string name="settings_colorHistoryEnabled">Is save colors in color-pickers to history</string>
</resources>

0 comments on commit 1594613

Please sign in to comment.