Update controls and settings

This commit is contained in:
Victor Shcherb 2012-08-01 13:31:43 +02:00
parent 62a9a66098
commit 2ed60e0914
11 changed files with 149 additions and 61 deletions

View file

@ -9,6 +9,10 @@
1. 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="map_widget_fluorescent">Fluorescent colors</string>
<string name="map_widget_appearance">Appearance</string>
<string name="map_widget_view_direction">View direction</string>
<string name="map_widget_transparent">Transparent views</string>
<string name="monitoring_mode_off">GPX rec</string>
<string name="monitoring_mode_on">GPX off</string>
<string name="bg_service_sleep_mode_off">Stop background</string>

View file

@ -8,9 +8,6 @@
<PreferenceScreen android:key="appearance_settings" android:title="@string/map_settings" android:summary="@string/map_settings_descr">
<ListPreference android:key="rotate_map" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></ListPreference>
<ListPreference android:key="daynight_mode" android:title="@string/daynight" android:summary="@string/daynight_descr"></ListPreference>
<CheckBoxPreference android:key="show_view_angle" android:title="@string/show_view_angle" android:summary="@string/show_view_angle_descr"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
<PreferenceCategory android:title="@string/pref_vector_map">
<ListPreference android:key="renderer" android:title="@string/renderers" android:summary="@string/renderers_descr"></ListPreference>
<ListPreference android:key="map_text_size" android:title="@string/map_text_size" android:summary="@string/map_text_size_descr"/>
@ -28,6 +25,7 @@
android:key="show_speed_limits"></CheckBoxPreference>
<CheckBoxPreference android:summary="@string/show_cameras_descr" android:title="@string/show_cameras"
android:key="show_cameras"></CheckBoxPreference>
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
<CheckBoxPreference android:summary="@string/avoid_toll_roads_descr" android:title="@string/avoid_toll_roads"
android:key="avoid_toll_roads"></CheckBoxPreference>
<CheckBoxPreference android:summary="@string/use_compass_navigation_descr" android:title="@string/use_compass_navigation"

View file

@ -1065,19 +1065,14 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
}
public void updateApplicationModeSettings(){
boolean currentShowingAngle = settings.SHOW_VIEW_ANGLE.get();
int currentMapRotation = settings.ROTATE_MAP.get();
if(currentMapRotation == OsmandSettings.ROTATE_MAP_NONE){
mapView.setRotate(0);
}
if(!currentShowingAngle){
mapLayers.getLocationLayer().setHeading(null);
}
routingHelper.setAppMode(settings.getApplicationMode());
mapView.setMapPosition(settings.POSITION_ON_MAP.get());
registerUnregisterSensor(getLastKnownLocation(), false);
mapLayers.getMapInfoLayer().recreateControls();
mapLayers.getMapInfoLayer().applyTheme();
mapLayers.updateLayers(mapView);
getMyApplication().getDaynightHelper().setDayNightMode(settings.DAYNIGHT_MODE.get());

View file

@ -267,7 +267,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
// bidForFixHelper.generatePreferenceList(screen, getString(R.string.support_new_features), this);
OsmandPlugin.onSettingsActivityCreate(this, screen);
registerBooleanPreference(osmandSettings.SHOW_VIEW_ANGLE, screen);
registerBooleanPreference(osmandSettings.USE_ENGLISH_NAMES, screen);
registerBooleanPreference(osmandSettings.AUTO_ZOOM_MAP, screen);
registerBooleanPreference(osmandSettings.FAST_ROUTE_MODE, screen);

View file

@ -1,11 +1,18 @@
package net.osmand.plus.extrasettings;
import java.util.EnumSet;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.views.MapInfoControls;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.MapInfoControls.MapInfoControlRegInfo;
import net.osmand.plus.voice.CommandPlayer;
import android.media.AudioManager;
import android.preference.ListPreference;
@ -18,6 +25,7 @@ public class OsmandExtraSettings extends OsmandPlugin {
private static final String ID = "osmand.extrasettings";
private OsmandSettings settings;
private OsmandApplication app;
private boolean registerControls;
public OsmandExtraSettings(OsmandApplication app) {
this.app = app;
@ -43,6 +51,40 @@ public class OsmandExtraSettings extends OsmandPlugin {
}
@Override
public void registerLayers(MapActivity activity) {
if (registerControls) {
registerControls = true;
final OsmandMapTileView view = activity.getMapView();
final MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
final MapInfoControls mapInfoControls = mapInfoLayer.getMapInfoControls();
final MapInfoControlRegInfo transparent = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_transparent,
"transparent", EnumSet.of(ApplicationMode.PEDESTRIAN, ApplicationMode.DEFAULT));
transparent.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().TRANSPARENT_MAP_THEME.set(transparent.visible(am));
mapInfoLayer.recreateControls();
}
});
final MapInfoControlRegInfo fluorescent = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_fluorescent,
"fluorescent", EnumSet.noneOf(ApplicationMode.class));
fluorescent.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().FLUORESCENT_OVERLAYS.set(fluorescent.visible(am));
view.refreshMap();
}
});
}
}
@Override
public void updateLayers(final OsmandMapTileView view, MapActivity activity) {
if(!registerControls) {
registerLayers(activity);
}
}
@ -86,20 +128,19 @@ public class OsmandExtraSettings extends OsmandPlugin {
vectorSettings.setKey("custom_vector_rendering");
appearance.addPreference(vectorSettings);
cat = new PreferenceCategory(app);
cat.setTitle(R.string.extra_settings);
appearance.addPreference(cat);
cat.addPreference(activity.createCheckBoxPreference(settings.TRANSPARENT_MAP_THEME,
R.string.use_transparent_map_theme, R.string.use_transparent_map_theme_descr));
cat.addPreference(activity.createCheckBoxPreference(settings.SHOW_RULER,
R.string.show_ruler_level, R.string.show_ruler_level_descr));
cat.addPreference(activity.createCheckBoxPreference(settings.FLUORESCENT_OVERLAYS,
R.string.use_fluorescent_overlays, R.string.use_fluorescent_overlays_descr));
cat.addPreference(activity.createListPreference(settings.POSITION_ON_MAP,
new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) },
new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT }, R.string.position_on_map,
R.string.position_on_map_descr));
// Not used any more TODO remove strings
// cat = new PreferenceCategory(app);
// cat.setTitle(R.string.extra_settings);
// appearance.addPreference(cat);
// cat.addPreference(activity.createCheckBoxPreference(settings.FLUORESCENT_OVERLAYS,
// R.string.use_fluorescent_overlays, R.string.use_fluorescent_overlays_descr));
// cat.addPreference(activity.createListPreference(settings.POSITION_ON_MAP,
// new String[] { activity.getString(R.string.position_on_map_center), activity.getString(R.string.position_on_map_bottom) },
// new Integer[] { OsmandSettings.CENTER_CONSTANT, OsmandSettings.BOTTOM_CONSTANT }, R.string.position_on_map,
// R.string.position_on_map_descr));
// cat.addPreference(activity.createCheckBoxPreference(settings.TRANSPARENT_MAP_THEME,
// R.string.use_transparent_map_theme, R.string.use_transparent_map_theme_descr));
// cat.addPreference(activity.createCheckBoxPreference(settings.SHOW_RULER,
// R.string.show_ruler_level, R.string.show_ruler_level_descr));
}
}

