From 7e062f5759afa5f501557e6be44ee326f8070125 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 19 Aug 2016 17:19:15 +0300 Subject: [PATCH] Fix open live updates subscription from banner --- .../net/osmand/plus/download/DownloadActivity.java | 1 + .../osmand/plus/download/ui/UpdatesIndexFragment.java | 1 + .../osmand/plus/liveupdates/LiveUpdatesFragment.java | 5 +++++ .../net/osmand/plus/liveupdates/OsmLiveActivity.java | 11 +++++++++++ 4 files changed, 18 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 20bd407f86..38519859d4 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -437,6 +437,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo public void onClick(View v) { Intent intent = new Intent(ctx, OsmLiveActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true); ctx.startActivity(intent); } }); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java index 7a375b1518..46023ee5a1 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java @@ -168,6 +168,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download if (listAdapter.isShowOsmLiveBanner() && position == 0) { Intent intent = new Intent(getMyActivity(), OsmLiveActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true); getMyActivity().startActivity(intent); } else { final IndexItem e = (IndexItem) getListAdapter().getItem(position); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index 80da19684a..9679ba199b 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -210,6 +210,11 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList helper.addListener(this); helper.start(false); } + if (((OsmLiveActivity) getActivity()).shouldOpenSubscription()) { + SubscriptionFragment subscriptionFragment = new SubscriptionFragment(); + subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG); + } + } @Override diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java index 554c5c8d7f..1333bbf67e 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java @@ -22,8 +22,10 @@ import org.apache.commons.logging.Log; public class OsmLiveActivity extends AbstractDownloadActivity implements DownloadIndexesThread.DownloadEvents{ private final static Log LOG = PlatformUtil.getLog(OsmLiveActivity.class); + public final static String OPEN_SUBSCRIPTION_INTENT_PARAM = "open_subscription_intent_param"; private LiveUpdatesFragmentPagerAdapter pagerAdapter; private InAppHelper inAppHelper; + private boolean openSubscription; public InAppHelper getInAppHelper() { return inAppHelper; @@ -40,6 +42,11 @@ public class OsmLiveActivity extends AbstractDownloadActivity inAppHelper = null; } + Intent intent = getIntent(); + if (intent != null && intent.getExtras() != null) { + openSubscription = intent.getExtras().getBoolean(OPEN_SUBSCRIPTION_INTENT_PARAM, false); + } + ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); pagerAdapter = new LiveUpdatesFragmentPagerAdapter(getSupportFragmentManager(), getResources()); viewPager.setAdapter(pagerAdapter); @@ -94,6 +101,10 @@ public class OsmLiveActivity extends AbstractDownloadActivity ((LiveUpdatesFragment) pagerAdapter.fragments[0]).notifyLiveUpdatesChanged(); } + public boolean shouldOpenSubscription() { + return openSubscription; + } + public static class LiveUpdatesFragmentPagerAdapter extends FragmentPagerAdapter { private final Fragment[] fragments = new Fragment[]{new LiveUpdatesFragment(), new ReportsFragment()};