Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2013-11-28 01:11:23 +01:00
commit 2f01ad11ca
82 changed files with 330 additions and 213 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -12,35 +12,7 @@
android:gravity="center" android:gravity="center"
android:orientation="horizontal" > android:orientation="horizontal" >
<ToggleButton
android:id="@+id/CarButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_car"
android:textOff=""
android:textOn="" />
<ToggleButton
android:id="@+id/BicycleButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_bicycle"
android:textOff=""
android:textOn="" />
<ToggleButton
android:id="@+id/PedestrianButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_pedestrian"
android:textOff=""
android:textOn="" />
</LinearLayout> </LinearLayout>
<ScrollView <ScrollView

View file

@ -6,44 +6,4 @@
android:paddingTop="7dp" android:paddingTop="7dp"
android:paddingBottom="7dp"> android:paddingBottom="7dp">
<ToggleButton
android:id="@+id/DefaultButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_default"
android:textOff=""
android:textOn="" />
<ToggleButton
android:id="@+id/CarButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_car"
android:textOff=""
android:textOn="" />
<ToggleButton
android:id="@+id/BicycleButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_bicycle"
android:textOff=""
android:textOn="" />
<ToggleButton
android:id="@+id/PedestrianButton"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:contentDescription="@string/app_mode_pedestrian"
android:textOff=""
android:textOn="" />
</LinearLayout> </LinearLayout>

View file

@ -9,6 +9,10 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="app_mode_hiking">Hiking</string>
<string name="app_mode_motorcycle">Motorcycle</string>
<string name="app_mode_boat">Boat</string>
<string name="app_mode_aircraft">Aircraft</string>
<string name="tip_faq_t">Please visit https://code.google.com/p/osmand/wiki/FAQ to see frequently asked questions.</string> <string name="tip_faq_t">Please visit https://code.google.com/p/osmand/wiki/FAQ to see frequently asked questions.</string>
<string name="tip_faq">Frequently Asked Questions</string> <string name="tip_faq">Frequently Asked Questions</string>
<string name="local_osm_changes_delete_all_confirm">You are going to delete %1$d osm changes. Are you sure?</string> <string name="local_osm_changes_delete_all_confirm">You are going to delete %1$d osm changes. Are you sure?</string>

View file

@ -1,23 +1,206 @@
package net.osmand.plus; package net.osmand.plus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public enum ApplicationMode { import android.content.Context;
public class ApplicationMode {
private static List<ApplicationMode> values = new ArrayList<ApplicationMode>();
/* /*
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); * DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian");
*/ */
DEFAULT(R.string.app_mode_default), public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).defLocation().
CAR(R.string.app_mode_car), icon(R.drawable.ic_browse_map, R.drawable.app_mode_globus_light, R.drawable.app_mode_globus_dark).reg();
BICYCLE(R.string.app_mode_bicycle),
PEDESTRIAN(R.string.app_mode_pedestrian);
private final int key; public static final ApplicationMode CAR = create(R.string.app_mode_car, "car").speed(15.3f, 35).carLocation().
icon(R.drawable.ic_car, R.drawable.ic_action_car_light, R.drawable.ic_action_car_dark).reg();
ApplicationMode(int key) { public static final ApplicationMode BICYCLE = create(R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).bicycleLocation().
this.key = key; icon(R.drawable.ic_bicycle, R.drawable.ic_action_bicycle_light, R.drawable.ic_action_bicycle_dark).reg();
public static final ApplicationMode PEDESTRIAN = create(R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).
icon(R.drawable.ic_pedestrian, R.drawable.ic_action_pedestrian_light, R.drawable.ic_action_parking_dark).reg();
// public static final ApplicationMode AIRCRAFT = create(R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
// icon(R.drawable.ic_aircraft, R.drawable.ic_action_aircraft_light, R.drawable.ic_action_aircraft_dark).reg();
//
// public static final ApplicationMode BOAT = create(R.string.app_mode_boat, "boat").speed(5.5f, 20).carLocation().
// icon(R.drawable.ic_sail_boat, R.drawable.ic_action_sail_boat_light, R.drawable.ic_action_sail_boat_dark).reg();
//
// public static final ApplicationMode HIKING = create(R.string.app_mode_hiking, "hiking").speed(1.5f, 5).parent(PEDESTRIAN).
// icon(R.drawable.ic_trekking, R.drawable.ic_action_trekking_light, R.drawable.ic_action_trekking_dark).reg();
//
// public static final ApplicationMode MOTORCYCLE = create(R.string.app_mode_motorcycle, "motorcycle").speed(15.3f, 40).
// carLocation().parent(CAR).
// icon(R.drawable.ic_motorcycle, R.drawable.ic_action_motorcycle_light, R.drawable.ic_action_motorcycle_dark).reg();
private static class ApplicationModeBuilder {
private ApplicationMode applicationMode;
public ApplicationMode reg() {
values.add(applicationMode);
return applicationMode;
} }
public String toHumanString(ClientContext ctx) { public ApplicationModeBuilder icon(int bigIcon, int smallIconLight, int smallIconDark) {
applicationMode.iconId = bigIcon;
applicationMode.smallIconLight = smallIconLight;
applicationMode.smallIconDark = smallIconDark;
return this;
}
public ApplicationModeBuilder carLocation(){
applicationMode.bearingIcon = R.drawable.car_bearing;
applicationMode.locationIcon = R.drawable.car_location;
return this;
}
public ApplicationModeBuilder parent(ApplicationMode parent){
applicationMode.parent = parent;
return this;
}
public ApplicationModeBuilder bicycleLocation(){
applicationMode.bearingIcon = R.drawable.bicycle_bearing;
applicationMode.locationIcon = R.drawable.bicycle_location;
return this;
}
public ApplicationModeBuilder defLocation(){
applicationMode.bearingIcon = R.drawable.pedestrian_bearing;
applicationMode.locationIcon = R.drawable.pedestrian_location;
return this;
}
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
applicationMode.defaultSpeed = defSpeed;
applicationMode.minDistanceForTurn = distForTurn;
return this;
}
}
private static ApplicationModeBuilder create(int key, String stringKey) {
ApplicationModeBuilder builder = new ApplicationModeBuilder();
builder.applicationMode = new ApplicationMode(key, stringKey);
return builder;
}
private final int key;
private final String stringKey;
private ApplicationMode parent;
private int iconId = R.drawable.ic_browse_map;
private int smallIconDark = R.drawable.app_mode_globus_dark ;
private int smallIconLight = R.drawable.app_mode_globus_light ;
private float defaultSpeed = 10f;
private int minDistanceForTurn = 50;
private int bearingIcon = R.drawable.pedestrian_bearing;
private int locationIcon = R.drawable.pedestrian_location;
private ApplicationMode(int key, String stringKey) {
this.key = key;
this.stringKey = stringKey;
}
public static List<ApplicationMode> values(OsmandSettings settings) {
// TODO
return values;
}
public static List<ApplicationMode> allPossibleValues(ClientContext ctx) {
return values;
}
public static Set<ApplicationMode> allOf() {
// TODO
return new HashSet<ApplicationMode>(values);
}
public static Set<ApplicationMode> noneOf() {
// TODO
return new HashSet<ApplicationMode>();
}
public static Set<ApplicationMode> of(ApplicationMode... modes ) {
// TODO
HashSet<ApplicationMode> ts = new HashSet<ApplicationMode>();
Collections.addAll(ts, modes);
return ts;
}
public static List<ApplicationMode> getModesDerivedFrom(ApplicationMode am) {
List<ApplicationMode> list = new ArrayList<ApplicationMode>();
for(ApplicationMode a : values) {
if(a == am || a.getParent() == am) {
list.add(a);
}
}
return list;
}
public ApplicationMode getParent() {
return parent;
}
public int getSmallIcon(boolean nightMode) {
return nightMode? smallIconDark : smallIconLight;
}
public boolean hasFastSpeed(){
return getDefaultSpeed() > 10;
}
public int getResourceBearing() {
return bearingIcon;
}
public int getResourceLocation() {
return locationIcon;
}
public String getStringKey() {
return stringKey;
}
public int getIconId() {
return iconId;
}
public int getStringResource() {
return key;
}
public String toHumanString(Context ctx) {
return ctx.getString(key); return ctx.getString(key);
} }
public static ApplicationMode valueOfStringKey(String key, ApplicationMode def) {
for(ApplicationMode p : values) {
if(p.getStringKey().equals(key)) {
return p;
}
}
return def;
}
public float getDefaultSpeed() {
return defaultSpeed;
}
public int getMinDistanceForTurn() {
return minDistanceForTurn;
}
} }

