Refactoring

pull/194/merge
M66B 3 years ago
parent ba0809ba2d
commit d060febc4d

@ -110,29 +110,13 @@ public class Widget extends AppWidgetProvider {
RemoteViews views = new RemoteViews(context.getPackageName(),
layout == 0 ? R.layout.widget : R.layout.widget_new);
views.setOnClickPendingIntent(android.R.id.background, pi);
if (layout == 1)
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.baseline_mail_outline_widget_24
: R.drawable.baseline_mail_widget_24);
else
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.twotone_mail_outline_24
: R.drawable.baseline_mail_24);
views.setTextViewText(R.id.tvCount, unseen < 100 ? nf.format(unseen) : "99+");
views.setViewVisibility(R.id.tvCount, layout == 1 && unseen == 0 ? View.GONE : View.VISIBLE);
if (!TextUtils.isEmpty(name)) {
views.setTextViewText(R.id.tvAccount, name);
views.setViewVisibility(R.id.tvAccount, ViewStripe.VISIBLE);
}
views.setOnClickPendingIntent(R.id.background, pi);
if (background == Color.TRANSPARENT) {
if (semi)
views.setInt(android.R.id.background, "setBackgroundResource", R.drawable.widget_background);
views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background);
else
views.setInt(android.R.id.background, "setBackgroundColor", background);
views.setInt(R.id.background, "setBackgroundColor", background);
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
views.setInt(R.id.ivMessage, "setColorFilter", colorWidgetForeground);
@ -144,7 +128,7 @@ public class Widget extends AppWidgetProvider {
if (semi)
background = ColorUtils.setAlphaComponent(background, 127);
views.setInt(android.R.id.background, "setBackgroundColor", background);
views.setInt(R.id.background, "setBackgroundColor", background);
if (lum > 0.7f) {
views.setInt(R.id.ivMessage, "setColorFilter", Color.BLACK);
@ -153,6 +137,22 @@ public class Widget extends AppWidgetProvider {
}
}
if (layout == 1)
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.baseline_mail_outline_widget_24
: R.drawable.baseline_mail_widget_24);
else
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.twotone_mail_outline_24
: R.drawable.baseline_mail_24);
views.setTextViewText(R.id.tvCount, unseen < 100 ? nf.format(unseen) : "99+");
views.setViewVisibility(R.id.tvCount, layout == 1 && unseen == 0 ? View.GONE : View.VISIBLE);
if (!TextUtils.isEmpty(name)) {
views.setTextViewText(R.id.tvAccount, name);
views.setViewVisibility(R.id.tvAccount, ViewStripe.VISIBLE);
}
int pad = Helper.dp2pixels(context, layout == 0 ? 3 : 6);
views.setViewPadding(R.id.content, pad, pad, pad, pad);

@ -59,9 +59,9 @@ public class WidgetSync extends AppWidgetProvider {
if (background == Color.TRANSPARENT) {
if (semi)
views.setInt(android.R.id.background, "setBackgroundResource", R.drawable.widget_background);
views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background);
else
views.setInt(android.R.id.background, "setBackgroundColor", background);
views.setInt(R.id.background, "setBackgroundColor", background);
views.setInt(R.id.ivSync, "setColorFilter",
context.getResources().getColor(R.color.colorWidgetForeground));
} else {
@ -70,7 +70,7 @@ public class WidgetSync extends AppWidgetProvider {
if (semi)
background = ColorUtils.setAlphaComponent(background, 127);
views.setInt(android.R.id.background, "setBackgroundColor", background);
views.setInt(R.id.background, "setBackgroundColor", background);
if (lum > 0.7f)
views.setInt(R.id.ivSync, "setColorFilter", Color.BLACK);

@ -131,9 +131,9 @@ public class WidgetUnified extends AppWidgetProvider {
if (background == Color.TRANSPARENT) {
if (semi)
views.setInt(android.R.id.background, "setBackgroundResource", R.drawable.widget_background);
views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background);
else
views.setInt(android.R.id.background, "setBackgroundColor", background);
views.setInt(R.id.background, "setBackgroundColor", background);
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
views.setTextColor(R.id.title, colorWidgetForeground);
@ -143,7 +143,7 @@ public class WidgetUnified extends AppWidgetProvider {
if (semi)
background = ColorUtils.setAlphaComponent(background, 127);
views.setInt(android.R.id.background, "setBackgroundColor", background);
views.setInt(R.id.background, "setBackgroundColor", background);
if (lum > 0.7f)
views.setTextColor(R.id.title, Color.BLACK);

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@android:id/background"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/widget_background">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@android:id/background"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/widget_background">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@android:id/background"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/widget_background">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@android:id/background"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/widget_background">

Loading…
Cancel
Save