Improve check for installed market plugins
This commit is contained in:
parent
ff7ab9bc2d
commit
80c922449f
7 changed files with 62 additions and 45 deletions
18
OsmAnd/res/layout/bottom_sheet_item_title_big.xml
Normal file
18
OsmAnd/res/layout/bottom_sheet_item_title_big.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<net.osmand.plus.widgets.TextViewEx xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="bottom"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_title_height"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
android:textSize="@dimen/bottom_sheet_title_big"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="@string/new_plugin_added" />
|
|
@ -137,6 +137,7 @@
|
||||||
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
|
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
|
||||||
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
|
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
|
||||||
<dimen name="map_widget_icon_margin">2dp</dimen>
|
<dimen name="map_widget_icon_margin">2dp</dimen>
|
||||||
|
<dimen name="bottom_sheet_title_big">20sp</dimen>
|
||||||
|
|
||||||
<dimen name="dash_margin">2dp</dimen>
|
<dimen name="dash_margin">2dp</dimen>
|
||||||
<dimen name="dash_margin_h">6dp</dimen>
|
<dimen name="dash_margin_h">6dp</dimen>
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ import net.osmand.plus.activities.TabActivity.TabItem;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
|
import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
|
@ -121,6 +123,12 @@ public abstract class OsmandPlugin {
|
||||||
* Plugin was installed
|
* Plugin was installed
|
||||||
*/
|
*/
|
||||||
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
||||||
|
if (activity instanceof FragmentActivity) {
|
||||||
|
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
|
||||||
|
if (fragmentManager != null) {
|
||||||
|
PluginInstalledBottomSheetDialog.showInstance(fragmentManager, getId(), activity instanceof MapActivity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable(OsmandApplication app) {
|
public void disable(OsmandApplication app) {
|
||||||
|
@ -264,19 +272,30 @@ public abstract class OsmandPlugin {
|
||||||
public static void checkInstalledMarketPlugins(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
public static void checkInstalledMarketPlugins(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
||||||
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
|
for (OsmandPlugin plugin : OsmandPlugin.getAvailablePlugins()) {
|
||||||
if (plugin.getInstallURL() != null) {
|
if (plugin.getInstallURL() != null) {
|
||||||
boolean pckg = false;
|
|
||||||
if (plugin instanceof SRTMPlugin) {
|
if (plugin instanceof SRTMPlugin) {
|
||||||
pckg = checkPackage(app, SRTM_PLUGIN_COMPONENT_PAID, SRTM_PLUGIN_COMPONENT);
|
if (checkPackage(app, SRTM_PLUGIN_COMPONENT_PAID, SRTM_PLUGIN_COMPONENT)
|
||||||
|
&& updateMarketPlugin(app, plugin, true, SRTM_PLUGIN_COMPONENT_PAID, SRTM_PLUGIN_COMPONENT)) {
|
||||||
|
plugin.onInstall(app, activity);
|
||||||
|
initPlugin(app, plugin);
|
||||||
|
}
|
||||||
} else if (plugin instanceof NauticalMapsPlugin) {
|
} else if (plugin instanceof NauticalMapsPlugin) {
|
||||||
pckg = checkPackage(app, NauticalMapsPlugin.COMPONENT, null);
|
if (checkPackage(app, NauticalMapsPlugin.COMPONENT, null)
|
||||||
|
&& updateMarketPlugin(app, plugin, false, NauticalMapsPlugin.COMPONENT, null)) {
|
||||||
|
plugin.onInstall(app, activity);
|
||||||
|
initPlugin(app, plugin);
|
||||||
|
}
|
||||||
} else if (plugin instanceof SkiMapsPlugin) {
|
} else if (plugin instanceof SkiMapsPlugin) {
|
||||||
pckg = checkPackage(app, SkiMapsPlugin.COMPONENT, null);
|
if (checkPackage(app, SkiMapsPlugin.COMPONENT, null)
|
||||||
|
&& updateMarketPlugin(app, plugin, false, SkiMapsPlugin.COMPONENT, null)) {
|
||||||
|
plugin.onInstall(app, activity);
|
||||||
|
initPlugin(app, plugin);
|
||||||
|
}
|
||||||
} else if (plugin instanceof ParkingPositionPlugin) {
|
} else if (plugin instanceof ParkingPositionPlugin) {
|
||||||
pckg = checkPackage(app, ParkingPositionPlugin.PARKING_PLUGIN_COMPONENT, null);
|
if (checkPackage(app, ParkingPositionPlugin.PARKING_PLUGIN_COMPONENT, null)
|
||||||
}
|
&& updateMarketPlugin(app, plugin, false, ParkingPositionPlugin.PARKING_PLUGIN_COMPONENT, null)) {
|
||||||
if (pckg) {
|
plugin.onInstall(app, activity);
|
||||||
plugin.onInstall(app, activity);
|
initPlugin(app, plugin);
|
||||||
initPlugin(app, plugin);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,11 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add(new TitleItem(getString(R.string.new_plugin_added)));
|
BaseBottomSheetItem titleItem = new TitleItem.Builder()
|
||||||
|
.setTitle(getString(R.string.new_plugin_added))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_title_big)
|
||||||
|
.create();
|
||||||
|
items.add(titleItem);
|
||||||
|
|
||||||
BaseBottomSheetItem pluginTitle = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem pluginTitle = new SimpleBottomSheetItem.Builder()
|
||||||
.setTitle(plugin.getName())
|
.setTitle(plugin.getName())
|
||||||
|
@ -178,10 +182,13 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
||||||
|
|
||||||
items.add(new DividerItem(getContext()));
|
items.add(new DividerItem(getContext()));
|
||||||
|
|
||||||
|
View categoryView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.bottom_sheet_item_with_descr_56dp, null);
|
||||||
|
categoryView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||||
|
|
||||||
BaseBottomSheetItem addedAppProfiles = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem addedAppProfiles = new BottomSheetItemWithDescription.Builder()
|
||||||
.setDescription(getString(R.string.added_profiles_descr))
|
.setDescription(getString(R.string.added_profiles_descr))
|
||||||
.setTitle(getString(R.string.added_profiles))
|
.setTitle(getString(R.string.added_profiles))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
.setCustomView(categoryView)
|
||||||
.create();
|
.create();
|
||||||
items.add(addedAppProfiles);
|
items.add(addedAppProfiles);
|
||||||
|
|
||||||
|
@ -211,10 +218,13 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
||||||
|
|
||||||
items.add(new DividerItem(getContext()));
|
items.add(new DividerItem(getContext()));
|
||||||
|
|
||||||
|
View categoryView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.bottom_sheet_item_with_descr_56dp, null);
|
||||||
|
categoryView.findViewById(R.id.icon).setVisibility(View.GONE);
|
||||||
|
|
||||||
BaseBottomSheetItem addedAppProfiles = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem addedAppProfiles = new BottomSheetItemWithDescription.Builder()
|
||||||
.setDescription(getString(R.string.suggested_maps_descr))
|
.setDescription(getString(R.string.suggested_maps_descr))
|
||||||
.setTitle(getString(R.string.suggested_maps))
|
.setTitle(getString(R.string.suggested_maps))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
.setCustomView(categoryView)
|
||||||
.create();
|
.create();
|
||||||
items.add(addedAppProfiles);
|
items.add(addedAppProfiles);
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -17,7 +15,6 @@ import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog;
|
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
|
|
||||||
|
@ -95,12 +92,7 @@ public class NauticalMapsPlugin extends OsmandPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
||||||
ApplicationMode.changeProfileAvailability(ApplicationMode.BOAT, true, app);
|
ApplicationMode.changeProfileAvailability(ApplicationMode.BOAT, true, app);
|
||||||
if (activity instanceof FragmentActivity) {
|
super.onInstall(app, activity);
|
||||||
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
|
|
||||||
if (fragmentManager != null) {
|
|
||||||
PluginInstalledBottomSheetDialog.showInstance(fragmentManager, getId(), activity instanceof MapActivity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,15 +3,11 @@ package net.osmand.plus.skimapsplugin;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -65,12 +61,7 @@ public class SkiMapsPlugin extends OsmandPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
||||||
ApplicationMode.changeProfileAvailability(ApplicationMode.SKI, true, app);
|
ApplicationMode.changeProfileAvailability(ApplicationMode.SKI, true, app);
|
||||||
if (activity instanceof FragmentActivity) {
|
super.onInstall(app, activity);
|
||||||
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
|
|
||||||
if (fragmentManager != null) {
|
|
||||||
PluginInstalledBottomSheetDialog.showInstance(fragmentManager, getId(), activity instanceof MapActivity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,9 +4,6 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
@ -24,7 +21,6 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog;
|
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.download.DownloadIndexesThread;
|
import net.osmand.plus.download.DownloadIndexesThread;
|
||||||
import net.osmand.plus.download.DownloadResources;
|
import net.osmand.plus.download.DownloadResources;
|
||||||
|
@ -113,16 +109,6 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInstall(@NonNull OsmandApplication app, @Nullable Activity activity) {
|
|
||||||
if (activity instanceof FragmentActivity) {
|
|
||||||
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
|
|
||||||
if (fragmentManager != null) {
|
|
||||||
PluginInstalledBottomSheetDialog.showInstance(fragmentManager, getId(), activity instanceof MapActivity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerLayers(MapActivity activity) {
|
public void registerLayers(MapActivity activity) {
|
||||||
if (hillshadeLayer != null) {
|
if (hillshadeLayer != null) {
|
||||||
|
|
Loading…
Reference in a new issue