From 27cf21d95e7d03284d84268c184db1c94f27e041 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 28 Apr 2022 07:57:05 +0200 Subject: [PATCH] Fixed widget sync indication --- .../java/eu/faircode/email/WidgetUnified.java | 23 ++++++++++++------- .../twotone_compare_arrows_24_black.xml | 10 ++++++++ .../twotone_compare_arrows_24_white.xml | 10 ++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/drawable/twotone_compare_arrows_24_black.xml create mode 100644 app/src/main/res/drawable/twotone_compare_arrows_24_white.xml diff --git a/app/src/main/java/eu/faircode/email/WidgetUnified.java b/app/src/main/java/eu/faircode/email/WidgetUnified.java index e1388e8eac..5ffec8e513 100644 --- a/app/src/main/java/eu/faircode/email/WidgetUnified.java +++ b/app/src/main/java/eu/faircode/email/WidgetUnified.java @@ -107,10 +107,6 @@ public class WidgetUnified extends AppWidgetProvider { views.setViewPadding(R.id.refresh, px, px, px, px); views.setOnClickPendingIntent(R.id.refresh, piSync); - boolean syncing = prefs.getBoolean("widget." + appWidgetId + ".syncing", false); - views.setImageViewResource(R.id.refresh, syncing ? R.drawable.twotone_compare_arrows_24 : R.drawable.twotone_sync_24); - views.setViewVisibility(R.id.refresh, refresh ? View.VISIBLE : View.GONE); - views.setViewVisibility(R.id.compose, compose ? View.VISIBLE : View.GONE); views.setViewPadding(R.id.compose, px, px, px, px); views.setOnClickPendingIntent(R.id.compose, piCompose); @@ -133,6 +129,8 @@ public class WidgetUnified extends AppWidgetProvider { views.setPendingIntentTemplate(R.id.lv, piItem); + boolean syncing = prefs.getBoolean("widget." + appWidgetId + ".syncing", false); + if (background == Color.TRANSPARENT) { if (semi) views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background); @@ -141,7 +139,9 @@ public class WidgetUnified extends AppWidgetProvider { views.setTextColor(R.id.title, colorWidgetForeground); views.setInt(R.id.separator, "setBackgroundColor", lightColorSeparator); - views.setImageViewResource(R.id.refresh, R.drawable.twotone_sync_24_white); + views.setImageViewResource(R.id.refresh, syncing + ? R.drawable.twotone_compare_arrows_24_white + : R.drawable.twotone_sync_24_white); views.setImageViewResource(R.id.compose, R.drawable.twotone_edit_24_white); } else { float lum = (float) ColorUtils.calculateLuminance(background); @@ -155,10 +155,17 @@ public class WidgetUnified extends AppWidgetProvider { views.setTextColor(R.id.title, fg); views.setInt(R.id.separator, "setBackgroundColor", lum > 0.7f ? darkColorSeparator : lightColorSeparator); - views.setImageViewResource(R.id.refresh, lum > 0.7f - ? R.drawable.twotone_sync_24_black : R.drawable.twotone_sync_24_white); + if (syncing) + views.setImageViewResource(R.id.refresh, lum > 0.7f + ? R.drawable.twotone_compare_arrows_24_black + : R.drawable.twotone_compare_arrows_24_white); + else + views.setImageViewResource(R.id.refresh, lum > 0.7f + ? R.drawable.twotone_sync_24_black + : R.drawable.twotone_sync_24_white); views.setImageViewResource(R.id.compose, lum > 0.7f - ? R.drawable.twotone_edit_24_black : R.drawable.twotone_edit_24_white); + ? R.drawable.twotone_edit_24_black + : R.drawable.twotone_edit_24_white); } int dp6 = Helper.dp2pixels(context, 6); diff --git a/app/src/main/res/drawable/twotone_compare_arrows_24_black.xml b/app/src/main/res/drawable/twotone_compare_arrows_24_black.xml new file mode 100644 index 0000000000..7e563961e9 --- /dev/null +++ b/app/src/main/res/drawable/twotone_compare_arrows_24_black.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/twotone_compare_arrows_24_white.xml b/app/src/main/res/drawable/twotone_compare_arrows_24_white.xml new file mode 100644 index 0000000000..e51086da72 --- /dev/null +++ b/app/src/main/res/drawable/twotone_compare_arrows_24_white.xml @@ -0,0 +1,10 @@ + + +