Use warning color for message delete

pull/198/head
M66B 4 years ago
parent 5885b280ff
commit 0563c8808b

@ -20,7 +20,6 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -344,16 +343,16 @@ public class EntityFolder extends EntityOrder implements Serializable {
return R.drawable.twotone_folder_24; return R.drawable.twotone_folder_24;
} }
static Integer getDefaultColor(String type) { static Integer getDefaultColor(String type, Context context) {
if (EntityFolder.TRASH.equals(type) || EntityFolder.JUNK.equals(type)) if (EntityFolder.TRASH.equals(type) || EntityFolder.JUNK.equals(type))
return Color.RED; return Helper.resolveColor(context, R.attr.colorError);
return null; return null;
} }
static Integer getDefaultColor(Long action, String type) { static Integer getDefaultColor(Long action, String type, Context context) {
if (EntityMessage.SWIPE_ACTION_DELETE.equals(action)) if (EntityMessage.SWIPE_ACTION_DELETE.equals(action))
return Color.RED; return Helper.resolveColor(context, R.attr.colorError);
return getDefaultColor(type); return getDefaultColor(type, context);
} }
String getDisplayName(Context context) { String getDisplayName(Context context) {

@ -2066,7 +2066,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
// Right swipe // Right swipe
d.setAlpha(Math.round(255 * Math.min(dX / (2 * margin + size), 1.0f))); d.setAlpha(Math.round(255 * Math.min(dX / (2 * margin + size), 1.0f)));
if (swipes.right_color == null) { if (swipes.right_color == null) {
Integer color = EntityFolder.getDefaultColor(swipes.swipe_right, swipes.right_type); Integer color = EntityFolder.getDefaultColor(swipes.swipe_right, swipes.right_type, context);
if (color != null) if (color != null)
d.setTint(color); d.setTint(color);
} else } else
@ -2082,7 +2082,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
// Left swipe // Left swipe
d.setAlpha(Math.round(255 * Math.min(-dX / (2 * margin + size), 1.0f))); d.setAlpha(Math.round(255 * Math.min(-dX / (2 * margin + size), 1.0f)));
if (swipes.left_color == null) { if (swipes.left_color == null) {
Integer color = EntityFolder.getDefaultColor(swipes.swipe_left, swipes.left_type); Integer color = EntityFolder.getDefaultColor(swipes.swipe_left, swipes.left_type, context);
if (color != null) if (color != null)
d.setTint(color); d.setTint(color);
} else } else
@ -8334,13 +8334,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
String notagain = getArguments().getString("notagain"); String notagain = getArguments().getString("notagain");
ArrayList<MessageTarget> result = getArguments().getParcelableArrayList("result"); ArrayList<MessageTarget> result = getArguments().getParcelableArrayList("result");
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_move, null); final Context context = getContext();
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_move, null);
TextView tvMessages = dview.findViewById(R.id.tvMessages); TextView tvMessages = dview.findViewById(R.id.tvMessages);
TextView tvSourceFolders = dview.findViewById(R.id.tvSourceFolders); TextView tvSourceFolders = dview.findViewById(R.id.tvSourceFolders);
TextView tvTargetFolders = dview.findViewById(R.id.tvTargetFolders); TextView tvTargetFolders = dview.findViewById(R.id.tvTargetFolders);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
String question = getResources() String question = context.getResources()
.getQuantityString(R.plurals.title_moving_messages, .getQuantityString(R.plurals.title_moving_messages,
result.size(), result.size()); result.size(), result.size());
@ -8365,21 +8366,21 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Drawable source = null; Drawable source = null;
if (sources.size() == 1) { if (sources.size() == 1) {
source = getContext().getDrawable(EntityFolder.getIcon(sources.get(0))); source = context.getDrawable(EntityFolder.getIcon(sources.get(0)));
if (source != null) if (source != null)
source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight()); source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight());
if (sourceColor == null) if (sourceColor == null)
sourceColor = EntityFolder.getDefaultColor(sources.get(0)); sourceColor = EntityFolder.getDefaultColor(sources.get(0), context);
} else } else
sourceColor = null; sourceColor = null;
Drawable target = null; Drawable target = null;
if (targets.size() == 1) { if (targets.size() == 1) {
target = getContext().getDrawable(EntityFolder.getIcon(targets.get(0))); target = context.getDrawable(EntityFolder.getIcon(targets.get(0)));
if (target != null) if (target != null)
target.setBounds(0, 0, target.getIntrinsicWidth(), target.getIntrinsicHeight()); target.setBounds(0, 0, target.getIntrinsicWidth(), target.getIntrinsicHeight());
if (targetColor == null) if (targetColor == null)
targetColor = EntityFolder.getDefaultColor(targets.get(0)); targetColor = EntityFolder.getDefaultColor(targets.get(0), context);
} else } else
targetColor = null; targetColor = null;
@ -8397,12 +8398,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(buttonView.getContext());
prefs.edit().putBoolean(notagain, isChecked).apply(); prefs.edit().putBoolean(notagain, isChecked).apply();
} }
}); });
return new AlertDialog.Builder(getContext()) return new AlertDialog.Builder(context)
.setView(dview) .setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override

Loading…
Cancel
Save