fix small issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@288 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-06 09:00:32 +00:00
parent b411d48e3a
commit f186f7bc9d
9 changed files with 136 additions and 24 deletions

View file

@ -17,7 +17,6 @@ public class ToDoConstants {
// TODO ANDROID // TODO ANDROID
// 42. Revise UI (icons/layouts). Support different devices. Add inactive/focus(!) icon versions. // 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). // Some icons are not fine (as back menu from map - it is blured).
// Got by Andrei
// 60. Audio guidance for routing // 60. Audio guidance for routing
@ -40,13 +39,13 @@ public class ToDoConstants {
// FIXME BUGS Android // FIXME BUGS Android
// double tap to zoom [done] // double tap to zoom [done]
// forbid rotate map to landscape [ done]
// REFACTOR Settings activity ( for check box properties!) // 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 choose near by or last map selection.
// Show poi direction (using sensor) // Show poi direction (using sensor)
// hide center point (enable only when trackball using) // 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 // Improvement : Show stops in the transport route
// TODO swing // TODO swing

View file

@ -10,7 +10,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".activities.MapActivity" android:label="@string/app_name"></activity> <activity android:name=".activities.MapActivity" android:label="@string/app_name" android:screenOrientation="portrait"></activity>
<activity android:name=".activities.SettingsActivity" android:label="@string/settings_activity"></activity> <activity android:name=".activities.SettingsActivity" android:label="@string/settings_activity"></activity>
<activity android:name=".activities.search.SearchActivity" android:label="@string/search_activity" ></activity> <activity android:name=".activities.search.SearchActivity" android:label="@string/search_activity" ></activity>
<activity android:name=".activities.NavigatePointActivity"></activity> <activity android:name=".activities.NavigatePointActivity"></activity>

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="map_orientation_default">По умолчанию</string>
<string name="map_orientation_portrait">Портрет</string>
<string name="map_orientation_landscape">Пейзаж</string>
<string name="map_screen_orientation">Ориентация экрана</string>
<string name="map_screen_orientation_descr">Выберите ориентацию экрана</string>
<string name="opening_hours_not_supported">Формат времени работы не поддерживается для редактирования</string> <string name="opening_hours_not_supported">Формат времени работы не поддерживается для редактирования</string>
<string name="add_new_rule">Новое правило</string> <string name="add_new_rule">Новое правило</string>
<string name="transport_Routes">Маршруты</string> <string name="transport_Routes">Маршруты</string>

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="map_orientation_default">Default</string>
<string name="map_orientation_portrait">Portrait</string>
<string name="map_orientation_landscape">Landscape</string>
<string name="map_screen_orientation">Map screen orientation</string>
<string name="map_screen_orientation_descr">Choose screen orientation</string>
<string name="opening_hours_not_supported">Opening hours format is not supported for editing</string> <string name="opening_hours_not_supported">Opening hours format is not supported for editing</string>
<string name="add_new_rule">Add new rule</string> <string name="add_new_rule">Add new rule</string>
<string name="transport_Routes">Routes</string> <string name="transport_Routes">Routes</string>

View file

@ -13,6 +13,7 @@
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference> <CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
<CheckBoxPreference android:key="show_view_angle" android:title="@string/show_view_angle" android:summary="@string/show_view_angle_descr"></CheckBoxPreference> <CheckBoxPreference android:key="show_view_angle" android:title="@string/show_view_angle" android:summary="@string/show_view_angle_descr"></CheckBoxPreference>
<CheckBoxPreference android:key="rotate_map_to_bearing" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></CheckBoxPreference> <CheckBoxPreference android:key="rotate_map_to_bearing" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></CheckBoxPreference>
<ListPreference android:key="map_screen_orientation" android:title="@string/map_screen_orientation" android:summary="@string/map_screen_orientation_descr"></ListPreference>
<ListPreference android:key="position_on_map" android:title="@string/position_on_map" android:summary="@string/position_on_map_descr"></ListPreference> <ListPreference android:key="position_on_map" android:title="@string/position_on_map" android:summary="@string/position_on_map_descr"></ListPreference>
</PreferenceScreen> </PreferenceScreen>

View file

@ -5,6 +5,7 @@ import java.util.List;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.content.pm.ActivityInfo;
import com.osmand.activities.RouteProvider.RouteService; import com.osmand.activities.RouteProvider.RouteService;
import com.osmand.activities.search.SearchHistoryHelper; import com.osmand.activities.search.SearchHistoryHelper;
@ -166,6 +167,14 @@ public class OsmandSettings {
return prefs.getBoolean(SHOW_OSM_BUGS, false); 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 // this value string is synchronized with settings_pref.xml preference name
public static final String SHOW_VIEW_ANGLE = "show_view_angle"; //$NON-NLS-1$ public static final String SHOW_VIEW_ANGLE = "show_view_angle"; //$NON-NLS-1$

View file

@ -543,6 +543,11 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if(OsmandSettings.getMapOrientation(this) != getRequestedOrientation()){
setRequestedOrientation(OsmandSettings.getMapOrientation(this));
}
// routing helper with current activity // routing helper with current activity
routingHelper = RoutingHelper.getInstance(this); routingHelper = RoutingHelper.getInstance(this);
if(mapView.getMap() != OsmandSettings.getMapTileSource(this)){ if(mapView.getMap() != OsmandSettings.getMapTileSource(this)){

View file

@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.content.pm.ActivityInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
@ -51,6 +52,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private ListPreference routerPreference; private ListPreference routerPreference;
private ListPreference maxLevelToDownload; private ListPreference maxLevelToDownload;
private CheckBoxPreference showTransport; private CheckBoxPreference showTransport;
private ListPreference mapScreenOrientation;
@Override @Override
public void onCreate(Bundle savedInstanceState) { 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 =(ListPreference) screen.findPreference(OsmandSettings.POSITION_ON_MAP);
positionOnMap.setOnPreferenceChangeListener(this); 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 =(ListPreference) screen.findPreference(OsmandSettings.MAX_LEVEL_TO_DOWNLOAD_TILE);
maxLevelToDownload.setOnPreferenceChangeListener(this); maxLevelToDownload.setOnPreferenceChangeListener(this);
tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES); tileSourcePreference =(ListPreference) screen.findPreference(OsmandSettings.MAP_TILE_SOURCES);
@ -123,14 +127,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
saveTrackToGpx.setChecked(OsmandSettings.isSavingTrackToGpx(this)); saveTrackToGpx.setChecked(OsmandSettings.isSavingTrackToGpx(this));
useEnglishNames.setChecked(OsmandSettings.usingEnglishNames(this)); useEnglishNames.setChecked(OsmandSettings.usingEnglishNames(this));
autoZoom.setChecked(OsmandSettings.isAutoZoomEnabled(this)); autoZoom.setChecked(OsmandSettings.isAutoZoomEnabled(this));
userName.setText(OsmandSettings.getUserName(this));
userPassword.setText(OsmandSettings.getUserPassword(this));
Resources resources = this.getResources(); Resources resources = this.getResources();
String[] e = new String[] {resources.getString(R.string.position_on_map_center), String[] e = new String[] {resources.getString(R.string.position_on_map_center),
resources.getString(R.string.position_on_map_bottom)}; resources.getString(R.string.position_on_map_bottom)};
positionOnMap.setEntryValues(e); positionOnMap.setEntryValues(e);
positionOnMap.setEntries(e); positionOnMap.setEntries(e);
positionOnMap.setValueIndex(OsmandSettings.getPositionOnMap(this)); positionOnMap.setValueIndex(OsmandSettings.getPositionOnMap(this));
userName.setText(OsmandSettings.getUserName(this));
userPassword.setText(OsmandSettings.getUserPassword(this));
saveTrackInterval.setEntries(new String[]{ saveTrackInterval.setEntries(new String[]{
resources.getString(R.string.interval_1_second), 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.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$ 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(); ApplicationMode[] presets = ApplicationMode.values();
String[] values = new String[presets.length]; String[] values = new String[presets.length];
String[] valueEntries = 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){ } else if(preference == saveTrackToGpx){
edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, (Boolean) newValue); edit.putBoolean(OsmandSettings.SAVE_TRACK_TO_GPX, (Boolean) newValue);
edit.commit(); edit.commit();
} else if(preference == mapScreenOrientation){
edit.putInt(OsmandSettings.MAP_SCREEN_ORIENTATION, Integer.parseInt(newValue.toString()));
edit.commit();
} else if(preference == saveTrackInterval){ } else if(preference == saveTrackInterval){
edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, Integer.parseInt(newValue.toString())); edit.putInt(OsmandSettings.SAVE_TRACK_INTERVAL, Integer.parseInt(newValue.toString()));
edit.commit(); edit.commit();

View file

@ -3,6 +3,8 @@ package com.osmand.views;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -11,6 +13,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
@ -593,24 +596,78 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
// dumpEvent(event); // checkMultiTouchEvent(event);
/*return */ gestureDetector.onTouchEvent(event); /*return */ gestureDetector.onTouchEvent(event);
return true; return true;
} }
private void dumpEvent(MotionEvent event) { private static Pattern x2Pattern = Pattern.compile("x2=([0-9]+)"); //$NON-NLS-1$
String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , private static Pattern y2Pattern = Pattern.compile("y2=([0-9]+)"); //$NON-NLS-1$
"POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; private int lastX2 = 0;
StringBuilder sb = new StringBuilder(); private int lastY2 = 0;
int action = event.getAction(); private PointF mtStart = null;
int actionCode = action & 255; private PointF mtStart2 = null;
sb.append("event ACTION_" ).append(names[actionCode]); private int mtZoom = 0;
if (actionCode == 5 private float mtDist = 0;
|| actionCode == 6) { private boolean checkMultiTouchEvent(MotionEvent event) {
sb.append("(pid " ).append(action >> 8); String str = event.toString();
sb.append(")" ); 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;
} }
sb.append("[" ); 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++) { // for (int i = 0; i < event.getPointerCount(); i++) {
// sb.append("#" ).append(i); // sb.append("#" ).append(i);
// sb.append("(pid " ).append(event.getPointerId(i)); // sb.append("(pid " ).append(event.getPointerId(i));
@ -619,8 +676,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
// if (i + 1 < event.getPointerCount()) // if (i + 1 < event.getPointerCount())
// sb.append(";" ); // sb.append(";" );
// } // }
sb.append("]" );
android.util.Log.d("com.osmand", sb.toString());
} }
@ -662,12 +717,18 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 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()); animatedDraggingThread.startDragging(Math.abs(velocityX/1000), Math.abs(velocityY/1000), e1.getX(), e1.getY(), e2.getX(), e2.getY());
return true; return true;
} }
@Override @Override
public void onLongPress(MotionEvent e) { public void onLongPress(MotionEvent e) {
if(mtStart != null){
return;
}
if(log.isDebugEnabled()){ if(log.isDebugEnabled()){
log.debug("On long click event "+ e.getX() + " " + e.getY()); //$NON-NLS-1$ //$NON-NLS-2$ 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 @Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { 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()); dragTo(e2.getX() + distanceX, e2.getY() + distanceY, e2.getX(), e2.getY());
return true; return true;
} }
@ -694,6 +759,9 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
@Override @Override
public boolean onSingleTapUp(MotionEvent e) { public boolean onSingleTapUp(MotionEvent e) {
if(mtStart != null){
return true;
}
PointF point = new PointF(e.getX(), e.getY()); PointF point = new PointF(e.getX(), e.getY());
if(log.isDebugEnabled()){ if(log.isDebugEnabled()){
log.debug("On click event "+ point.x + " " + point.y); //$NON-NLS-1$ //$NON-NLS-2$ log.debug("On click event "+ point.x + " " + point.y); //$NON-NLS-1$ //$NON-NLS-2$