Allow transparent widgets

pull/197/head
M66B 4 years ago
parent 1ba2953308
commit 0107168095

@ -180,6 +180,7 @@ public class ActivityWidget extends ActivityBase {
((TextView) inOld.findViewById(R.id.tvCount)).setText("12"); ((TextView) inOld.findViewById(R.id.tvCount)).setText("12");
((TextView) inNew.findViewById(R.id.tvCount)).setText("12"); ((TextView) inNew.findViewById(R.id.tvCount)).setText("12");
btnColor.setColor(Color.TRANSPARENT);
setBackground(); setBackground();
grpReady.setVisibility(View.GONE); grpReady.setVisibility(View.GONE);
@ -223,8 +224,13 @@ public class ActivityWidget extends ActivityBase {
boolean semi = cbSemiTransparent.isChecked(); boolean semi = cbSemiTransparent.isChecked();
int background = btnColor.getColor(); int background = btnColor.getColor();
if (background == Color.TRANSPARENT) { if (background == Color.TRANSPARENT) {
inOld.setBackgroundResource(R.drawable.widget_background); if (semi) {
inNew.setBackgroundResource(R.drawable.widget_background); inOld.setBackgroundResource(R.drawable.widget_background);
inNew.setBackgroundResource(R.drawable.widget_background);
} else {
inOld.setBackgroundColor(background);
inNew.setBackgroundColor(background);
}
} else { } else {
float lum = (float) ColorUtils.calculateLuminance(background); float lum = (float) ColorUtils.calculateLuminance(background);
int color = (lum > 0.7 ? Color.BLACK : getResources().getColor(R.color.colorWidgetForeground)); int color = (lum > 0.7 ? Color.BLACK : getResources().getColor(R.color.colorWidgetForeground));

@ -112,6 +112,8 @@ public class ActivityWidgetSync extends ActivityBase {
} }
}); });
btnColor.setColor(Color.TRANSPARENT);
setResult(RESULT_CANCELED, resultValue); setResult(RESULT_CANCELED, resultValue);
} }
} }

@ -256,6 +256,8 @@ public class ActivityWidgetUnified extends ActivityBase {
adapterPadding.setDropDownViewResource(R.layout.spinner_item1_dropdown); adapterPadding.setDropDownViewResource(R.layout.spinner_item1_dropdown);
spPadding.setAdapter(adapterPadding); spPadding.setAdapter(adapterPadding);
btnColor.setColor(Color.TRANSPARENT);
grpReady.setVisibility(View.GONE); grpReady.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE); pbWait.setVisibility(View.VISIBLE);

@ -123,7 +123,10 @@ public class Widget extends AppWidgetProvider {
views.setViewVisibility(R.id.tvAccount, ViewStripe.VISIBLE); views.setViewVisibility(R.id.tvAccount, ViewStripe.VISIBLE);
} }
if (background != Color.TRANSPARENT) { if (background == Color.TRANSPARENT) {
if (!semi && version > 1550)
views.setInt(R.id.widget, "setBackgroundColor", background);
} else {
float lum = (float) ColorUtils.calculateLuminance(background); float lum = (float) ColorUtils.calculateLuminance(background);
if (semi) if (semi)

@ -48,12 +48,16 @@ public class WidgetSync extends AppWidgetProvider {
for (int appWidgetId : appWidgetIds) { for (int appWidgetId : appWidgetIds) {
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true); boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT); int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_sync); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_sync);
views.setOnClickPendingIntent(R.id.ivSync, pi); views.setOnClickPendingIntent(R.id.ivSync, pi);
views.setImageViewResource(R.id.ivSync, enabled ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24); views.setImageViewResource(R.id.ivSync, enabled ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
if (background != Color.TRANSPARENT) { if (background == Color.TRANSPARENT) {
if (!semi && version > 1550)
views.setInt(R.id.widget, "setBackgroundColor", background);
} else {
float lum = (float) ColorUtils.calculateLuminance(background); float lum = (float) ColorUtils.calculateLuminance(background);
if (semi) if (semi)

@ -95,7 +95,10 @@ public class WidgetUnified extends AppWidgetProvider {
views.setPendingIntentTemplate(R.id.lv, piItem); views.setPendingIntentTemplate(R.id.lv, piItem);
if (background != Color.TRANSPARENT) { if (background == Color.TRANSPARENT) {
if (!semi && version > 1550)
views.setInt(R.id.widget, "setBackgroundColor", background);
} else {
float lum = (float) ColorUtils.calculateLuminance(background); float lum = (float) ColorUtils.calculateLuminance(background);
if (semi) if (semi)

Loading…
Cancel
Save