View file

@ -97,7 +97,8 @@ public class OsmAndFormatter {
ApplicationMode am = settings.getApplicationMode(); ApplicationMode am = settings.getApplicationMode();
float kmh = metersperseconds * 3.6f; float kmh = metersperseconds * 3.6f;
if (mc == MetricsConstants.KILOMETERS_AND_METERS) { if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
if (kmh >= 10 || (am == ApplicationMode.CAR)) { if (kmh >= 10 || am.hasFastSpeed()) {
// case of car
return ((int) Math.round(kmh)) + " " + ctx.getString(R.string.km_h); return ((int) Math.round(kmh)) + " " + ctx.getString(R.string.km_h);
} }
int kmh10 = (int) (kmh * 10f); int kmh10 = (int) (kmh * 10f);

View file

@ -1,5 +1,7 @@
package net.osmand.plus; package net.osmand.plus;
import java.util.List;
import android.app.backup.BackupAgentHelper; import android.app.backup.BackupAgentHelper;
import android.app.backup.FileBackupHelper; import android.app.backup.FileBackupHelper;
import android.app.backup.SharedPreferencesBackupHelper; import android.app.backup.SharedPreferencesBackupHelper;
@ -11,10 +13,11 @@ public class OsmandBackupAgent extends BackupAgentHelper {
@Override @Override
public void onCreate() { public void onCreate() {
String[] prefs = new String[ApplicationMode.values().length + 1]; List<ApplicationMode> all = ApplicationMode.allPossibleValues((OsmandApplication) getApplicationContext());
String[] prefs = new String[all.size() + 1];
prefs[0] = OsmandSettings.getSharedPreferencesName(null); prefs[0] = OsmandSettings.getSharedPreferencesName(null);
int i = 1; int i = 1;
for (ApplicationMode m : ApplicationMode.values()) { for (ApplicationMode m : all) {
prefs[i++] = OsmandSettings.getSharedPreferencesName(m); prefs[i++] = OsmandSettings.getSharedPreferencesName(m);
} }

View file

@ -121,7 +121,7 @@ public class OsmandSettings {
if(mode == null){ if(mode == null){
return SHARED_PREFERENCES_NAME; return SHARED_PREFERENCES_NAME;
} else { } else {
return SHARED_PREFERENCES_NAME + "." + mode.name().toLowerCase(); return SHARED_PREFERENCES_NAME + "." + mode.getStringKey().toLowerCase();
} }
} }
@ -158,7 +158,7 @@ public class OsmandSettings {
@Override @Override
public boolean set(ApplicationMode val) { public boolean set(ApplicationMode val) {
ApplicationMode oldMode = currentMode; ApplicationMode oldMode = currentMode;
boolean changed = settingsAPI.edit(globalPreferences).putString(getId(), val.name()).commit(); boolean changed = settingsAPI.edit(globalPreferences).putString(getId(), val.getStringKey()).commit();
if(changed){ if(changed){
currentMode = val; currentMode = val;
profilePreferences = getProfilePreferences(currentMode); profilePreferences = getProfilePreferences(currentMode);
@ -183,12 +183,8 @@ public class OsmandSettings {
} }
protected ApplicationMode readApplicationMode() { protected ApplicationMode readApplicationMode() {
String s = settingsAPI.getString(globalPreferences, APPLICATION_MODE.getId(), ApplicationMode.DEFAULT.name()); String s = settingsAPI.getString(globalPreferences, APPLICATION_MODE.getId(), ApplicationMode.DEFAULT.getStringKey());
try { return ApplicationMode.valueOfStringKey(s, ApplicationMode.DEFAULT);
return ApplicationMode.valueOf(s);
} catch (IllegalArgumentException e) {
return ApplicationMode.DEFAULT;
}
} }
@ -574,8 +570,19 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache(); public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new EnumIntPreference<ApplicationMode>( public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new CommonPreference<ApplicationMode>("default_application_mode", ApplicationMode.DEFAULT) {
"default_application_mode", ApplicationMode.DEFAULT, ApplicationMode.values()).makeGlobal();
@Override
protected ApplicationMode getValue(Object prefs, ApplicationMode defaultValue) {
String key = settingsAPI.getString(prefs, getId(), defaultValue.getStringKey());
return ApplicationMode.valueOfStringKey(key, defaultValue);
}
@Override
protected boolean setValue(Object prefs, ApplicationMode val) {
return settingsAPI.edit( prefs).putString(getId(), val.getStringKey()).commit();
}
};
public final OsmandPreference<DrivingRegion> DRIVING_REGION = new EnumIntPreference<DrivingRegion>( public final OsmandPreference<DrivingRegion> DRIVING_REGION = new EnumIntPreference<DrivingRegion>(
"default_driving_region", DrivingRegion.EUROPE_ASIA, DrivingRegion.values()) { "default_driving_region", DrivingRegion.EUROPE_ASIA, DrivingRegion.values()) {

View file

@ -234,7 +234,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
if (profileSettings) { if (profileSettings) {
modes.clear(); modes.clear();
for (ApplicationMode a : ApplicationMode.values()) { for (ApplicationMode a : ApplicationMode.values(settings)) {
if (a != ApplicationMode.DEFAULT) { if (a != ApplicationMode.DEFAULT) {
modes.add(a); modes.add(a);
} }

View file

@ -169,11 +169,12 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
entries = new String[ApplicationMode.values().length]; ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
for(int i=0; i<entries.length; i++){ for(int i=0; i<entries.length; i++){
entries[i] = ApplicationMode.values()[i].toHumanString(getMyApplication()); entries[i] = appModes[i].toHumanString(getMyApplication());
} }
registerListPreference(settings.APPLICATION_MODE, screen, entries, ApplicationMode.values()); registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
if (!Version.isBlackberry((ClientContext) getApplication())) { if (!Version.isBlackberry((ClientContext) getApplication())) {
PreferenceScreen cat = getPreferenceScreen(); PreferenceScreen cat = getPreferenceScreen();

View file

@ -10,25 +10,30 @@ import net.osmand.Location;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams; import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RouteProvider.RouteService;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener; import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -119,17 +124,14 @@ public class NavigateAction {
final Location current = getLastKnownLocation(); final Location current = getLastKnownLocation();
Builder builder = new AlertDialog.Builder(mapActivity); Builder builder = new AlertDialog.Builder(mapActivity);
final TargetPointsHelper targets = app.getTargetPointsHelper(); final TargetPointsHelper targets = app.getTargetPointsHelper();
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(app.getSettings()));
values.remove(ApplicationMode.DEFAULT);
View view = mapActivity.getLayoutInflater().inflate(R.layout.calculate_route, null); View view = mapActivity.getLayoutInflater().inflate(R.layout.calculate_route, null);
boolean osmandRouter = mapActivity.getMyApplication().getSettings().ROUTER_SERVICE.get() == RouteService.OSMAND; boolean osmandRouter = mapActivity.getMyApplication().getSettings().ROUTER_SERVICE.get() == RouteService.OSMAND;
final CheckBox nonoptimal = (CheckBox) view.findViewById(R.id.OptimalCheckox); final CheckBox nonoptimal = (CheckBox) view.findViewById(R.id.OptimalCheckox);
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length]; LinearLayout topLayout = (LinearLayout) view.findViewById(R.id.LinearLayout);
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton); final ToggleButton[] buttons = createToggles(values, topLayout, mapActivity);
buttons[ApplicationMode.CAR.ordinal()].setButtonDrawable(R.drawable.ic_car );
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
buttons[ApplicationMode.BICYCLE.ordinal()].setButtonDrawable(R.drawable.ic_bicycle);
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
buttons[ApplicationMode.PEDESTRIAN.ordinal()].setButtonDrawable(R.drawable.ic_pedestrian);
final Spinner fromSpinner = setupFromSpinner(mapView, name, view, style); final Spinner fromSpinner = setupFromSpinner(mapView, name, view, style);
final List<LatLon> toList = new ArrayList<LatLon>(); final List<LatLon> toList = new ArrayList<LatLon>();
@ -157,7 +159,7 @@ public class NavigateAction {
if (buttons[i] != null) { if (buttons[i] != null) {
final int ind = i; final int ind = i;
ToggleButton b = buttons[i]; ToggleButton b = buttons[i];
final ApplicationMode buttonAppMode = ApplicationMode.values()[i]; final ApplicationMode buttonAppMode = values.get(i);
b.setChecked(appMode == buttonAppMode); b.setChecked(appMode == buttonAppMode);
if(b.isChecked()) { if(b.isChecked()) {
nonoptimal.setChecked(!settings.OPTIMAL_ROUTE_MODE.getModeValue(buttonAppMode)); nonoptimal.setChecked(!settings.OPTIMAL_ROUTE_MODE.getModeValue(buttonAppMode));
@ -213,7 +215,7 @@ public class NavigateAction {
return; return;
} }
ApplicationMode mode = getAppMode(buttons, settings); ApplicationMode mode = getAppMode(buttons, settings, values);
app.getRoutingHelper().setAppMode(mode); app.getRoutingHelper().setAppMode(mode);
settings.OPTIMAL_ROUTE_MODE.setModeValue(mode, !nonoptimal.isChecked()); settings.OPTIMAL_ROUTE_MODE.setModeValue(mode, !nonoptimal.isChecked());
settings.FOLLOW_THE_ROUTE.set(false); settings.FOLLOW_THE_ROUTE.set(false);
@ -246,7 +248,7 @@ public class NavigateAction {
if (msg) { if (msg) {
AccessibleToast.makeText(mapActivity, R.string.route_updated_loc_found, Toast.LENGTH_LONG).show(); AccessibleToast.makeText(mapActivity, R.string.route_updated_loc_found, Toast.LENGTH_LONG).show();
} }
ApplicationMode mode = getAppMode(buttons, settings); ApplicationMode mode = getAppMode(buttons, settings, values);
settings.OPTIMAL_ROUTE_MODE.setModeValue(mode, !nonoptimal.isChecked()); settings.OPTIMAL_ROUTE_MODE.setModeValue(mode, !nonoptimal.isChecked());
dialog.dismiss(); dialog.dismiss();
mapActivity.followRoute(mode, targets.getPointToNavigate(), targets.getIntermediatePoints(), mapActivity.followRoute(mode, targets.getPointToNavigate(), targets.getIntermediatePoints(),
@ -261,7 +263,7 @@ public class NavigateAction {
if ( tos != null && tos != targets.getPointToNavigate()) { if ( tos != null && tos != targets.getPointToNavigate()) {
targets.navigateToPoint(tos, false, -1); targets.navigateToPoint(tos, false, -1);
} }
ApplicationMode mode = getAppMode(buttons, settings); ApplicationMode mode = getAppMode(buttons, settings, values);
navigateUsingGPX(mode); navigateUsingGPX(mode);
} }
}; };
@ -278,6 +280,32 @@ public class NavigateAction {
builder.show(); builder.show();
} }
private static ToggleButton[] createToggles(final List<ApplicationMode> values, LinearLayout topLayout, Context ctx) {
final ToggleButton[] buttons = new ToggleButton[values.size()];
HorizontalScrollView scroll = new HorizontalScrollView(ctx);
topLayout.addView(scroll);
LinearLayout ll = new LinearLayout(ctx);
ll.setOrientation(LinearLayout.HORIZONTAL);
scroll.addView(ll);
int k = 0;
int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, ctx.getResources().getDisplayMetrics());
int metrics = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, ctx.getResources().getDisplayMetrics());
for(ApplicationMode ma : values) {
ToggleButton tb = new ToggleButton(ctx);
buttons[k++] = tb;
tb.setTextOn("");
tb.setTextOff("");
tb.setContentDescription(ma.toHumanString(ctx));
tb.setButtonDrawable(ma.getIconId());
LayoutParams lp = new LinearLayout.LayoutParams(metrics, metrics);
lp.setMargins(left, 0, 0, 0);
ll.addView(tb, lp);
}
return buttons;
}
public String getRoutePointDescription(double lat, double lon) { public String getRoutePointDescription(double lat, double lon) {
return mapActivity.getString(R.string.route_descr_lat_lon, lat, lon); return mapActivity.getString(R.string.route_descr_lat_lon, lat, lon);
} }
@ -333,28 +361,19 @@ public class NavigateAction {
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault, public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
ViewGroup parent, final View.OnClickListener onClickListener) { ViewGroup parent, final View.OnClickListener onClickListener) {
View view = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent); LinearLayout ll = (LinearLayout) a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings(); OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length]; final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(settings));
if(showDefault) { if(!showDefault) {
buttons[ApplicationMode.DEFAULT.ordinal()] = (ToggleButton) view.findViewById(R.id.DefaultButton); values.remove(ApplicationMode.DEFAULT);
buttons[ApplicationMode.DEFAULT.ordinal()].setButtonDrawable(R.drawable.ic_browse_map );
} else {
view.findViewById(R.id.DefaultButton).setVisibility(View.GONE);
} }
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton); final ToggleButton[] buttons = createToggles(values, ll, a);
buttons[ApplicationMode.CAR.ordinal()].setButtonDrawable(R.drawable.ic_car );
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
buttons[ApplicationMode.BICYCLE.ordinal()].setButtonDrawable(R.drawable.ic_bicycle);
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
buttons[ApplicationMode.PEDESTRIAN.ordinal()].setButtonDrawable(R.drawable.ic_pedestrian);
ApplicationMode appMode = settings.getApplicationMode(); ApplicationMode appMode = settings.getApplicationMode();
for (int i = 0; i < buttons.length; i++) { for (int i = 0; i < buttons.length; i++) {
if (buttons[i] != null) { if (buttons[i] != null) {
final int ind = i; final int ind = i;
ToggleButton b = buttons[i]; ToggleButton b = buttons[i];
final ApplicationMode buttonAppMode = ApplicationMode.values()[i]; final ApplicationMode buttonAppMode = values.get(i);
b.setChecked(appMode == buttonAppMode); b.setChecked(appMode == buttonAppMode);
if(appMode == buttonAppMode) { if(appMode == buttonAppMode) {
selected.add(appMode); selected.add(appMode);
@ -367,7 +386,7 @@ public class NavigateAction {
for (int j = 0; j < buttons.length; j++) { for (int j = 0; j < buttons.length; j++) {
if (buttons[j] != null) { if (buttons[j] != null) {
if(ind == j) { if(ind == j) {
selected.add(ApplicationMode.values()[j]); selected.add(values.get(j));
} }
if (buttons[j].isChecked() != (ind == j)) { if (buttons[j].isChecked() != (ind == j)) {
buttons[j].setChecked(ind == j); buttons[j].setChecked(ind == j);
@ -396,7 +415,7 @@ public class NavigateAction {
}); });
} }
} }
return view; return ll;
} }
private Spinner setupFromSpinner(final Location mapView, String name, View view, DirectionDialogStyle style) { private Spinner setupFromSpinner(final Location mapView, String name, View view, DirectionDialogStyle style) {
@ -463,10 +482,10 @@ public class NavigateAction {
return mapActivity.getString(resId); return mapActivity.getString(resId);
} }
private ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings){ private ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings, List<ApplicationMode> modes){
for (int i = 0; i < buttons.length; i++) { for (int i = 0; i < buttons.length; i++) {
if(buttons[i] != null && buttons[i].isChecked() && i < ApplicationMode.values().length){ if (buttons[i] != null && buttons[i].isChecked() && i < modes.size()) {
return ApplicationMode.values()[i]; return modes.get(i);
} }
} }
return settings.getApplicationMode(); return settings.getApplicationMode();

View file

@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -468,8 +467,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
recordControl.setImageDrawable(activity.getResources().getDrawable(R.drawable.monitoring_rec_inactive)); recordControl.setImageDrawable(activity.getResources().getDrawable(R.drawable.monitoring_rec_inactive));
setRecordListener(recordControl, activity); setRecordListener(recordControl, activity);
mapInfoLayer.getMapInfoControls().registerSideWidget(recordControl, R.drawable.widget_icon_av_inactive, mapInfoLayer.getMapInfoControls().registerSideWidget(recordControl, R.drawable.widget_icon_av_inactive,
R.string.map_widget_av_notes, "audionotes", false, EnumSet.allOf(ApplicationMode.class), R.string.map_widget_av_notes, "audionotes", false, ApplicationMode.allOf(),
EnumSet.noneOf(ApplicationMode.class), 22); ApplicationMode.noneOf(), 22);
mapInfoLayer.recreateControls(); mapInfoLayer.recreateControls();
} }
} }

View file

@ -68,8 +68,8 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
} }
}; };
mapInfoLayer.getMapInfoControls().registerSideWidget(fps, 0, mapInfoLayer.getMapInfoControls().registerSideWidget(fps, 0,
R.string.map_widget_fps_info, "fps", false, EnumSet.noneOf(ApplicationMode.class), R.string.map_widget_fps_info, "fps", false, ApplicationMode.noneOf(),
EnumSet.noneOf(ApplicationMode.class), 30); ApplicationMode.noneOf(), 30);
mapInfoLayer.recreateControls(); mapInfoLayer.recreateControls();
} }
} }

View file

@ -6,7 +6,6 @@ import java.io.File;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.EnumSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -115,8 +114,8 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
distanceControl = createDistanceControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText()); distanceControl = createDistanceControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText());
mapInfoLayer.getMapInfoControls().registerSideWidget(distanceControl, mapInfoLayer.getMapInfoControls().registerSideWidget(distanceControl,
R.drawable.widget_distance, R.string.map_widget_distancemeasurement, "distance.measurement", false, R.drawable.widget_distance, R.string.map_widget_distancemeasurement, "distance.measurement", false,
EnumSet.of(ApplicationMode.DEFAULT, ApplicationMode.PEDESTRIAN), ApplicationMode.of(ApplicationMode.DEFAULT, ApplicationMode.PEDESTRIAN),
EnumSet.noneOf(ApplicationMode.class), 21); ApplicationMode.noneOf(), 21);
mapInfoLayer.recreateControls(); mapInfoLayer.recreateControls();
updateText(); updateText();
} }

View file

@ -71,7 +71,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
layer.getMapInfoControls().registerSideWidget(monitoringControl, layer.getMapInfoControls().registerSideWidget(monitoringControl,
R.drawable.monitoring_rec_big, R.string.map_widget_monitoring, "monitoring", false, R.drawable.monitoring_rec_big, R.string.map_widget_monitoring, "monitoring", false,
EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN), EnumSet.noneOf(ApplicationMode.class), 18); ApplicationMode.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN), ApplicationMode.noneOf(), 18);
layer.recreateControls(); layer.recreateControls();
} }

