diff --git a/.gitmodules b/.gitmodules
index a7400dae4e..d6bc660b04 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "colorpicker"]
path = colorpicker
url = https://github.com/M66B/colorpicker.git
+[submodule "qcolorpicker"]
+ path = qcolorpicker
+ url = https://github.com/QuadFlask/colorpicker.git
diff --git a/app/src/main/java/eu/faircode/email/ButtonColor.java b/app/src/main/java/eu/faircode/email/ButtonColor.java
new file mode 100644
index 0000000000..901399b5f1
--- /dev/null
+++ b/app/src/main/java/eu/faircode/email/ButtonColor.java
@@ -0,0 +1,114 @@
+package eu.faircode.email;
+
+/*
+ This file is part of FairEmail.
+
+ FairEmail is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ FairEmail is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with FairEmail. If not, see .
+
+ Copyright 2018-2019 by Marcel Bokhorst (M66B)
+*/
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.AttributeSet;
+import android.view.View;
+
+import androidx.appcompat.widget.AppCompatButton;
+import androidx.core.graphics.ColorUtils;
+
+public class ButtonColor extends AppCompatButton {
+ private int color = Color.TRANSPARENT;
+
+ public ButtonColor(Context context) {
+ super(context);
+ }
+
+ public ButtonColor(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public ButtonColor(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ return new SavedState(superState, this.color);
+ }
+
+ @Override
+ public void onRestoreInstanceState(Parcelable state) {
+ SavedState savedState = (SavedState) state;
+ super.onRestoreInstanceState(savedState.getSuperState());
+ setColor(savedState.getColor());
+ }
+
+ void setColor(Integer color) {
+ if (color == null)
+ color = Color.TRANSPARENT;
+ this.color = color;
+
+ GradientDrawable background = new GradientDrawable();
+ background.setColor(color);
+ background.setStroke(
+ Helper.dp2pixels(getContext(), 1),
+ Helper.resolveColor(getContext(), R.attr.colorSeparator));
+ setBackground(background);
+
+ double lum = ColorUtils.calculateLuminance(color);
+ setTextColor(lum < 0.5 ? Color.WHITE : Color.BLACK);
+ }
+
+ int getColor() {
+ return this.color;
+ }
+
+ static class SavedState extends View.BaseSavedState {
+ private int color;
+
+ private SavedState(Parcelable superState, int color) {
+ super(superState);
+ this.color = color;
+ }
+
+ private SavedState(Parcel in) {
+ super(in);
+ color = in.readInt();
+ }
+
+ public int getColor() {
+ return this.color;
+ }
+
+ @Override
+ public void writeToParcel(Parcel destination, int flags) {
+ super.writeToParcel(destination, flags);
+ destination.writeInt(color);
+ }
+
+ public static final Parcelable.Creator CREATOR = new Creator() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+}
diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java
index 1d4e23523d..981098e5c5 100644
--- a/app/src/main/java/eu/faircode/email/FragmentAccount.java
+++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java
@@ -24,7 +24,6 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -43,7 +42,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
-import android.widget.ImageButton;
import android.widget.RadioGroup;
import android.widget.ScrollView;
import android.widget.Spinner;
@@ -93,9 +91,7 @@ public class FragmentAccount extends FragmentBase {
private EditText etRealm;
private EditText etName;
- private Button btnColor;
- private View vwColor;
- private ImageButton ibColorDefault;
+ private ButtonColor btnColor;
private TextView tvColorPro;
private Button btnAdvanced;
@@ -142,7 +138,6 @@ public class FragmentAccount extends FragmentBase {
private long copy = -1;
private int auth = MailService.AUTH_TYPE_PASSWORD;
private boolean saving = false;
- private int color = Color.TRANSPARENT;
private static final int REQUEST_COLOR = 1;
private static final int REQUEST_SAVE = 2;
@@ -191,8 +186,6 @@ public class FragmentAccount extends FragmentBase {
etName = view.findViewById(R.id.etName);
btnColor = view.findViewById(R.id.btnColor);
- vwColor = view.findViewById(R.id.vwColor);
- ibColorDefault = view.findViewById(R.id.ibColorDefault);
tvColorPro = view.findViewById(R.id.tvColorPro);
btnAdvanced = view.findViewById(R.id.btnAdvanced);
@@ -307,24 +300,16 @@ public class FragmentAccount extends FragmentBase {
}
});
- setColor(color);
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentDialogColor fragment = new FragmentDialogColor();
- fragment.initialize(R.string.title_color, color, new Bundle(), getContext());
+ fragment.initialize(R.string.title_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setTargetFragment(FragmentAccount.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "account:color");
}
});
- ibColorDefault.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setColor(Color.TRANSPARENT);
- }
- });
-
Helper.linkPro(tvColorPro);
btnAdvanced.setOnClickListener(new View.OnClickListener() {
@@ -693,7 +678,7 @@ public class FragmentAccount extends FragmentBase {
args.putString("realm", etRealm.getText().toString());
args.putString("name", etName.getText().toString());
- args.putInt("color", color);
+ args.putInt("color", btnColor.getColor());
args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
@@ -1129,7 +1114,6 @@ public class FragmentAccount extends FragmentBase {
outState.putString("fair:password", tilPassword.getEditText().getText().toString());
outState.putInt("fair:advanced", grpAdvanced.getVisibility());
outState.putInt("fair:auth", auth);
- outState.putInt("fair:color", color);
super.onSaveInstanceState(outState);
}
@@ -1191,6 +1175,7 @@ public class FragmentAccount extends FragmentBase {
etRealm.setText(account == null ? null : account.realm);
etName.setText(account == null ? null : account.name);
+ btnColor.setColor(account == null ? null : account.color);
boolean pro = ActivityBilling.isPro(getContext());
cbNotify.setChecked(account != null && account.notify && pro);
@@ -1204,7 +1189,6 @@ public class FragmentAccount extends FragmentBase {
cbPartialFetch.setChecked(account == null ? true : account.partial_fetch);
auth = (account == null ? MailService.AUTH_TYPE_PASSWORD : account.auth_type);
- color = (account == null || account.color == null ? Color.TRANSPARENT : account.color);
new SimpleTask() {
@Override
@@ -1231,7 +1215,6 @@ public class FragmentAccount extends FragmentBase {
tilPassword.getEditText().setText(savedInstanceState.getString("fair:password"));
grpAdvanced.setVisibility(savedInstanceState.getInt("fair:advanced"));
auth = savedInstanceState.getInt("fair:auth");
- color = savedInstanceState.getInt("fair:color");
}
Helper.setViewsEnabled(view, true);
@@ -1241,7 +1224,6 @@ public class FragmentAccount extends FragmentBase {
tilPassword.setEnabled(false);
}
- setColor(color);
cbPrimary.setEnabled(cbSynchronize.isChecked());
// Consider previous check/save/delete as cancelled
@@ -1329,7 +1311,7 @@ public class FragmentAccount extends FragmentBase {
if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
- setColor(args.getInt("color"));
+ btnColor.setColor(args.getInt("color"));
} else
startActivity(new Intent(getContext(), ActivityBilling.class));
}
@@ -1356,15 +1338,6 @@ public class FragmentAccount extends FragmentBase {
}
}
- private void setColor(int color) {
- this.color = color;
-
- GradientDrawable border = new GradientDrawable();
- border.setColor(color);
- border.setStroke(1, Helper.resolveColor(getContext(), R.attr.colorSeparator));
- vwColor.setBackground(border);
- }
-
private void onDelete() {
Bundle args = new Bundle();
args.putLong("id", id);
diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java
index 74dbfb8daf..13dee748ed 100644
--- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java
+++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java
@@ -25,7 +25,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
-import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -47,7 +46,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
-import android.widget.ImageButton;
import android.widget.RadioGroup;
import android.widget.ScrollView;
import android.widget.Spinner;
@@ -84,9 +82,7 @@ public class FragmentIdentity extends FragmentBase {
private Spinner spAccount;
private EditText etDisplay;
- private Button btnColor;
- private View vwColor;
- private ImageButton ibColorDefault;
+ private ButtonColor btnColor;
private TextView tvColorPro;
private EditText etSignature;
private Button btnHtml;
@@ -133,7 +129,6 @@ public class FragmentIdentity extends FragmentBase {
private long copy = -1;
private int auth = MailService.AUTH_TYPE_PASSWORD;
private boolean saving = false;
- private int color = Color.TRANSPARENT;
private static final int REQUEST_COLOR = 1;
private static final int REQUEST_SAVE = 2;
@@ -167,8 +162,6 @@ public class FragmentIdentity extends FragmentBase {
spAccount = view.findViewById(R.id.spAccount);
etDisplay = view.findViewById(R.id.etDisplay);
btnColor = view.findViewById(R.id.btnColor);
- vwColor = view.findViewById(R.id.vwColor);
- ibColorDefault = view.findViewById(R.id.ibColorDefault);
tvColorPro = view.findViewById(R.id.tvColorPro);
etSignature = view.findViewById(R.id.etSignature);
btnHtml = view.findViewById(R.id.btnHtml);
@@ -290,24 +283,16 @@ public class FragmentIdentity extends FragmentBase {
}
});
- setColor(color);
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentDialogColor fragment = new FragmentDialogColor();
- fragment.initialize(R.string.title_flag_color, color, new Bundle(), getContext());
+ fragment.initialize(R.string.title_flag_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setTargetFragment(FragmentIdentity.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "identity:color");
}
});
- ibColorDefault.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setColor(Color.TRANSPARENT);
- }
- });
-
Helper.linkPro(tvColorPro);
etSignature.addTextChangedListener(new TextWatcher() {
@@ -516,6 +501,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("name", name);
args.putString("email", etEmail.getText().toString().trim());
args.putString("display", etDisplay.getText().toString());
+ args.putInt("color", btnColor.getColor());
args.putBoolean("sender_extra", cbSenderExtra.isChecked());
args.putString("sender_extra_regex", etSenderExtra.getText().toString());
args.putString("replyto", etReplyTo.getText().toString().trim());
@@ -533,7 +519,6 @@ public class FragmentIdentity extends FragmentBase {
args.putString("password", tilPassword.getEditText().getText().toString());
args.putString("realm", etRealm.getText().toString());
args.putBoolean("use_ip", cbUseIp.isChecked());
- args.putInt("color", color);
args.putString("signature", (String) etSignature.getTag());
args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
@@ -858,7 +843,6 @@ public class FragmentIdentity extends FragmentBase {
outState.putString("fair:password", tilPassword.getEditText().getText().toString());
outState.putInt("fair:advanced", grpAdvanced.getVisibility());
outState.putInt("fair:auth", auth);
- outState.putInt("fair:color", color);
outState.putString("fair:html", (String) etSignature.getTag());
super.onSaveInstanceState(outState);
}
@@ -884,6 +868,7 @@ public class FragmentIdentity extends FragmentBase {
etEmail.setText(identity == null ? null : identity.email);
etDisplay.setText(identity == null ? null : identity.display);
+ btnColor.setColor(identity == null ? null : identity.color);
String signature = (identity == null ? null : identity.signature);
etSignature.setText(TextUtils.isEmpty(signature) ? null : HtmlHelper.fromHtml(signature));
@@ -909,7 +894,6 @@ public class FragmentIdentity extends FragmentBase {
cbReadReceipt.setChecked(identity == null ? false : identity.read_receipt);
auth = (identity == null ? MailService.AUTH_TYPE_PASSWORD : identity.auth_type);
- color = (identity == null || identity.color == null ? Color.TRANSPARENT : identity.color);
if (identity == null || copy > 0)
new SimpleTask() {
@@ -932,7 +916,6 @@ public class FragmentIdentity extends FragmentBase {
tilPassword.getEditText().setText(savedInstanceState.getString("fair:password"));
grpAdvanced.setVisibility(savedInstanceState.getInt("fair:advanced"));
auth = savedInstanceState.getInt("fair:auth");
- color = savedInstanceState.getInt("fair:color");
etSignature.setTag(savedInstanceState.getString("fair:html"));
}
@@ -943,8 +926,6 @@ public class FragmentIdentity extends FragmentBase {
tilPassword.setEnabled(false);
}
- setColor(color);
-
cbPrimary.setEnabled(cbSynchronize.isChecked());
pbWait.setVisibility(View.GONE);
@@ -1073,7 +1054,7 @@ public class FragmentIdentity extends FragmentBase {
if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
- setColor(args.getInt("color"));
+ btnColor.setColor(args.getInt("color"));
} else
startActivity(new Intent(getContext(), ActivityBilling.class));
}
@@ -1104,15 +1085,6 @@ public class FragmentIdentity extends FragmentBase {
}
}
- private void setColor(int color) {
- this.color = color;
-
- GradientDrawable border = new GradientDrawable();
- border.setColor(color);
- border.setStroke(1, Helper.resolveColor(getContext(), R.attr.colorSeparator));
- vwColor.setBackground(border);
- }
-
private void onDelete() {
Bundle args = new Bundle();
args.putLong("id", id);
diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java
index 6aebdc8851..03c6b71e81 100644
--- a/app/src/main/java/eu/faircode/email/FragmentPop.java
+++ b/app/src/main/java/eu/faircode/email/FragmentPop.java
@@ -23,7 +23,6 @@ import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
-import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -38,7 +37,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
-import android.widget.ImageButton;
import android.widget.RadioGroup;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -69,9 +67,7 @@ public class FragmentPop extends FragmentBase {
private TextInputLayout tilPassword;
private EditText etName;
- private Button btnColor;
- private View vwColor;
- private ImageButton ibColorDefault;
+ private ButtonColor btnColor;
private TextView tvColorPro;
private CheckBox cbSynchronize;
@@ -87,7 +83,6 @@ public class FragmentPop extends FragmentBase {
private long id = -1;
private boolean saving = false;
- private int color = Color.TRANSPARENT;
private static final int REQUEST_COLOR = 1;
private static final int REQUEST_DELETE = 2;
@@ -120,8 +115,6 @@ public class FragmentPop extends FragmentBase {
etName = view.findViewById(R.id.etName);
btnColor = view.findViewById(R.id.btnColor);
- vwColor = view.findViewById(R.id.vwColor);
- ibColorDefault = view.findViewById(R.id.ibColorDefault);
tvColorPro = view.findViewById(R.id.tvColorPro);
cbSynchronize = view.findViewById(R.id.cbSynchronize);
@@ -136,24 +129,16 @@ public class FragmentPop extends FragmentBase {
pbWait = view.findViewById(R.id.pbWait);
- setColor(color);
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentDialogColor fragment = new FragmentDialogColor();
- fragment.initialize(R.string.title_color, color, new Bundle(), getContext());
+ fragment.initialize(R.string.title_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setTargetFragment(FragmentPop.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "account:color");
}
});
- ibColorDefault.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setColor(Color.TRANSPARENT);
- }
- });
-
Helper.linkPro(tvColorPro);
cbSynchronize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@@ -193,7 +178,7 @@ public class FragmentPop extends FragmentBase {
args.putString("password", tilPassword.getEditText().getText().toString());
args.putString("name", etName.getText().toString());
- args.putInt("color", color);
+ args.putInt("color", btnColor.getColor());
args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
@@ -428,7 +413,6 @@ public class FragmentPop extends FragmentBase {
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putString("fair:password", tilPassword.getEditText().getText().toString());
- outState.putInt("fair:color", color);
super.onSaveInstanceState(outState);
}
@@ -461,14 +445,13 @@ public class FragmentPop extends FragmentBase {
tilPassword.getEditText().setText(account == null ? null : account.password);
etName.setText(account == null ? null : account.name);
+ btnColor.setColor(account == null ? null : account.color);
cbSynchronize.setChecked(account == null ? true : account.synchronize);
cbPrimary.setChecked(account == null ? false : account.primary);
cbLeave.setChecked(account == null ? true : account.browse);
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
- color = (account == null || account.color == null ? Color.TRANSPARENT : account.color);
-
new SimpleTask() {
@Override
protected EntityAccount onExecute(Context context, Bundle args) {
@@ -488,10 +471,8 @@ public class FragmentPop extends FragmentBase {
}.execute(FragmentPop.this, new Bundle(), "account:primary");
} else {
tilPassword.getEditText().setText(savedInstanceState.getString("fair:password"));
- color = savedInstanceState.getInt("fair:color");
}
- setColor(color);
cbPrimary.setEnabled(cbSynchronize.isChecked());
Helper.setViewsEnabled(view, true);
@@ -529,15 +510,6 @@ public class FragmentPop extends FragmentBase {
}
}
- private void setColor(int color) {
- this.color = color;
-
- GradientDrawable border = new GradientDrawable();
- border.setColor(color);
- border.setStroke(1, Helper.resolveColor(getContext(), R.attr.colorSeparator));
- vwColor.setBackground(border);
- }
-
private void onMenuDelete() {
Bundle aargs = new Bundle();
aargs.putString("question", getString(R.string.title_account_delete));
@@ -558,7 +530,7 @@ public class FragmentPop extends FragmentBase {
if (resultCode == RESULT_OK && data != null) {
if (ActivityBilling.isPro(getContext())) {
Bundle args = data.getBundleExtra("args");
- setColor(args.getInt("color"));
+ btnColor.setColor(args.getInt("color"));
} else
startActivity(new Intent(getContext(), ActivityBilling.class));
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java
index 67931ee9c5..21d02ae4f3 100644
--- a/app/src/main/java/eu/faircode/email/FragmentRule.java
+++ b/app/src/main/java/eu/faircode/email/FragmentRule.java
@@ -24,8 +24,6 @@ import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
-import android.graphics.Color;
-import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -42,7 +40,6 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
-import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.NumberPicker;
import android.widget.ScrollView;
@@ -113,9 +110,7 @@ public class FragmentRule extends FragmentBase {
private NumberPicker npDuration;
private CheckBox cbScheduleEnd;
- private Button btnColor;
- private View vwColor;
- private ImageButton ibColorDefault;
+ private ButtonColor btnColor;
private Spinner spTarget;
private CheckBox cbMoveSeen;
@@ -149,7 +144,6 @@ public class FragmentRule extends FragmentBase {
private long copy = -1;
private long account = -1;
private long folder = -1;
- private int color = Color.TRANSPARENT;
private final static int MAX_CHECK = 10;
@@ -218,8 +212,6 @@ public class FragmentRule extends FragmentBase {
cbScheduleEnd = view.findViewById(R.id.cbScheduleEnd);
btnColor = view.findViewById(R.id.btnColor);
- vwColor = view.findViewById(R.id.vwColor);
- ibColorDefault = view.findViewById(R.id.ibColorDefault);
spTarget = view.findViewById(R.id.spTarget);
cbMoveSeen = view.findViewById(R.id.cbMoveSeen);
@@ -371,24 +363,16 @@ public class FragmentRule extends FragmentBase {
tvActionRemark.setVisibility(View.GONE);
- onSelectColor(color);
btnColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentDialogColor fragment = new FragmentDialogColor();
- fragment.initialize(R.string.title_flag_color, color, new Bundle(), getContext());
+ fragment.initialize(R.string.title_flag_color, btnColor.getColor(), new Bundle(), getContext());
fragment.setTargetFragment(FragmentRule.this, REQUEST_COLOR);
fragment.show(getFragmentManager(), "rule:color");
}
});
- ibColorDefault.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onSelectColor(Color.TRANSPARENT);
- }
- });
-
tvAutomation.setText(getString(R.string.title_rule_automation_hint,
EntityRule.ACTION_AUTOMATION,
TextUtils.join(",", new String[]{
@@ -511,7 +495,7 @@ public class FragmentRule extends FragmentBase {
}
Bundle args = data.getBundleExtra("args");
- onSelectColor(args.getInt("color"));
+ btnColor.setColor(args.getInt("color"));
}
break;
case REQUEST_DELETE:
@@ -551,15 +535,6 @@ public class FragmentRule extends FragmentBase {
}
}
- private void onSelectColor(int color) {
- this.color = color;
-
- GradientDrawable border = new GradientDrawable();
- border.setColor(color);
- border.setStroke(1, Helper.resolveColor(getContext(), R.attr.colorSeparator));
- vwColor.setBackground(border);
- }
-
private void onDelete() {
Bundle args = new Bundle();
args.putLong("id", id);
@@ -682,8 +657,9 @@ public class FragmentRule extends FragmentBase {
break;
case EntityRule.TYPE_FLAG:
- onSelectColor(jaction.isNull("color")
- ? Color.TRANSPARENT : jaction.optInt("color", 0));
+ btnColor.setColor(
+ !jaction.has("color") || jaction.isNull("color")
+ ? null : jaction.getInt("color"));
break;
case EntityRule.TYPE_MOVE:
@@ -962,7 +938,7 @@ public class FragmentRule extends FragmentBase {
break;
case EntityRule.TYPE_FLAG:
- jaction.put("color", color);
+ jaction.put("color", btnColor.getColor());
break;
case EntityRule.TYPE_MOVE:
diff --git a/app/src/main/res/layout/fragment_account.xml b/app/src/main/res/layout/fragment_account.xml
index 3f0cb621ac..bfb3ccb560 100644
--- a/app/src/main/res/layout/fragment_account.xml
+++ b/app/src/main/res/layout/fragment_account.xml
@@ -320,11 +320,12 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" />
-
-
-
-
-
+ tvColor,btnColor,tvColorHint,tvColorPro" />
-
-
-
-
-
diff --git a/app/src/main/res/layout/fragment_pop.xml b/app/src/main/res/layout/fragment_pop.xml
index 1d6fdc2e83..f30f1eb6d1 100644
--- a/app/src/main/res/layout/fragment_pop.xml
+++ b/app/src/main/res/layout/fragment_pop.xml
@@ -194,11 +194,12 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" />
-
-
-
-
-
-
-
-
-
-
+ app:constraint_referenced_ids="tvColor,btnColor" />
@color/pink
- @color/purple
- @color/deep_purple
+
- @color/indigo
- @color/blue
- @color/light_blue
- @color/cyan
+
- @color/teal
- @color/green
- @color/light_green
- @color/lime
+
- @color/yellow
- @color/amber
- @color/orange
- @color/deep_orange
+
- @color/brown
- @color/blue_grey
- @color/grey
- @color/dark_grey
+
+ - @android:color/transparent
17BA15C1AF55D925F98B99CEA4375D4CDF4C174B
diff --git a/qcolorpicker b/qcolorpicker
new file mode 160000
index 0000000000..3583e34ac3
--- /dev/null
+++ b/qcolorpicker
@@ -0,0 +1 @@
+Subproject commit 3583e34ac3895b3c01e89bab6a7d32bca124a974