mirror of https://github.com/M66B/FairEmail.git
Small widget improvement
This commit is contained in:
parent
d937d4edfd
commit
aa76c6f478
|
@ -53,6 +53,7 @@ public class Widget extends AppWidgetProvider {
|
|||
|
||||
DB db = DB.getInstance(context);
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance();
|
||||
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
|
||||
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
String name = prefs.getString("widget." + appWidgetId + ".name", null);
|
||||
|
@ -118,7 +119,6 @@ public class Widget extends AppWidgetProvider {
|
|||
else
|
||||
views.setInt(R.id.background, "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);
|
||||
|
@ -130,11 +130,10 @@ public class Widget extends AppWidgetProvider {
|
|||
|
||||
views.setInt(R.id.background, "setBackgroundColor", background);
|
||||
|
||||
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);
|
||||
}
|
||||
int fg = (lum > 0.7f ? Color.BLACK : colorWidgetForeground);
|
||||
views.setInt(R.id.ivMessage, "setColorFilter", fg);
|
||||
views.setTextColor(R.id.tvCount, layout == 0 ? fg : colorWidgetForeground);
|
||||
views.setTextColor(R.id.tvAccount, fg);
|
||||
}
|
||||
|
||||
if (layout == 1)
|
||||
|
|
|
@ -45,6 +45,8 @@ public class WidgetSync extends AppWidgetProvider {
|
|||
PendingIntent pi = PendingIntentCompat.getForegroundService(
|
||||
context, ServiceSynchronize.PI_ENABLE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
|
||||
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
|
||||
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
||||
|
@ -62,8 +64,7 @@ public class WidgetSync extends AppWidgetProvider {
|
|||
views.setInt(R.id.background, "setBackgroundResource", R.drawable.widget_background);
|
||||
else
|
||||
views.setInt(R.id.background, "setBackgroundColor", background);
|
||||
views.setInt(R.id.ivSync, "setColorFilter",
|
||||
context.getResources().getColor(R.color.colorWidgetForeground));
|
||||
views.setInt(R.id.ivSync, "setColorFilter", colorWidgetForeground);
|
||||
} else {
|
||||
float lum = (float) ColorUtils.calculateLuminance(background);
|
||||
|
||||
|
@ -72,8 +73,8 @@ public class WidgetSync extends AppWidgetProvider {
|
|||
|
||||
views.setInt(R.id.background, "setBackgroundColor", background);
|
||||
|
||||
if (lum > 0.7f)
|
||||
views.setInt(R.id.ivSync, "setColorFilter", Color.BLACK);
|
||||
int fg = (lum > 0.7f ? Color.BLACK : colorWidgetForeground);
|
||||
views.setInt(R.id.ivSync, "setColorFilter", fg);
|
||||
}
|
||||
|
||||
int dp6 = Helper.dp2pixels(context, 6);
|
||||
|
|
|
@ -40,6 +40,8 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
|
||||
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
String name = prefs.getString("widget." + appWidgetId + ".name", null);
|
||||
long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
|
||||
|
@ -135,7 +137,6 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
else
|
||||
views.setInt(R.id.background, "setBackgroundColor", background);
|
||||
|
||||
int colorWidgetForeground = context.getResources().getColor(R.color.colorWidgetForeground);
|
||||
views.setTextColor(R.id.title, colorWidgetForeground);
|
||||
} else {
|
||||
float lum = (float) ColorUtils.calculateLuminance(background);
|
||||
|
@ -145,8 +146,8 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
|
||||
views.setInt(R.id.background, "setBackgroundColor", background);
|
||||
|
||||
if (lum > 0.7f)
|
||||
views.setTextColor(R.id.title, Color.BLACK);
|
||||
int fg = (lum > 0.7f ? Color.BLACK : colorWidgetForeground);
|
||||
views.setTextColor(R.id.title, fg);
|
||||
}
|
||||
|
||||
int dp6 = Helper.dp2pixels(context, 6);
|
||||
|
|
Loading…
Reference in New Issue