View file

@ -191,7 +191,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
parkingPlaceControl = createParkingPlaceInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText()); parkingPlaceControl = createParkingPlaceInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText());
mapInfoLayer.getMapInfoControls().registerSideWidget(parkingPlaceControl, mapInfoLayer.getMapInfoControls().registerSideWidget(parkingPlaceControl,
R.drawable.widget_parking, R.string.map_widget_parking, "parking", false, R.drawable.widget_parking, R.string.map_widget_parking, "parking", false,
EnumSet.allOf(ApplicationMode.class), EnumSet.noneOf(ApplicationMode.class), 8); ApplicationMode.allOf(), ApplicationMode.noneOf(), 8);
mapInfoLayer.recreateControls(); mapInfoLayer.recreateControls();
} }
} }

View file

@ -299,16 +299,8 @@ public class RouteCalculationResult {
return; return;
} }
// speed m/s // speed m/s
float speed = 1.5f; float speed = mode.getDefaultSpeed();
int minDistanceForTurn = 5; int minDistanceForTurn = mode.getMinDistanceForTurn();
if(mode == ApplicationMode.CAR){
speed = 15.3f;
minDistanceForTurn = 35;
} else if(mode == ApplicationMode.BICYCLE){
speed = 5.5f;
minDistanceForTurn = 12;
}
List<RouteDirectionInfo> computeDirections = new ArrayList<RouteDirectionInfo>(); List<RouteDirectionInfo> computeDirections = new ArrayList<RouteDirectionInfo>();
int[] listDistance = new int[locations.size()]; int[] listDistance = new int[locations.size()];

