From 07bd24ccf36b874616cf2cc51a41e04f5d14b425 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 9 Dec 2016 19:15:08 +0300 Subject: [PATCH] Improved srtm plugin --- plugins/Osmand-SRTMPlugin/AndroidManifest.xml | 4 +- plugins/Osmand-SRTMPlugin/build.gradle | 9 +- .../Osmand-SRTMPlugin/google-services.json | 218 ++++++++++++++++++ plugins/Osmand-SRTMPlugin/res/layout/main.xml | 74 +++++- .../Osmand-SRTMPlugin/res/values/strings.xml | 3 + .../osmand/srtmPlugin/SRTMPluginActivity.java | 48 +++- 6 files changed, 333 insertions(+), 23 deletions(-) create mode 100644 plugins/Osmand-SRTMPlugin/google-services.json diff --git a/plugins/Osmand-SRTMPlugin/AndroidManifest.xml b/plugins/Osmand-SRTMPlugin/AndroidManifest.xml index d546c88cdc..04cf42f492 100644 --- a/plugins/Osmand-SRTMPlugin/AndroidManifest.xml +++ b/plugins/Osmand-SRTMPlugin/AndroidManifest.xml @@ -13,12 +13,12 @@ android:label="@string/app_label" > - + diff --git a/plugins/Osmand-SRTMPlugin/build.gradle b/plugins/Osmand-SRTMPlugin/build.gradle index 892d058f33..b8447a1ee1 100644 --- a/plugins/Osmand-SRTMPlugin/build.gradle +++ b/plugins/Osmand-SRTMPlugin/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 21 + compileSdkVersion 23 buildToolsVersion "23.0.1" signingConfigs { @@ -63,4 +63,11 @@ repositories { } dependencies { + compile 'com.google.firebase:firebase-core:9.8.0' + compile 'com.google.firebase:firebase-config:9.8.0' + compile 'com.android.support:appcompat-v7:23.3.0' + compile 'com.android.support:design:23.3.0' } + +println "Apply GMS plugin" +apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/plugins/Osmand-SRTMPlugin/google-services.json b/plugins/Osmand-SRTMPlugin/google-services.json new file mode 100644 index 0000000000..42d581ebd7 --- /dev/null +++ b/plugins/Osmand-SRTMPlugin/google-services.json @@ -0,0 +1,218 @@ +{ + "project_info": { + "project_number": "521675454867", + "firebase_url": "https://osmand-1e236.firebaseio.com", + "project_id": "osmand-1e236", + "storage_bucket": "osmand-1e236.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:521675454867:android:be0477f14dc015f4", + "android_client_info": { + "package_name": "net.osmand" + } + }, + "oauth_client": [ + { + "client_id": "521675454867-te1hdssotqq2dhu7pj2pjm17eulm1tvf.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "net.osmand", + "certificate_hash": "49A9ACE0BFEE7BB91506D7921F93A47808CB62AB" + } + }, + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 2, + "other_platform_oauth_client": [ + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "521675454867-ta1aisohg7g0k542gdh9fbeb2v4qsncf.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "net.osmand.maps", + "app_store_id": "934850257" + } + } + ] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:521675454867:android:89d7051c910a2ed6", + "android_client_info": { + "package_name": "net.osmand.plus" + } + }, + "oauth_client": [ + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:521675454867:android:7e1b6333fdbe27e4", + "android_client_info": { + "package_name": "net.osmand.skimapsPlugin" + } + }, + "oauth_client": [ + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:521675454867:android:b53cc47c00e16275", + "android_client_info": { + "package_name": "net.osmand.nauticalPlugin" + } + }, + "oauth_client": [ + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:521675454867:android:d3c770d3b10e292d", + "android_client_info": { + "package_name": "net.osmand.parkingPlugin" + } + }, + "oauth_client": [ + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:521675454867:android:eedc4a033f567685", + "android_client_info": { + "package_name": "net.osmand.srtmPlugin.paid" + } + }, + "oauth_client": [ + { + "client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/plugins/Osmand-SRTMPlugin/res/layout/main.xml b/plugins/Osmand-SRTMPlugin/res/layout/main.xml index 35e8b132cc..2e6fdf93cc 100644 --- a/plugins/Osmand-SRTMPlugin/res/layout/main.xml +++ b/plugins/Osmand-SRTMPlugin/res/layout/main.xml @@ -1,13 +1,71 @@ + android:layout_width="fill_parent" + android:layout_height="fill_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:background="@color/white"> - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Osmand-SRTMPlugin/res/values/strings.xml b/plugins/Osmand-SRTMPlugin/res/values/strings.xml index f65a8afcb6..c2f472a873 100644 --- a/plugins/Osmand-SRTMPlugin/res/values/strings.xml +++ b/plugins/Osmand-SRTMPlugin/res/values/strings.xml @@ -1,5 +1,8 @@ + Contour lines — OsmAnd + Thank you for installing OsmAnd Contour lines!<br/><br/>It\'s a plugin for OsmAnd Maps & Navigation. To start using contour lines, please install <b>OsmAnd Maps & Navigation</b>. + Install OsmAnd No Yes OsmAnd is not installed diff --git a/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java b/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java index 8350cd84b4..1604fae125 100644 --- a/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java +++ b/plugins/Osmand-SRTMPlugin/src/net/osmand/srtmPlugin/SRTMPluginActivity.java @@ -1,17 +1,22 @@ package net.osmand.srtmPlugin; -import net.osmand.srtmPlugin.paid.R; import android.app.Activity; -import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ComponentName; -import android.content.DialogInterface; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; +import android.text.Html; +import android.view.View; +import android.widget.TextView; + +import net.osmand.srtmPlugin.paid.R; + +import java.lang.reflect.Method; public class SRTMPluginActivity extends Activity { private static final String OSMAND_COMPONENT = "net.osmand"; //$NON-NLS-1$ @@ -24,39 +29,58 @@ public class SRTMPluginActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.main); + TextView descriptionTextView = (TextView) findViewById(R.id.descriptionTextView); + descriptionTextView.setText(Html.fromHtml(getString(R.string.plugin_description))); + 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) { + logEvent(this, "open_osmand_plus"); stopService(intentPlus); startActivity(intentPlus); + finish(); } 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) { + logEvent(this, "open_osmand"); stopService(intentNormal); startActivity(intentNormal); + finish(); } else { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(getString(R.string.osmand_app_not_found)); - builder.setPositiveButton(getString(R.string.shared_string_yes), new DialogInterface.OnClickListener() { + logEvent(this, "open_dialog"); + findViewById(R.id.buyButton).setOnClickListener(new View.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)); + public void onClick(View v) { + String appName = OSMAND_COMPONENT; + logEvent(SRTMPluginActivity.this, "open_play_store_" + appName); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + appName)); try { - stopService(intent); + //stopService(intent); startActivity(intent); + finish(); } catch (ActivityNotFoundException e) { + // ignore } } }); - builder.setNegativeButton(getString(R.string.shared_string_no), null); - builder.show(); } } } - + + public void logEvent(Activity ctx, String event) { + try { + Class cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics"); + Method mm = cl.getMethod("getInstance", Context.class); + Object inst = mm.invoke(null, ctx == null ? this : ctx); + Method log = cl.getMethod("logEvent", String.class, Bundle.class); + log.invoke(inst, event, new Bundle()); + } catch (Exception e) { + e.printStackTrace(); + } + } } \ No newline at end of file