Default swipe icon colors

pull/190/head
M66B 4 years ago
parent ffd4487870
commit 68c55c4300

@ -20,6 +20,7 @@ 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;
@ -325,6 +326,12 @@ public class EntityFolder extends EntityOrder implements Serializable {
return R.drawable.twotone_folder_24; return R.drawable.twotone_folder_24;
} }
static Integer getDefaultColor(String type) {
if (EntityFolder.TRASH.equals(type) || EntityFolder.JUNK.equals(type))
return Color.RED;
return null;
}
String getDisplayName(Context context) { String getDisplayName(Context context) {
return (display == null ? localizeName(context, name) : display); return (display == null ? localizeName(context, name) : display);
} }

@ -1974,7 +1974,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (dX > 0) { if (dX > 0) {
// 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.right_type);
if (color != null)
d.setTint(color);
} else
d.setTint(swipes.right_color); d.setTint(swipes.right_color);
int padding = (rect.height() - size); int padding = (rect.height() - size);
d.setBounds( d.setBounds(
@ -1986,7 +1990,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} else if (dX < 0) { } else if (dX < 0) {
// 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.left_type);
if (color != null)
d.setTint(color);
} else
d.setTint(swipes.left_color); d.setTint(swipes.left_color);
int padding = (rect.height() - size); int padding = (rect.height() - size);
d.setBounds( d.setBounds(

Loading…
Cancel
Save