Allow semi transparent widget color

This commit is contained in:
M66B
2021-03-26 14:38:51 +01:00
parent fae306ee3f
commit 2230cbc40f
7 changed files with 35 additions and 47 deletions

View File

@@ -59,9 +59,6 @@ public class WidgetUnified extends AppWidgetProvider {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_unified);
if (!semi)
views.setInt(R.id.widget, "setBackgroundColor", background);
if (font > 0)
views.setTextViewTextSize(R.id.title, TypedValue.COMPLEX_UNIT_SP, getFontSizeSp(font));
@@ -70,10 +67,6 @@ public class WidgetUnified extends AppWidgetProvider {
views.setViewPadding(R.id.title, px, px, px, px);
}
float lum = (float) ColorUtils.calculateLuminance(background);
if (lum > 0.7f)
views.setTextColor(R.id.title, Color.BLACK);
if (name == null)
views.setTextViewText(R.id.title, context.getString(R.string.title_folder_unified));
else
@@ -99,6 +92,18 @@ public class WidgetUnified extends AppWidgetProvider {
views.setPendingIntentTemplate(R.id.lv, piItem);
if (background != Color.TRANSPARENT) {
float lum = (float) ColorUtils.calculateLuminance(background);
if (semi)
background = ColorUtils.setAlphaComponent(background, 127);
views.setInt(R.id.widget, "setBackgroundColor", background);
if (lum > 0.7f)
views.setTextColor(R.id.title, Color.BLACK);
}
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}