Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorDmitry Kunin <dkunin@mapswith.me>2013-06-13 15:28:50 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:56:42 +0300
commite5bd8ce8886b038bbc4b7549efe98c0ee8f7b3c3 (patch)
tree40c400d5ef9f0cd32fcaf1b441e6f1da1b52b706 /api
parente0442546d1fc86a13f9021d8992c3bb364ab834d (diff)
[android, api] Download MWM dialog.
Diffstat (limited to 'api')
-rw-r--r--api/android/lib/res/drawable-hdpi/button.pngbin0 -> 15692 bytes
-rw-r--r--api/android/lib/res/drawable-hdpi/button_pressed.pngbin0 -> 14323 bytes
-rw-r--r--api/android/lib/res/drawable-hdpi/logo.pngbin0 -> 87420 bytes
-rw-r--r--api/android/lib/res/drawable-ldpi/button.pngbin0 -> 7329 bytes
-rw-r--r--api/android/lib/res/drawable-ldpi/button_pressed.pngbin0 -> 6736 bytes
-rw-r--r--api/android/lib/res/drawable-ldpi/logo.pngbin0 -> 26795 bytes
-rw-r--r--api/android/lib/res/drawable-mdpi/button.pngbin0 -> 9931 bytes
-rw-r--r--api/android/lib/res/drawable-mdpi/button_pressed.pngbin0 -> 9026 bytes
-rw-r--r--api/android/lib/res/drawable-mdpi/logo.pngbin0 -> 43667 bytes
-rw-r--r--api/android/lib/res/drawable-xhdpi/button.pngbin0 -> 21427 bytes
-rw-r--r--api/android/lib/res/drawable-xhdpi/button_pressed.pngbin0 -> 19644 bytes
-rw-r--r--api/android/lib/res/drawable-xhdpi/logo.pngbin0 -> 148377 bytes
-rw-r--r--api/android/lib/res/drawable-xxhdpi/button.pngbin0 -> 35099 bytes
-rw-r--r--api/android/lib/res/drawable-xxhdpi/button_pressed.pngbin0 -> 32332 bytes
-rw-r--r--api/android/lib/res/drawable-xxhdpi/logo.pngbin0 -> 336153 bytes
-rw-r--r--api/android/lib/res/drawable/background_pattern.xml5
-rw-r--r--api/android/lib/res/drawable/download_btn_selector.xml7
-rw-r--r--api/android/lib/res/drawable/pattern.pngbin0 -> 67027 bytes
-rw-r--r--api/android/lib/res/layout/dlg_install_mwm.xml50
-rw-r--r--api/android/lib/res/values/dimen.xml5
-rw-r--r--api/android/lib/res/values/strings.xml7
-rw-r--r--api/android/lib/src/com/mapswithme/maps/api/DownloadMapsWithMeDialog.java37
-rw-r--r--api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java62
23 files changed, 143 insertions, 30 deletions
diff --git a/api/android/lib/res/drawable-hdpi/button.png b/api/android/lib/res/drawable-hdpi/button.png
new file mode 100644
index 0000000000..423db24bf5
--- /dev/null
+++ b/api/android/lib/res/drawable-hdpi/button.png
Binary files differ
diff --git a/api/android/lib/res/drawable-hdpi/button_pressed.png b/api/android/lib/res/drawable-hdpi/button_pressed.png
new file mode 100644
index 0000000000..036791b512
--- /dev/null
+++ b/api/android/lib/res/drawable-hdpi/button_pressed.png
Binary files differ
diff --git a/api/android/lib/res/drawable-hdpi/logo.png b/api/android/lib/res/drawable-hdpi/logo.png
new file mode 100644
index 0000000000..74d9051fe1
--- /dev/null
+++ b/api/android/lib/res/drawable-hdpi/logo.png
Binary files differ
diff --git a/api/android/lib/res/drawable-ldpi/button.png b/api/android/lib/res/drawable-ldpi/button.png
new file mode 100644
index 0000000000..672b2266a6
--- /dev/null
+++ b/api/android/lib/res/drawable-ldpi/button.png
Binary files differ
diff --git a/api/android/lib/res/drawable-ldpi/button_pressed.png b/api/android/lib/res/drawable-ldpi/button_pressed.png
new file mode 100644
index 0000000000..0d76e072e7
--- /dev/null
+++ b/api/android/lib/res/drawable-ldpi/button_pressed.png
Binary files differ
diff --git a/api/android/lib/res/drawable-ldpi/logo.png b/api/android/lib/res/drawable-ldpi/logo.png
new file mode 100644
index 0000000000..232ffb163a
--- /dev/null
+++ b/api/android/lib/res/drawable-ldpi/logo.png
Binary files differ
diff --git a/api/android/lib/res/drawable-mdpi/button.png b/api/android/lib/res/drawable-mdpi/button.png
new file mode 100644
index 0000000000..3ed5455cc0
--- /dev/null
+++ b/api/android/lib/res/drawable-mdpi/button.png
Binary files differ
diff --git a/api/android/lib/res/drawable-mdpi/button_pressed.png b/api/android/lib/res/drawable-mdpi/button_pressed.png
new file mode 100644
index 0000000000..b1d4f8b86a
--- /dev/null
+++ b/api/android/lib/res/drawable-mdpi/button_pressed.png
Binary files differ
diff --git a/api/android/lib/res/drawable-mdpi/logo.png b/api/android/lib/res/drawable-mdpi/logo.png
new file mode 100644
index 0000000000..87e4ad28da
--- /dev/null
+++ b/api/android/lib/res/drawable-mdpi/logo.png
Binary files differ
diff --git a/api/android/lib/res/drawable-xhdpi/button.png b/api/android/lib/res/drawable-xhdpi/button.png
new file mode 100644
index 0000000000..5d37f7ce3b
--- /dev/null
+++ b/api/android/lib/res/drawable-xhdpi/button.png
Binary files differ
diff --git a/api/android/lib/res/drawable-xhdpi/button_pressed.png b/api/android/lib/res/drawable-xhdpi/button_pressed.png
new file mode 100644
index 0000000000..d93986f3c8
--- /dev/null
+++ b/api/android/lib/res/drawable-xhdpi/button_pressed.png
Binary files differ
diff --git a/api/android/lib/res/drawable-xhdpi/logo.png b/api/android/lib/res/drawable-xhdpi/logo.png
new file mode 100644
index 0000000000..6385ceab0d
--- /dev/null
+++ b/api/android/lib/res/drawable-xhdpi/logo.png
Binary files differ
diff --git a/api/android/lib/res/drawable-xxhdpi/button.png b/api/android/lib/res/drawable-xxhdpi/button.png
new file mode 100644
index 0000000000..f550647b71
--- /dev/null
+++ b/api/android/lib/res/drawable-xxhdpi/button.png
Binary files differ
diff --git a/api/android/lib/res/drawable-xxhdpi/button_pressed.png b/api/android/lib/res/drawable-xxhdpi/button_pressed.png
new file mode 100644
index 0000000000..5c24725eb2
--- /dev/null
+++ b/api/android/lib/res/drawable-xxhdpi/button_pressed.png
Binary files differ
diff --git a/api/android/lib/res/drawable-xxhdpi/logo.png b/api/android/lib/res/drawable-xxhdpi/logo.png
new file mode 100644
index 0000000000..1e085b02c4
--- /dev/null
+++ b/api/android/lib/res/drawable-xxhdpi/logo.png
Binary files differ
diff --git a/api/android/lib/res/drawable/background_pattern.xml b/api/android/lib/res/drawable/background_pattern.xml
new file mode 100644
index 0000000000..88af2b7dd1
--- /dev/null
+++ b/api/android/lib/res/drawable/background_pattern.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/pattern"
+ android:tileMode="repeat"
+ android:dither="true"/>
diff --git a/api/android/lib/res/drawable/download_btn_selector.xml b/api/android/lib/res/drawable/download_btn_selector.xml
new file mode 100644
index 0000000000..f2018ba43c
--- /dev/null
+++ b/api/android/lib/res/drawable/download_btn_selector.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:drawable="@drawable/button_pressed" android:state_pressed="true"/>
+ <item android:drawable="@drawable/button"/>
+
+</selector>
diff --git a/api/android/lib/res/drawable/pattern.png b/api/android/lib/res/drawable/pattern.png
new file mode 100644
index 0000000000..33b8d96389
--- /dev/null
+++ b/api/android/lib/res/drawable/pattern.png
Binary files differ
diff --git a/api/android/lib/res/layout/dlg_install_mwm.xml b/api/android/lib/res/layout/dlg_install_mwm.xml
new file mode 100644
index 0000000000..1dc8905d2e
--- /dev/null
+++ b/api/android/lib/res/layout/dlg_install_mwm.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/background_pattern"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ android:paddingLeft="@dimen/margin_mid"
+ android:paddingRight="@dimen/margin_mid" >
+
+ <TextView
+ style="@android:style/TextAppearance.Medium"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_large"
+ android:gravity="center"
+ android:text="@string/dlg_title"
+ android:textColor="@android:color/black" />
+
+ <TextView
+ style="@android:style/TextAppearance.Large"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_large"
+ android:gravity="center"
+ android:text="@string/download_please"
+ android:textColor="@android:color/black" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_mid"
+ android:src="@drawable/logo" />
+
+ <ImageButton
+ android:id="@+id/download"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/margin_mid"
+ android:layout_marginTop="@dimen/margin_mid"
+ android:background="@null"
+ android:scaleType="centerInside"
+ android:src="@drawable/download_btn_selector"/>
+ </LinearLayout>
+
+</ScrollView>
diff --git a/api/android/lib/res/values/dimen.xml b/api/android/lib/res/values/dimen.xml
new file mode 100644
index 0000000000..7e88b862cf
--- /dev/null
+++ b/api/android/lib/res/values/dimen.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="margin_large">24dp</dimen>
+ <dimen name="margin_mid">12dp</dimen>
+</resources>
diff --git a/api/android/lib/res/values/strings.xml b/api/android/lib/res/values/strings.xml
new file mode 100644
index 0000000000..d3981d2203
--- /dev/null
+++ b/api/android/lib/res/values/strings.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="downolad_url">http://www.mapswithme.com/get/</string>
+ <string name="mapswithme">MapsWithMe</string>
+ <string name="dlg_title">We have partnered with <b><font fgcolor="#ff70B82A">MapsWithMe</font></b> to provide you with offline maps of the entire world.</string>
+ <string name="download_please">To continue please\ndownload the app</string>
+</resources>
diff --git a/api/android/lib/src/com/mapswithme/maps/api/DownloadMapsWithMeDialog.java b/api/android/lib/src/com/mapswithme/maps/api/DownloadMapsWithMeDialog.java
new file mode 100644
index 0000000000..648e473687
--- /dev/null
+++ b/api/android/lib/src/com/mapswithme/maps/api/DownloadMapsWithMeDialog.java
@@ -0,0 +1,37 @@
+package com.mapswithme.maps.api;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.view.View;
+
+import com.mapwithme.maps.api.R;
+
+public class DownloadMapsWithMeDialog extends Dialog implements android.view.View.OnClickListener
+{
+
+ public DownloadMapsWithMeDialog(Context context)
+ {
+ super(context);
+
+ setTitle(R.string.mapswithme);
+ setContentView(R.layout.dlg_install_mwm);
+ findViewById(R.id.download).setOnClickListener(this);
+ }
+
+
+ public void onDownloadButtonClicked(){
+ Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(getContext().getString(R.string.downolad_url)));
+ getContext().startActivity(i);
+ dismiss();
+ }
+
+
+ @Override
+ public void onClick(View v)
+ {
+ if (v.getId() == R.id.download)
+ onDownloadButtonClicked();
+ }
+}
diff --git a/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java b/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java
index f456b211cc..99cac09135 100644
--- a/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java
+++ b/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java
@@ -1,15 +1,15 @@
package com.mapswithme.maps.api;
+import java.util.Locale;
+
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
-import android.widget.Toast;
-
-import java.util.Locale;
//TODO add javadoc for public interface
public final class MapsWithMeApi
@@ -20,7 +20,7 @@ public final class MapsWithMeApi
/**
* Shows single point on the map.
- *
+ *
* @param caller
* @param lat
* @param lon
@@ -30,12 +30,12 @@ public final class MapsWithMeApi
{
showPointsOnMap(caller, (String)null, (PendingIntent)null, new MWMPoint(lat, lon, name));
}
-
-
- /**
- * Shows single point on the map using specified
+
+
+ /**
+ * Shows single point on the map using specified
* zoom level in range from {@link MapsWithMeApi#ZOOM_MIN} to {@link MapsWithMeApi#ZOOM_MAX}.
- *
+ *
* @param caller
* @param lat
* @param lon
@@ -49,7 +49,7 @@ public final class MapsWithMeApi
/**
* Shows set of points on the map.
- *
+ *
* @param caller
* @param title
* @param points
@@ -62,7 +62,7 @@ public final class MapsWithMeApi
/**
* Shows set of points on the maps
* and allows MapsWithMeApplication to send {@link PendingIntent} provided by client application.
- *
+ *
* @param caller
* @param title
* @param pendingIntent
@@ -72,11 +72,11 @@ public final class MapsWithMeApi
{
showPointsOnMap(caller, title, -1, pendingIntent, points);
}
-
+
/**
* Detects if any version (Lite, Pro) of MapsWithMe, which supports
* API calls are installed on the device.
- *
+ *
* @param context
* @return
*/
@@ -85,16 +85,16 @@ public final class MapsWithMeApi
final Intent intent = new Intent(Const.ACTION_MWM_REQUEST);
return context.getPackageManager().resolveActivity(intent, 0) != null;
}
-
- // Internal only code
-
+
+ // Internal only code
+
private static void showPointsOnMap(Activity caller, String title, double zoomLevel, PendingIntent pendingIntent, MWMPoint... points)
{
final Intent mwmIntent = new Intent(Const.ACTION_MWM_REQUEST);
-
+
mwmIntent.putExtra(Const.EXTRA_URL, createMwmUrl(caller, title, zoomLevel, points).toString());
mwmIntent.putExtra(Const.EXTRA_TITLE, title);
-
+
final boolean hasIntent = pendingIntent != null;
mwmIntent.putExtra(Const.EXTRA_HAS_PENDING_INTENT, hasIntent);
if (hasIntent)
@@ -109,11 +109,13 @@ public final class MapsWithMeApi
mwmIntent.setClassName(aInfo.packageName, aInfo.name);
caller.startActivity(mwmIntent);
}
- //TODO this is temporally solution, add dialog
- else
- Toast.makeText(caller, "MapsWithMe is not installed.", Toast.LENGTH_LONG).show();
+ else
+ {
+ final DownloadMapsWithMeDialog dialog = new DownloadMapsWithMeDialog(caller);
+ dialog.show();
+ }
}
-
+
static StringBuilder createMwmUrl(Context context, String title, double zoomLevel, MWMPoint ... points)
{
StringBuilder urlBuilder = new StringBuilder("mapswithme://map?");
@@ -129,20 +131,20 @@ public final class MapsWithMeApi
appendIfNotNull(urlBuilder, "appname", title);
// zoom
appendIfNotNull(urlBuilder, "z", isValidZoomLevel(zoomLevel) ? String.valueOf(zoomLevel) : null);
-
+
// points
for (MWMPoint point : points)
{
if (point != null)
- {
+ {
urlBuilder.append("ll=")
.append(String.format(Locale.US, "%f,%f&", point.getLat(), point.getLon()));
-
+
appendIfNotNull(urlBuilder, "n", point.getName());
appendIfNotNull(urlBuilder, "u", point.getId());
}
}
-
+
return urlBuilder;
}
@@ -151,14 +153,14 @@ public final class MapsWithMeApi
return Const.CALLBACK_PREFIX + context.getPackageName();
}
- private static Intent addCommonExtras(Context context, Intent intent)
+ @SuppressLint("NewApi") private static Intent addCommonExtras(Context context, Intent intent)
{
intent.putExtra(Const.EXTRA_CALLER_APP_INFO, context.getApplicationInfo());
intent.putExtra(Const.EXTRA_API_VERSION, Const.API_VERSION);
return intent;
}
-
+
private static StringBuilder appendIfNotNull(StringBuilder builder, String key, String value)
{
if (value != null)
@@ -166,10 +168,10 @@ public final class MapsWithMeApi
.append("=")
.append(Uri.encode(value))
.append("&");
-
+
return builder;
}
-
+
private static boolean isValidZoomLevel(double zoom)
{
return zoom >= ZOOM_MIN && zoom <= ZOOM_MAX;