Improved parking plugin
This commit is contained in:
parent
f1986f156d
commit
9a1a2a6827
6 changed files with 298 additions and 19 deletions
|
@ -13,13 +13,12 @@
|
|||
android:label="OsmAnd Parking" >
|
||||
<activity
|
||||
android:name=".ParkingPluginActivity"
|
||||
android:theme="@style/AppTheme"
|
||||
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>
|
||||
|
||||
|
|
|
@ -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'
|
187
plugins/Osmand-ParkingPlugin/google-services.json
Normal file
187
plugins/Osmand-ParkingPlugin/google-services.json
Normal file
|
@ -0,0 +1,187 @@
|
|||
{
|
||||
"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-ta1aisohg7g0k542gdh9fbeb2v4qsncf.apps.googleusercontent.com",
|
||||
"client_type": 2,
|
||||
"ios_info": {
|
||||
"bundle_id": "net.osmand.maps",
|
||||
"app_store_id": "934850257"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
|
@ -1,13 +1,71 @@
|
|||
<?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" >
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/white">
|
||||
|
||||
<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"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/blue_background"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/plugin_title"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/icon"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/descriptionTextView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:text="@string/plugin_description"
|
||||
android:textColor="@color/primary_text_light"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/buyButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="@color/blue_background"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/install_osmand"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,5 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="plugin_title">Parking — OsmAnd</string>
|
||||
<string name="plugin_description">Thank you for installing OsmAnd Parking!<br/><br/>It\'s a plugin for OsmAnd Maps & Navigation. To start using parking, please install <b>OsmAnd Maps & Navigation</b>.</string>
|
||||
<string name="install_osmand">Install OsmAnd</string>
|
||||
<string name="shared_string_no">No</string>
|
||||
<string name="shared_string_yes">Yes</string>
|
||||
<string name="osmand_app_not_found">OsmAnd is not installed</string>
|
||||
|
|
|
@ -5,12 +5,18 @@ import android.app.Activity;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
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;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ParkingPluginActivity extends Activity {
|
||||
private static final String OSMAND_COMPONENT = "net.osmand"; //$NON-NLS-1$
|
||||
|
@ -23,39 +29,58 @@ public class ParkingPluginActivity 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(ParkingPluginActivity.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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue