]> git.ktnx.net Git - mobile-ledger.git/commitdiff
improvement in the color selection UI
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 13 Apr 2019 18:20:29 +0000 (21:20 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 13 Apr 2019 20:10:30 +0000 (23:10 +0300)
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
app/src/main/java/net/ktnx/mobileledger/ui/HueRingDialog.java
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java

index e6b4b58b581d262617530275dcbb98e628e5d521..2de15fe2f4b01efb2d7c17f6e542976f7a9de57a 100644 (file)
@@ -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;
index d02284169ff2f97e5580747507aaeb82c436b3a0..9dc637317e4302b926f56c69a481e355c0d584e1 100644 (file)
@@ -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());
index 0021e2ce5cf308e2c3fd05188bf79e13fe621104..91780c71b4dbec9a29d1e0f115a45c1c117e3053 100644 (file)
@@ -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);
         });