mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-04 02:28:18 +00:00
Refactoring
This commit is contained in:
parent
b99fcb48f7
commit
960c589e3a
5 changed files with 37 additions and 39 deletions
|
@ -180,7 +180,7 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
|
|||
.putBoolean("play_store", false)
|
||||
.apply();
|
||||
|
||||
WidgetUnified.update(context);
|
||||
WidgetUnified.updateData(context);
|
||||
return true;
|
||||
} else {
|
||||
Log.i("IAB response invalid");
|
||||
|
@ -400,7 +400,7 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
|
|||
|
||||
editor.apply();
|
||||
|
||||
WidgetUnified.update(this);
|
||||
WidgetUnified.updateData(this);
|
||||
}
|
||||
|
||||
if (query.size() > 0)
|
||||
|
@ -462,7 +462,7 @@ public class ActivityBilling extends ActivityBase implements PurchasesUpdatedLis
|
|||
for (IBillingListener listener : listeners)
|
||||
listener.onPurchased(purchase.getSku());
|
||||
|
||||
WidgetUnified.update(ActivityBilling.this);
|
||||
WidgetUnified.updateData(ActivityBilling.this);
|
||||
} else {
|
||||
if (retry < 3) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
|
|
|
@ -102,7 +102,6 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|||
editor.apply();
|
||||
|
||||
WidgetUnified.init(ActivityWidgetUnified.this, appWidgetId);
|
||||
//WidgetUnified.update(ActivityWidgetUnified.this);
|
||||
|
||||
setResult(RESULT_OK, resultValue);
|
||||
finish();
|
||||
|
|
|
@ -215,7 +215,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("threading", checked).apply();
|
||||
WidgetUnified.update(getContext());
|
||||
WidgetUnified.updateData(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -352,7 +352,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("subject_top", checked).apply();
|
||||
WidgetUnified.update(getContext());
|
||||
WidgetUnified.updateData(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -386,7 +386,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("subject_italic", checked).apply();
|
||||
WidgetUnified.update(getContext());
|
||||
WidgetUnified.updateData(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
if (changed)
|
||||
WidgetUnified.update(ServiceSynchronize.this);
|
||||
WidgetUnified.updateData(ServiceSynchronize.this);
|
||||
|
||||
last = current;
|
||||
}
|
||||
|
|
|
@ -34,37 +34,7 @@ import androidx.preference.PreferenceManager;
|
|||
|
||||
public class WidgetUnified extends AppWidgetProvider {
|
||||
@Override
|
||||
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
|
||||
update(context, appWidgetManager, appWidgetIds);
|
||||
}
|
||||
|
||||
static void init(Context context, int appWidgetId) {
|
||||
Log.i("Widget unified init=" + appWidgetId);
|
||||
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
if (appWidgetManager == null) {
|
||||
Log.w("No app widget manager"); // Fairphone FP2
|
||||
return;
|
||||
}
|
||||
|
||||
update(context, appWidgetManager, new int[]{appWidgetId});
|
||||
}
|
||||
|
||||
static void update(Context context) {
|
||||
Log.i("Widget unified update");
|
||||
if (ActivityBilling.isPro(context)) {
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
if (appWidgetManager == null) {
|
||||
Log.w("No app widget manager"); // Fairphone FP2
|
||||
return;
|
||||
}
|
||||
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
|
||||
}
|
||||
}
|
||||
|
||||
private static void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
boolean pro = ActivityBilling.isPro(context);
|
||||
|
@ -112,4 +82,33 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||
}
|
||||
}
|
||||
|
||||
static void init(Context context, int appWidgetId) {
|
||||
Log.i("Widget unified init=" + appWidgetId);
|
||||
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
if (appWidgetManager == null) {
|
||||
Log.w("No app widget manager"); // Fairphone FP2
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, WidgetUnified.class);
|
||||
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{appWidgetId});
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
static void updateData(Context context) {
|
||||
Log.i("Widget unified update");
|
||||
if (ActivityBilling.isPro(context)) {
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
if (appWidgetManager == null) {
|
||||
Log.w("No app widget manager"); // Fairphone FP2
|
||||
return;
|
||||
}
|
||||
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetUnified.class));
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.lv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue