diff --git a/OsmAnd/src/net/osmand/plus/Version.java b/OsmAnd/src/net/osmand/plus/Version.java index 1ad99c96e8..1d5d5088d7 100644 --- a/OsmAnd/src/net/osmand/plus/Version.java +++ b/OsmAnd/src/net/osmand/plus/Version.java @@ -23,7 +23,7 @@ public class Version { return getBuildFlavor().contains("huawei"); } - private static boolean isAmazon() { + public static boolean isAmazon() { return getBuildFlavor().contains("amazon"); } diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java index 7deb85768c..5fdf2eab46 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginInfoFragment.java @@ -31,6 +31,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog.PluginStateListener; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; @@ -168,7 +169,7 @@ public class PluginInfoFragment extends BaseOsmAndFragment implements PluginStat if (plugin instanceof SRTMPlugin) { FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); if (fragmentManager != null) { - ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(fragmentManager); + ChoosePlanDialogFragment.showDialogInstance(app, fragmentManager, ChoosePlanDialogType.HILLSHADE_SRTM_PLUGIN); } } else { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index 256a845dc7..543d7a9c46 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -5,6 +5,8 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; @@ -27,6 +29,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -34,7 +37,6 @@ import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; @@ -48,6 +50,7 @@ import net.osmand.plus.inapp.InAppPurchases.InAppPurchase; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; import net.osmand.plus.inapp.InAppPurchases.InAppSubscriptionIntroductoryInfo; import net.osmand.plus.liveupdates.SubscriptionFragment; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -709,57 +712,41 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } } - public static void showFreeVersionInstance(@NonNull FragmentManager fm) { - try { - ChoosePlanFreeBannerDialogFragment fragment = new ChoosePlanFreeBannerDialogFragment(); - fragment.show(fm, ChoosePlanFreeBannerDialogFragment.TAG); - } catch (RuntimeException e) { - LOG.error("showFreeVersionInstance", e); + public enum ChoosePlanDialogType { + + FREE_VERSION("showFreeVersionInstance", ChoosePlanFreeBannerDialogFragment.TAG, ChoosePlanFreeBannerDialogFragment.class), + WIKIPEDIA("showWikipediaInstance", ChoosePlanWikipediaDialogFragment.TAG, ChoosePlanWikipediaDialogFragment.class), + WIKIVOYAGE("showWikivoyageInstance", ChoosePlanWikivoyageDialogFragment.TAG, ChoosePlanWikivoyageDialogFragment.class), + SEA_DEPTH_MAPS("showSeaDepthMapsInstance", ChoosePlanSeaDepthMapsDialogFragment.TAG, ChoosePlanSeaDepthMapsDialogFragment.class), + HILLSHADE_SRTM_PLUGIN("showHillshadeSrtmPluginInstance", ChoosePlanHillshadeSrtmDialogFragment.TAG, ChoosePlanHillshadeSrtmDialogFragment.class), + OSM_LIVE("showOsmLiveInstance", ChoosePlanOsmLiveBannerDialogFragment.TAG, ChoosePlanOsmLiveBannerDialogFragment.class); + + private final String tag; + private final String errorName; + private final Class fragmentClass; + + ChoosePlanDialogType(String errorName, String tag, Class fragmentClass) { + this.tag = tag; + this.errorName = errorName; + this.fragmentClass = fragmentClass; } } - public static void showWikipediaInstance(@NonNull FragmentManager fm) { - try { - ChoosePlanWikipediaDialogFragment fragment = new ChoosePlanWikipediaDialogFragment(); - fragment.show(fm, ChoosePlanWikipediaDialogFragment.TAG); - } catch (RuntimeException e) { - LOG.error("showWikipediaInstance", e); - } - } - - public static void showWikivoyageInstance(@NonNull FragmentManager fm) { - try { - ChoosePlanWikivoyageDialogFragment fragment = new ChoosePlanWikivoyageDialogFragment(); - fragment.show(fm, ChoosePlanWikivoyageDialogFragment.TAG); - } catch (RuntimeException e) { - LOG.error("showWikivoyageInstance", e); - } - } - - public static void showSeaDepthMapsInstance(@NonNull FragmentManager fm) { - try { - ChoosePlanSeaDepthMapsDialogFragment fragment = new ChoosePlanSeaDepthMapsDialogFragment(); - fragment.show(fm, ChoosePlanSeaDepthMapsDialogFragment.TAG); - } catch (RuntimeException e) { - LOG.error("showSeaDepthMapsInstance", e); - } - } - - public static void showHillshadeSrtmPluginInstance(@NonNull FragmentManager fm) { - try { - ChoosePlanHillshadeSrtmDialogFragment fragment = new ChoosePlanHillshadeSrtmDialogFragment(); - fragment.show(fm, ChoosePlanHillshadeSrtmDialogFragment.TAG); - } catch (RuntimeException e) { - LOG.error("showHillshadeSrtmPluginInstance", e); - } - } - - public static void showOsmLiveInstance(@NonNull FragmentManager fm) { - try { - ChoosePlanOsmLiveBannerDialogFragment fragment = new ChoosePlanOsmLiveBannerDialogFragment(); - fragment.show(fm, ChoosePlanOsmLiveBannerDialogFragment.TAG); - } catch (RuntimeException e) { - LOG.error("showOsmLiveInstance", e); + public static void showDialogInstance(@NonNull OsmandApplication app, @NonNull FragmentManager manager, + @NonNull ChoosePlanDialogType dialogType) { + if (Version.isAmazon() && !Version.isPaidVersion(app)) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus"))); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + if (AndroidUtils.isIntentSafe(app, intent)) { + app.startActivity(intent); + } + } else { + try { + ChoosePlanDialogFragment fragment = (ChoosePlanDialogFragment) Fragment.instantiate(app, dialogType.fragmentClass.getName()); + fragment.show(manager, dialogType.tag); + } catch (RuntimeException e) { + LOG.error(dialogType.errorName, e); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveGoneDialog.java b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveGoneDialog.java index fdbce9a076..a4dba21024 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveGoneDialog.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveGoneDialog.java @@ -28,6 +28,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.OsmAndFeature; import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchases.InAppSubscription; @@ -235,7 +236,7 @@ public abstract class OsmLiveGoneDialog extends BaseOsmAndDialogFragment { dismiss(); FragmentActivity activity = getActivity(); if (activity != null) { - ChoosePlanDialogFragment.showOsmLiveInstance(activity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(app, activity.getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); } } }); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java index 15d222a980..58d8302f63 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java @@ -21,6 +21,7 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.PluginsFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; @@ -55,7 +56,7 @@ public class DashPluginsFragment extends DashBaseFragment { if (plugin instanceof SRTMPlugin) { FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager != null) { - ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(fragmentManager); + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), fragmentManager, ChoosePlanDialogType.HILLSHADE_SRTM_PLUGIN); } } else { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index ebbd7d4e3b..ed45d50e84 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -22,8 +22,6 @@ import android.widget.ProgressBar; import android.widget.Space; import android.widget.TextView; -import com.ibm.icu.impl.IllegalIcuArgumentException; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; @@ -35,6 +33,8 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.viewpager.widget.ViewPager; +import com.ibm.icu.impl.IllegalIcuArgumentException; + import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -52,7 +52,9 @@ import net.osmand.plus.activities.TabActivity; import net.osmand.plus.base.BasicProgressAsyncTask; import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.download.ReloadIndexesTask.ReloadIndexesListener; import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment; import net.osmand.plus.download.ui.DownloadResourceGroupFragment; import net.osmand.plus.download.ui.LocalIndexesFragment; @@ -63,7 +65,6 @@ import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.download.ReloadIndexesTask.ReloadIndexesListener; import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.views.controls.PagerSlidingTabStrip; import net.osmand.util.Algorithms; @@ -407,7 +408,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo collapseBanner(); } else { ctx.getMyApplication().logEvent("click_free_dialog"); - ChoosePlanDialogFragment.showFreeVersionInstance(ctx.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(ctx.getMyApplication(), ctx.getSupportFragmentManager(), ChoosePlanDialogType.FREE_VERSION); } } }; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 7a8deaf506..a24e2c5b2a 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -32,6 +32,7 @@ import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.PluginsFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.download.CityItem; import net.osmand.plus.download.CustomIndexItem; import net.osmand.plus.download.DownloadItem; @@ -353,10 +354,10 @@ public class ItemViewHolder { switch (clickAction) { case ASK_FOR_FULL_VERSION_PURCHASE: context.getMyApplication().logEvent("in_app_purchase_show_from_wiki_context_menu"); - ChoosePlanDialogFragment.showWikipediaInstance(context.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(context.getMyApplication(), context.getSupportFragmentManager(), ChoosePlanDialogType.WIKIPEDIA); break; case ASK_FOR_DEPTH_CONTOURS_PURCHASE: - ChoosePlanDialogFragment.showSeaDepthMapsInstance(context.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(context.getMyApplication(), context.getSupportFragmentManager(), ChoosePlanDialogType.SEA_DEPTH_MAPS); break; case ASK_FOR_SEAMARKS_PLUGIN: showPluginsScreen(); @@ -364,7 +365,7 @@ public class ItemViewHolder { context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show(); break; case ASK_FOR_SRTM_PLUGIN_PURCHASE: - ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(context.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(context.getMyApplication(), context.getSupportFragmentManager(), ChoosePlanDialogType.HILLSHADE_SRTM_PLUGIN); break; case ASK_FOR_SRTM_PLUGIN_ENABLE: showPluginsScreen(); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java index faf39a56f7..f12639a805 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java @@ -24,6 +24,7 @@ import net.osmand.Collator; import net.osmand.OsmAndCollator; import net.osmand.map.OsmandRegions; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.base.OsmAndListFragment; @@ -190,7 +191,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download if (listAdapter.isShowOsmLiveBanner() && position == 0) { DownloadActivity activity = getMyActivity(); if (activity != null) { - ChoosePlanDialogFragment.showOsmLiveInstance(activity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(activity.getMyApplication(), activity.getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); } } else { final IndexItem e = (IndexItem) getListAdapter().getItem(position); diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index a4bb6ec74f..c91655dafc 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -28,6 +28,7 @@ import net.osmand.osm.PoiType; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; @@ -322,7 +323,7 @@ public class DiscountHelper { } else { for (InAppPurchase p : purchaseHelper.getLiveUpdates().getAllSubscriptions()) { if (url.contains(p.getSku())) { - ChoosePlanDialogFragment.showOsmLiveInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(app, mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); break; } } @@ -367,17 +368,17 @@ public class DiscountHelper { } else if (url.startsWith(SHOW_CHOOSE_PLAN_PREFIX)) { String planType = url.substring(SHOW_CHOOSE_PLAN_PREFIX.length()).trim(); if (CHOOSE_PLAN_TYPE_FREE.equals(planType)) { - ChoosePlanDialogFragment.showFreeVersionInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.FREE_VERSION); } else if (CHOOSE_PLAN_TYPE_LIVE.equals(planType)) { - ChoosePlanDialogFragment.showOsmLiveInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); } else if (CHOOSE_PLAN_TYPE_SEA_DEPTH.equals(planType)) { - ChoosePlanDialogFragment.showSeaDepthMapsInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.SEA_DEPTH_MAPS); } else if (CHOOSE_PLAN_TYPE_HILLSHADE.equals(planType)) { - ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.HILLSHADE_SRTM_PLUGIN); } else if (CHOOSE_PLAN_TYPE_WIKIPEDIA.equals(planType)) { - ChoosePlanDialogFragment.showWikipediaInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.WIKIPEDIA); } else if (CHOOSE_PLAN_TYPE_WIKIVOYAGE.equals(planType)) { - ChoosePlanDialogFragment.showWikivoyageInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.WIKIVOYAGE); } } else { Intent intent = new Intent(Intent.ACTION_VIEW); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index c503162910..eb8e2abff4 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -35,6 +35,7 @@ import androidx.fragment.app.FragmentManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -213,7 +214,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc subscriptionsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - ChoosePlanDialogFragment.showOsmLiveInstance(getActivity().getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(app, getActivity().getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); } }); if (isDonationSupported()) { @@ -249,7 +250,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null) { - ChoosePlanDialogFragment.showOsmLiveInstance(activity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(app, activity.getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); } } }); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java index 6014ebbc88..f6df0d3690 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/OsmLiveActivity.java @@ -22,6 +22,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogListener; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.download.AbstractDownloadActivity; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.inapp.InAppPurchaseHelper; @@ -95,7 +96,7 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa protected void onResume() { super.onResume(); if (!InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication()) && showSettingOnly) { - ChoosePlanDialogFragment.showOsmLiveInstance(getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), getSupportFragmentManager(), ChoosePlanDialogType.OSM_LIVE); } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 9251e555b0..d8ab361a82 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -10,12 +10,9 @@ import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ListView; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.ContextThemeWrapper; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; @@ -32,9 +29,9 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; -import net.osmand.plus.search.listitems.QuickSearchBannerListItem; -import net.osmand.plus.search.listitems.QuickSearchFreeBannerListItem; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.mapcontextmenu.MenuController; +import net.osmand.plus.search.listitems.QuickSearchBannerListItem; import net.osmand.plus.search.listitems.QuickSearchHeaderListItem; import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItemType; @@ -50,9 +47,9 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; +import static net.osmand.plus.search.listitems.QuickSearchBannerListItem.ButtonItem; import static net.osmand.plus.search.listitems.QuickSearchBannerListItem.INVALID_ID; import static net.osmand.search.core.ObjectType.POI_TYPE; -import static net.osmand.plus.search.listitems.QuickSearchBannerListItem.ButtonItem; public class QuickSearchListAdapter extends ArrayAdapter { @@ -265,8 +262,7 @@ public class QuickSearchListAdapter extends ArrayAdapter { btnGet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - ChoosePlanDialogFragment.showWikipediaInstance( - activity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(app, activity.getSupportFragmentManager(), ChoosePlanDialogType.WIKIPEDIA); } }); } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java index 86abdee880..ed3d781745 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java @@ -8,6 +8,7 @@ import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuItem; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; @@ -139,7 +140,8 @@ public class ContourLinesMenu { } }); } else if (itemId == R.string.srtm_plugin_name) { - ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(mapActivity.getSupportFragmentManager()); + ChoosePlanDialogFragment.showDialogInstance(mapActivity.getMyApplication(), + mapActivity.getSupportFragmentManager(), ChoosePlanDialogType.HILLSHADE_SRTM_PLUGIN); closeDashboard(mapActivity); } else if (contourWidthProp != null && itemId == contourWidthName.hashCode()) { plugin.selectPropertyValue(mapActivity, contourWidthProp, widthPref, new Runnable() { diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaArticleWikiLinkFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaArticleWikiLinkFragment.java index 1c34b823ab..df66f651df 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaArticleWikiLinkFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaArticleWikiLinkFragment.java @@ -16,6 +16,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.wikivoyage.article.WikivoyageArticleWikiLinkFragment; @@ -78,7 +79,7 @@ public class WikipediaArticleWikiLinkFragment extends MenuBottomSheetDialogFragm public void onClick(View v) { FragmentManager fm = getFragmentManager(); if (fm != null) { - ChoosePlanDialogFragment.showWikivoyageInstance(fm); + ChoosePlanDialogFragment.showDialogInstance(getMyApplication(), fm, ChoosePlanDialogType.WIKIVOYAGE); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 396da70e43..80b3c50da4 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -22,6 +22,7 @@ import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; @@ -300,7 +301,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv || item.getType() == DownloadActivityType.TRAVEL_FILE) && !Version.isPaidVersion(app)) { FragmentManager fm = getFragmentManager(); if (fm != null) { - ChoosePlanDialogFragment.showWikipediaInstance(fm); + ChoosePlanDialogFragment.showDialogInstance(app, fm, ChoosePlanDialogType.WIKIPEDIA); } } else { DownloadIndexesThread downloadThread = app.getDownloadThread(); @@ -356,7 +357,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv || item.getType() == DownloadActivityType.TRAVEL_FILE) && !Version.isPaidVersion(app)) { FragmentManager fm = getFragmentManager(); if (fm != null) { - ChoosePlanDialogFragment.showWikipediaInstance(fm); + ChoosePlanDialogFragment.showDialogInstance(app, fm, ChoosePlanDialogType.WIKIPEDIA); } } else { DownloadIndexesThread downloadThread = app.getDownloadThread();