Refresh on widget tap

This commit is contained in:
M66B 2019-08-12 15:18:35 +02:00
parent 59b79bac2b
commit 68acb278a3
3 changed files with 11 additions and 5 deletions

View File

@ -84,11 +84,10 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
@Override @Override
protected void onExecuted(Bundle args, Boolean hasAccounts) { protected void onExecuted(Bundle args, Boolean hasAccounts) {
if (hasAccounts) { if (hasAccounts) {
startActivity(new Intent(ActivityMain.this, ActivityView.class)); Intent view = new Intent(ActivityMain.this, ActivityView.class);
if (ACTION_REFRESH.equals(getIntent().getAction())) view.putExtra("refresh", true);
ServiceSynchronize.process(ActivityMain.this, true); startActivity(view);
else ServiceSynchronize.watchdog(ActivityMain.this);
ServiceSynchronize.watchdog(ActivityMain.this);
ServiceSend.watchdog(ActivityMain.this); ServiceSend.watchdog(ActivityMain.this);
} else } else
startActivity(new Intent(ActivityMain.this, ActivitySetup.class)); startActivity(new Intent(ActivityMain.this, ActivitySetup.class));

View File

@ -473,6 +473,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void checkIntent() { private void checkIntent() {
Intent intent = getIntent(); Intent intent = getIntent();
if (intent.getBooleanExtra("refresh", false)) {
intent.removeExtra("refresh");
setIntent(intent);
ServiceSynchronize.process(this, true);
}
String action = intent.getAction(); String action = intent.getAction();
Log.i("View intent=" + intent + " action=" + action); Log.i("View intent=" + intent + " action=" + action);
if (action != null) { if (action != null) {

View File

@ -55,6 +55,7 @@ public class Widget extends AppWidgetProvider {
private static void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, int count) { private static void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, int count) {
Intent view = new Intent(context, ActivityView.class); Intent view = new Intent(context, ActivityView.class);
view.setAction("unified"); view.setAction("unified");
view.putExtra("refresh", true);
view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); view.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pi = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT);