mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 22:26:06 +02:00
Revert "Refactoring, small improvements"
This reverts commit ee99ae3ecb.
This would cause existing widgets not to work anymore
This commit is contained in:
@@ -180,7 +180,7 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
|
||||
.putBoolean("play_store", false)
|
||||
.apply();
|
||||
|
||||
WidgetList.update(context);
|
||||
WidgetUnified.update(context);
|
||||
return true;
|
||||
} else {
|
||||
Log.i("IAB response invalid");
|
||||
@@ -400,7 +400,7 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
|
||||
|
||||
editor.apply();
|
||||
|
||||
WidgetList.update(this);
|
||||
WidgetUnified.update(this);
|
||||
}
|
||||
|
||||
if (query.size() > 0)
|
||||
@@ -462,7 +462,7 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
|
||||
for (IBillingListener listener : listeners)
|
||||
listener.onPurchased(purchase.getSku());
|
||||
|
||||
WidgetList.update(ActivityBilling.this);
|
||||
WidgetUnified.update(ActivityBilling.this);
|
||||
} else
|
||||
reportError(result, "IAB acknowledged SKU=" + purchase.getSku());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityWidgetList extends ActivityBase {
|
||||
public class ActivityWidgetUnified extends ActivityBase {
|
||||
private int appWidgetId;
|
||||
|
||||
private Spinner spAccount;
|
||||
@@ -65,7 +65,7 @@ public class ActivityWidgetList extends ActivityBase {
|
||||
appWidgetId = extras.getInt(
|
||||
AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
|
||||
getSupportActionBar().setSubtitle(R.string.title_widget_title_list);
|
||||
getSupportActionBar().setSubtitle(R.string.title_folder_unified);
|
||||
setContentView(R.layout.activity_widget_unified);
|
||||
|
||||
spAccount = findViewById(R.id.spAccount);
|
||||
@@ -85,11 +85,11 @@ public class ActivityWidgetList extends ActivityBase {
|
||||
EntityAccount account = (EntityAccount) spAccount.getSelectedItem();
|
||||
TupleFolderEx folder = (TupleFolderEx) spFolder.getSelectedItem();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityWidgetList.this);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityWidgetUnified.this);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
if (account != null && account.id > 0)
|
||||
if (folder != null && folder.id > 0)
|
||||
editor.putString("widget." + appWidgetId + ".name", folder.getDisplayName(ActivityWidgetList.this));
|
||||
editor.putString("widget." + appWidgetId + ".name", folder.getDisplayName(ActivityWidgetUnified.this));
|
||||
else
|
||||
editor.putString("widget." + appWidgetId + ".name", account.name);
|
||||
else
|
||||
@@ -100,7 +100,7 @@ public class ActivityWidgetList extends ActivityBase {
|
||||
editor.putBoolean("widget." + appWidgetId + ".flagged", cbFlagged.isChecked());
|
||||
editor.apply();
|
||||
|
||||
WidgetList.init(ActivityWidgetList.this, appWidgetId);
|
||||
WidgetUnified.init(ActivityWidgetUnified.this, appWidgetId);
|
||||
//WidgetUnified.update(ActivityWidgetUnified.this);
|
||||
|
||||
setResult(RESULT_OK, resultValue);
|
||||
@@ -159,7 +159,7 @@ public class ActivityWidgetList extends ActivityBase {
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Helper.unexpectedError(getSupportFragmentManager(), ex);
|
||||
}
|
||||
}.execute(ActivityWidgetList.this, args, "widget:folders");
|
||||
}.execute(ActivityWidgetUnified.this, args, "widget:folders");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -206,7 +206,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("threading", checked).apply();
|
||||
WidgetList.update(getContext());
|
||||
WidgetUnified.update(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -336,7 +336,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("subject_top", checked).apply();
|
||||
WidgetList.update(getContext());
|
||||
WidgetUnified.update(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -344,7 +344,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("subject_italic", checked).apply();
|
||||
WidgetList.update(getContext());
|
||||
WidgetUnified.update(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ public class ServiceSynchronize extends ServiceBase {
|
||||
last = messages;
|
||||
|
||||
if (changed)
|
||||
WidgetList.update(ServiceSynchronize.this);
|
||||
WidgetUnified.update(ServiceSynchronize.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -412,7 +412,7 @@ public class ServiceSynchronize extends ServiceBase {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean badge = prefs.getBoolean("badge", true);
|
||||
|
||||
WidgetCount.update(this, unseen);
|
||||
Widget.update(this, unseen);
|
||||
|
||||
try {
|
||||
if (unseen == null || !badge)
|
||||
|
||||
@@ -33,7 +33,7 @@ import androidx.preference.PreferenceManager;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
public class WidgetCount extends AppWidgetProvider {
|
||||
public class Widget extends AppWidgetProvider {
|
||||
private static final ExecutorService executor =
|
||||
Helper.getBackgroundExecutor(1, "widget");
|
||||
|
||||
@@ -63,7 +63,7 @@ public class WidgetCount extends AppWidgetProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetCount.class));
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, Widget.class));
|
||||
update(context, appWidgetManager, appWidgetIds, count);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class WidgetCount extends AppWidgetProvider {
|
||||
PendingIntent pi = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_count);
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
|
||||
|
||||
views.setOnClickPendingIntent(R.id.widget, pi);
|
||||
|
||||
@@ -32,7 +32,7 @@ import android.widget.RemoteViews;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
public class WidgetList extends AppWidgetProvider {
|
||||
public class WidgetUnified extends AppWidgetProvider {
|
||||
@Override
|
||||
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
|
||||
update(context, appWidgetManager, appWidgetIds);
|
||||
@@ -59,7 +59,7 @@ public class WidgetList extends AppWidgetProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetList.class));
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
|
||||
}
|
||||
}
|
||||
@@ -75,19 +75,17 @@ public class WidgetList extends AppWidgetProvider {
|
||||
|
||||
boolean pro = ActivityBilling.isPro(context);
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_list);
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_unified);
|
||||
|
||||
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
|
||||
if (name != null)
|
||||
views.setTextViewText(R.id.title, name);
|
||||
|
||||
views.setOnClickPendingIntent(R.id.title, pi);
|
||||
|
||||
Intent service = new Intent(context, WidgetListService.class);
|
||||
Intent service = new Intent(context, WidgetUnifiedService.class);
|
||||
service.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
service.setData(Uri.parse(service.toUri(Intent.URI_INTENT_SCHEME)));
|
||||
|
||||
@@ -38,7 +38,7 @@ import androidx.preference.PreferenceManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WidgetListRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
private Context context;
|
||||
private int appWidgetId;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class WidgetListRemoteViewsFactory implements RemoteViewsService.RemoteVi
|
||||
private int colorWidgetRead;
|
||||
private List<TupleMessageWidget> messages = new ArrayList<>();
|
||||
|
||||
WidgetListRemoteViewsFactory(final Context context, Intent intent) {
|
||||
WidgetUnifiedRemoteViewsFactory(final Context context, Intent intent) {
|
||||
this.context = context;
|
||||
this.appWidgetId = intent.getIntExtra(
|
||||
AppWidgetManager.EXTRA_APPWIDGET_ID,
|
||||
@@ -22,9 +22,9 @@ package eu.faircode.email;
|
||||
import android.content.Intent;
|
||||
import android.widget.RemoteViewsService;
|
||||
|
||||
public class WidgetListService extends RemoteViewsService {
|
||||
public class WidgetUnifiedService extends RemoteViewsService {
|
||||
@Override
|
||||
public RemoteViewsFactory onGetViewFactory(Intent intent) {
|
||||
return new WidgetListRemoteViewsFactory(this.getApplicationContext(), intent);
|
||||
return new WidgetUnifiedRemoteViewsFactory(this.getApplicationContext(), intent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user