small improvements

git-svn-id: https://osmand.googlecode.com/svn/trunk@416 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-30 17:13:28 +00:00
parent 36653a97b3
commit b95d38941c
8 changed files with 102 additions and 15 deletions

View file

@ -9,13 +9,18 @@ package com.osmand;
public class ToDoConstants {
// TODO
// 78. Add ruler to the main tile view (100m, 200m,...)
// 80. Export/import favorite points
// 81. Add some objects to POI category (1) to add them into OSM 2) to help navigation)
// highway (?), traffic_calming (?), barrier(?), military(?-), landuse (?), office(?), man_made(?), power(?).
// 84. Send letter to developer
// 84. Send letter to developer when app crashes
// TODO BUGS Android
// 2. GPS - network switch
// 3. different screens better support
// 5. route bug show further
// 4. save state yandex traffic (+)
// 1. Alert no addresses (+)
// Improvements
// ! Download with wget
@ -34,21 +39,17 @@ public class ToDoConstants {
// 63. Support simple offline routing(require new index file) (?)
// TODO BUGS Android
// 1. Alert no addresses (!)
// 2. GPS - network switch
// 3. different screens better support
// 4. save state yandex traffic
// TODO swing
// 9. Fix issues with big files (such as netherlands) - save memory (!) - very slow due to transport index !
// Current result : for big file (1 - task 60-80% time, 90% memory) (?)
// 10. Improve address indexing (use relations). (?) // SLOBODSKAYA 157
// 10. Improve address indexing (use relations). (?) // SLOBODSKAYA 157, 95
// use relation "a6" (to accumulate streets!), "a3" to read all cities & define boundaries for city (& define that street in city).
// BUGS Swing
// DONE ANDROID :
// 78. Add ruler to the main tile view (100m, 200m,...) (+)
// 82. Add overzoom +2 for Mapnik
// 64. Traffic information - yandex traffic
// 79. Download any WMS layer and add to swing version (add tile manager ${x}, ${y}, ${z} to swing and to android)

View file

@ -5,7 +5,7 @@
android:layout_height="fill_parent">
<com.osmand.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent"></com.osmand.views.OsmandMapTileView>
<com.osmand.views.OsmZoomControls android:id="@+id/ZoomControls"
android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="bottom|right">></com.osmand.views.OsmZoomControls >
android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="bottom|right"/>
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|left" android:id="@+id/BackToMenu" android:background="@drawable/back_menu"></ImageButton>
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|right" android:id="@+id/BackToLocation" android:background="@drawable/back_location"></ImageButton>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="none_region_found">Не найден ни один индекс на SD карточке. Можете загрузить их с интернета.</string>
<string name="poi_namefinder_query_empty">Введите запрос для поиска POI</string>
<string name="any_poi">Все</string>
<string name="layer_transport_route">Маршрут на транспорте</string>
@ -257,7 +258,7 @@
<string name="incremental_search_city">Выберите город. Введите 3 первых буквы, чтобы найти деревню, 2 цифры - индекс.</string>
<string name="incremental_search_street">Выберите улицу</string>
<string name="incremental_search_building">Выберите здание</string>
<string name="choose_available_region">Выберите регион</string>
<string name="choose_available_region">Выберите регион из списка</string>
<string name="choose_intersected_street">Выберите пересечение улиц</string>
<string name="Closest_Amenities">Closest amenities</string>
<string name="app_mode_default">По умолчанию</string>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="none_region_found">None region were found on SD card. Try to download region from internet.</string>
<string name="poi_namefinder_query_empty">Input search query to find POI</string>
<string name="any_poi">Any</string>
<string name="layer_transport_route">Transport route</string>
@ -257,7 +258,7 @@ See osmand.googlecode.com.</string>
<string name="incremental_search_city">Search city incrementally. In order to find villages/postcodes input more than 3 first symbols.</string>
<string name="incremental_search_street">Search street incrementally</string>
<string name="incremental_search_building">Search building incrementally</string>
<string name="choose_available_region">Choose region</string>
<string name="choose_available_region">Choose region from list</string>
<string name="choose_intersected_street">Choose intersected street</string>
<string name="Closest_Amenities">Closest amenities</string>
<string name="app_mode_default">Default</string>

View file

@ -215,6 +215,20 @@ public class OsmandSettings {
return prefs.edit().putBoolean(SHOW_OSM_BUGS, val).commit();
}
// this value string is synchronized with settings_pref.xml preference name
public static final String SHOW_YANDEX_TRAFFIC = "show_yandex_traffic"; //$NON-NLS-1$
public static final boolean SHOW_YANDEX_TRAFFIC_DEF = false;
public static boolean isShowingYandexTraffic(Context ctx) {
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.getBoolean(SHOW_YANDEX_TRAFFIC, SHOW_YANDEX_TRAFFIC_DEF);
}
public static boolean setShowingYandexTraffic(Context ctx, boolean val) {
SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE);
return prefs.edit().putBoolean(SHOW_YANDEX_TRAFFIC, val).commit();
}
// this value string is synchronized with settings_pref.xml preference name
public static final String SHOW_FAVORITES = "show_favorites"; //$NON-NLS-1$
public static final boolean SHOW_FAVORITES_DEF = false;

View file

@ -687,7 +687,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
mapView.removeLayer(favoritesLayer);
}
}
trafficLayer.setVisible(OsmandSettings.isShowingYandexTraffic(this));
}
private void updateMapSource(ITileSource newSource){
@ -1164,7 +1164,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
} else if(item == transportRouteInfoInd){
transportInfoLayer.setVisible(isChecked);
} else if(item == trafficInd){
trafficLayer.setVisible(isChecked);
OsmandSettings.setShowingYandexTraffic(MapActivity.this, isChecked);
}
updateLayers();
mapView.refreshMap();

