From 68acb278a363d084c3caafafc09dddd806e31091 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 12 Aug 2019 15:18:35 +0200 Subject: [PATCH] Refresh on widget tap --- app/src/main/java/eu/faircode/email/ActivityMain.java | 9 ++++----- app/src/main/java/eu/faircode/email/ActivityView.java | 6 ++++++ app/src/main/java/eu/faircode/email/Widget.java | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityMain.java b/app/src/main/java/eu/faircode/email/ActivityMain.java index d8a149fa45..9c236a2de8 100644 --- a/app/src/main/java/eu/faircode/email/ActivityMain.java +++ b/app/src/main/java/eu/faircode/email/ActivityMain.java @@ -84,11 +84,10 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack @Override protected void onExecuted(Bundle args, Boolean hasAccounts) { if (hasAccounts) { - startActivity(new Intent(ActivityMain.this, ActivityView.class)); - if (ACTION_REFRESH.equals(getIntent().getAction())) - ServiceSynchronize.process(ActivityMain.this, true); - else - ServiceSynchronize.watchdog(ActivityMain.this); + Intent view = new Intent(ActivityMain.this, ActivityView.class); + view.putExtra("refresh", true); + startActivity(view); + ServiceSynchronize.watchdog(ActivityMain.this); ServiceSend.watchdog(ActivityMain.this); } else startActivity(new Intent(ActivityMain.this, ActivitySetup.class)); diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index c1a461d68f..d7c55ee3c4 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -473,6 +473,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB private void checkIntent() { Intent intent = getIntent(); + if (intent.getBooleanExtra("refresh", false)) { + intent.removeExtra("refresh"); + setIntent(intent); + ServiceSynchronize.process(this, true); + } + String action = intent.getAction(); Log.i("View intent=" + intent + " action=" + action); if (action != null) { diff --git a/app/src/main/java/eu/faircode/email/Widget.java b/app/src/main/java/eu/faircode/email/Widget.java index 4614e58ee2..a1c1dbb2b9 100644 --- a/app/src/main/java/eu/faircode/email/Widget.java +++ b/app/src/main/java/eu/faircode/email/Widget.java @@ -55,6 +55,7 @@ public class Widget extends AppWidgetProvider { private static void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, int count) { Intent view = new Intent(context, ActivityView.class); view.setAction("unified"); + view.putExtra("refresh", true); view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pi = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT);