diff --git a/plugins/.classpath b/plugins/.classpath new file mode 100644 index 0000000000..a4763d1eec --- /dev/null +++ b/plugins/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 0000000000..36986d81cf --- /dev/null +++ b/plugins/.gitignore @@ -0,0 +1,4 @@ +bin +gen +raw +obj diff --git a/plugins/.project b/plugins/.project new file mode 100644 index 0000000000..1c708327e5 --- /dev/null +++ b/plugins/.project @@ -0,0 +1,33 @@ + + + Osmand-ParkingPlugin + + + + + + 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/AndroidManifest.xml b/plugins/AndroidManifest.xml new file mode 100644 index 0000000000..a51066317c --- /dev/null +++ b/plugins/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/proguard-project.txt b/plugins/proguard-project.txt new file mode 100644 index 0000000000..f2fe1559a2 --- /dev/null +++ b/plugins/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/project.properties b/plugins/project.properties new file mode 100644 index 0000000000..1f896ec2b7 --- /dev/null +++ b/plugins/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-4 diff --git a/plugins/res/drawable-hdpi/ic_launcher.png b/plugins/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000000..96a442e5b8 Binary files /dev/null and b/plugins/res/drawable-hdpi/ic_launcher.png differ diff --git a/plugins/res/drawable-hdpi/icon.png b/plugins/res/drawable-hdpi/icon.png new file mode 100644 index 0000000000..a4f76f9354 Binary files /dev/null and b/plugins/res/drawable-hdpi/icon.png differ diff --git a/plugins/res/drawable-ldpi/ic_launcher.png b/plugins/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000000..99238729d8 Binary files /dev/null and b/plugins/res/drawable-ldpi/ic_launcher.png differ diff --git a/plugins/res/drawable-ldpi/icon.png b/plugins/res/drawable-ldpi/icon.png new file mode 100644 index 0000000000..120a5c1bb0 Binary files /dev/null and b/plugins/res/drawable-ldpi/icon.png differ diff --git a/plugins/res/drawable-mdpi/ic_launcher.png b/plugins/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000000..359047dfa4 Binary files /dev/null and b/plugins/res/drawable-mdpi/ic_launcher.png differ diff --git a/plugins/res/drawable-mdpi/icon.png b/plugins/res/drawable-mdpi/icon.png new file mode 100644 index 0000000000..120a5c1bb0 Binary files /dev/null and b/plugins/res/drawable-mdpi/icon.png differ diff --git a/plugins/res/drawable-xhdpi/ic_launcher.png b/plugins/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..71c6d760f0 Binary files /dev/null and b/plugins/res/drawable-xhdpi/ic_launcher.png differ diff --git a/plugins/res/drawable-xhdpi/icon.png b/plugins/res/drawable-xhdpi/icon.png new file mode 100644 index 0000000000..a4f76f9354 Binary files /dev/null and b/plugins/res/drawable-xhdpi/icon.png differ diff --git a/plugins/res/layout/main.xml b/plugins/res/layout/main.xml new file mode 100644 index 0000000000..35e8b132cc --- /dev/null +++ b/plugins/res/layout/main.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/plugins/res/values/strings.xml b/plugins/res/values/strings.xml new file mode 100644 index 0000000000..d2df6e8874 --- /dev/null +++ b/plugins/res/values/strings.xml @@ -0,0 +1,8 @@ + + + No + Yes + Osmand is not installed + OsmAnd Parking Plugin + OsmAnd Parking Plugin is installed and enabled in OsmAnd settings. + \ No newline at end of file diff --git a/plugins/src/net/osmand/parkingPlugin/ParkingPluginActivity.java b/plugins/src/net/osmand/parkingPlugin/ParkingPluginActivity.java new file mode 100644 index 0000000000..3c36d9d57e --- /dev/null +++ b/plugins/src/net/osmand/parkingPlugin/ParkingPluginActivity.java @@ -0,0 +1,57 @@ +package net.osmand.parkingPlugin; + +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 ParkingPluginActivity 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) { + 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) { + 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 { + startActivity(intent); + } catch (ActivityNotFoundException e) { + } + } + }); + builder.setNegativeButton(getString(R.string.default_buttons_no), null); + builder.show(); + } + } + } + +} \ No newline at end of file