mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 21:58:52 +02:00
Reconfigurable count widget
This commit is contained in:
@@ -27,6 +27,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
@@ -62,6 +63,9 @@ public class Widget extends AppWidgetProvider {
|
||||
int layout = prefs.getInt("widget." + appWidgetId + ".layout", 0);
|
||||
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
||||
|
||||
if (version <= 1550)
|
||||
semi = true; // Legacy
|
||||
|
||||
List<EntityFolder> folders = db.folder().getNotifyingFolders(account);
|
||||
if (folders == null)
|
||||
folders = new ArrayList<>();
|
||||
@@ -126,8 +130,15 @@ public class Widget extends AppWidgetProvider {
|
||||
}
|
||||
|
||||
if (background == Color.TRANSPARENT) {
|
||||
if (!semi && version > 1550)
|
||||
if (semi)
|
||||
views.setInt(R.id.widget, "setBackgroundResource", R.drawable.widget_background);
|
||||
else
|
||||
views.setInt(R.id.widget, "setBackgroundColor", background);
|
||||
|
||||
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);
|
||||
|
||||
@@ -143,6 +154,9 @@ public class Widget extends AppWidgetProvider {
|
||||
}
|
||||
}
|
||||
|
||||
int pad = Helper.dp2pixels(context, layout == 0 ? 3 : 6);
|
||||
views.setViewPadding(R.id.widget, pad, pad, pad, pad);
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user