Add SRTM plugin
|
@ -22,11 +22,7 @@ import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
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.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
|
||||||
public abstract class OsmandPlugin {
|
public abstract class OsmandPlugin {
|
||||||
|
@ -36,6 +32,7 @@ public abstract class OsmandPlugin {
|
||||||
private static final Log LOG = LogUtil.getLog(OsmandPlugin.class);
|
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 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$
|
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 OsmandBackgroundServicePlugin(app));
|
||||||
installedPlugins.add(new OsmandExtraSettings(app));
|
installedPlugins.add(new OsmandExtraSettings(app));
|
||||||
installedPlugins.add(new AccessibilityPlugin(app));
|
installedPlugins.add(new AccessibilityPlugin(app));
|
||||||
installedPlugins.add(new SRTMPlugin(app));
|
installPlugin(SRTM_PLUGIN_COMPONENT, SRTMPlugin.ID, app,
|
||||||
installParkingPlugin(app);
|
new SRTMPlugin(app));
|
||||||
installOsmodroidPlugin(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 OsmEditingPlugin(app));
|
||||||
installedPlugins.add(new OsmandDevelopmentPlugin(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;
|
boolean installed = false;
|
||||||
try{
|
try{
|
||||||
installed = app.getPackageManager().getPackageInfo(PARKING_PLUGIN_COMPONENT, 0) != null;
|
installed = app.getPackageManager().getPackageInfo(packageInfo, 0) != null;
|
||||||
} catch ( NameNotFoundException e){
|
} catch ( NameNotFoundException e){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(installed) {
|
if(installed) {
|
||||||
ParkingPositionPlugin parkingPlugin = new ParkingPositionPlugin(app);
|
installedPlugins.add(plugin);
|
||||||
installedPlugins.add(parkingPlugin);
|
app.getSettings().enablePlugin(plugin.getId(), true);
|
||||||
app.getSettings().enablePlugin(parkingPlugin.getId(), true);
|
|
||||||
} else {
|
} 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
8
plugins/Osmand-SRTMPlugin/.classpath
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="gen"/>
|
||||||
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
|
</classpath>
|
4
plugins/Osmand-SRTMPlugin/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
bin
|
||||||
|
gen
|
||||||
|
raw
|
||||||
|
obj
|
33
plugins/Osmand-SRTMPlugin/.project
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Osmand-SRTMPlugin</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
22
plugins/Osmand-SRTMPlugin/AndroidManifest.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="net.osmand.srtmPlugin"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0" >
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="4" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:icon="@drawable/icon"
|
||||||
|
android:label="OsmAnd SRTM" >
|
||||||
|
<activity
|
||||||
|
android:name=".SRTMPluginActivity"
|
||||||
|
android:label="@string/app_name" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
20
plugins/Osmand-SRTMPlugin/proguard-project.txt
Normal file
|
@ -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 *;
|
||||||
|
#}
|
14
plugins/Osmand-SRTMPlugin/project.properties
Normal file
|
@ -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
|
BIN
plugins/Osmand-SRTMPlugin/res/drawable-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-hdpi/icon.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-ldpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-ldpi/icon.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-mdpi/icon.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
plugins/Osmand-SRTMPlugin/res/drawable-xhdpi/icon.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
13
plugins/Osmand-SRTMPlugin/res/layout/main.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:text="@string/parking_plugin_installed"
|
||||||
|
android:textSize="22sp"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
8
plugins/Osmand-SRTMPlugin/res/values/strings.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="default_buttons_no">No</string>
|
||||||
|
<string name="default_buttons_yes">Yes</string>
|
||||||
|
<string name="osmand_app_not_found">OsmAnd is not installed</string>
|
||||||
|
<string name="app_name">OsmAnd SRTM</string>
|
||||||
|
<string name="parking_plugin_installed">OsmAnd SRTM Plugin is installed and enabled in OsmAnd settings.</string>
|
||||||
|
</resources>
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|