diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
index a2bdb1d14a..1bd833a71e 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
@@ -22,11 +22,7 @@ import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
import android.preference.PreferenceScreen;
public abstract class OsmandPlugin {
@@ -36,6 +32,7 @@ public abstract class OsmandPlugin {
private static final Log LOG = LogUtil.getLog(OsmandPlugin.class);
private static final String PARKING_PLUGIN_COMPONENT = "net.osmand.parkingPlugin"; //$NON-NLS-1$
+ private static final String SRTM_PLUGIN_COMPONENT = "net.osmand.srtmPlugin"; //$NON-NLS-1$
private static final String OSMODROID_PLUGIN_COMPONENT = "com.OsMoDroid"; //$NON-NLS-1$
@@ -66,9 +63,10 @@ public abstract class OsmandPlugin {
installedPlugins.add(new OsmandBackgroundServicePlugin(app));
installedPlugins.add(new OsmandExtraSettings(app));
installedPlugins.add(new AccessibilityPlugin(app));
- installedPlugins.add(new SRTMPlugin(app));
- installParkingPlugin(app);
- installOsmodroidPlugin(app);
+ installPlugin(SRTM_PLUGIN_COMPONENT, SRTMPlugin.ID, app,
+ new SRTMPlugin(app));
+ installPlugin(PARKING_PLUGIN_COMPONENT, ParkingPositionPlugin.ID, app, new ParkingPositionPlugin(app));
+ installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app));
installedPlugins.add(new OsmEditingPlugin(app));
installedPlugins.add(new OsmandDevelopmentPlugin(app));
@@ -220,33 +218,20 @@ public abstract class OsmandPlugin {
}
}
- private static void installParkingPlugin(OsmandApplication app) {
+ private static void installPlugin(String packageInfo,
+ String pluginId, OsmandApplication app, OsmandPlugin plugin) {
boolean installed = false;
try{
- installed = app.getPackageManager().getPackageInfo(PARKING_PLUGIN_COMPONENT, 0) != null;
+ installed = app.getPackageManager().getPackageInfo(packageInfo, 0) != null;
} catch ( NameNotFoundException e){
}
if(installed) {
- ParkingPositionPlugin parkingPlugin = new ParkingPositionPlugin(app);
- installedPlugins.add(parkingPlugin);
- app.getSettings().enablePlugin(parkingPlugin.getId(), true);
+ installedPlugins.add(plugin);
+ app.getSettings().enablePlugin(plugin.getId(), true);
} else {
- app.getSettings().enablePlugin(ParkingPositionPlugin.ID, false);
+ app.getSettings().enablePlugin(pluginId, false);
}
}
- private static void installOsmodroidPlugin(OsmandApplication app) {
- boolean installed = false;
- try{
- installed = app.getPackageManager().getPackageInfo(OSMODROID_PLUGIN_COMPONENT, 0) != null;
- } catch ( NameNotFoundException e){
- }
- if(installed) {
- installedPlugins.add(new OsMoDroidPlugin(app));
- app.getSettings().enablePlugin(OsMoDroidPlugin.ID, true);
- } else {
- app.getSettings().enablePlugin(OsMoDroidPlugin.ID, false);
- }
- }
}
diff --git a/plugins/Osmand-SRTMPlugin/.classpath b/plugins/Osmand-SRTMPlugin/.classpath
new file mode 100644
index 0000000000..a4763d1eec
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/plugins/Osmand-SRTMPlugin/.gitignore b/plugins/Osmand-SRTMPlugin/.gitignore
new file mode 100644
index 0000000000..36986d81cf
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/.gitignore
@@ -0,0 +1,4 @@
+bin
+gen
+raw
+obj
diff --git a/plugins/Osmand-SRTMPlugin/.project b/plugins/Osmand-SRTMPlugin/.project
new file mode 100644
index 0000000000..6c3b83059d
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/.project
@@ -0,0 +1,33 @@
+
+
+ Osmand-SRTMPlugin
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/plugins/Osmand-SRTMPlugin/AndroidManifest.xml b/plugins/Osmand-SRTMPlugin/AndroidManifest.xml
new file mode 100644
index 0000000000..8fdab06065
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/AndroidManifest.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/Osmand-SRTMPlugin/proguard-project.txt b/plugins/Osmand-SRTMPlugin/proguard-project.txt
new file mode 100644
index 0000000000..f2fe1559a2
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/plugins/Osmand-SRTMPlugin/project.properties b/plugins/Osmand-SRTMPlugin/project.properties
new file mode 100644
index 0000000000..85aac54016
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-8
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-hdpi/ic_launcher.png b/plugins/Osmand-SRTMPlugin/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000000..96a442e5b8
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-hdpi/ic_launcher.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-hdpi/icon.png b/plugins/Osmand-SRTMPlugin/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000000..a4f76f9354
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-hdpi/icon.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-ldpi/ic_launcher.png b/plugins/Osmand-SRTMPlugin/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000000..99238729d8
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-ldpi/ic_launcher.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-ldpi/icon.png b/plugins/Osmand-SRTMPlugin/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000000..a4f76f9354
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-ldpi/icon.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-mdpi/ic_launcher.png b/plugins/Osmand-SRTMPlugin/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000000..359047dfa4
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-mdpi/ic_launcher.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-mdpi/icon.png b/plugins/Osmand-SRTMPlugin/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000000..a4f76f9354
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-mdpi/icon.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/ic_launcher.png b/plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000000..71c6d760f0
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/icon.png b/plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/icon.png
new file mode 100644
index 0000000000..a4f76f9354
Binary files /dev/null and b/plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/icon.png differ
diff --git a/plugins/Osmand-SRTMPlugin/res/layout/main.xml b/plugins/Osmand-SRTMPlugin/res/layout/main.xml
new file mode 100644
index 0000000000..35e8b132cc
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/res/layout/main.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/Osmand-SRTMPlugin/res/values/strings.xml b/plugins/Osmand-SRTMPlugin/res/values/strings.xml
new file mode 100644
index 0000000000..201315ad8f
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+ No
+ Yes
+ OsmAnd is not installed
+ OsmAnd SRTM
+ OsmAnd SRTM Plugin is installed and enabled in OsmAnd settings.
+
\ No newline at end of file
diff --git a/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java b/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java
new file mode 100644
index 0000000000..b1a2412d29
--- /dev/null
+++ b/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java
@@ -0,0 +1,60 @@
+package net.osmand.srtmPlugin;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.os.Bundle;
+
+public class SRTMPluginActivity extends Activity {
+ private static final String OSMAND_COMPONENT = "net.osmand"; //$NON-NLS-1$
+ private static final String OSMAND_COMPONENT_PLUS = "net.osmand.plus"; //$NON-NLS-1$
+ private static final String OSMAND_ACTIVITY = "net.osmand.plus.activities.MainMenuActivity"; //$NON-NLS-1$
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Intent intentPlus = new Intent();
+ intentPlus.setComponent(new ComponentName(OSMAND_COMPONENT_PLUS, OSMAND_ACTIVITY));
+ intentPlus.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ ResolveInfo resolved = getPackageManager().resolveActivity(intentPlus, PackageManager.MATCH_DEFAULT_ONLY);
+ if(resolved != null) {
+ stopService(intentPlus);
+ startActivity(intentPlus);
+ } else {
+ Intent intentNormal = new Intent();
+ intentNormal.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ intentNormal.setComponent(new ComponentName(OSMAND_COMPONENT, OSMAND_ACTIVITY));
+ resolved = getPackageManager().resolveActivity(intentNormal, PackageManager.MATCH_DEFAULT_ONLY);
+ if (resolved != null) {
+ stopService(intentNormal);
+ startActivity(intentNormal);
+ } else {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(getString(R.string.osmand_app_not_found));
+ builder.setPositiveButton(getString(R.string.default_buttons_yes), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + OSMAND_COMPONENT_PLUS));
+ try {
+ stopService(intent);
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ }
+ }
+ });
+ builder.setNegativeButton(getString(R.string.default_buttons_no), null);
+ builder.show();
+ }
+ }
+ }
+
+}
\ No newline at end of file