View file

@ -263,7 +263,7 @@ public class RoutingHelper {
recalculateRouteInBackground(currentLocation, finalLocation, intermediatePoints, currentGPXRoute, route.isCalculated() ? route recalculateRouteInBackground(currentLocation, finalLocation, intermediatePoints, currentGPXRoute, route.isCalculated() ? route
: null); : null);
} }
double projectDist = mode == ApplicationMode.CAR ? posTolerance : posTolerance / 2; double projectDist = mode.hasFastSpeed() ? posTolerance : posTolerance / 2;
if(returnUpdatedLocation && locationProjection != null && currentLocation.distanceTo(locationProjection) < projectDist) { if(returnUpdatedLocation && locationProjection != null && currentLocation.distanceTo(locationProjection) < projectDist) {
return locationProjection; return locationProjection;
} else { } else {

View file

@ -32,7 +32,7 @@ public class SRTMPlugin extends OsmandPlugin {
OsmandSettings settings = app.getSettings(); OsmandSettings settings = app.getSettings();
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines"); CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
if(pref.get().equals("")) { if(pref.get().equals("")) {
for(ApplicationMode m : ApplicationMode.values()) { for(ApplicationMode m : ApplicationMode.allPossibleValues(app)) {
if(pref.getModeValue(m).equals("")) { if(pref.getModeValue(m).equals("")) {
pref.setModeValue(m, "13"); pref.setModeValue(m, "13");
} }

View file

@ -160,19 +160,7 @@ public class MapControlsLayer extends OsmandMapLayer {
if(appMode != cacheApplicationMode){ if(appMode != cacheApplicationMode){
modeShadow.setBounds(backToMenuButton.getLeft() + (int) (2 * scaleCoefficient), backToMenuButton.getTop() - (int) (24 * scaleCoefficient), modeShadow.setBounds(backToMenuButton.getLeft() + (int) (2 * scaleCoefficient), backToMenuButton.getTop() - (int) (24 * scaleCoefficient),
backToMenuButton.getRight() - (int) (4 * scaleCoefficient), backToMenuButton.getBottom()); backToMenuButton.getRight() - (int) (4 * scaleCoefficient), backToMenuButton.getBottom());
if(appMode == ApplicationMode.CAR){ cacheAppModeIcon = view.getResources().getDrawable(appMode.getSmallIcon(nightMode));
// cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.car_small_white : R.drawable.car_small);
cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.ic_action_car_dark : R.drawable.ic_action_car_light);
} else if(appMode == ApplicationMode.BICYCLE){
// cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.bicycle_small_white : R.drawable.bicycle_small);
cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.ic_action_bicycle_dark : R.drawable.ic_action_bicycle_light);
} else if(appMode == ApplicationMode.PEDESTRIAN){
// cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.pedestrian_small_white : R.drawable.pedestrian_small);
cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.ic_action_pedestrian_dark : R.drawable.ic_action_pedestrian_light);
} else {
// cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.default_small_white : R.drawable.default_small);
cacheAppModeIcon = view.getResources().getDrawable(nightMode? R.drawable.app_mode_globus_dark : R.drawable.app_mode_globus_light);
}
int l = modeShadow.getBounds().left + (modeShadow.getBounds().width() - cacheAppModeIcon.getMinimumWidth()) / 2; int l = modeShadow.getBounds().left + (modeShadow.getBounds().width() - cacheAppModeIcon.getMinimumWidth()) / 2;
int t = (int) (modeShadow.getBounds().top + 2 * scaleCoefficient); int t = (int) (modeShadow.getBounds().top + 2 * scaleCoefficient);
cacheAppModeIcon.setBounds(l, t, l + cacheAppModeIcon.getMinimumWidth(), t + cacheAppModeIcon.getMinimumHeight()); cacheAppModeIcon.setBounds(l, t, l + cacheAppModeIcon.getMinimumWidth(), t + cacheAppModeIcon.getMinimumHeight());
@ -186,13 +174,15 @@ public class MapControlsLayer extends OsmandMapLayer {
private void onApplicationModePress() { private void onApplicationModePress() {
final QuickAction mQuickAction = new QuickAction(backToMenuButton); final QuickAction mQuickAction = new QuickAction(backToMenuButton);
//int[] icons = new int[] { R.drawable.default_small, R.drawable.car_small, R.drawable.bicycle_small, R.drawable.pedestrian_small }; List<ApplicationMode> vls = ApplicationMode.values(activity.getMyApplication().getSettings());
int[] icons = new int[] { R.drawable.ic_action_globus_light, R.drawable.ic_action_car_light, R.drawable.ic_action_bicycle_light, R.drawable.ic_action_pedestrian_light }; final ApplicationMode[] modes = vls.toArray(new ApplicationMode[vls.size()]);
int[] values = new int[] { R.string.app_mode_default, R.string.app_mode_car, R.string.app_mode_bicycle, int[] icons = new int[vls.size()];
R.string.app_mode_pedestrian }; int[] values = new int[vls.size()];
final ApplicationMode[] modes = new ApplicationMode[] { ApplicationMode.DEFAULT, ApplicationMode.CAR, ApplicationMode.BICYCLE, for(int k = 0; k < modes.length; k++) {
ApplicationMode.PEDESTRIAN }; icons[k] = modes[k].getSmallIcon(false);
for (int i = 0; i < 4; i++) { values[k] = modes[k].getStringResource();
}
for (int i = 0; i < modes.length; i++) {
final ActionItem action = new ActionItem(); final ActionItem action = new ActionItem();
action.setTitle(view.getResources().getString(values[i])); action.setTitle(view.getResources().getString(values[i]));
action.setIcon(view.getResources().getDrawable(icons[i])); action.setIcon(view.getResources().getDrawable(icons[i]));

View file

@ -3,7 +3,6 @@ package net.osmand.plus.views;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
@ -171,10 +170,10 @@ public class MapInfoLayer extends OsmandMapLayer {
alarmControl = ric.createAlarmInfoControl(app, map); alarmControl = ric.createAlarmInfoControl(app, map);
// register right stack // register right stack
EnumSet<ApplicationMode> all = EnumSet.allOf(ApplicationMode.class); Set<ApplicationMode> all = ApplicationMode.allOf();
EnumSet<ApplicationMode> carBicycleDefault = EnumSet.of(ApplicationMode.CAR, ApplicationMode.DEFAULT, ApplicationMode.BICYCLE); Set<ApplicationMode> carBicycleDefault = ApplicationMode.of(ApplicationMode.CAR, ApplicationMode.DEFAULT, ApplicationMode.BICYCLE);
EnumSet<ApplicationMode> exceptCar = EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT); Set<ApplicationMode> exceptCar = ApplicationMode.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT);
EnumSet<ApplicationMode> none = EnumSet.noneOf(ApplicationMode.class); Set<ApplicationMode> none = ApplicationMode.noneOf();
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(), paintText, NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(), paintText,
paintSubText, false); paintSubText, false);
@ -182,7 +181,7 @@ public class MapInfoLayer extends OsmandMapLayer {
NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(), NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(),
paintSmallText, paintSmallSubText, true); paintSmallText, paintSmallSubText, true);
mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true, mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true,
EnumSet.of(ApplicationMode.PEDESTRIAN), none, 10); ApplicationMode.of(ApplicationMode.PEDESTRIAN), none, 10);
NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(routingHelper, app, view.getSettings(), NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(routingHelper, app, view.getSettings(),
paintSmallText, paintSmallSubText, true); paintSmallText, paintSmallSubText, true);
mapInfoControls.registerSideWidget(nextNextInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, carBicycleDefault, none, 15); mapInfoControls.registerSideWidget(nextNextInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, carBicycleDefault, none, 15);
@ -265,26 +264,26 @@ public class MapInfoLayer extends OsmandMapLayer {
// we want that status bar lays over map stack controls // we want that status bar lays over map stack controls
topMargin -= topRectPadding.top; topMargin -= topRectPadding.top;
FrameLayout.LayoutParams flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT); android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT);
flp.rightMargin = STATUS_BAR_MARGIN_X; flp.rightMargin = STATUS_BAR_MARGIN_X;
flp.topMargin = topMargin; flp.topMargin = topMargin;
rightStack.setLayoutParams(flp); rightStack.setLayoutParams(flp);
flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP); android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP);
flp.topMargin = (int) (topMargin + scaleCoefficient * 8); flp.topMargin = (int) (topMargin + scaleCoefficient * 8);
lanesControl.setLayoutParams(flp); lanesControl.setLayoutParams(flp);
flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.LEFT); android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.LEFT);
flp.leftMargin = STATUS_BAR_MARGIN_X; flp.leftMargin = STATUS_BAR_MARGIN_X;
flp.topMargin = topMargin; flp.topMargin = topMargin;
leftStack.setLayoutParams(flp); leftStack.setLayoutParams(flp);
flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, flp = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP); android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP);
flp.leftMargin = STATUS_BAR_MARGIN_X; flp.leftMargin = STATUS_BAR_MARGIN_X;
flp.rightMargin = STATUS_BAR_MARGIN_X; flp.rightMargin = STATUS_BAR_MARGIN_X;

