Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8d95e7569c
19 changed files with 356 additions and 219 deletions
|
@ -9,6 +9,8 @@
|
|||
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
|
||||
-->
|
||||
<string name="app_modes_choose_descr">Choose available application modes in application</string>
|
||||
<string name="app_modes_choose">Application Modes</string>
|
||||
<string name="map_widget_appearance">Remaining elements:</string>
|
||||
<string name="map_widget_map_rendering">Map rendering:</string>
|
||||
<string name="app_mode_hiking">Hiking</string>
|
||||
|
|
|
@ -3,14 +3,20 @@ package net.osmand.plus;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.StateChangedListener;
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
public class ApplicationMode {
|
||||
private static Map<String, Set<ApplicationMode>> widgets = new LinkedHashMap<String, Set<ApplicationMode>>();
|
||||
private static List<ApplicationMode> values = new ArrayList<ApplicationMode>();
|
||||
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<ApplicationMode>();
|
||||
private static boolean listenerRegistered = false;
|
||||
/*
|
||||
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian");
|
||||
*/
|
||||
|
@ -26,18 +32,51 @@ public class ApplicationMode {
|
|||
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();
|
||||
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();
|
||||
|
||||
static {
|
||||
ApplicationMode[] exceptPedestrian = new ApplicationMode[] { DEFAULT, CAR, BICYCLE, BOAT, AIRCRAFT };
|
||||
ApplicationMode[] exceptAirBoat = new ApplicationMode[] { DEFAULT, CAR, BICYCLE};
|
||||
ApplicationMode[] exceptCarBoatAir = new ApplicationMode[] { DEFAULT, BICYCLE, PEDESTRIAN };
|
||||
ApplicationMode[] pedestrian = new ApplicationMode[] { PEDESTRIAN };
|
||||
|
||||
ApplicationMode[] all = null;
|
||||
ApplicationMode[] none = new ApplicationMode[] {};
|
||||
|
||||
// left
|
||||
regWidget("next_turn", exceptPedestrian);
|
||||
regWidget("next_turn_small", pedestrian);
|
||||
regWidget("next_next_turn", exceptPedestrian);
|
||||
|
||||
// right
|
||||
regWidget("intermediate_distance", all);
|
||||
regWidget("distance", all);
|
||||
regWidget("time", all);
|
||||
regWidget("speed", exceptPedestrian);
|
||||
regWidget("max_speed", exceptAirBoat);
|
||||
regWidget("gps_info", exceptCarBoatAir);
|
||||
regWidget("altitude", exceptCarBoatAir);
|
||||
|
||||
// top
|
||||
regWidget("compass", all);
|
||||
regWidget("config", all);
|
||||
regWidget("street_name", exceptAirBoat);
|
||||
regWidget("back_to_location", all);
|
||||
regWidget("monitoring_services", exceptCarBoatAir);
|
||||
regWidget("bgService", none);
|
||||
regWidget("layers", none);
|
||||
}
|
||||
|
||||
|
||||
private static class ApplicationModeBuilder {
|
||||
|
@ -113,30 +152,63 @@ public class ApplicationMode {
|
|||
}
|
||||
|
||||
public static List<ApplicationMode> values(OsmandSettings settings) {
|
||||
// TODO
|
||||
if (cachedFilteredValues.isEmpty()) {
|
||||
if (!listenerRegistered) {
|
||||
settings.AVAILABLE_APP_MODES.addListener(new StateChangedListener<String>() {
|
||||
@Override
|
||||
public void stateChanged(String change) {
|
||||
cachedFilteredValues = new ArrayList<ApplicationMode>();
|
||||
}
|
||||
});
|
||||
listenerRegistered = true;
|
||||
}
|
||||
String available = settings.AVAILABLE_APP_MODES.get();
|
||||
cachedFilteredValues = new ArrayList<ApplicationMode>();
|
||||
for (ApplicationMode v : values) {
|
||||
if (available.indexOf(v.getStringKey() + ",") != -1 || v == DEFAULT) {
|
||||
cachedFilteredValues.add(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cachedFilteredValues;
|
||||
}
|
||||
|
||||
public static List<ApplicationMode> allPossibleValues(OsmandSettings settings) {
|
||||
return values;
|
||||
}
|
||||
|
||||
public static List<ApplicationMode> allPossibleValues(ClientContext ctx) {
|
||||
return values;
|
||||
|
||||
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
|
||||
public static Set<ApplicationMode> regWidget(String widgetId, ApplicationMode... am) {
|
||||
HashSet<ApplicationMode> set = new HashSet<ApplicationMode>();
|
||||
if(am == null) {
|
||||
set.addAll(values);
|
||||
} else {
|
||||
Collections.addAll(set, am);
|
||||
}
|
||||
for(ApplicationMode m : values) {
|
||||
// add derived modes
|
||||
if(set.contains(m.getParent())) {
|
||||
set.add(m);
|
||||
}
|
||||
}
|
||||
widgets.put(widgetId, set);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static Set<ApplicationMode> allOf() {
|
||||
// TODO
|
||||
return new HashSet<ApplicationMode>(values);
|
||||
public boolean isWidgetCollapsible(String key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Set<ApplicationMode> noneOf() {
|
||||
// TODO
|
||||
return new HashSet<ApplicationMode>();
|
||||
public boolean isWidgetVisible(String key) {
|
||||
Set<ApplicationMode> set = widgets.get(key);
|
||||
if(set == null) {
|
||||
return false;
|
||||
}
|
||||
return set.contains(this);
|
||||
}
|
||||
|
||||
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>();
|
||||
|
@ -184,6 +256,10 @@ public class ApplicationMode {
|
|||
return ctx.getString(key);
|
||||
}
|
||||
|
||||
public String toHumanStringCtx(ClientContext ctx) {
|
||||
return ctx.getString(key);
|
||||
}
|
||||
|
||||
public static ApplicationMode valueOfStringKey(String key, ApplicationMode def) {
|
||||
for(ApplicationMode p : values) {
|
||||
if(p.getStringKey().equals(key)) {
|
||||
|
@ -202,5 +278,11 @@ public class ApplicationMode {
|
|||
}
|
||||
|
||||
|
||||
public boolean isDerivedRoutingFrom(ApplicationMode mode) {
|
||||
return this == mode || getParent() == mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -27,12 +27,14 @@ public class CurrentPositionHelper {
|
|||
private void initCtx(ClientContext app) {
|
||||
am = app.getSettings().getApplicationMode();
|
||||
GeneralRouterProfile p ;
|
||||
if (am == ApplicationMode.BICYCLE) {
|
||||
if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
p = GeneralRouterProfile.BICYCLE;
|
||||
} else if (am == ApplicationMode.PEDESTRIAN) {
|
||||
} else if (am.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
p = GeneralRouterProfile.PEDESTRIAN;
|
||||
} else {
|
||||
} else if (am.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
p = GeneralRouterProfile.CAR;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
RoutingConfiguration cfg = RoutingConfiguration.getDefault().build(p.name().toLowerCase(), 10);
|
||||
ctx = new RoutingContext(cfg, null, app.getTodoAPI().getRoutingMapFiles());
|
||||
|
@ -43,6 +45,9 @@ public class CurrentPositionHelper {
|
|||
try {
|
||||
if(ctx == null || am != app.getSettings().getApplicationMode()) {
|
||||
initCtx(app);
|
||||
if(ctx == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
RouteSegment sg = rp.findRouteSegment(loc.getLatitude(), loc.getLongitude(), ctx);
|
||||
if(sg == null) {
|
||||
|
|
|
@ -13,7 +13,8 @@ public class OsmandBackupAgent extends BackupAgentHelper {
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
List<ApplicationMode> all = ApplicationMode.allPossibleValues((OsmandApplication) getApplicationContext());
|
||||
OsmandApplication app = (OsmandApplication) getApplicationContext();
|
||||
List<ApplicationMode> all = ApplicationMode.allPossibleValues(app.getSettings());
|
||||
String[] prefs = new String[all.size() + 1];
|
||||
prefs[0] = OsmandSettings.getSharedPreferencesName(null);
|
||||
int i = 1;
|
||||
|
|
|
@ -570,6 +570,8 @@ public class OsmandSettings {
|
|||
// 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 OsmandPreference<String> AVAILABLE_APP_MODES = new StringPreference("available_application_modes", "car,bicycle,pedestrian,").makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<ApplicationMode> DEFAULT_APPLICATION_MODE = new CommonPreference<ApplicationMode>("default_application_mode", ApplicationMode.DEFAULT) {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -306,7 +306,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
|
|||
protected void profileDialog() {
|
||||
Builder b = new AlertDialog.Builder(this);
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
View v = NavigateAction.prepareAppModeView(this, selected, false, null,
|
||||
View v = NavigateAction.prepareAppModeView(this, selected, false, null, false,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -360,52 +360,63 @@ public class NavigateAction {
|
|||
|
||||
|
||||
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
|
||||
ViewGroup parent, final View.OnClickListener onClickListener) {
|
||||
LinearLayout ll = (LinearLayout) a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
|
||||
ViewGroup parent, final boolean singleSelection, final View.OnClickListener onClickListener) {
|
||||
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
|
||||
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(settings));
|
||||
if(!showDefault) {
|
||||
values.remove(ApplicationMode.DEFAULT);
|
||||
}
|
||||
selected.add(settings.getApplicationMode());
|
||||
return prepareAppModeView(a, values, selected, parent, singleSelection, onClickListener);
|
||||
|
||||
}
|
||||
|
||||
public static View prepareAppModeView(Activity a, final List<ApplicationMode> values , final Set<ApplicationMode> selected,
|
||||
ViewGroup parent, final boolean singleSelection, final View.OnClickListener onClickListener) {
|
||||
LinearLayout ll = (LinearLayout) a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
|
||||
final ToggleButton[] buttons = createToggles(values, ll, a);
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
if (buttons[i] != null) {
|
||||
final int ind = i;
|
||||
ToggleButton b = buttons[i];
|
||||
final ApplicationMode buttonAppMode = values.get(i);
|
||||
b.setChecked(appMode == buttonAppMode);
|
||||
if(appMode == buttonAppMode) {
|
||||
selected.add(appMode);
|
||||
}
|
||||
b.setChecked(selected.contains(buttonAppMode));
|
||||
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
selected.clear();
|
||||
for (int j = 0; j < buttons.length; j++) {
|
||||
if (buttons[j] != null) {
|
||||
if(ind == j) {
|
||||
selected.add(values.get(j));
|
||||
if (singleSelection) {
|
||||
if (isChecked) {
|
||||
selected.clear();
|
||||
for (int j = 0; j < buttons.length; j++) {
|
||||
if (buttons[j] != null) {
|
||||
if (ind == j) {
|
||||
selected.add(values.get(j));
|
||||
}
|
||||
if (buttons[j].isChecked() != (ind == j)) {
|
||||
buttons[j].setChecked(ind == j);
|
||||
}
|
||||
}
|
||||
if (buttons[j].isChecked() != (ind == j)) {
|
||||
buttons[j].setChecked(ind == j);
|
||||
}
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 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);
|
||||
if (isChecked) {
|
||||
selected.add(buttonAppMode);
|
||||
} else {
|
||||
selected.remove(buttonAppMode);
|
||||
}
|
||||
}
|
||||
if(onClickListener != null) {
|
||||
|
@ -482,7 +493,7 @@ public class NavigateAction {
|
|||
return mapActivity.getString(resId);
|
||||
}
|
||||
|
||||
private ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings, List<ApplicationMode> modes){
|
||||
private static ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings, List<ApplicationMode> modes){
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
if (buttons[i] != null && buttons[i].isChecked() && i < modes.size()) {
|
||||
return modes.get(i);
|
||||
|
|
|
@ -334,6 +334,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
public AudioVideoNotesPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
OsmandSettings settings = app.getSettings();
|
||||
ApplicationMode.regWidget("audionotes", (ApplicationMode[])null);
|
||||
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
|
||||
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
|
||||
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
|
||||
|
@ -467,8 +468,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
recordControl.setImageDrawable(activity.getResources().getDrawable(R.drawable.monitoring_rec_inactive));
|
||||
setRecordListener(recordControl, activity);
|
||||
mapInfoLayer.getMapInfoControls().registerSideWidget(recordControl, R.drawable.widget_icon_av_inactive,
|
||||
R.string.map_widget_av_notes, "audionotes", false, ApplicationMode.allOf(),
|
||||
ApplicationMode.noneOf(), 22);
|
||||
R.string.map_widget_av_notes, "audionotes", false, 22);
|
||||
mapInfoLayer.recreateControls();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package net.osmand.plus.development;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.audionotes.AudioNotesLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -25,6 +21,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
|
||||
public OsmandDevelopmentPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,8 +65,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
}
|
||||
};
|
||||
mapInfoLayer.getMapInfoControls().registerSideWidget(fps, 0,
|
||||
R.string.map_widget_fps_info, "fps", false, ApplicationMode.noneOf(),
|
||||
ApplicationMode.noneOf(), 30);
|
||||
R.string.map_widget_fps_info, "fps", false, 30);
|
||||
mapInfoLayer.recreateControls();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,17 @@ package net.osmand.plus.development;
|
|||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.actions.NavigateAction;
|
||||
import net.osmand.util.SunriseSunset;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Debug;
|
||||
|
@ -14,10 +21,12 @@ import android.preference.CheckBoxPreference;
|
|||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.view.View;
|
||||
|
||||
public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -43,6 +52,19 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
});
|
||||
cat.addPreference(pref);
|
||||
|
||||
pref = new Preference(this);
|
||||
pref.setTitle(R.string.app_modes_choose);
|
||||
pref.setSummary(R.string.app_modes_choose_descr);
|
||||
pref.setKey("available_application_modes");
|
||||
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
availableProfileDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
cat.addPreference(pref);
|
||||
|
||||
pref = new Preference(this);
|
||||
pref.setTitle(R.string.global_app_allocated_memory);
|
||||
|
||||
|
@ -80,6 +102,32 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
cat.addPreference(pref);
|
||||
}
|
||||
|
||||
protected void availableProfileDialog() {
|
||||
Builder b = new AlertDialog.Builder(this);
|
||||
final List<ApplicationMode> modes = ApplicationMode.allPossibleValues(settings);
|
||||
modes.remove(ApplicationMode.DEFAULT);
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>(ApplicationMode.values(settings));
|
||||
selected.remove(ApplicationMode.DEFAULT);
|
||||
View v = NavigateAction.prepareAppModeView(this, modes, selected, null, false,
|
||||
new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey()+",");
|
||||
for(ApplicationMode mode : modes) {
|
||||
if(selected.contains(mode)) {
|
||||
vls.append(mode.getStringKey()+",");
|
||||
}
|
||||
}
|
||||
settings.AVAILABLE_APP_MODES.set(vls.toString());
|
||||
}
|
||||
});
|
||||
b.setTitle(R.string.profile_settings);
|
||||
b.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
b.setView(v);
|
||||
b.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
|
||||
public DistanceCalculatorPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
ApplicationMode.regWidget("distance.measurement", ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -113,9 +114,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
if (mapInfoLayer != null ) {
|
||||
distanceControl = createDistanceControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText());
|
||||
mapInfoLayer.getMapInfoControls().registerSideWidget(distanceControl,
|
||||
R.drawable.widget_distance, R.string.map_widget_distancemeasurement, "distance.measurement", false,
|
||||
ApplicationMode.of(ApplicationMode.DEFAULT, ApplicationMode.PEDESTRIAN),
|
||||
ApplicationMode.noneOf(), 21);
|
||||
R.drawable.widget_distance, R.string.map_widget_distancemeasurement, "distance.measurement", false, 21);
|
||||
mapInfoLayer.recreateControls();
|
||||
updateText();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
|
@ -41,6 +39,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
|
|||
|
||||
public OsmandMonitoringPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
ApplicationMode.regWidget("monitoring", ApplicationMode.DEFAULT, ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,8 +69,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
|
|||
monitoringControl = createMonitoringControl(activity, layer.getPaintText(), layer.getPaintSubText());
|
||||
|
||||
layer.getMapInfoControls().registerSideWidget(monitoringControl,
|
||||
R.drawable.monitoring_rec_big, R.string.map_widget_monitoring, "monitoring", false,
|
||||
ApplicationMode.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN), ApplicationMode.noneOf(), 18);
|
||||
R.drawable.monitoring_rec_big, R.string.map_widget_monitoring, "monitoring", false, 18);
|
||||
layer.recreateControls();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
public ParkingPositionPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
OsmandSettings set = app.getSettings();
|
||||
ApplicationMode. regWidget("parking", (ApplicationMode[]) null);
|
||||
parkingLat = set.registerFloatPreference(PARKING_POINT_LAT, 0f).makeGlobal();
|
||||
parkingLon = set.registerFloatPreference(PARKING_POINT_LON, 0f).makeGlobal();
|
||||
parkingType = set.registerBooleanPreference(PARKING_TYPE, false).makeGlobal();
|
||||
|
@ -190,8 +191,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
if (mapInfoLayer != null) {
|
||||
parkingPlaceControl = createParkingPlaceInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText());
|
||||
mapInfoLayer.getMapInfoControls().registerSideWidget(parkingPlaceControl,
|
||||
R.drawable.widget_parking, R.string.map_widget_parking, "parking", false,
|
||||
ApplicationMode.allOf(), ApplicationMode.noneOf(), 8);
|
||||
R.drawable.widget_parking, R.string.map_widget_parking, "parking", false, 8);
|
||||
mapInfoLayer.recreateControls();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,12 +282,14 @@ public class RouteProvider {
|
|||
uri.append("&flon=").append(params.start.getLongitude()); //$NON-NLS-1$
|
||||
uri.append("&tlat=").append(params.end.getLatitude()); //$NON-NLS-1$
|
||||
uri.append("&tlon=").append(params.end.getLongitude()); //$NON-NLS-1$
|
||||
if(ApplicationMode.PEDESTRIAN == params.mode){
|
||||
uri.append("&v=foot") ; //$NON-NLS-1$
|
||||
} else if(ApplicationMode.BICYCLE == params.mode){
|
||||
if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
uri.append("&v=bicycle") ; //$NON-NLS-1$
|
||||
} else {
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
uri.append("&v=foot") ; //$NON-NLS-1$
|
||||
} else if(params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)){
|
||||
uri.append("&v=motorcar"); //$NON-NLS-1$
|
||||
} else {
|
||||
return applicationModeNotSupported(params);
|
||||
}
|
||||
uri.append("&fast=").append(params.fast ? "1" : "0").append("&layer=mapnik"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
log.info("URL route " + uri);
|
||||
|
@ -349,12 +351,14 @@ public class RouteProvider {
|
|||
config = RoutingConfiguration.getDefault();
|
||||
}
|
||||
GeneralRouterProfile p ;
|
||||
if (params.mode == ApplicationMode.BICYCLE) {
|
||||
if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
p = GeneralRouterProfile.BICYCLE;
|
||||
} else if (params.mode == ApplicationMode.PEDESTRIAN) {
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
p = GeneralRouterProfile.PEDESTRIAN;
|
||||
} else {
|
||||
} else if(params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)){
|
||||
p = GeneralRouterProfile.CAR;
|
||||
} else {
|
||||
return applicationModeNotSupported(params);
|
||||
}
|
||||
// order matters
|
||||
List<String> specs = new ArrayList<String>();
|
||||
|
@ -417,10 +421,10 @@ public class RouteProvider {
|
|||
return new RouteCalculationResult("Route can not be found from end point (" +ctx.calculationProgress.distanceFromEnd/1000f+" km)");
|
||||
}
|
||||
if(ctx.calculationProgress.isCancelled) {
|
||||
return new RouteCalculationResult("Route calculation was interrupted");
|
||||
return interrupted();
|
||||
}
|
||||
// something really strange better to see that message on the scren
|
||||
return new RouteCalculationResult("Empty result");
|
||||
return emptyResult();
|
||||
} else {
|
||||
RouteCalculationResult res = new RouteCalculationResult(result, params.start, params.end,
|
||||
params.intermediates, params.ctx, params.leftSide, ctx.routingTime);
|
||||
|
@ -429,7 +433,7 @@ public class RouteProvider {
|
|||
} catch (RuntimeException e) {
|
||||
return new RouteCalculationResult(e.getMessage() );
|
||||
} catch (InterruptedException e) {
|
||||
return new RouteCalculationResult("Route calculation was interrupted");
|
||||
return interrupted();
|
||||
} catch (OutOfMemoryError e) {
|
||||
// ActivityManager activityManager = (ActivityManager)app.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
// ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||
|
@ -443,6 +447,21 @@ public class RouteProvider {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private RouteCalculationResult applicationModeNotSupported(RouteCalculationParams params) {
|
||||
return new RouteCalculationResult("Application mode '"+ params.mode.toHumanStringCtx(params.ctx)+ "'is not supported.");
|
||||
}
|
||||
|
||||
private RouteCalculationResult interrupted() {
|
||||
return new RouteCalculationResult("Route calculation was interrupted");
|
||||
}
|
||||
|
||||
private RouteCalculationResult emptyResult() {
|
||||
return new RouteCalculationResult("Empty result");
|
||||
}
|
||||
|
||||
|
||||
protected RouteCalculationResult findCloudMadeRoute(RouteCalculationParams params)
|
||||
throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, SAXException {
|
||||
List<Location> res = new ArrayList<Location>();
|
||||
|
@ -470,27 +489,27 @@ public class RouteProvider {
|
|||
uri.append(params.end.getLatitude() + "").append(","); //$NON-NLS-1$//$NON-NLS-2$
|
||||
uri.append(params.end.getLongitude() + "").append("/"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
float speed = 1.5f;
|
||||
if (ApplicationMode.PEDESTRIAN == params.mode) {
|
||||
if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
uri.append("foot.gpx"); //$NON-NLS-1$
|
||||
} else if (ApplicationMode.BICYCLE == params.mode) {
|
||||
speed = 4.2f;
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
uri.append("bicycle.gpx"); //$NON-NLS-1$
|
||||
} else {
|
||||
speed = 15.3f;
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
if (params.fast) {
|
||||
uri.append("car.gpx"); //$NON-NLS-1$
|
||||
} else {
|
||||
uri.append("car/shortest.gpx"); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
return applicationModeNotSupported(params);
|
||||
}
|
||||
|
||||
uri.append("?lang=").append(Locale.getDefault().getLanguage()); //$NON-NLS-1$
|
||||
log.info("URL route " + uri);
|
||||
URL url = new URL(uri.toString());
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", Version.getFullVersion(params.ctx));
|
||||
GPXFile gpxFile = GPXUtilities.loadGPXFile(params.ctx, connection.getInputStream(), false);
|
||||
directions = parseCloudmadeRoute(res, gpxFile, false, params.leftSide, speed);
|
||||
directions = parseCloudmadeRoute(res, gpxFile, false, params.leftSide, params.mode.getDefaultSpeed());
|
||||
|
||||
return new RouteCalculationResult(res, directions, params, null);
|
||||
}
|
||||
|
@ -616,9 +635,9 @@ public class RouteProvider {
|
|||
List<Location> res = new ArrayList<Location>();
|
||||
|
||||
String rpref = "Fastest";
|
||||
if (ApplicationMode.PEDESTRIAN == params.mode) {
|
||||
if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
rpref = "Pedestrian";
|
||||
} else if (ApplicationMode.BICYCLE == params.mode) {
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
rpref = "Bicycle";
|
||||
// } else if (ApplicationMode.LOWTRAFFIC == mode) {
|
||||
// rpref = "BicycleSafety";
|
||||
|
@ -628,8 +647,12 @@ public class RouteProvider {
|
|||
// rpref = "BicycleRoute";
|
||||
// } else if (ApplicationMode.MTBIKE == mode) {
|
||||
// rpref = "BicycleMTB";
|
||||
} else if (!params.fast) {
|
||||
rpref = "Shortest";
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
if (!params.fast) {
|
||||
rpref = "Shortest";
|
||||
}
|
||||
} else {
|
||||
return applicationModeNotSupported(params);
|
||||
}
|
||||
|
||||
StringBuilder request = new StringBuilder();
|
||||
|
|
|
@ -104,7 +104,7 @@ public class VoiceRouter {
|
|||
// lead time criterion only for TURN_IN and TURN
|
||||
PREPARE_LONG_DISTANCE = 3500; // [105 sec] - 120 km/h
|
||||
PREPARE_LONG_DISTANCE_END = 3000; // [ 90 sec] - 120 km/h
|
||||
if(router.getAppMode() == ApplicationMode.PEDESTRIAN){
|
||||
if(router.getAppMode().isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)){
|
||||
// prepare_long_distance warning not needed for pedestrian
|
||||
PREPARE_LONG_DISTANCE_END = PREPARE_LONG_DISTANCE + 100; // do not play
|
||||
// prepare distance is not needed for pedestrian
|
||||
|
@ -116,7 +116,7 @@ public class VoiceRouter {
|
|||
TURN_IN_DISTANCE_END = 30; // 15 sec (was 70m, 35 sec)
|
||||
TURN_DISTANCE = 15; // 7,5sec (was 25m, 12 sec). Check if this works with GPS accuracy!
|
||||
TURN_DEFAULT_SPEED = DEFAULT_SPEED = 2f; // 7,2 km/h
|
||||
} else if(router.getAppMode() == ApplicationMode.BICYCLE){
|
||||
} else if(router.getAppMode().isDerivedRoutingFrom(ApplicationMode.BICYCLE)){
|
||||
PREPARE_LONG_DISTANCE = 500; // [100 sec]
|
||||
PREPARE_LONG_DISTANCE_END = 300; // [ 60 sec]
|
||||
PREPARE_DISTANCE = 200; // [ 40 sec] (was 500m, 100sec)
|
||||
|
@ -125,7 +125,7 @@ public class VoiceRouter {
|
|||
TURN_IN_DISTANCE_END = 60; // 12 sec (was 80m, 16sec)
|
||||
TURN_DISTANCE = 30; // 6 sec (was 45m, 9sec). Check if this works with GPS accuracy!
|
||||
TURN_DEFAULT_SPEED = DEFAULT_SPEED = 5; // 18 km/h
|
||||
} else {
|
||||
} else if(router.getAppMode().isDerivedRoutingFrom(ApplicationMode.CAR)){
|
||||
PREPARE_DISTANCE = 1500; // [125 sec]
|
||||
PREPARE_DISTANCE_END = 1200; // [100 sec]
|
||||
TURN_IN_DISTANCE = 390; // 30 sec
|
||||
|
@ -133,6 +133,16 @@ public class VoiceRouter {
|
|||
TURN_DISTANCE = 50; // 7 sec
|
||||
TURN_DEFAULT_SPEED = 7f; // 25 km/h
|
||||
DEFAULT_SPEED = 13; // 48 km/h
|
||||
} else {
|
||||
DEFAULT_SPEED = router.getAppMode().getDefaultSpeed();
|
||||
TURN_DEFAULT_SPEED = DEFAULT_SPEED / 2;
|
||||
PREPARE_LONG_DISTANCE = (int) (DEFAULT_SPEED * 305);
|
||||
PREPARE_LONG_DISTANCE_END = (int) (DEFAULT_SPEED * 225);
|
||||
PREPARE_DISTANCE = (int) (DEFAULT_SPEED * 125);
|
||||
PREPARE_DISTANCE_END = (int) (DEFAULT_SPEED * 100);
|
||||
TURN_IN_DISTANCE = (int) (DEFAULT_SPEED * 30);
|
||||
TURN_IN_DISTANCE_END = (int) (DEFAULT_SPEED * 14);
|
||||
TURN_DISTANCE = (int) (DEFAULT_SPEED * 7);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
OsmandSettings settings = app.getSettings();
|
||||
CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
|
||||
if(pref.get().equals("")) {
|
||||
for(ApplicationMode m : ApplicationMode.allPossibleValues(app)) {
|
||||
for(ApplicationMode m : ApplicationMode.allPossibleValues(settings)) {
|
||||
if(pref.getModeValue(m).equals("")) {
|
||||
pref.setModeValue(m, "13");
|
||||
}
|
||||
|
|
|
@ -170,57 +170,54 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
alarmControl = ric.createAlarmInfoControl(app, map);
|
||||
// register right stack
|
||||
Set<ApplicationMode> all = ApplicationMode.allOf();
|
||||
Set<ApplicationMode> carBicycleDefault = ApplicationMode.of(ApplicationMode.CAR, ApplicationMode.DEFAULT, ApplicationMode.BICYCLE);
|
||||
Set<ApplicationMode> exceptCar = ApplicationMode.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT);
|
||||
Set<ApplicationMode> none = ApplicationMode.noneOf();
|
||||
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(), paintText,
|
||||
paintSubText, false);
|
||||
mapInfoControls.registerSideWidget(bigInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn,"next_turn", true, carBicycleDefault, none, 5);
|
||||
mapInfoControls.registerSideWidget(bigInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn,"next_turn", true, 5);
|
||||
NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(routingHelper, app, view.getSettings(),
|
||||
paintSmallText, paintSmallSubText, true);
|
||||
mapInfoControls.registerSideWidget(smallInfoControl, R.drawable.widget_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true,
|
||||
ApplicationMode.of(ApplicationMode.PEDESTRIAN), none, 10);
|
||||
10);
|
||||
NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(routingHelper, app, view.getSettings(),
|
||||
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, 15);
|
||||
//MiniMapControl miniMap = ric.createMiniMapControl(routingHelper, view);
|
||||
//mapInfoControls.registerSideWidget(miniMap, R.drawable.widget_next_turn, R.string.map_widget_mini_route, "mini_route", true, none, none, 20);
|
||||
// right stack
|
||||
TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(intermediateDist, R.drawable.widget_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, all, none, 3);
|
||||
mapInfoControls.registerSideWidget(intermediateDist, R.drawable.widget_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, 3);
|
||||
TextInfoWidget dist = ric.createDistanceControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(dist, R.drawable.widget_target, R.string.map_widget_distance, "distance", false, all, none, 5);
|
||||
mapInfoControls.registerSideWidget(dist, R.drawable.widget_target, R.string.map_widget_distance, "distance", false, 5);
|
||||
TextInfoWidget time = ric.createTimeControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(time, R.drawable.widget_time, R.string.map_widget_time, "time",false, all, none, 10);
|
||||
mapInfoControls.registerSideWidget(time, R.drawable.widget_time, R.string.map_widget_time, "time",false, 10);
|
||||
TextInfoWidget speed = ric.createSpeedControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, carBicycleDefault, none, 15);
|
||||
mapInfoControls.registerSideWidget(speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, 15);
|
||||
TextInfoWidget gpsInfo = mic.createGPSInfoControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(gpsInfo, R.drawable.widget_gps_info, R.string.map_widget_gps_info, "gps_info", false, exceptCar, none, 17);
|
||||
mapInfoControls.registerSideWidget(gpsInfo, R.drawable.widget_gps_info, R.string.map_widget_gps_info, "gps_info", false, 17);
|
||||
TextInfoWidget maxspeed = ric.createMaxSpeedControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(maxspeed, R.drawable.widget_max_speed, R.string.map_widget_max_speed, "max_speed", false, carBicycleDefault, none, 18);
|
||||
mapInfoControls.registerSideWidget(maxspeed, R.drawable.widget_max_speed, R.string.map_widget_max_speed, "max_speed", false, 18);
|
||||
TextInfoWidget alt = mic.createAltitudeControl(map, paintText, paintSubText);
|
||||
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, exceptCar, none, 20);
|
||||
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, 20);
|
||||
|
||||
// Top widgets
|
||||
ImageViewWidget compassView = mic.createCompassView(map);
|
||||
mapInfoControls.registerTopWidget(compassView, R.drawable.widget_compass, R.string.map_widget_compass, "compass", MapWidgetRegistry.LEFT_CONTROL, all, 5);
|
||||
mapInfoControls.registerTopWidget(compassView, R.drawable.widget_compass, R.string.map_widget_compass, "compass", MapWidgetRegistry.LEFT_CONTROL, 5);
|
||||
View config = createConfiguration();
|
||||
mapInfoControls.registerTopWidget(config, R.drawable.widget_config, R.string.map_widget_config, "config", MapWidgetRegistry.RIGHT_CONTROL, all, 10).required(ApplicationMode.DEFAULT);
|
||||
mapInfoControls.registerTopWidget(config, R.drawable.widget_config, R.string.map_widget_config, "config", MapWidgetRegistry.RIGHT_CONTROL, 10).required(ApplicationMode.DEFAULT);
|
||||
mapInfoControls.registerTopWidget(monitoringServices.createMonitoringWidget(view, map), R.drawable.widget_monitoring, R.string.map_widget_monitoring_services,
|
||||
"monitoring_services", MapWidgetRegistry.LEFT_CONTROL, exceptCar, 12);
|
||||
"monitoring_services", MapWidgetRegistry.LEFT_CONTROL, 12);
|
||||
mapInfoControls.registerTopWidget(mic.createLockInfo(map), R.drawable.widget_lock_screen, R.string.bg_service_screen_lock, "bgService",
|
||||
MapWidgetRegistry.LEFT_CONTROL, none, 15);
|
||||
MapWidgetRegistry.LEFT_CONTROL, 15);
|
||||
backToLocation = mic.createBackToLocation(map);
|
||||
mapInfoControls.registerTopWidget(backToLocation, R.drawable.widget_backtolocation, R.string.map_widget_back_to_loc, "back_to_location", MapWidgetRegistry.RIGHT_CONTROL, all, 5);
|
||||
mapInfoControls.registerTopWidget(backToLocation, R.drawable.widget_backtolocation, R.string.map_widget_back_to_loc, "back_to_location", MapWidgetRegistry.RIGHT_CONTROL, 5);
|
||||
|
||||
View globus = createLayer();
|
||||
mapInfoControls.registerTopWidget(globus, R.drawable.widget_layer, R.string.menu_layers, "progress", MapWidgetRegistry.RIGHT_CONTROL, none, 15);
|
||||
mapInfoControls.registerTopWidget(globus, R.drawable.widget_layer, R.string.menu_layers, "layers", MapWidgetRegistry.RIGHT_CONTROL, 15);
|
||||
|
||||
topText = mic.createStreetView(app, map, paintText);
|
||||
mapInfoControls.registerTopWidget(topText, R.drawable.street_name, R.string.map_widget_top_text,
|
||||
"street_name", MapWidgetRegistry.MAIN_CONTROL, all, 100);
|
||||
"street_name", MapWidgetRegistry.MAIN_CONTROL, 100);
|
||||
|
||||
// Register appearance widgets
|
||||
AppearanceWidgetsFactory.INSTANCE.registerAppearanceWidgets(map, this, mapInfoControls);
|
||||
|
@ -330,7 +327,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
final OsmandSettings settings = view.getSettings();
|
||||
|
||||
final ArrayList<Object> list = new ArrayList<Object>();
|
||||
String appMode = settings.getApplicationMode().toHumanString(view.getApplication());
|
||||
list.add(map.getString(R.string.map_widget_reset));
|
||||
list.add(map.getString(R.string.map_widget_top_stack));
|
||||
list.addAll(mapInfoControls.getTop());
|
||||
|
@ -423,7 +419,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
View confirmDialog = view.inflate(view.getContext(), R.layout.configuration_dialog, null);
|
||||
final ListView lv = (ListView) confirmDialog.findViewById(android.R.id.list);
|
||||
NavigateAction.prepareAppModeView(map, selected, true,
|
||||
(ViewGroup) confirmDialog.findViewById(R.id.TopBar),
|
||||
(ViewGroup) confirmDialog.findViewById(R.id.TopBar), false,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -24,6 +24,7 @@ public class AppearanceWidgetsFactory {
|
|||
public static AppearanceWidgetsFactory INSTANCE = new AppearanceWidgetsFactory();
|
||||
private String ADDITIONAL_VECTOR_RENDERING_CATEGORY;
|
||||
public static boolean EXTRA_SETTINGS = true;
|
||||
public static boolean POSITION_ON_THE_MAP = false;
|
||||
|
||||
|
||||
public void registerAppearanceWidgets(final MapActivity map, final MapInfoLayer mapInfoLayer,
|
||||
|
@ -42,8 +43,6 @@ public class AppearanceWidgetsFactory {
|
|||
});
|
||||
|
||||
if (EXTRA_SETTINGS) {
|
||||
// previous extra settings
|
||||
|
||||
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
|
||||
"showRuler", view.getSettings().SHOW_RULER);
|
||||
showRuler.setStateChangeListener(new Runnable() {
|
||||
|
@ -74,28 +73,32 @@ public class AppearanceWidgetsFactory {
|
|||
}
|
||||
});
|
||||
|
||||
// final OsmandSettings.OsmandPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
|
||||
// final MapWidgetRegistry.MapWidgetRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map,
|
||||
// "position_on_map", textSizePref);
|
||||
// posMap.setStateChangeListener(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// String[] entries = new String[] {map.getString(R.string.position_on_map_center), map.getString(R.string.position_on_map_bottom) };
|
||||
// final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT };
|
||||
// AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||
// int i = Arrays.binarySearch(vals, posPref.get());
|
||||
// b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// posPref.set(vals[which]);
|
||||
// map.updateApplicationModeSettings();
|
||||
// view.refreshMap(true);
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// });
|
||||
// b.show();
|
||||
// }
|
||||
// });
|
||||
if (POSITION_ON_THE_MAP) {
|
||||
final OsmandSettings.OsmandPreference<Integer> posPref = view.getSettings().POSITION_ON_MAP;
|
||||
final MapWidgetRegistry.MapWidgetRegInfo posMap = mapInfoControls.registerAppearanceWidget(
|
||||
R.drawable.widget_position_marker, R.string.position_on_map, "position_on_map", posPref);
|
||||
posMap.setStateChangeListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String[] entries = new String[] { map.getString(R.string.position_on_map_center),
|
||||
map.getString(R.string.position_on_map_bottom) };
|
||||
final Integer[] vals = new Integer[] { OsmandSettings.CENTER_CONSTANT,
|
||||
OsmandSettings.BOTTOM_CONSTANT };
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||
int i = Arrays.binarySearch(vals, posPref.get());
|
||||
b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
posPref.set(vals[which]);
|
||||
map.updateApplicationModeSettings();
|
||||
view.refreshMap(true);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -164,34 +167,6 @@ public class AppearanceWidgetsFactory {
|
|||
bld.show();
|
||||
}
|
||||
});
|
||||
|
||||
/*final OsmandSettings.OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
|
||||
final MapWidgetRegistry.MapWidgetRegInfo textSize = mapInfoControls.registerAppearanceWidget(R.drawable.widget_text_size, R.string.map_text_size,
|
||||
"text_size", textSizePref, map.getString(R.string.map_widget_map_rendering));
|
||||
textSize.setStateChangeListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Float[] floatValues = new Float[] {0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 1.75f, 2f};
|
||||
String[] entries = new String[floatValues.length];
|
||||
for (int i = 0; i < floatValues.length; i++) {
|
||||
entries[i] = (int) (floatValues[i] * 100) +" %";
|
||||
}
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(view.getContext());
|
||||
b.setTitle(R.string.map_text_size);
|
||||
int i = Arrays.binarySearch(floatValues, textSizePref.get());
|
||||
b.setSingleChoiceItems(entries, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
textSizePref.set(floatValues[which]);
|
||||
app.getResourceManager().getRenderer().clearCache();
|
||||
view.refreshMap(true);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
}
|
||||
});*/
|
||||
|
||||
RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if(renderer != null && EXTRA_SETTINGS) {
|
||||
createCustomRenderingProperties(renderer, map, mapInfoLayer, mapInfoControls);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MapWidgetRegistry {
|
|||
return cmp;
|
||||
}
|
||||
});
|
||||
private Map<ApplicationMode, Set<String>> visibleElements = new LinkedHashMap<ApplicationMode, Set<String>>();
|
||||
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<ApplicationMode, Set<String>>();
|
||||
private final OsmandSettings settings;
|
||||
|
||||
|
||||
|
@ -52,10 +52,10 @@ public class MapWidgetRegistry {
|
|||
for(ApplicationMode ms : ApplicationMode.values(settings) ) {
|
||||
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
|
||||
if(mpf.equals("")) {
|
||||
visibleElements.put(ms, null);
|
||||
visibleElementsFromSettings.put(ms, null);
|
||||
} else {
|
||||
LinkedHashSet<String> set = new LinkedHashSet<String>();
|
||||
visibleElements.put(ms, set);
|
||||
visibleElementsFromSettings.put(ms, set);
|
||||
Collections.addAll(set, mpf.split(";"));
|
||||
}
|
||||
}
|
||||
|
@ -65,11 +65,9 @@ public class MapWidgetRegistry {
|
|||
public MapWidgetRegInfo registerAppearanceWidget(int drawable, int messageId, String key,
|
||||
OsmandPreference<?> pref) {
|
||||
MapWidgetRegInfo ii = new MapWidgetRegInfo();
|
||||
ii.defaultModes = ApplicationMode.noneOf();
|
||||
ii.defaultCollapsible = null;
|
||||
ii.key = key;
|
||||
ii.preference = pref;
|
||||
ii.visibleModes = ApplicationMode.noneOf();
|
||||
ii.visibleModes = new LinkedHashSet<ApplicationMode>();
|
||||
ii.visibleCollapsible = null;
|
||||
ii.drawable = drawable;
|
||||
ii.messageId = messageId;
|
||||
|
@ -89,12 +87,10 @@ public class MapWidgetRegistry {
|
|||
public MapWidgetRegInfo registerAppearanceWidget(int drawable, String message, String key,
|
||||
CommonPreference<?> pref, String subcategory) {
|
||||
MapWidgetRegInfo ii = new MapWidgetRegInfo();
|
||||
ii.defaultModes = ApplicationMode.noneOf();
|
||||
ii.defaultCollapsible = null;
|
||||
ii.key = key;
|
||||
ii.category = subcategory;
|
||||
ii.preference = pref;
|
||||
ii.visibleModes = ApplicationMode.noneOf();
|
||||
ii.visibleModes = new LinkedHashSet<ApplicationMode>();
|
||||
ii.visibleCollapsible = null;
|
||||
ii.drawable = drawable;
|
||||
ii.messageId = message.hashCode();
|
||||
|
@ -103,17 +99,14 @@ public class MapWidgetRegistry {
|
|||
return ii;
|
||||
}
|
||||
|
||||
public MapWidgetRegInfo registerTopWidget(View m, int drawable, int messageId, String key, int left,
|
||||
Set<ApplicationMode> appDefaultModes, int priorityOrder) {
|
||||
public MapWidgetRegInfo registerTopWidget(View m, int drawable, int messageId, String key, int left, int priorityOrder) {
|
||||
MapWidgetRegInfo ii = new MapWidgetRegInfo();
|
||||
ii.defaultModes = new LinkedHashSet<ApplicationMode>(appDefaultModes);
|
||||
ii.defaultCollapsible = null;
|
||||
ii.key = key;
|
||||
ii.visibleModes = ApplicationMode.noneOf();
|
||||
ii.visibleModes = new LinkedHashSet<ApplicationMode>();
|
||||
ii.visibleCollapsible = null;
|
||||
for(ApplicationMode ms : ApplicationMode.values(settings) ) {
|
||||
boolean def = appDefaultModes.contains(ms);
|
||||
Set<String> set = visibleElements.get(ms);
|
||||
boolean def = ms.isWidgetVisible(key);
|
||||
Set<String> set = visibleElementsFromSettings.get(ms);
|
||||
if (set != null) {
|
||||
if (set.contains(key)) {
|
||||
def = true;
|
||||
|
@ -138,18 +131,15 @@ public class MapWidgetRegistry {
|
|||
|
||||
|
||||
|
||||
public void registerSideWidget(BaseMapWidget m, int drawable, int messageId, String key, boolean left,
|
||||
Set<ApplicationMode> appDefaultModes, Set<ApplicationMode> defaultCollapsible, int priorityOrder) {
|
||||
public void registerSideWidget(BaseMapWidget m, int drawable, int messageId, String key, boolean left, int priorityOrder) {
|
||||
MapWidgetRegInfo ii = new MapWidgetRegInfo();
|
||||
ii.defaultModes = new LinkedHashSet<ApplicationMode>(appDefaultModes);
|
||||
ii.defaultCollapsible = new LinkedHashSet<ApplicationMode>(defaultCollapsible);
|
||||
ii.key = key;
|
||||
ii.visibleModes = ApplicationMode.noneOf();
|
||||
ii.visibleCollapsible = ApplicationMode.noneOf();
|
||||
ii.visibleModes = new LinkedHashSet<ApplicationMode>();
|
||||
ii.visibleCollapsible = new LinkedHashSet<ApplicationMode>();
|
||||
for(ApplicationMode ms : ApplicationMode.values(settings) ) {
|
||||
boolean collapse = defaultCollapsible.contains(ms);;
|
||||
boolean def = appDefaultModes.contains(ms);
|
||||
Set<String> set = visibleElements.get(ms);
|
||||
boolean collapse = ms.isWidgetCollapsible(key);
|
||||
boolean def = ms.isWidgetVisible(key);
|
||||
Set<String> set = visibleElementsFromSettings.get(ms);
|
||||
if(set != null) {
|
||||
if (set.contains(key)) {
|
||||
def = true;
|
||||
|
@ -202,17 +192,17 @@ public class MapWidgetRegistry {
|
|||
boolean visible = m.visible(mode);
|
||||
boolean collapseEnabled = m.collapseEnabled(mode);
|
||||
boolean collapse = m.visibleCollapsed(mode);
|
||||
if (this.visibleElements.get(mode) == null) {
|
||||
if (this.visibleElementsFromSettings.get(mode) == null) {
|
||||
LinkedHashSet<String> set = new LinkedHashSet<String>();
|
||||
restoreModes(set, left, mode);
|
||||
restoreModes(set, right, mode);
|
||||
restoreModes(set, top, mode);
|
||||
this.visibleElements.put(mode, set);
|
||||
this.visibleElementsFromSettings.put(mode, set);
|
||||
}
|
||||
// clear everything
|
||||
this.visibleElements.get(mode).remove(m.key);
|
||||
this.visibleElements.get(mode).remove("+" + m.key);
|
||||
this.visibleElements.get(mode).remove("-" + m.key);
|
||||
this.visibleElementsFromSettings.get(mode).remove(m.key);
|
||||
this.visibleElementsFromSettings.get(mode).remove("+" + m.key);
|
||||
this.visibleElementsFromSettings.get(mode).remove("-" + m.key);
|
||||
m.visibleModes.remove(mode);
|
||||
if (m.visibleCollapsible != null) {
|
||||
m.visibleCollapsible.remove(mode);
|
||||
|
@ -220,16 +210,16 @@ public class MapWidgetRegistry {
|
|||
if (visible || collapse) {
|
||||
if (collapseEnabled && !collapse) {
|
||||
m.visibleCollapsible.add(mode);
|
||||
this.visibleElements.get(mode).add("+" + m.key);
|
||||
this.visibleElementsFromSettings.get(mode).add("+" + m.key);
|
||||
} else {
|
||||
this.visibleElements.get(mode).add("-" + m.key);
|
||||
this.visibleElementsFromSettings.get(mode).add("-" + m.key);
|
||||
}
|
||||
} else {
|
||||
m.visibleModes.add(mode);
|
||||
this.visibleElements.get(mode).add("" + m.key);
|
||||
this.visibleElementsFromSettings.get(mode).add("" + m.key);
|
||||
}
|
||||
StringBuilder bs = new StringBuilder();
|
||||
for (String ks : this.visibleElements.get(mode)) {
|
||||
for (String ks : this.visibleElementsFromSettings.get(mode)) {
|
||||
bs.append(ks).append(";");
|
||||
}
|
||||
settings.MAP_INFO_CONTROLS.set(bs.toString());
|
||||
|
@ -290,11 +280,12 @@ public class MapWidgetRegistry {
|
|||
ri.visibleCollapsible.remove(mode);
|
||||
}
|
||||
ri.visibleModes.remove(mode);
|
||||
if (ri.defaultCollapsible != null && ri.defaultCollapsible.contains(mode)) {
|
||||
ri.visibleCollapsible.add(mode);
|
||||
}
|
||||
if (ri.defaultModes.contains(mode)) {
|
||||
ri.visibleModes.add(mode);
|
||||
if (mode.isWidgetVisible(ri.key)) {
|
||||
if (mode.isWidgetCollapsible(ri.key)) {
|
||||
ri.visibleCollapsible.add(mode);
|
||||
} else {
|
||||
ri.visibleModes.add(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +297,7 @@ public class MapWidgetRegistry {
|
|||
resetDefault(appMode, right);
|
||||
resetDefault(appMode, top);
|
||||
resetDefault(appMode, appearanceWidgets);
|
||||
this.visibleElements.put(appMode, null);
|
||||
this.visibleElementsFromSettings.put(appMode, null);
|
||||
settings.MAP_INFO_CONTROLS.set("");
|
||||
}
|
||||
|
||||
|
@ -326,8 +317,6 @@ public class MapWidgetRegistry {
|
|||
private String key;
|
||||
private int position;
|
||||
private String category;
|
||||
private Set<ApplicationMode> defaultModes;
|
||||
private Set<ApplicationMode> defaultCollapsible;
|
||||
private Set<ApplicationMode> visibleModes;
|
||||
private Set<ApplicationMode> visibleCollapsible;
|
||||
private OsmandPreference<?> preference = null;
|
||||
|
|
Loading…
Reference in a new issue