From 1c939bc859b062fcaa2a0a79bd2442915a32ad7d Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 13 Apr 2019 21:20:29 +0300 Subject: [PATCH] improvement in the color selection UI keep initial and current colors separately. these are two different things initial is the current profile color, current is the currently selected color in the color selector, also used by the color selector icon --- app/src/main/java/net/ktnx/mobileledger/ui/HueRing.java | 2 ++ .../main/java/net/ktnx/mobileledger/ui/HueRingDialog.java | 6 ++++-- .../mobileledger/ui/profiles/ProfileDetailFragment.java | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/HueRing.java b/app/src/main/java/net/ktnx/mobileledger/ui/HueRing.java index e6b4b58b..2de15fe2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/HueRing.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/HueRing.java @@ -100,6 +100,8 @@ public class HueRing extends View { return hueDegrees; } public void setHue(int hueDegrees) { + if (hueDegrees == -1) hueDegrees = Colors.DEFAULT_HUE_DEG; + if (hueDegrees != Colors.DEFAULT_HUE_DEG) { // round to 15 degrees int rem = hueDegrees % 15; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/HueRingDialog.java b/app/src/main/java/net/ktnx/mobileledger/ui/HueRingDialog.java index d0228416..9dc63731 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/HueRingDialog.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/HueRingDialog.java @@ -27,13 +27,15 @@ import net.ktnx.mobileledger.utils.Colors; import androidx.annotation.NonNull; public class HueRingDialog extends Dialog { + private final int currentHue; private int initialHue; private HueRing hueRing; private HueSelectedListener listener; - public HueRingDialog(@NonNull Context context, int initialHue) { + public HueRingDialog(@NonNull Context context, int initialHue, int currentHue) { super(context); this.initialHue = initialHue; + this.currentHue = currentHue; } @Override protected void onCreate(Bundle savedInstanceState) { @@ -41,7 +43,7 @@ public class HueRingDialog extends Dialog { setContentView(R.layout.hue_dialog); hueRing = findViewById(R.id.ring); hueRing.setInitialHue(initialHue); - hueRing.setHue(initialHue); + hueRing.setHue(currentHue); findViewById(R.id.btn_ok).setOnClickListener(v -> { if (listener != null) listener.onHueSelected(hueRing.getHueDegrees()); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index 0021e2ce..91780c71 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -264,7 +264,8 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue huePickerView.setTag(profileThemeId); huePickerView.setOnClickListener(v -> { HueRingDialog d = new HueRingDialog( - Objects.requireNonNull(ProfileDetailFragment.this.getContext()), hue); + Objects.requireNonNull(ProfileDetailFragment.this.getContext()), + profileThemeId, (Integer) v.getTag()); d.show(); d.setColorSelectedListener(this); }); -- 2.39.5