View file

@ -5,6 +5,7 @@ import java.util.List;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.osmand.OsmandSettings;
import com.osmand.R;
@ -17,6 +18,9 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((TextView)findViewById(R.id.Label)).setText(R.string.choose_available_region);
if(ResourceManager.getResourceManager().getAddressRepositories().isEmpty()){
Toast.makeText(this, R.string.none_region_found, Toast.LENGTH_LONG).show();
}
}
@Override

View file

@ -11,10 +11,12 @@ import android.graphics.Paint.Style;
import android.location.Location;
import android.text.format.DateFormat;
import android.util.FloatMath;
import android.view.View;
import com.osmand.Algoritms;
import com.osmand.Messages;
import com.osmand.OsmandSettings;
import com.osmand.R;
import com.osmand.activities.MapActivity;
import com.osmand.activities.RoutingHelper.RouteDirectionInfo;
import com.osmand.activities.RoutingHelper.TurnType;
@ -150,6 +152,7 @@ public class MapInfoLayer implements OsmandMapLayer {
@Override
public void onDraw(Canvas canvas) {
// prepare data (left distance, speed)
if(map.getPointToNavigate() != null){
int d = 0;
if(map.getRoutingHelper().isRouterEnabled()){
@ -210,6 +213,8 @@ public class MapInfoLayer implements OsmandMapLayer {
canvas.drawText(cachedDistString, boundsForDist.left + 15, boundsForDist.bottom - 9, paintBlack);
}
// draw ruler
drawRuler(canvas);
// draw route information
drawRouteInfo(canvas);
@ -223,6 +228,67 @@ public class MapInfoLayer implements OsmandMapLayer {
}
// cache values for ruler
int rulerDistPix = 0;
String rulerDistName = null;
int rulerBaseLine = 50;
float rulerTextLen = 0;
// cache properties
int rulerCZoom = 0;
double rulerCTileX = 0;
double rulerCTileY = 0;
private void drawRuler(Canvas canvas) {
// occupy length over screen
double screenPercent = 0.2;
// update cache
if (view.getFloatZoom() != (int) view.getFloatZoom()) {
rulerDistName = null;
} else if(view.getFloatZoom() != rulerCZoom ||
Math.abs(view.getXTile() - rulerCTileX) + Math.abs(view.getYTile() - rulerCTileY) > 1){
rulerCZoom = (int) view.getFloatZoom();
rulerCTileX = view.getXTile();
rulerCTileY = view.getYTile();
double latitude = view.getLatitude();
double tileNumberLeft = rulerCTileX - ((double) view.getWidth()) / (2d * view.getTileSize());
double tileNumberRight = rulerCTileX + ((double) view.getWidth()) / (2d * view.getTileSize());
double dist = MapUtils.getDistance(latitude, MapUtils.getLongitudeFromTile(view.getFloatZoom(), tileNumberLeft), latitude,
MapUtils.getLongitudeFromTile(view.getFloatZoom(), tileNumberRight));
dist *= screenPercent;
int baseDist = 50;
byte pointer = 0;
while (dist > baseDist) {
if (pointer++ % 3 == 2) {
baseDist = baseDist * 5 / 2;
} else {
baseDist *= 2;
}
}
rulerDistPix = (int) (view.getWidth() * screenPercent / dist * baseDist);
rulerDistName = MapUtils.getFormattedDistance(baseDist);
rulerBaseLine = view.getHeight() - 70;
if(view.getParent() instanceof View){
View zoomControls = ((View) view.getParent()).findViewById(R.id.ZoomControls);
if(zoomControls != null){
rulerBaseLine = zoomControls.getTop() - 5;
}
}
rulerTextLen = paintBlack.measureText(rulerDistName);
}
if (rulerDistName != null) {
int w2 = view.getWidth() - 5;
canvas.drawLine(w2 - rulerDistPix, rulerBaseLine, w2, rulerBaseLine, paintBlack);
canvas.drawLine(w2 - rulerDistPix, rulerBaseLine, w2 - rulerDistPix, rulerBaseLine - 10, paintBlack);
canvas.drawLine(w2, rulerBaseLine, w2, rulerBaseLine - 10, paintBlack);
canvas.drawText(rulerDistName, w2 - (rulerDistPix + rulerTextLen)/2 + 1, rulerBaseLine - 5, paintBlack);
}
}
private void drawRouteInfo(Canvas canvas) {
if(routeLayer != null && routeLayer.getHelper().isRouterEnabled()){
if (routeLayer.getHelper().isFollowingMode()) {