diff --git a/README.md b/README.md
index bbfbaeabb4..cd96c9a811 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,7 @@ All pro features are convenience or advanced features.
* Keyword management
* Biometric authentication ([instructions](https://github.com/M66B/FairEmail/blob/master/FAQ.md#user-content-faq113))
* Encryption/decryption ([OpenPGP](https://www.openpgp.org/)) ([instructions](https://github.com/M66B/FairEmail/blob/master/FAQ.md#user-content-faq12))
+* Unified inbox widget
* Export settings
## Simple
diff --git a/app/src/main/java/eu/faircode/email/WidgetUnified.java b/app/src/main/java/eu/faircode/email/WidgetUnified.java
index dc23aa84a9..ffed2aadff 100644
--- a/app/src/main/java/eu/faircode/email/WidgetUnified.java
+++ b/app/src/main/java/eu/faircode/email/WidgetUnified.java
@@ -26,6 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.view.View;
import android.widget.RemoteViews;
public class WidgetUnified extends AppWidgetProvider {
@@ -36,24 +37,29 @@ public class WidgetUnified extends AppWidgetProvider {
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT);
+ boolean pro = Helper.isPro(context);
for (int id : appWidgetIds) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_unified);
- views.setOnClickPendingIntent(R.id.title, pi);
+ views.setViewVisibility(R.id.pro, pro ? View.GONE : View.VISIBLE);
+ if (pro) {
+ views.setOnClickPendingIntent(R.id.title, pi);
- Intent service = new Intent(context, WidgetUnifiedService.class);
- service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
- service.setData(Uri.parse(service.toUri(Intent.URI_INTENT_SCHEME)));
+ Intent service = new Intent(context, WidgetUnifiedService.class);
+ service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
+ service.setData(Uri.parse(service.toUri(Intent.URI_INTENT_SCHEME)));
- views.setRemoteAdapter(R.id.lv, service);
+ views.setRemoteAdapter(R.id.lv, service);
- Intent thread = new Intent(context, ActivityView.class);
- thread.setAction("widget");
- thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- PendingIntent piItem = PendingIntent.getActivity(
- context, ActivityView.REQUEST_WIDGET, thread, PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent thread = new Intent(context, ActivityView.class);
+ thread.setAction("widget");
+ thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ PendingIntent piItem = PendingIntent.getActivity(
+ context, ActivityView.REQUEST_WIDGET, thread, PendingIntent.FLAG_UPDATE_CURRENT);
- views.setPendingIntentTemplate(R.id.lv, piItem);
+ views.setPendingIntentTemplate(R.id.lv, piItem);
+ } else
+ views.setTextViewText(R.id.pro, context.getText(R.string.title_pro_feature));
appWidgetManager.updateAppWidget(id, views);
}
@@ -61,8 +67,10 @@ public class WidgetUnified extends AppWidgetProvider {
static void update(Context context) {
Log.i("Widget unified update");
- AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
- int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
- appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
+ if (Helper.isPro(context)) {
+ AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
+ int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
+ appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
+ }
}
}
diff --git a/app/src/main/res/layout/widget_unified.xml b/app/src/main/res/layout/widget_unified.xml
index b26bd312da..337e717d99 100644
--- a/app/src/main/res/layout/widget_unified.xml
+++ b/app/src/main/res/layout/widget_unified.xml
@@ -24,6 +24,16 @@
android:layout_height="1dp"
android:background="@color/colorWidgetForeground" />
+
+