From 1fdb663204fad422854a64b16a3d4f8d3ac48fe3 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 30 Apr 2018 10:53:15 +0300 Subject: [PATCH] Dismiss osmlive activity on choose plan dismiss --- .../plus/chooseplan/ChoosePlanDialogFragment.java | 9 +++++---- .../net/osmand/plus/liveupdates/OsmLiveActivity.java | 11 +++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index fe5d013a2c..714854c502 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -3,6 +3,7 @@ package net.osmand.plus.chooseplan; import android.app.Activity; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; @@ -56,7 +57,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment private View planTypeCardButton; public interface ChoosePlanDialogListener { - void onChoosePlanDialogDismissed(); + void onChoosePlanDialogDismiss(); } public enum OsmAndFeature { @@ -198,11 +199,11 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } @Override - public void dismiss() { - super.dismiss(); + public void onDismiss(DialogInterface dialog) { + super.onDismiss(dialog); Activity activity = getActivity(); if (activity != null && activity instanceof ChoosePlanDialogListener) { - ((ChoosePlanDialogListener) activity).onChoosePlanDialogDismissed(); + ((ChoosePlanDialogListener) activity).onChoosePlanDialogDismiss(); } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java index 53c7203c51..2d42d40da3 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java @@ -35,12 +35,10 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa private final static Log LOG = PlatformUtil.getLog(OsmLiveActivity.class); public final static String OPEN_SUBSCRIPTION_INTENT_PARAM = "open_subscription_intent_param"; public final static String SHOW_SETTINGS_ONLY_INTENT_PARAM = "show_settings_only_intent_param"; - public final static String CHOOSE_PLAN_DIALOG_DISMISSED_KEY = "choose_plan_dialog_dismissed_key"; private LiveUpdatesFragmentPagerAdapter pagerAdapter; private boolean openSubscription; private boolean showSettingOnly; - private boolean choosePlanDialogDismissed; private GetLastUpdateDateTask getLastUpdateDateTask; private static final String URL = "https://osmand.net/api/osmlive_status"; @@ -57,7 +55,6 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa } else if (savedInstanceState != null) { openSubscription = savedInstanceState.getBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, false); showSettingOnly = savedInstanceState.getBoolean(SHOW_SETTINGS_ONLY_INTENT_PARAM, false); - choosePlanDialogDismissed = savedInstanceState.getBoolean(CHOOSE_PLAN_DIALOG_DISMISSED_KEY, false); } ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); @@ -89,8 +86,7 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa @Override protected void onResume() { super.onResume(); - if (!getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get() && showSettingOnly - && !choosePlanDialogDismissed) { + if (!getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get() && showSettingOnly) { ChoosePlanDialogFragment.showOsmLiveInstance(getSupportFragmentManager()); } } @@ -114,12 +110,11 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa super.onSaveInstanceState(outState); outState.putBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, openSubscription); outState.putBoolean(SHOW_SETTINGS_ONLY_INTENT_PARAM, showSettingOnly); - outState.putBoolean(CHOOSE_PLAN_DIALOG_DISMISSED_KEY, choosePlanDialogDismissed); } @Override - public void onChoosePlanDialogDismissed() { - choosePlanDialogDismissed = true; + public void onChoosePlanDialogDismiss() { + finish(); } public boolean isShowSettingOnly() {