From f2755361311c92355f6a18e2d79b393403929bec Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 26 Nov 2019 16:36:25 +0300 Subject: [PATCH] Fix dashboard/settings srtm plugin get --- .../plus/activities/PluginActivity.java | 13 +++++++++- .../plus/dashboard/DashPluginsFragment.java | 24 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/PluginActivity.java b/OsmAnd/src/net/osmand/plus/activities/PluginActivity.java index e12f0266f1..4f64d740d8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/PluginActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/PluginActivity.java @@ -8,6 +8,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; import android.util.Log; import android.view.MenuItem; import android.view.View; @@ -18,7 +19,9 @@ import android.widget.TextView; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.download.DownloadIndexesThread; +import net.osmand.plus.srtmplugin.SRTMPlugin; public class PluginActivity extends OsmandActionBarActivity implements DownloadIndexesThread.DownloadEvents { private static final String TAG = "PluginActivity"; @@ -94,11 +97,19 @@ public class PluginActivity extends OsmandActionBarActivity implements Download } }); Button getButton = (Button)findViewById(R.id.plugin_get); + getButton.setText(plugin.isPaid() ? R.string.get_plugin : R.string.shared_string_install); getButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); + if (plugin instanceof SRTMPlugin) { + FragmentManager fragmentManager = getSupportFragmentManager(); + if (fragmentManager != null) { + ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(fragmentManager); + } + } else { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); + } } catch (Exception e) { //ignored } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java index 0bb0a03741..f50cc1af1a 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashPluginsFragment.java @@ -5,6 +5,7 @@ import android.content.res.TypedArray; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.FragmentManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,8 +18,12 @@ import android.widget.TextView; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.PluginActivity; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.development.OsmandDevelopmentPlugin; +import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; +import net.osmand.plus.skimapsplugin.SkiMapsPlugin; +import net.osmand.plus.srtmplugin.SRTMPlugin; import java.util.ArrayList; import java.util.Collections; @@ -45,7 +50,14 @@ public class DashPluginsFragment extends DashBaseFragment { return new View.OnClickListener() { @Override public void onClick(View view) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); + if (plugin instanceof SRTMPlugin) { + FragmentManager fragmentManager = getFragmentManager(); + if (fragmentManager != null) { + ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(fragmentManager); + } + } else { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); + } closeDashboard(); } }; @@ -82,10 +94,17 @@ public class DashPluginsFragment extends DashBaseFragment { private void initPlugins() { List notActivePlugins = OsmandPlugin.getNotEnabledVisiblePlugins(); + notActivePlugins.remove(OsmandPlugin.getPlugin(SkiMapsPlugin.class)); + notActivePlugins.remove(OsmandPlugin.getPlugin(NauticalMapsPlugin.class)); Collections.shuffle(notActivePlugins); + + List enabledPlugins = OsmandPlugin.getEnabledVisiblePlugins(); + enabledPlugins.remove(OsmandPlugin.getPlugin(SkiMapsPlugin.class)); + enabledPlugins.remove(OsmandPlugin.getPlugin(NauticalMapsPlugin.class)); + plugins = new ArrayList(); Iterator nit = notActivePlugins.iterator(); - Iterator it = OsmandPlugin.getEnabledVisiblePlugins().iterator(); + Iterator it = enabledPlugins.iterator(); addPluginsToLimit(nit, 1); addPluginsToLimit(it, 5); addPluginsToLimit(nit, 5); @@ -152,6 +171,7 @@ public class DashPluginsFragment extends DashBaseFragment { CompoundButton enableDisableButton = (CompoundButton) view.findViewById(R.id.plugin_enable_disable); Button getButton = (Button) view.findViewById(R.id.get_plugin); + getButton.setText(plugin.isPaid() ? R.string.get_plugin : R.string.shared_string_install); getButton.setOnClickListener(getListener(plugin)); enableDisableButton.setOnCheckedChangeListener(null); updatePluginState(view, plugin);