mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 13:47:05 +02:00
Simplify color selection
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user