Added option to disable widget background

This commit is contained in:
M66B
2020-04-08 12:08:50 +02:00
parent cb274f1db7
commit 1e654d7765
8 changed files with 43 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Spinner;
import androidx.constraintlayout.widget.Group;
@@ -39,6 +40,7 @@ public class ActivityWidget extends ActivityBase {
private int appWidgetId;
private Spinner spAccount;
private CheckBox cbSemiTransparent;
private Button btnSave;
private ContentLoadingProgressBar pbWait;
private Group grpReady;
@@ -62,6 +64,7 @@ public class ActivityWidget extends ActivityBase {
setContentView(R.layout.activity_widget);
spAccount = findViewById(R.id.spAccount);
cbSemiTransparent = findViewById(R.id.cbSemiTransparent);
btnSave = findViewById(R.id.btnSave);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);
@@ -81,6 +84,7 @@ public class ActivityWidget extends ActivityBase {
else
editor.remove("widget." + appWidgetId + ".name");
editor.putLong("widget." + appWidgetId + ".account", account == null ? -1L : account.id);
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
editor.apply();
Widget.init(ActivityWidget.this, appWidgetId);

View File

@@ -45,6 +45,7 @@ public class ActivityWidgetUnified extends ActivityBase {
private Spinner spFolder;
private CheckBox cbUnseen;
private CheckBox cbFlagged;
private CheckBox cbSemiTransparent;
private Button btnSave;
private ContentLoadingProgressBar pbWait;
private Group grpReady;
@@ -72,6 +73,7 @@ public class ActivityWidgetUnified extends ActivityBase {
spFolder = findViewById(R.id.spFolder);
cbUnseen = findViewById(R.id.cbUnseen);
cbFlagged = findViewById(R.id.cbFlagged);
cbSemiTransparent = findViewById(R.id.cbSemiTransparent);
btnSave = findViewById(R.id.btnSave);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);
@@ -99,6 +101,7 @@ public class ActivityWidgetUnified extends ActivityBase {
editor.putString("widget." + appWidgetId + ".type", folder == null ? null : folder.type);
editor.putBoolean("widget." + appWidgetId + ".unseen", cbUnseen.isChecked());
editor.putBoolean("widget." + appWidgetId + ".flagged", cbFlagged.isChecked());
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
editor.apply();
WidgetUnified.init(ActivityWidgetUnified.this, appWidgetId);

View File

@@ -26,6 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.text.TextUtils;
import android.widget.RemoteViews;
@@ -54,6 +55,7 @@ public class Widget extends AppWidgetProvider {
for (int appWidgetId : appWidgetIds) {
long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
String name = prefs.getString("widget." + appWidgetId + ".name", null);
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
List<EntityFolder> folders = db.folder().getNotifyingFolders(account);
if (folders == null)
@@ -93,6 +95,9 @@ public class Widget extends AppWidgetProvider {
views.setOnClickPendingIntent(R.id.widget, pi);
if (!semi)
views.setInt(R.id.widget, "setBackgroundColor", Color.TRANSPARENT);
views.setImageViewResource(R.id.ivMessage, unseen == 0
? R.drawable.baseline_mail_outline_24
: R.drawable.baseline_mail_24);

View File

@@ -26,6 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.view.View;
import android.widget.RemoteViews;
@@ -42,6 +43,7 @@ public class WidgetUnified extends AppWidgetProvider {
long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
String type = prefs.getString("widget." + appWidgetId + ".type", null);
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
Intent view = new Intent(context, ActivityView.class);
view.setAction("folder:" + folder);
@@ -53,6 +55,9 @@ public class WidgetUnified extends AppWidgetProvider {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_unified);
if (!semi)
views.setInt(R.id.widget, "setBackgroundColor", Color.TRANSPARENT);
views.setViewVisibility(R.id.pro, pro ? View.GONE : View.VISIBLE);
if (pro) {
String name = prefs.getString("widget." + appWidgetId + ".name", null);