View file

@ -24,17 +24,10 @@ public class GPXLayer extends OsmandMapLayer {
private Path path;
private OsmandSettings settings;
private boolean fluorescent;
private void initUI() {
paint = new Paint();
fluorescent = view.getSettings().FLUORESCENT_OVERLAYS.get();
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
paint.setColor(view.getResources().getColor(R.color.gpx_track_fluorescent));
} else {
paint.setColor(view.getResources().getColor(R.color.gpx_track));
}
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(14);
paint.setAntiAlias(true);
@ -60,8 +53,10 @@ public class GPXLayer extends OsmandMapLayer {
return;
}
List<List<WptPt>> points = gpxFile.processedPointsToDisplay;
if(view.getSettings().FLUORESCENT_OVERLAYS.get() != fluorescent) {
initUI(); //to change color immediately when needed
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
paint.setColor(view.getResources().getColor(R.color.gpx_track_fluorescent));
} else {
paint.setColor(view.getResources().getColor(R.color.gpx_track));
}
for (List<WptPt> l : points) {

View file

@ -22,6 +22,7 @@ public class MapInfoControls {
public static final int RIGHT_CONTROL = 1;
public static final int MAIN_CONTROL = 0;
private Set<MapInfoControlRegInfo> appearanceWidgets = new TreeSet<MapInfoControls.MapInfoControlRegInfo>();
private Set<MapInfoControlRegInfo> left = new TreeSet<MapInfoControls.MapInfoControlRegInfo>();
private Set<MapInfoControlRegInfo> right = new TreeSet<MapInfoControls.MapInfoControlRegInfo>();
private Set<MapInfoControlRegInfo> top = new TreeSet<MapInfoControls.MapInfoControlRegInfo>(new Comparator<MapInfoControlRegInfo>() {
@ -65,6 +66,30 @@ public class MapInfoControls {
}
public MapInfoControlRegInfo registerAppearanceWidget(int drawable, int messageId, String key,
EnumSet<ApplicationMode> appDefaultModes) {
MapInfoControlRegInfo ii = new MapInfoControlRegInfo();
ii.defaultModes = appDefaultModes.clone();
ii.defaultCollapsible = null;
ii.key = key;
ii.visibleModes = EnumSet.noneOf(ApplicationMode.class);
ii.visibleCollapsible = null;
for(ApplicationMode ms : ApplicationMode.values() ) {
boolean def = appDefaultModes.contains(ms);
Set<String> set = visibleElements.get(ms);
if(set != null) {
def = set.contains(key);
}
if(def){
ii.visibleModes.add(ms);
}
}
ii.drawable = drawable;
ii.messageId = messageId;
this.appearanceWidgets.add(ii);
return ii;
}
public MapInfoControlRegInfo registerTopWidget(View m, int drawable, int messageId, String key, int left,
EnumSet<ApplicationMode> appDefaultModes, int priorityOrder) {
MapInfoControlRegInfo ii = new MapInfoControlRegInfo();
@ -167,6 +192,9 @@ public class MapInfoControls {
bs.append(ks).append(";");
}
settings.MAP_INFO_CONTROLS.set(bs.toString());
if(m.stateChangeListener != null) {
m.stateChangeListener.run();
}
}
public Set<MapInfoControlRegInfo> getLeft() {
@ -181,6 +209,10 @@ public class MapInfoControls {
return top;
}
public Set<MapInfoControlRegInfo> getAppearanceWidgets() {
return appearanceWidgets;
}
public void populateStackControl(MapStackControl stack, OsmandMapTileView v, boolean left){
ApplicationMode appMode = settings.getApplicationMode();
Set<MapInfoControlRegInfo> st = left ? this.left : this.right;
@ -239,7 +271,6 @@ public class MapInfoControls {
}
public static class MapInfoControlRegInfo implements Comparable<MapInfoControlRegInfo> {
public View m;
public int drawable;
@ -250,6 +281,7 @@ public class MapInfoControls {
private EnumSet<ApplicationMode> defaultCollapsible;
private EnumSet<ApplicationMode> visibleModes;
private EnumSet<ApplicationMode> visibleCollapsible;
private Runnable stateChangeListener = null;
public int priorityOrder;
public boolean visibleCollapsed(ApplicationMode mode){
@ -272,6 +304,10 @@ public class MapInfoControls {
}
public void setStateChangeListener(Runnable stateChangeListener) {
this.stateChangeListener = stateChangeListener;
}
@Override
public int hashCode() {
return messageId;

View file

@ -154,7 +154,7 @@ public class MapInfoLayer extends OsmandMapLayer {
createControls();
}
public void applyTheme() {
private void applyTheme() {
int boxTop = R.drawable.box_top_stack;
int boxTopR = R.drawable.box_top_r;
int boxTopL = R.drawable.box_top_l;
@ -211,24 +211,52 @@ public class MapInfoLayer extends OsmandMapLayer {
TextInfoControl alt = ric.createAltitudeControl(map, paintText, paintSubText);
mapInfoControls.registerSideWidget(alt, R.drawable.ic_altitude, R.string.map_widget_altitude, "altitude", false, EnumSet.of(ApplicationMode.PEDESTRIAN), none, 20);
// Top widgets
ImageViewControl compassView = createCompassView(map);
mapInfoControls.registerTopWidget(compassView, R.drawable.compass, R.string.map_widget_compass, "compass", MapInfoControls.LEFT_CONTROL, all, 5);
View config = createConfiguration();
mapInfoControls.registerTopWidget(config, R.drawable.widget_config, R.string.map_widget_config, "config", MapInfoControls.RIGHT_CONTROL, all, 10).required(ApplicationMode.values());
ImageView bgServiceView = lockInfoControl.createLockScreenWidget(view);
mapInfoControls.registerTopWidget(bgServiceView, R.drawable.lock_enabled, R.string.bg_service_screen_lock, "bgService", MapInfoControls.LEFT_CONTROL, all, 15);
ImageView lockView = lockInfoControl.createLockScreenWidget(view);
mapInfoControls.registerTopWidget(lockView, R.drawable.lock_enabled, R.string.bg_service_screen_lock, "bgService", MapInfoControls.LEFT_CONTROL, all, 15);
backToLocation = createBackToLocation(map);
mapInfoControls.registerTopWidget(backToLocation, R.drawable.default_location, R.string.map_widget_back_to_loc, "back_to_location", MapInfoControls.RIGHT_CONTROL, all, 5);
View globus = createGlobusAndProgress();
View globus = createGlobus();
mapInfoControls.registerTopWidget(globus, R.drawable.globus, R.string.map_widget_map_select, "progress", MapInfoControls.RIGHT_CONTROL, none, 15);
topText = new TopTextView(routingHelper, map);
mapInfoControls.registerTopWidget(topText, R.drawable.street_name, R.string.map_widget_top_text, "street_name", MapInfoControls.MAIN_CONTROL, all, 100);
// Register appearance widgets
registerAppearanceWidgets();
}
private void registerAppearanceWidgets() {
final MapInfoControlRegInfo showRuler = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_transparent,
"showRuler", EnumSet.allOf(ApplicationMode.class));
showRuler.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().SHOW_RULER.set(showRuler.visible(am));
view.refreshMap();
}
});
final MapInfoControlRegInfo displayViewDirections = mapInfoControls.registerAppearanceWidget(0, R.string.map_widget_view_direction,
"viewDirection", EnumSet.of(ApplicationMode.BICYCLE, ApplicationMode.PEDESTRIAN));
displayViewDirections.setStateChangeListener(new Runnable() {
@Override
public void run() {
ApplicationMode am = view.getSettings().getApplicationMode();
view.getSettings().SHOW_VIEW_ANGLE.set(displayViewDirections.visible(am));
map.updateApplicationModeSettings();
}
});
}
public void recreateControls(){
rightStack.clearAllViews();
mapInfoControls.populateStackControl(rightStack, view, false);
@ -240,6 +268,7 @@ public class MapInfoLayer extends OsmandMapLayer {
statusBar.removeAllViews();
mapInfoControls.populateStatusBar(statusBar);
applyTheme();
}
public void createControls() {
@ -305,7 +334,6 @@ public class MapInfoLayer extends OsmandMapLayer {
lanesControl.setVisibility(View.GONE);
// update and create controls
applyTheme();
recreateControls();
}
@ -320,6 +348,8 @@ public class MapInfoLayer extends OsmandMapLayer {
list.addAll(mapInfoControls.getRight());
list.add(map.getString(R.string.map_widget_left_stack));
list.addAll(mapInfoControls.getLeft());
list.add(map.getString(R.string.map_widget_appearance));
list.addAll(mapInfoControls.getAppearanceWidgets());
// final LayerMenuListener listener = new LayerMenuListener(adapter, mapView, settings);
@ -480,13 +510,13 @@ public class MapInfoLayer extends OsmandMapLayer {
progressBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
map.getMapLayers().selectMapLayer(view);
openViewConfigureDialog();
}
});
fl.addView(progressBar, fparams);
return fl;
}
private View createGlobusAndProgress(){
private View createGlobus(){
Drawable globusDrawable = view.getResources().getDrawable(R.drawable.globus);
ImageView globus = new ImageView(view.getContext());
globus.setImageDrawable(globusDrawable);

View file

@ -36,11 +36,6 @@ public class MiniMapControl extends MapInfoControl {
paintMiniRoute = new Paint();
paintMiniRoute.setStyle(Style.STROKE);
paintMiniRoute.setStrokeWidth(35 * scaleCoefficient);
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
paintMiniRoute.setColor(getResources().getColor(R.color.nav_track_fluorescent));
} else {
paintMiniRoute.setColor(getResources().getColor(R.color.nav_track));
}
paintMiniRoute.setStrokeJoin(Join.ROUND);
paintMiniRoute.setStrokeCap(Cap.ROUND);
paintMiniRoute.setAntiAlias(true);

View file

@ -101,7 +101,7 @@ public class PointLocationLayer extends OsmandMapLayer {
locationPaint);
}
if (heading != null) {
if (heading != null && view.getSettings().SHOW_VIEW_ANGLE.get()) {
canvas.drawArc(getHeadingRect(locationX, locationY), heading - HEADING_ANGLE / 2 - 90, HEADING_ANGLE, true, headingPaint);
}

View file

@ -29,8 +29,6 @@ public class RouteLayer extends OsmandMapLayer {
private Path path;
private Boolean fluorescent;
public RouteLayer(RoutingHelper helper){
this.helper = helper;
}
@ -40,12 +38,7 @@ public class RouteLayer extends OsmandMapLayer {
boundsRect = new Rect(0, 0, view.getWidth(), view.getHeight());
latlonRect = new RectF();
paint = new Paint();
fluorescent = view.getSettings().FLUORESCENT_OVERLAYS.get();
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
paint.setColor(view.getResources().getColor(R.color.nav_track_fluorescent));
} else {
paint.setColor(view.getResources().getColor(R.color.nav_track));
}
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(14);
paint.setAntiAlias(true);
@ -66,8 +59,10 @@ public class RouteLayer extends OsmandMapLayer {
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
path.reset();
if (helper.getFinalLocation() != null && helper.getRoute().isCalculated()) {
if(view.getSettings().FLUORESCENT_OVERLAYS.get() != fluorescent) {
initUI(); //to change color immediately when needed
if (view.getSettings().FLUORESCENT_OVERLAYS.get()) {
paint.setColor(view.getResources().getColor(R.color.nav_track_fluorescent));
} else {
paint.setColor(view.getResources().getColor(R.color.nav_track));
}
int w = view.getWidth();
int h = view.getHeight();