fix small issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@422 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-08-01 22:44:02 +00:00
parent 2cc3eb1a41
commit 3b5a535af9
6 changed files with 123 additions and 68 deletions

View file

@ -16,15 +16,16 @@ public class ToDoConstants {
// TODO BUGS Android
// ! 3. different screens better support
// 5. add progress saving track from settings
// 6. Add car choose for show only route from point
// 7. Remove speed length arrow
// 8. Give message before 3km & take into account speed (to say faster)
// 9. Check again cancel route!
// 6. Add car choose for show only route from point (+)
// 8. Check again cancel route (+)
// 7. Remove speed length arrow (+)
// 5. add progress saving track from settings (+)
// Improvements
// ! Download with wget
// ! progress while map is loading
// ! Give voice alert before 3km to the turn & take into account speed (to say faster)
// Not clear if it is really needed
// 69. Add phone information to POI

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="show_route">Показать маршрут</string>
<string name="fav_imported_sucessfully">Избранные точки успешно импортированы</string>
<string name="fav_file_to_load_not_found">GPX файл, содержащий точки, не был найден в {0}</string>
<string name="fav_saved_sucessfully">Избранные точки сохранены в {0}</string>
@ -23,7 +24,7 @@
<string name="menu_layers">Слои</string>
<string name="continue_follow_previous_route">Предыдущий маршрут был не закончен. Продолжить следовать по нему?</string>
<string name="context_menu_item_search_poi">Искать POI</string>
<string name="context_menu_item_show_route">Маршрут от точки</string>
<string name="context_menu_item_show_route">Маршрут от</string>
<string name="use_trackball_descr">Использовать трекбол, чтобы перемещать карту</string>
<string name="use_trackball">Использовать трекбол</string>
<string name="background_service_wait_int_descr">Выберите время поиска позиции сервиса</string>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="show_route">Show route</string>
<string name="fav_imported_sucessfully">Favorite points were succesfully imported</string>
<string name="fav_file_to_load_not_found">GPX file to load favorite points is not found at {0}</string>
<string name="fav_saved_sucessfully">Favorite points were succesfully saved to {0}</string>
@ -23,7 +24,7 @@
<string name="menu_layers">Layers</string>
<string name="continue_follow_previous_route">Previous route was unfinished. Do you want to continue follow with it? </string>
<string name="context_menu_item_search_poi">Search POI</string>
<string name="context_menu_item_show_route">Show route from</string>
<string name="context_menu_item_show_route">Route from</string>
<string name="use_trackball_descr">Use trackball to move map</string>
<string name="use_trackball">Use trackball</string>
<string name="background_service_wait_int_descr">Choose wait interval determining location</string>

View file

@ -137,8 +137,6 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
private WakeLock wakeLock;
private boolean sensorRegistered = false;
private MenuItem navigateToPointMenu;
private MenuItem muteMenu;
private NotificationManager mNotificationManager;
private Handler mapPositionHandler = null;
private int APP_NOTIFICATION_ID;
@ -512,7 +510,6 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
}
navigationLayer.setPointToNavigate(point);
updateNavigateToPointMenu();
}
public Location getLastKnownLocation(){
@ -841,7 +838,16 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
locationLayer.setHeading(val);
}
private void updateNavigateToPointMenu(){
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.map_menu, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean val = super.onPrepareOptionsMenu(menu);
MenuItem navigateToPointMenu = menu.findItem(R.id.map_navigate_to_point);
if (navigateToPointMenu != null) {
navigateToPointMenu.setTitle(routingHelper.isRouteCalculated() ? R.string.stop_routing : R.string.stop_navigation);
if (OsmandSettings.getPointToNavigate(this) != null) {
@ -850,6 +856,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
navigateToPointMenu.setVisible(false);
}
}
MenuItem muteMenu = menu.findItem(R.id.map_mute);
if(muteMenu != null){
muteMenu.setTitle(routingHelper.getVoiceRouter().isMute() ? R.string.menu_mute_on : R.string.menu_mute_off);
if (routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode()) {
@ -858,15 +865,8 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
muteMenu.setVisible(false);
}
}
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.map_menu, menu);
navigateToPointMenu = menu.findItem(R.id.map_navigate_to_point);
muteMenu = menu.findItem(R.id.map_mute);
updateNavigateToPointMenu();
return true;
return val;
}
@Override
@ -895,7 +895,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude(), true);
return true;
} else if (item.getItemId() == R.id.map_get_directions) {
getDirections(mapView.getLatitude(), mapView.getLongitude());
getDirections(mapView.getLatitude(), mapView.getLongitude(), true);
return true;
} else if (item.getItemId() == R.id.map_layers) {
openLayerSelectionDialog();
@ -905,7 +905,6 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
return true;
} else if (item.getItemId() == R.id.map_mute) {
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
updateNavigateToPointMenu();
return true;
} else if (item.getItemId() == R.id.map_navigate_to_point) {
if(navigationLayer.getPointToNavigate() != null){
@ -913,7 +912,6 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
routingHelper.setFinalAndCurrentLocation(null, null);
OsmandSettings.setFollowingByRoute(MapActivity.this, false);
routingHelper.setFollowingMode(false);
updateNavigateToPointMenu();
} else {
navigateToPoint(null);
}
@ -925,13 +923,22 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
return super.onOptionsItemSelected(item);
}
protected void getDirections(final double lat, final double lon){
private ApplicationMode getAppMode(ToggleButton[] buttons){
for(int i=0; i<buttons.length; i++){
if(buttons[i] != null && buttons[i].isChecked() && i < ApplicationMode.values().length){
return ApplicationMode.values()[i];
}
}
return OsmandSettings.getApplicationMode(this);
}
protected void getDirections(final double lat, final double lon, boolean followEnabled){
if(navigationLayer.getPointToNavigate() == null){
Toast.makeText(this, R.string.mark_final_location_first, Toast.LENGTH_LONG).show();
return;
}
Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.follow_route);
View view = getLayoutInflater().inflate(R.layout.calculate_route, null);
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
@ -947,75 +954,99 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
if (OsmandSettings.getApplicationMode(MapActivity.this) != ApplicationMode.values()[ind]) {
Editor edit = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_WRITEABLE).edit();
edit.putString(OsmandSettings.APPLICATION_MODE, ApplicationMode.values()[ind].name());
SettingsActivity.setAppMode(ApplicationMode.values()[ind], edit);
edit.commit();
for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) {
for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) {
if(buttons[j].isChecked() != (ind == j)){
buttons[j].setChecked(ind == j);
}
}
updateApplicationModeSettings();
mapView.refreshMap();
}
} else {
// revert state
if (OsmandSettings.getApplicationMode(MapActivity.this) == ApplicationMode.values()[ind]){
// revert state
boolean revert = true;
for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) {
if(buttons[j].isChecked()){
revert = false;
break;
}
}
}
if (revert){
buttons[ind].setChecked(true);
}
}
}
});
}
}
builder.setView(view);
builder.setPositiveButton(R.string.follow, new DialogInterface.OnClickListener(){
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode mode = getAppMode(buttons);
Location map = new Location("map"); //$NON-NLS-1$
map.setLatitude(lat);
map.setLongitude(lon);
routingHelper.setAppMode(mode);
routingHelper.setFollowingMode(false);
routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), map);
}
};
DialogInterface.OnClickListener followCall = new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode mode = getAppMode(buttons);
// change global settings
if (OsmandSettings.getApplicationMode(MapActivity.this) != mode) {
Editor edit = getSharedPreferences(OsmandSettings.SHARED_PREFERENCES_NAME, MODE_WORLD_WRITEABLE).edit();
edit.putString(OsmandSettings.APPLICATION_MODE, mode.name());
SettingsActivity.setAppMode(mode, edit);
edit.commit();
updateApplicationModeSettings();
mapView.refreshMap();
}
Location location = locationLayer.getLastKnownLocation();
if(location == null){
location = new Location("map"); //$NON-NLS-1$
location.setLatitude(lat);
location.setLongitude(lon);
}
routingHelper.setAppMode(mode);
routingHelper.setFollowingMode(true);
routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), location);
OsmandSettings.setFollowingByRoute(MapActivity.this, true);
updateNavigateToPointMenu();
}
});
if(routingHelper.isRouterEnabled() && routingHelper.isRouteCalculated()){
builder.setNeutralButton(R.string.route_about, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(MapActivity.this, ShowRouteInfoActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
}
builder.setNegativeButton(R.string.only_show, new DialogInterface.OnClickListener(){
};
DialogInterface.OnClickListener showRoute = new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
showRoute(lat, lon);
Intent intent = new Intent(MapActivity.this, ShowRouteInfoActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
};
builder.setView(view);
if (followEnabled) {
builder.setTitle(R.string.follow_route);
builder.setPositiveButton(R.string.follow, followCall);
if (routingHelper.isRouterEnabled() && routingHelper.isRouteCalculated()) {
builder.setNeutralButton(R.string.route_about, showRoute);
}
builder.setNegativeButton(R.string.only_show, onlyShowCall);
} else {
builder.setTitle(R.string.show_route);
view.findViewById(R.id.TextView).setVisibility(View.GONE);
builder.setPositiveButton(R.string.show_route, onlyShowCall);
builder.setNegativeButton(R.string.default_buttons_cancel, null);
}
builder.show();
}
private void showRoute(double lat, double lon){
Location map = new Location("map"); //$NON-NLS-1$
map.setLatitude(lat);
map.setLongitude(lon);
routingHelper.setFollowingMode(false);
updateNavigateToPointMenu();
routingHelper.setFinalAndCurrentLocation(navigationLayer.getPointToNavigate(), map);
}
protected void reloadTile(final int zoom, final double latitude, final double longitude){
Builder builder = new AlertDialog.Builder(this);
@ -1254,7 +1285,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
} else if(which == 2){
showRoute(latitude, longitude);
getDirections(latitude, longitude, false);
} else if(which == 3){
addFavouritePoint(latitude, longitude);
} else if(which == 4){

View file

@ -566,8 +566,28 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
return true;
} else if(preference == saveCurrentTrack){
SavingTrackHelper helper = new SavingTrackHelper(this);
helper.saveDataToGpx();
helper.close();
if (helper.hasDataToSave()) {
progressDlg = ProgressDialog.show(this, getString(R.string.saving_gpx_tracks), getString(R.string.saving_gpx_tracks), true);
final ProgressDialogImplementation impl = new ProgressDialogImplementation(progressDlg);
impl.setRunnable("SavingGPX", new Runnable() { //$NON-NLS-1$
@Override
public void run() {
try {
SavingTrackHelper helper = new SavingTrackHelper(SettingsActivity.this);
helper.saveDataToGpx();
helper.close();
} finally {
if (progressDlg != null) {
progressDlg.dismiss();
progressDlg = null;
}
}
}
});
impl.run();
} else {
helper.close();
}
return true;
}
return false;

View file

@ -103,10 +103,11 @@ public class PointLocationLayer implements OsmandMapLayer {
if(lastKnownLocation.hasBearing()){
float bearing = lastKnownLocation.getBearing();
int radiusBearing = 30;
if(lastKnownLocation.hasSpeed()){
if(lastKnownLocation.hasSpeed() && appMode != ApplicationMode.CAR){
radiusBearing =
Math.max(MapUtils.getLengthXFromMeters(view.getFloatZoom(), view.getLatitude(), view.getLongitude(),
lastKnownLocation.getSpeed(), view.getTileSize(), view.getWidth()) * 2, radiusBearing);
radiusBearing = Math.min(radiusBearing, view.getHeight() / 4);
}
radiusBearing += RADIUS /2;