mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 05:44:51 +02:00
Added option to disable widget background
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,6 +22,17 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvAccount" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSemiTransparent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_widget_semi_transparent"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/spAccount" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSave"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -29,7 +40,7 @@
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_save"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/spAccount" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbSemiTransparent" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbWait"
|
||||
|
||||
@@ -58,6 +58,17 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbUnseen" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSemiTransparent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_widget_semi_transparent"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSave"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -65,7 +76,7 @@
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_save"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbFlagged" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbSemiTransparent" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbWait"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/widget_background"
|
||||
|
||||
@@ -1230,6 +1230,7 @@
|
||||
<string name="title_widget_folder_unified">Unified inbox folders</string>
|
||||
<string name="title_widget_unseen">Unread messages only</string>
|
||||
<string name="title_widget_flagged">Starred messages only</string>
|
||||
<string name="title_widget_semi_transparent">Semi transparent background</string>
|
||||
|
||||
<string name="title_accessibility_collapsed">Collapsed</string>
|
||||
<string name="title_accessibility_expanded">Expanded</string>
|
||||
|
||||
Reference in New Issue
Block a user