mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Show example
This commit is contained in:
parent
1e654d7765
commit
b1d516f61b
3 changed files with 23 additions and 34 deletions
|
@ -28,7 +28,6 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
@ -38,7 +37,6 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
boolean pro = ActivityBilling.isPro(context);
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
long account = prefs.getLong("widget." + appWidgetId + ".account", -1L);
|
||||
long folder = prefs.getLong("widget." + appWidgetId + ".folder", -1L);
|
||||
|
@ -58,32 +56,28 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
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);
|
||||
if (name == null)
|
||||
views.setTextViewText(R.id.title, context.getString(R.string.title_folder_unified));
|
||||
else
|
||||
views.setTextViewText(R.id.title, name);
|
||||
String name = prefs.getString("widget." + appWidgetId + ".name", null);
|
||||
if (name == null)
|
||||
views.setTextViewText(R.id.title, context.getString(R.string.title_folder_unified));
|
||||
else
|
||||
views.setTextViewText(R.id.title, name);
|
||||
|
||||
views.setOnClickPendingIntent(R.id.title, pi);
|
||||
views.setOnClickPendingIntent(R.id.title, pi);
|
||||
|
||||
Intent service = new Intent(context, WidgetUnifiedService.class);
|
||||
service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
service.setData(Uri.parse(service.toUri(Intent.URI_INTENT_SCHEME)));
|
||||
Intent service = new Intent(context, WidgetUnifiedService.class);
|
||||
service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
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.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(type));
|
||||
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.putExtra("filter_archive", !EntityFolder.ARCHIVE.equals(type));
|
||||
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);
|
||||
} else
|
||||
views.setTextViewText(R.id.pro, context.getText(R.string.title_pro_feature));
|
||||
views.setPendingIntentTemplate(R.id.lv, piItem);
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
private boolean flagged;
|
||||
private int colorWidgetForeground;
|
||||
private int colorWidgetRead;
|
||||
private boolean pro;
|
||||
private List<TupleMessageWidget> messages = new ArrayList<>();
|
||||
|
||||
WidgetUnifiedRemoteViewsFactory(final Context context, Intent intent) {
|
||||
|
@ -80,6 +81,8 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
colorWidgetForeground = ContextCompat.getColor(context, R.color.colorWidgetForeground);
|
||||
colorWidgetRead = ContextCompat.getColor(context, R.color.colorWidgetRead);
|
||||
|
||||
pro = ActivityBilling.isPro(context);
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
@ -127,7 +130,9 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
|
||||
SpannableString ssFrom = new SpannableString(MessageHelper.formatAddressesShort(message.from));
|
||||
SpannableString ssTime = new SpannableString(Helper.getRelativeTimeSpanString(context, message.received));
|
||||
SpannableString ssSubject = new SpannableString(TextUtils.isEmpty(message.subject) ? "" : message.subject);
|
||||
SpannableString ssSubject = new SpannableString(pro
|
||||
? TextUtils.isEmpty(message.subject) ? "" : message.subject
|
||||
: context.getString(R.string.title_pro_feature));
|
||||
SpannableString ssAccount = new SpannableString(TextUtils.isEmpty(message.accountName) ? "" : message.accountName);
|
||||
|
||||
if (message.ui_seen) {
|
||||
|
|
|
@ -25,16 +25,6 @@
|
|||
android:layout_height="1dp"
|
||||
android:background="@color/colorWidgetForeground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pro"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="12dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textColor="@color/colorWidgetForeground"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lv"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue