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
diff options
context:
space:
mode:
authorDmitry Kunin <dkunin@mapswith.me>2013-09-18 13:50:49 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:02:16 +0300
commitef78f7f60a076aa4f7b4098e4d319f4ca9ee8b78 (patch)
tree8a1d9cb3bae9ee096558f06d8d063f324ee90db3
parent69af634fbf1ffe88aff2f022ae79ab4f3b39218c (diff)
[and, yota] Mwm call to Yopme
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp16
-rw-r--r--android/res/drawable-xhdpi/ic_ptb_gray.pngbin0 -> 1478 bytes
-rw-r--r--android/res/drawable-xhdpi/ic_ptb_white.pngbin0 -> 1344 bytes
-rw-r--r--android/res/layout/fragment_map_object.xml7
-rw-r--r--android/res/layout/map.xml27
-rw-r--r--android/res/values/prefs_names.xml1
-rw-r--r--android/res/xml/preferences.xml7
-rw-r--r--android/src/com/mapswithme/maps/Framework.java1
-rw-r--r--android/src/com/mapswithme/maps/MWMActivity.java34
-rw-r--r--android/src/com/mapswithme/maps/MapObjectFragment.java30
-rw-r--r--android/src/com/mapswithme/maps/settings/SettingsActivity.java30
-rw-r--r--android/src/com/mapswithme/util/Yota.java72
12 files changed, 209 insertions, 16 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index 2faeb68c95..3aa45bae9a 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -858,4 +858,20 @@ extern "C"
return static_cast<jint>(g_framework->NativeFramework()->GetDrawScale());
}
+ JNIEXPORT jdoubleArray Java_com_mapswithme_maps_Framework_getScreenRectCenter(JNIEnv * env, jclass clazz)
+ {
+ const m2::PointD center = g_framework
+ ->NativeFramework()
+ ->GetNavigator()
+ .Screen()
+ .GlobalRect()
+ .GlobalCenter();
+
+ double latlon[] = {MercatorBounds::YToLat(center.y), MercatorBounds::XToLon(center.x)};
+ jdoubleArray jLatLon = env->NewDoubleArray(2);
+ env->SetDoubleArrayRegion(jLatLon, 0, 2, latlon);
+
+ return jLatLon;
+ }
+
}
diff --git a/android/res/drawable-xhdpi/ic_ptb_gray.png b/android/res/drawable-xhdpi/ic_ptb_gray.png
new file mode 100644
index 0000000000..1b921a4209
--- /dev/null
+++ b/android/res/drawable-xhdpi/ic_ptb_gray.png
Binary files differ
diff --git a/android/res/drawable-xhdpi/ic_ptb_white.png b/android/res/drawable-xhdpi/ic_ptb_white.png
new file mode 100644
index 0000000000..569f120dcc
--- /dev/null
+++ b/android/res/drawable-xhdpi/ic_ptb_white.png
Binary files differ
diff --git a/android/res/layout/fragment_map_object.xml b/android/res/layout/fragment_map_object.xml
index 33dde6237c..59c5e7d9da 100644
--- a/android/res/layout/fragment_map_object.xml
+++ b/android/res/layout/fragment_map_object.xml
@@ -81,6 +81,13 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_small"
android:text="@string/more_info" />
+
+ <Button
+ android:id="@+id/p2b"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/margin_small"
+ android:text="Показать на E-Ink" />
</LinearLayout>
</ScrollView> \ No newline at end of file
diff --git a/android/res/layout/map.xml b/android/res/layout/map.xml
index 825a307c51..23809f7ebf 100644
--- a/android/res/layout/map.xml
+++ b/android/res/layout/map.xml
@@ -6,7 +6,7 @@
android:id="@+id/map_surfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="bottom|center_horizontal"/>
+ android:layout_gravity="bottom|center_horizontal" />
<LinearLayout
android:id="@+id/title_bar"
@@ -41,7 +41,6 @@
android:paddingTop="@dimen/abs__action_bar_icon_vertical_padding"
android:scaleType="fitStart"
tools:ignore="ContentDescription" />
-
</LinearLayout>
<TextView
@@ -98,24 +97,24 @@
android:src="@drawable/myposition_button_normal" />
<ImageButton
- android:id="@+id/map_button_download"
+ android:id="@+id/map_button_search"
style="@style/Widget.MapButtonBottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
- android:contentDescription="@string/download_maps"
- android:onClick="onDownloadClicked"
- android:src="@drawable/download_button" />
+ android:contentDescription="@string/search_map"
+ android:onClick="onSearchClicked"
+ android:src="@drawable/search_button" />
<ImageButton
- android:id="@+id/map_button_search"
+ android:id="@+id/map_button_download"
style="@style/Widget.MapButtonBottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
- android:contentDescription="@string/search_map"
- android:onClick="onSearchClicked"
- android:src="@drawable/search_button" />
+ android:contentDescription="@string/download_maps"
+ android:onClick="onDownloadClicked"
+ android:src="@drawable/download_button" />
<ImageButton
android:id="@+id/map_button_bookmarks"
@@ -126,6 +125,14 @@
android:contentDescription="@string/bookmarks"
android:onClick="onBookmarksClicked"
android:src="@drawable/bookmarks_button" />
+
+ <ImageButton
+ android:id="@+id/yop_it"
+ style="@style/Widget.MapButtonBottom"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:src="@drawable/ic_ptb_white" />
</LinearLayout>
</merge> \ No newline at end of file
diff --git a/android/res/values/prefs_names.xml b/android/res/values/prefs_names.xml
index bc16217f55..2944499c4a 100644
--- a/android/res/values/prefs_names.xml
+++ b/android/res/values/prefs_names.xml
@@ -4,5 +4,6 @@
<string name="pref_allow_stat">AllowStat</string>
<string name="pref_munits">MeasurementUnits</string>
<string name="pref_storage_activity">StorageActivity</string>
+ <string name="pref_yota">Yota</string>
</resources> \ No newline at end of file
diff --git a/android/res/xml/preferences.xml b/android/res/xml/preferences.xml
index dc1033b669..62615e56f6 100644
--- a/android/res/xml/preferences.xml
+++ b/android/res/xml/preferences.xml
@@ -18,4 +18,9 @@
android:summary="@string/allow_statistics_hint"
android:title="@string/allow_statistics" />
-</PreferenceScreen>
+ <Preference
+ android:key="@string/pref_yota"
+ android:summary="Some preferences for Yopme"
+ android:title="How to Yop It" />
+
+</PreferenceScreen> \ No newline at end of file
diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java
index 572c6d65a6..e7af107f03 100644
--- a/android/src/com/mapswithme/maps/Framework.java
+++ b/android/src/com/mapswithme/maps/Framework.java
@@ -86,6 +86,7 @@ public class Framework
public native static boolean wasAdvertised(String appId);
public native static int getDrawScale();
+ public native static double[] getScreenRectCenter();
/*
* "Implementation" - native methods
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java
index 4b64cf0b04..f07ae78e3f 100644
--- a/android/src/com/mapswithme/maps/MWMActivity.java
+++ b/android/src/com/mapswithme/maps/MWMActivity.java
@@ -45,7 +45,9 @@ import com.mapswithme.maps.promo.PromocodeActivationDialog;
import com.mapswithme.maps.settings.UnitLocale;
import com.mapswithme.maps.state.SuppotedState;
import com.mapswithme.util.ConnectionState;
+import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
+import com.mapswithme.util.Yota;
import com.nvidia.devtech.NvEventQueueActivity;
public class MWMActivity extends NvEventQueueActivity implements LocationService.Listener, OnBalloonListener
@@ -66,6 +68,8 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
private ImageButton mMyPositionButton;
private SurfaceView mMapSurface;
+ private View mYopItButton;
+
// for API
private View mTitleBar;
private ImageView mAppIcon;
@@ -582,6 +586,8 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
mAppTitle = (TextView) findViewById(R.id.app_title);
mMapSurface = (SurfaceView) findViewById(R.id.map_surfaceview);
+ yotaSetup();
+
alignZoomButtons();
Framework.connectBalloonListeners(this);
@@ -592,6 +598,34 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
addTask(intent);
}
+ private void yotaSetup()
+ {
+ // yota setup
+ mYopItButton = findViewById(R.id.yop_it);
+ if (!Yota.isYota())
+ UiUtils.hide(mYopItButton);
+ else
+ {
+ mYopItButton.setOnClickListener(new OnClickListener()
+ {
+
+ @Override
+ public void onClick(View v)
+ {
+ final double[] latLon = Framework.getScreenRectCenter();
+ final double zoom = Framework.getDrawScale();
+
+ final LocationState locState = mApplication.getLocationState();
+
+ if (locState.hasPosition() && locState.isCentered())
+ Yota.showLocation(getApplicationContext(), zoom);
+ else
+ Yota.showPoi(getApplicationContext(), latLon[0], latLon[1], zoom, "", locState.hasPosition());
+ }
+ });
+ }
+ }
+
@Override
public void onDestroy()
{
diff --git a/android/src/com/mapswithme/maps/MapObjectFragment.java b/android/src/com/mapswithme/maps/MapObjectFragment.java
index 1debf6c8d4..ddaf19a637 100644
--- a/android/src/com/mapswithme/maps/MapObjectFragment.java
+++ b/android/src/com/mapswithme/maps/MapObjectFragment.java
@@ -32,6 +32,7 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.util.ShareAction;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
+import com.mapswithme.util.Yota;
@SuppressLint("NewApi")
public class MapObjectFragment extends Fragment
@@ -59,6 +60,7 @@ public class MapObjectFragment extends Fragment
private Button mEditBmk;
private Button mShare;
private Button mOpenWith;
+ private Button mYotaP2B;
//POI, API
@@ -202,6 +204,7 @@ public class MapObjectFragment extends Fragment
mEditBmk = (Button) view.findViewById(R.id.editBookmark);
mOpenWith = (Button) view.findViewById(R.id.openWith);
mShare = (Button) view.findViewById(R.id.share);
+ mYotaP2B = (Button) view.findViewById(R.id.p2b);
// set up listeners, drawables, visibility
mAddToBookmarks.setOnClickListener(this);
@@ -221,9 +224,29 @@ public class MapObjectFragment extends Fragment
UiUtils.show(mShare);
}
+ yotaSetup();
+
return view;
}
+ private void yotaSetup()
+ {
+ if (!Yota.isYota())
+ UiUtils.hide(mYotaP2B);
+ else
+ {
+ mYotaP2B.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ final boolean addLastKnown = MWMApplication.get().getLocationState().hasPosition();
+ Yota.showPoi(getActivity(), mLat, mLon, Framework.getDrawScale(), mName, addLastKnown);
+ }
+ });
+ }
+ }
+
@Override
public void onResume()
{
@@ -336,6 +359,13 @@ public class MapObjectFragment extends Fragment
Utils.addMenuCompat(menu, MENU_ADD, MENU_ADD, R.string.add_to_bookmarks, R.drawable.add_bookmark);
Utils.addMenuCompat(menu, MENU_SHARE, MENU_SHARE, R.string.share, R.drawable.share);
+
+// if (Yota.isYota())
+// {
+// menu.add(Menu.NONE, 0, 999, "Yota")
+// .setIcon(R.drawable.ic_ptb_gray)
+// .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+// }
}
@Override
diff --git a/android/src/com/mapswithme/maps/settings/SettingsActivity.java b/android/src/com/mapswithme/maps/settings/SettingsActivity.java
index 22c3409a20..aa6adc0abf 100644
--- a/android/src/com/mapswithme/maps/settings/SettingsActivity.java
+++ b/android/src/com/mapswithme/maps/settings/SettingsActivity.java
@@ -17,6 +17,7 @@ import android.view.inputmethod.InputMethodManager;
import com.mapswithme.maps.R;
import com.mapswithme.util.Utils;
+import com.mapswithme.util.Yota;
import com.mapswithme.util.statistics.Statistics;
public class SettingsActivity extends PreferenceActivity
@@ -33,7 +34,7 @@ public class SettingsActivity extends PreferenceActivity
if (Utils.apiEqualOrGreaterThan(11))
{
// http://stackoverflow.com/questions/6867076/getactionbar-returns-null
- ActionBar bar = getActionBar();
+ final ActionBar bar = getActionBar();
if (bar != null)
bar.setDisplayHomeAsUpEnabled(true);
}
@@ -42,7 +43,7 @@ public class SettingsActivity extends PreferenceActivity
final Activity parent = this;
- Preference pref = findPreference(getString(R.string.pref_storage_activity));
+ final Preference pref = findPreference(getString(R.string.pref_storage_activity));
pref.setOnPreferenceClickListener(new OnPreferenceClickListener()
{
@Override
@@ -74,7 +75,7 @@ public class SettingsActivity extends PreferenceActivity
}
});
- ListPreference lPref = (ListPreference) findPreference(getString(R.string.pref_munits));
+ final ListPreference lPref = (ListPreference) findPreference(getString(R.string.pref_munits));
lPref.setValue(String.valueOf(UnitLocale.getUnits()));
lPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
@@ -88,7 +89,7 @@ public class SettingsActivity extends PreferenceActivity
});
- CheckBoxPreference allowStatsPreference = (CheckBoxPreference) findPreference(getString(R.string.pref_allow_stat));
+ final CheckBoxPreference allowStatsPreference = (CheckBoxPreference) findPreference(getString(R.string.pref_allow_stat));
allowStatsPreference.setChecked(Statistics.INSTANCE.isStatisticsEnabled(this));
allowStatsPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
{
@@ -99,6 +100,25 @@ public class SettingsActivity extends PreferenceActivity
return true;
}
});
+
+ yotaSetup();
+ }
+
+ private void yotaSetup()
+ {
+ final Preference yopPreference = findPreference(getString(R.string.pref_yota));
+ if (!Yota.isYota())
+ getPreferenceScreen().removePreference(yopPreference);
+ else
+ yopPreference.setOnPreferenceClickListener(new OnPreferenceClickListener()
+ {
+ @Override
+ public boolean onPreferenceClick(Preference preference)
+ {
+ SettingsActivity.this.startActivity(new Intent(Yota.ACTION_PREFERENCE));
+ return true;
+ }
+ });
}
@Override
@@ -122,7 +142,7 @@ public class SettingsActivity extends PreferenceActivity
{
if (item.getItemId() == android.R.id.home)
{
- InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
+ final InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
onBackPressed();
return true;
diff --git a/android/src/com/mapswithme/util/Yota.java b/android/src/com/mapswithme/util/Yota.java
new file mode 100644
index 0000000000..1698e086cd
--- /dev/null
+++ b/android/src/com/mapswithme/util/Yota.java
@@ -0,0 +1,72 @@
+package com.mapswithme.util;
+
+import com.mapswithme.maps.MWMApplication;
+
+import android.content.Context;
+import android.content.Intent;
+import android.location.Location;
+import android.os.Build;
+
+public class Yota
+{
+ public static boolean isYota()
+ {
+ return Build.DEVICE.contains("yotaphone");
+ }
+
+ private final static String YOPME_AUTHORITY = "com.mapswithme.yopme";
+ public final static String ACTION_PREFERENCE = YOPME_AUTHORITY + ".preference";
+ public final static String ACTION_SHOW_RECT = YOPME_AUTHORITY + ".show_rect";
+ public final static String ACTION_LOCATION = YOPME_AUTHORITY + ".location";
+
+ public final static String EXTRA_LAT = YOPME_AUTHORITY + ".lat";
+ public final static String EXTRA_LON = YOPME_AUTHORITY + ".lon";
+ public final static String EXTRA_ZOOM = YOPME_AUTHORITY + ".zoom";
+ public final static String EXTRA_NAME = YOPME_AUTHORITY + ".name";
+ public final static String EXTRA_MODE = YOPME_AUTHORITY + ".mode";
+
+ public final static String EXTRA_HAS_LOCATION = YOPME_AUTHORITY + ".haslocation";
+ public final static String EXTRA_MY_LAT = YOPME_AUTHORITY + ".mylat";
+ public final static String EXTRA_MY_LON = YOPME_AUTHORITY + ".mylon";
+
+
+
+ public static void showLocation(Context context, double zoom)
+ {
+ final Intent locationYotaIntent = populateIntent(ACTION_LOCATION, 0, 0, zoom, null, true);
+ context.startService(locationYotaIntent);
+ }
+
+ public static void showPoi(Context context, double lat, double lon, double zoom, String name, boolean addLastKnown)
+ {
+ final Intent poiYotaIntent = populateIntent(ACTION_SHOW_RECT, lat, lon, zoom, name, addLastKnown);
+ context.startService(poiYotaIntent);
+ }
+
+ private static Intent populateIntent(String action, double lat, double lon,
+ double zoom, String name, boolean addLastKnow)
+ {
+ final Intent i = new Intent(action)
+ .putExtra(EXTRA_LAT, lat)
+ .putExtra(EXTRA_LON, lon)
+ .putExtra(EXTRA_ZOOM, zoom)
+ .putExtra(EXTRA_NAME, name);
+
+ if (addLastKnow)
+ {
+ final Location lastLocation = MWMApplication.get().getLocationService().getLastKnown();
+ if (lastLocation != null)
+ {
+ i.putExtra(EXTRA_HAS_LOCATION, true)
+ .putExtra(EXTRA_MY_LAT, lastLocation.getLatitude())
+ .putExtra(EXTRA_MY_LON, lastLocation.getLongitude());
+ }
+ else
+ i.putExtra(EXTRA_HAS_LOCATION, false);
+ }
+
+ return i;
+ }
+
+ private Yota() {};
+}