diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java
index d880e93448..69b9b99582 100644
--- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java
+++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java
@@ -17,7 +17,6 @@ public class ToDoConstants {
// TODO ANDROID
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions.
// Some icons are not fine (as back menu from map - it is blured).
- // Got by Andrei
// 60. Audio guidance for routing
@@ -40,13 +39,13 @@ public class ToDoConstants {
// FIXME BUGS Android
// double tap to zoom [done]
+ // forbid rotate map to landscape [ done]
+
// REFACTOR Settings activity ( for check box properties!)
- // Fix bugs with test data (bug with follow turn / left time / add turn)
// show POI choose near by or last map selection.
// Show poi direction (using sensor)
-
// hide center point (enable only when trackball using)
- // forbid rotate map to landscape
+ // Fix bugs with test data (bug with follow turn / left time / add turn)
// Improvement : Show stops in the transport route
// TODO swing
diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index 400a7f82d7..d540a38e9e 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/OsmAnd/res/values-ru-rRU/strings.xml b/OsmAnd/res/values-ru-rRU/strings.xml
index a5645a2e9b..1a1623c792 100644
--- a/OsmAnd/res/values-ru-rRU/strings.xml
+++ b/OsmAnd/res/values-ru-rRU/strings.xml
@@ -1,5 +1,10 @@
+ По умолчанию
+ Портрет
+ Пейзаж
+ Ориентация экрана
+ Выберите ориентацию экрана
Формат времени работы не поддерживается для редактирования
Новое правило
Маршруты
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 67295670bd..db18ebd134 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -1,5 +1,10 @@
+ Default
+ Portrait
+ Landscape
+ Map screen orientation
+ Choose screen orientation
Opening hours format is not supported for editing
Add new rule
Routes
diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml
index df905f55fa..b0c7c875ab 100644
--- a/OsmAnd/res/xml/settings_pref.xml
+++ b/OsmAnd/res/xml/settings_pref.xml
@@ -13,6 +13,7 @@
+
diff --git a/OsmAnd/src/com/osmand/OsmandSettings.java b/OsmAnd/src/com/osmand/OsmandSettings.java
index 1f6e87604b..48556cf7c8 100644
--- a/OsmAnd/src/com/osmand/OsmandSettings.java
+++ b/OsmAnd/src/com/osmand/OsmandSettings.java
@@ -5,6 +5,7 @@ import java.util.List;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
+import android.content.pm.ActivityInfo;
import com.osmand.activities.RouteProvider.RouteService;
import com.osmand.activities.search.SearchHistoryHelper;
@@ -165,7 +166,15 @@ public class OsmandSettings {
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.getBoolean(SHOW_OSM_BUGS, false);
}
-
+
+ // this value string is synchronized with settings_pref.xml preference name
+ public static final String MAP_SCREEN_ORIENTATION = "map_screen_orientation"; //$NON-NLS-1$
+
+ public static int getMapOrientation(Context ctx){
+ SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
+ return prefs.getInt(MAP_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ }
+
// this value string is synchronized with settings_pref.xml preference name
public static final String SHOW_VIEW_ANGLE = "show_view_angle"; //$NON-NLS-1$
diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java
index 7f5c2a7381..43dbb8b2c8 100644
--- a/OsmAnd/src/com/osmand/activities/MapActivity.java
+++ b/OsmAnd/src/com/osmand/activities/MapActivity.java
@@ -543,6 +543,11 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
@Override
protected void onResume() {
super.onResume();
+
+ if(OsmandSettings.getMapOrientation(this) != getRequestedOrientation()){
+ setRequestedOrientation(OsmandSettings.getMapOrientation(this));
+ }
+
// routing helper with current activity
routingHelper = RoutingHelper.getInstance(this);
if(mapView.getMap() != OsmandSettings.getMapTileSource(this)){
diff --git a/OsmAnd/src/com/osmand/activities/SettingsActivity.java b/OsmAnd/src/com/osmand/activities/SettingsActivity.java
index 34c1c01f80..729badcb85 100644
--- a/OsmAnd/src/com/osmand/activities/SettingsActivity.java
+++ b/OsmAnd/src/com/osmand/activities/SettingsActivity.java
@@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
+import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@@ -51,6 +52,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private ListPreference routerPreference;
private ListPreference maxLevelToDownload;
private CheckBoxPreference showTransport;
+ private ListPreference mapScreenOrientation;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -98,6 +100,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
positionOnMap =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
positionOnMap.setOnPreferenceChangeListener(this);
+ mapScreenOrientation =(ListPreference) screen.findPreference(OsmandSettings.MAP_SCREEN_ORIENTATION);
+ mapScreenOrientation.setOnPreferenceChangeListener(this);
maxLevelToDownload =(ListPreference) screen.findPreference(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE);
maxLevelToDownload.setOnPreferenceChangeListener(this);
tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES);
@@ -123,14 +127,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
saveTrackToGpx.setChecked(OsmandSettings.isSavingTrackToGpx(this));
useEnglishNames.setChecked(OsmandSettings.usingEnglishNames(this));
autoZoom.setChecked(OsmandSettings.isAutoZoomEnabled(this));
+ userName.setText(OsmandSettings.getUserName(this));
+ userPassword.setText(OsmandSettings.getUserPassword(this));
+
Resources resources = this.getResources();
String[] e = new String[] {resources.getString(R.string.position_on_map_center),
resources.getString(R.string.position_on_map_bottom)};
positionOnMap.setEntryValues(e);
positionOnMap.setEntries(e);
positionOnMap.setValueIndex(OsmandSettings.getPositionOnMap(this));
- userName.setText(OsmandSettings.getUserName(this));
- userPassword.setText(OsmandSettings.getUserPassword(this));
+
saveTrackInterval.setEntries(new String[]{
resources.getString(R.string.interval_1_second),
@@ -143,6 +149,17 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
saveTrackInterval.setEntryValues(new String[]{"1", "2", "5", "15", "30", "60", "300"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
saveTrackInterval.setValue(OsmandSettings.getSavingTrackInterval(this)+""); //$NON-NLS-1$
+
+
+ mapScreenOrientation.setEntries(new String[]{
+ resources.getString(R.string.map_orientation_portrait),
+ resources.getString(R.string.map_orientation_landscape),
+ resources.getString(R.string.map_orientation_default),
+ });
+ mapScreenOrientation.setEntryValues(new String[]{ActivityInfo.SCREEN_ORIENTATION_PORTRAIT+"", //$NON-NLS-1$
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE+"", ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED+""}); //$NON-NLS-1$ //$NON-NLS-2$
+ mapScreenOrientation.setValue(OsmandSettings.getMapOrientation(this)+""); //$NON-NLS-1$
+
ApplicationMode[] presets = ApplicationMode.values();
String[] values = new String[presets.length];
String[] valueEntries = new String[presets.length];
@@ -226,6 +243,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if(preference == saveTrackToGpx){
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, (Boolean) newValue);
edit.commit();
+ } else if(preference == mapScreenOrientation){
+ edit.putInt(OsmandSettings.MAP_SCREEN_ORIENTATION, Integer.parseInt(newValue.toString()));
+ edit.commit();
} else if(preference == saveTrackInterval){
edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, Integer.parseInt(newValue.toString()));
edit.commit();
diff --git a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java
index 01c27d4c09..8229918ab2 100644
--- a/OsmAnd/src/com/osmand/views/OsmandMapTileView.java
+++ b/OsmAnd/src/com/osmand/views/OsmandMapTileView.java
@@ -3,6 +3,8 @@ package com.osmand.views;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
@@ -11,6 +13,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -593,24 +596,78 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override
public boolean onTouchEvent(MotionEvent event) {
-// dumpEvent(event);
+// checkMultiTouchEvent(event);
/*return */ gestureDetector.onTouchEvent(event);
return true;
}
- private void dumpEvent(MotionEvent event) {
- String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,
- "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" };
- StringBuilder sb = new StringBuilder();
- int action = event.getAction();
- int actionCode = action & 255;
- sb.append("event ACTION_" ).append(names[actionCode]);
- if (actionCode == 5
- || actionCode == 6) {
- sb.append("(pid " ).append(action >> 8);
- sb.append(")" );
- }
- sb.append("[" );
+ private static Pattern x2Pattern = Pattern.compile("x2=([0-9]+)"); //$NON-NLS-1$
+ private static Pattern y2Pattern = Pattern.compile("y2=([0-9]+)"); //$NON-NLS-1$
+ private int lastX2 = 0;
+ private int lastY2 = 0;
+ private PointF mtStart = null;
+ private PointF mtStart2 = null;
+ private int mtZoom = 0;
+ private float mtDist = 0;
+ private boolean checkMultiTouchEvent(MotionEvent event) {
+ String str = event.toString();
+ Matcher m = x2Pattern.matcher(str);
+// log.debug(str);
+ if(m.find()){
+ int x2= Integer.parseInt(m.group(1));
+ m = y2Pattern.matcher(str);
+ if(m.find()){
+ int y2= Integer.parseInt(m.group(1));
+ if (x2 != lastX2 && y2 != lastY2) {
+ float dx = x2 - event.getX();
+ float dy = y2 - event.getY();
+ float dist = FloatMath.sqrt(dx*dx+dy*dy);
+ if (dist > 0) {
+ if (mtStart == null) {
+ mtStart = new PointF(event.getX(), event.getY());
+ mtStart2 = new PointF(x2, y2);
+ mtZoom = zoom;
+ mtDist = dist;
+ log.debug("Multitouch dist="+mtDist);
+ } else {
+ if(dist < mtDist){
+ dist *= 0.6f;
+ } else {
+ dist *= 1.3f;
+ }
+ int dz = (int) (Math.log(dist/mtDist) / Math.log(2));
+ log.debug("Mt dist=" +dist);
+ if (mtZoom + dz != zoom) {
+ setZoom(mtZoom + dz);
+ }
+ }
+ lastX2 = x2;
+ lastY2 = y2;
+// log.debug("Multi touch x=" + event.getX() + " y=" + event.getY() + " x2=" + x2 + " y2=" + y2 + " dist="
+// + dist +" mt="+mtDist);
+ }
+ return true;
+ } else if(event.getAction() == MotionEvent.ACTION_UP){
+ log.debug("UP");
+ mtStart = null;
+ mtStart2 = null;
+ return true;
+ }
+ }
+ }
+ return mtStart != null;
+// String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,
+// "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" };
+// StringBuilder sb = new StringBuilder();
+// int action = event.getAction();
+// int actionCode = action & 255;
+// sb.append("event ACTION_" ).append(names[actionCode]);
+// if (actionCode == 5
+// || actionCode == 6) {
+// sb.append("(pid " ).append(action >> 8);
+// sb.append(")" );
+// }
+// sb.append("[" );
// for (int i = 0; i < event.getPointerCount(); i++) {
// sb.append("#" ).append(i);
// sb.append("(pid " ).append(event.getPointerId(i));
@@ -619,8 +676,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
// if (i + 1 < event.getPointerCount())
// sb.append(";" );
// }
- sb.append("]" );
- android.util.Log.d("com.osmand", sb.toString());
}
@@ -662,12 +717,18 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
+ if(mtStart != null){
+ return true;
+ }
animatedDraggingThread.startDragging(Math.abs(velocityX/1000), Math.abs(velocityY/1000), e1.getX(), e1.getY(), e2.getX(), e2.getY());
return true;
}
@Override
public void onLongPress(MotionEvent e) {
+ if(mtStart != null){
+ return;
+ }
if(log.isDebugEnabled()){
log.debug("On long click event "+ e.getX() + " " + e.getY()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -684,7 +745,11 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
+ if(mtStart != null){
+ return true;
+ }
dragTo(e2.getX() + distanceX, e2.getY() + distanceY, e2.getX(), e2.getY());
+
return true;
}
@@ -694,6 +759,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override
public boolean onSingleTapUp(MotionEvent e) {
+ if(mtStart != null){
+ return true;
+ }
PointF point = new PointF(e.getX(), e.getY());
if(log.isDebugEnabled()){
log.debug("On click event "+ point.x + " " + point.y); //$NON-NLS-1$ //$NON-NLS-2$