mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Apply sync on launch to widgets
This commit is contained in:
parent
9ec584f08e
commit
77653d298b
6 changed files with 15 additions and 1 deletions
|
@ -1011,7 +1011,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
intent.removeExtra("refresh");
|
||||
setIntent(intent);
|
||||
|
||||
ServiceUI.sync(this, null);
|
||||
int version = intent.getIntExtra("version", 0);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityView.this);
|
||||
boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false);
|
||||
if (sync_on_launch || version < 1541)
|
||||
ServiceUI.sync(this, null);
|
||||
}
|
||||
|
||||
String action = intent.getAction();
|
||||
|
|
|
@ -163,6 +163,7 @@ public class ActivityWidget extends ActivityBase {
|
|||
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
|
||||
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
|
||||
editor.putInt("widget." + appWidgetId + ".layout", rbNew.isChecked() ? 1 : 0);
|
||||
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
||||
editor.apply();
|
||||
|
||||
Widget.init(ActivityWidget.this, appWidgetId);
|
||||
|
|
|
@ -102,6 +102,7 @@ public class ActivityWidgetSync extends ActivityBase {
|
|||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putBoolean("widget." + appWidgetId + ".semi", cbSemiTransparent.isChecked());
|
||||
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
|
||||
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
||||
editor.apply();
|
||||
|
||||
WidgetSync.init(ActivityWidgetSync.this, appWidgetId);
|
||||
|
|
|
@ -155,6 +155,7 @@ public class ActivityWidgetUnified extends ActivityBase {
|
|||
editor.putInt("widget." + appWidgetId + ".background", btnColor.getColor());
|
||||
editor.putInt("widget." + appWidgetId + ".font", spFontSize.getSelectedItemPosition());
|
||||
editor.putInt("widget." + appWidgetId + ".padding", spPadding.getSelectedItemPosition());
|
||||
editor.putInt("widget." + appWidgetId + ".version", BuildConfig.VERSION_CODE);
|
||||
|
||||
editor.apply();
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public class Widget extends AppWidgetProvider {
|
|||
boolean semi = prefs.getBoolean("widget." + appWidgetId + ".semi", true);
|
||||
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
||||
int layout = prefs.getInt("widget." + appWidgetId + ".layout", 0);
|
||||
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
||||
|
||||
List<EntityFolder> folders = db.folder().getNotifyingFolders(account);
|
||||
if (folders == null)
|
||||
|
@ -72,6 +73,7 @@ public class Widget extends AppWidgetProvider {
|
|||
view.putExtra("account", account);
|
||||
view.putExtra("type", folders.get(0).type);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
pi = PendingIntentCompat.getActivity(
|
||||
context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
@ -80,6 +82,7 @@ public class Widget extends AppWidgetProvider {
|
|||
Intent view = new Intent(context, ActivityView.class);
|
||||
view.setAction("unified");
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
pi = PendingIntentCompat.getActivity(
|
||||
context, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
@ -87,6 +90,7 @@ public class Widget extends AppWidgetProvider {
|
|||
Intent view = new Intent(context, ActivityView.class);
|
||||
view.setAction("folders:" + account);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
pi = PendingIntentCompat.getActivity(
|
||||
context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
|
|
@ -48,12 +48,14 @@ public class WidgetUnified extends AppWidgetProvider {
|
|||
int background = prefs.getInt("widget." + appWidgetId + ".background", Color.TRANSPARENT);
|
||||
int font = prefs.getInt("widget." + appWidgetId + ".font", 0);
|
||||
int padding = prefs.getInt("widget." + appWidgetId + ".padding", 0);
|
||||
int version = prefs.getInt("widget." + appWidgetId + ".version", 0);
|
||||
|
||||
Intent view = new Intent(context, ActivityView.class);
|
||||
view.setAction("folder:" + folder);
|
||||
view.putExtra("account", account);
|
||||
view.putExtra("type", type);
|
||||
view.putExtra("refresh", true);
|
||||
view.putExtra("version", version);
|
||||
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
PendingIntent pi = PendingIntentCompat.getActivity(
|
||||
context, appWidgetId, view, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
|
Loading…
Reference in a new issue