View file

@ -6,16 +6,12 @@ import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.util.MapUtils;
import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.RectF; import android.graphics.RectF;
import android.util.DisplayMetrics;
import android.view.WindowManager;
public class PointLocationLayer extends OsmandMapLayer { public class PointLocationLayer extends OsmandMapLayer {
protected final static int RADIUS = 7; protected final static int RADIUS = 7;
@ -135,16 +131,8 @@ public class PointLocationLayer extends OsmandMapLayer {
public void checkAppMode(ApplicationMode appMode) { public void checkAppMode(ApplicationMode appMode) {
if (appMode != this.appMode) { if (appMode != this.appMode) {
this.appMode = appMode; this.appMode = appMode;
if (appMode == ApplicationMode.CAR) { bearingIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceBearing());
bearingIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.car_bearing); locationIcon = BitmapFactory.decodeResource(view.getResources(), appMode.getResourceLocation());
locationIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.car_location);
} else if (appMode == ApplicationMode.BICYCLE) {
bearingIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.bicycle_bearing);
locationIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.bicycle_location);
} else {
bearingIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.pedestrian_bearing);
locationIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.pedestrian_location);
}
} }
} }

View file

@ -49,7 +49,7 @@ public class MapWidgetRegistry {
public MapWidgetRegistry(OsmandSettings settings) { public MapWidgetRegistry(OsmandSettings settings) {
this.settings = settings; this.settings = settings;
for(ApplicationMode ms : ApplicationMode.values() ) { for(ApplicationMode ms : ApplicationMode.values(settings) ) {
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms); String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
if(mpf.equals("")) { if(mpf.equals("")) {
visibleElements.put(ms, null); visibleElements.put(ms, null);
@ -65,11 +65,11 @@ public class MapWidgetRegistry {
public MapWidgetRegInfo registerAppearanceWidget(int drawable, int messageId, String key, public MapWidgetRegInfo registerAppearanceWidget(int drawable, int messageId, String key,
OsmandPreference<?> pref) { OsmandPreference<?> pref) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(); MapWidgetRegInfo ii = new MapWidgetRegInfo();
ii.defaultModes = EnumSet.noneOf(ApplicationMode.class); ii.defaultModes = ApplicationMode.noneOf();
ii.defaultCollapsible = null; ii.defaultCollapsible = null;
ii.key = key; ii.key = key;
ii.preference = pref; ii.preference = pref;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class); ii.visibleModes = ApplicationMode.noneOf();
ii.visibleCollapsible = null; ii.visibleCollapsible = null;
ii.drawable = drawable; ii.drawable = drawable;
ii.messageId = messageId; ii.messageId = messageId;
@ -89,12 +89,12 @@ public class MapWidgetRegistry {
public MapWidgetRegInfo registerAppearanceWidget(int drawable, String message, String key, public MapWidgetRegInfo registerAppearanceWidget(int drawable, String message, String key,
CommonPreference<?> pref, String subcategory) { CommonPreference<?> pref, String subcategory) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(); MapWidgetRegInfo ii = new MapWidgetRegInfo();
ii.defaultModes = EnumSet.noneOf(ApplicationMode.class); ii.defaultModes = ApplicationMode.noneOf();
ii.defaultCollapsible = null; ii.defaultCollapsible = null;
ii.key = key; ii.key = key;
ii.category = subcategory; ii.category = subcategory;
ii.preference = pref; ii.preference = pref;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class); ii.visibleModes = ApplicationMode.noneOf();
ii.visibleCollapsible = null; ii.visibleCollapsible = null;
ii.drawable = drawable; ii.drawable = drawable;
ii.messageId = message.hashCode(); ii.messageId = message.hashCode();
@ -104,14 +104,14 @@ public class MapWidgetRegistry {
} }
public MapWidgetRegInfo registerTopWidget(View m, int drawable, int messageId, String key, int left, public MapWidgetRegInfo registerTopWidget(View m, int drawable, int messageId, String key, int left,
EnumSet<ApplicationMode> appDefaultModes, int priorityOrder) { Set<ApplicationMode> appDefaultModes, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(); MapWidgetRegInfo ii = new MapWidgetRegInfo();
ii.defaultModes = appDefaultModes.clone(); ii.defaultModes = new LinkedHashSet<ApplicationMode>(appDefaultModes);
ii.defaultCollapsible = null; ii.defaultCollapsible = null;
ii.key = key; ii.key = key;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class); ii.visibleModes = ApplicationMode.noneOf();
ii.visibleCollapsible = null; ii.visibleCollapsible = null;
for(ApplicationMode ms : ApplicationMode.values() ) { for(ApplicationMode ms : ApplicationMode.values(settings) ) {
boolean def = appDefaultModes.contains(ms); boolean def = appDefaultModes.contains(ms);
Set<String> set = visibleElements.get(ms); Set<String> set = visibleElements.get(ms);
if (set != null) { if (set != null) {
@ -139,14 +139,14 @@ public class MapWidgetRegistry {
public void registerSideWidget(BaseMapWidget m, int drawable, int messageId, String key, boolean left, public void registerSideWidget(BaseMapWidget m, int drawable, int messageId, String key, boolean left,
EnumSet<ApplicationMode> appDefaultModes, EnumSet<ApplicationMode> defaultCollapsible, int priorityOrder) { Set<ApplicationMode> appDefaultModes, Set<ApplicationMode> defaultCollapsible, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(); MapWidgetRegInfo ii = new MapWidgetRegInfo();
ii.defaultModes = appDefaultModes.clone(); ii.defaultModes = new LinkedHashSet<ApplicationMode>(appDefaultModes);
ii.defaultCollapsible = defaultCollapsible.clone(); ii.defaultCollapsible = new LinkedHashSet<ApplicationMode>(defaultCollapsible);
ii.key = key; ii.key = key;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class); ii.visibleModes = ApplicationMode.noneOf();
ii.visibleCollapsible = EnumSet.noneOf(ApplicationMode.class); ii.visibleCollapsible = ApplicationMode.noneOf();
for(ApplicationMode ms : ApplicationMode.values() ) { for(ApplicationMode ms : ApplicationMode.values(settings) ) {
boolean collapse = defaultCollapsible.contains(ms);; boolean collapse = defaultCollapsible.contains(ms);;
boolean def = appDefaultModes.contains(ms); boolean def = appDefaultModes.contains(ms);
Set<String> set = visibleElements.get(ms); Set<String> set = visibleElements.get(ms);
@ -326,10 +326,10 @@ public class MapWidgetRegistry {
private String key; private String key;
private int position; private int position;
private String category; private String category;
private EnumSet<ApplicationMode> defaultModes; private Set<ApplicationMode> defaultModes;
private EnumSet<ApplicationMode> defaultCollapsible; private Set<ApplicationMode> defaultCollapsible;
private EnumSet<ApplicationMode> visibleModes; private Set<ApplicationMode> visibleModes;
private EnumSet<ApplicationMode> visibleCollapsible; private Set<ApplicationMode> visibleCollapsible;
private OsmandPreference<?> preference = null; private OsmandPreference<?> preference = null;
private Runnable stateChangeListener = null; private Runnable stateChangeListener = null;
public int priorityOrder; public int priorityOrder;