From c29c0ef96c2df0c144a2b62f7ec7e0ed5a4e7fd9 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 22 Aug 2021 20:24:31 +0200 Subject: [PATCH] Fade out swipe indicators --- .../main/java/eu/faircode/email/FragmentMessages.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 86b7c572ea..7c6c097d1f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -2142,9 +2142,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Drawable d = context.getDrawable(icon).mutate(); d.setTint(Helper.resolveColor(context, android.R.attr.textColorSecondary)); + int half = rect.width() / 2; if (dX > 0) { // Right swipe - d.setAlpha(Math.round(255 * Math.min(dX / (2 * margin + size), 1.0f))); + if (dX < half) + d.setAlpha(Math.round(255 * Math.min(dX / (2 * margin + size), 1.0f))); + else + d.setAlpha(Math.round(255 * (1.0f - (dX - half) / half))); if (swipes.right_color == null) { Integer color = EntityFolder.getDefaultColor(swipes.swipe_right, swipes.right_type, context); if (color != null) @@ -2160,7 +2164,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. d.draw(canvas); } else if (dX < 0) { // Left swipe - d.setAlpha(Math.round(255 * Math.min(-dX / (2 * margin + size), 1.0f))); + if (-dX < half) + d.setAlpha(Math.round(255 * Math.min(-dX / (2 * margin + size), 1.0f))); + else + d.setAlpha(Math.round(255 * (1.0f - (-dX - half) / half))); if (swipes.left_color == null) { Integer color = EntityFolder.getDefaultColor(swipes.swipe_left, swipes.left_type, context); if (color != null)