Revert "About widget color filters"

This reverts commit 6a92c6234b.
This commit is contained in:
M66B 2022-03-05 14:16:59 +01:00
parent 6a92c6234b
commit d937d4edfd
5 changed files with 20 additions and 46 deletions

View File

@ -26,10 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.widget.RemoteViews;
@ -115,15 +112,16 @@ public class Widget extends AppWidgetProvider {
views.setOnClickPendingIntent(R.id.background, pi);
int fg;
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
if (background == Color.TRANSPARENT) {
if (semi)
views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background);
else
views.setInt(R.id.background, "setBackgroundColor", background);
fg = colorWidgetForeground;
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
views.setInt(R.id.ivMessage, "setColorFilter", colorWidgetForeground);
views.setTextColor(R.id.tvCount, colorWidgetForeground);
views.setTextColor(R.id.tvAccount, colorWidgetForeground);
} else {
float lum = (float) ColorUtils.calculateLuminance(background);
@ -132,33 +130,21 @@ public class Widget extends AppWidgetProvider {
views.setInt(R.id.background, "setBackgroundColor", background);
fg = (lum > 0.7f ? Color.BLACK : colorWidgetForeground);
if (lum > 0.7f) {
views.setInt(R.id.ivMessage, "setColorFilter", Color.BLACK);
views.setTextColor(R.id.tvCount, Color.BLACK);
views.setTextColor(R.id.tvAccount, Color.BLACK);
}
}
views.setTextColor(R.id.tvCount, layout == 0 ? fg : colorWidgetForeground);
views.setTextColor(R.id.tvAccount, fg);
int resid;
if (layout == 1)
resid = (unseen == 0
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.baseline_mail_outline_widget_24
: R.drawable.baseline_mail_widget_24);
else
resid = (unseen == 0
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.twotone_mail_outline_24
: R.drawable.baseline_mail_24);
Drawable d = context.getDrawable(resid);
d.mutate();
d.setTint(fg);
Bitmap bm = Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bm);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
views.setImageViewBitmap(R.id.ivMessage, bm);
views.setTextViewText(R.id.tvCount, unseen < 100 ? nf.format(unseen) : "99+");
views.setViewVisibility(R.id.tvCount, layout == 1 && unseen == 0 ? View.GONE : View.VISIBLE);

View File

@ -26,10 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.widget.RemoteViews;
import androidx.core.graphics.ColorUtils;
@ -58,16 +55,15 @@ public class WidgetSync extends AppWidgetProvider {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_sync);
views.setOnClickPendingIntent(R.id.ivSync, pi);
views.setImageViewResource(R.id.ivSync, enabled ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
int fg;
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
if (background == Color.TRANSPARENT) {
if (semi)
views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background);
else
views.setInt(R.id.background, "setBackgroundColor", background);
fg = colorWidgetForeground;
views.setInt(R.id.ivSync, "setColorFilter",
context.getResources().getColor(R.color.colorWidgetForeground));
} else {
float lum = (float) ColorUtils.calculateLuminance(background);
@ -76,22 +72,10 @@ public class WidgetSync extends AppWidgetProvider {
views.setInt(R.id.background, "setBackgroundColor", background);
fg = (lum > 0.7f ? Color.BLACK : colorWidgetForeground);
if (lum > 0.7f)
views.setInt(R.id.ivSync, "setColorFilter", Color.BLACK);
}
int resid = (enabled ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
Drawable d = context.getDrawable(resid);
d.mutate();
d.setTint(fg);
Bitmap bm = Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bm);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
views.setImageViewBitmap(R.id.ivSync, bm);
int dp6 = Helper.dp2pixels(context, 6);
views.setViewPadding(R.id.content, dp6, dp6, dp6, dp6);

View File

@ -21,6 +21,7 @@
android:padding="3dp"
android:scaleType="fitXY"
android:src="@drawable/baseline_mail_widget_24"
android:tintMode="add"
app:tint="@color/colorWidgetForeground" />
<TextView

View File

@ -20,6 +20,7 @@
android:contentDescription="@string/title_widget_title_sync"
android:scaleType="fitXY"
android:src="@drawable/twotone_sync_disabled_24"
android:tintMode="add"
app:tint="@color/colorWidgetForeground" />
</RelativeLayout>
</FrameLayout>

View File

@ -39,6 +39,7 @@
android:contentDescription="@string/tile_synchronize"
android:padding="6dp"
android:src="@drawable/twotone_sync_24"
android:tintMode="add"
android:visibility="gone"
app:tint="@color/colorWidgetForeground" />
@ -50,6 +51,7 @@
android:contentDescription="@string/title_compose"
android:padding="6dp"
android:src="@drawable/twotone_edit_24"
android:tintMode="add"
android:visibility="gone"
app:tint="@color/colorWidgetForeground" />
</LinearLayout>