diff --git a/OsmAnd/res/drawable-hdpi/poi_parking_pos_info.png b/OsmAnd/res/drawable-hdpi/poi_parking_pos_info.png
deleted file mode 100644
index 3b2ffb13bf..0000000000
Binary files a/OsmAnd/res/drawable-hdpi/poi_parking_pos_info.png and /dev/null differ
diff --git a/OsmAnd/res/drawable/poi_parking_pos_info.png b/OsmAnd/res/drawable/poi_parking_pos_info.png
new file mode 100644
index 0000000000..c765cf5a61
Binary files /dev/null and b/OsmAnd/res/drawable/poi_parking_pos_info.png differ
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 7b470975d1..9bfcc8b5d7 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,11 @@
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
-->
+ Map selection
+ Where am I
+ Lock screen
+ Compass
+ Status bar
Reset to default
Right side
Left side
diff --git a/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java b/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java
index 57dd3b63a2..581c1ff093 100644
--- a/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java
+++ b/OsmAnd/src/net/osmand/plus/background/OsmandBackgroundServicePlugin.java
@@ -1,12 +1,17 @@
package net.osmand.plus.background;
+import java.util.EnumSet;
+
import net.osmand.plus.NavigationService;
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.ImageViewControl;
+import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@@ -29,9 +34,6 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.LinearLayout.LayoutParams;
import android.widget.Spinner;
public class OsmandBackgroundServicePlugin extends OsmandPlugin {
@@ -72,10 +74,17 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin {
@Override
public void registerLayers(MapActivity activity) {
backgroundServiceLayer = new OsmandBackgroundServiceLayer(activity);
+ MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
+ ImageViewControl lockView = createBgServiceView( activity.getMapView(), activity);
+ // TODO icon
+ layer.getMapInfoControls().registerTopWidget(lockView, R.drawable.monitoring_rec_big, R.string.map_widget_lock_screen, "lock_view", true, EnumSet.allOf(ApplicationMode.class), 10);
}
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
+ if(backgroundServiceLayer == null) {
+ registerLayers(activity);
+ }
if (isScreenLocked) {
mapView.addLayer(backgroundServiceLayer, mapView.getLayers().size());
} else {
@@ -159,16 +168,17 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin {
/**
*
- * @param statusBar
- * @param view
- * @param map
*/
- public void createBgServiceView(final LinearLayout statusBar, final OsmandMapTileView view, final MapActivity map) {
+ public ImageViewControl createBgServiceView(final OsmandMapTileView view, final MapActivity map) {
// TODO Lock icons
final Drawable lock = view.getResources().getDrawable(R.drawable.monitoring_rec_big);
final Drawable unLock = view.getResources().getDrawable(R.drawable.monitoring_rec_inactive);
-
- final ImageView lockView = new ImageView(view.getContext());
+ final ImageViewControl lockView = new ImageViewControl(view.getContext()) {
+ @Override
+ public boolean updateInfo() {
+ return false;
+ }
+ };
if (isScreenLocked) {
lockView.setBackgroundDrawable(lock);
@@ -189,7 +199,7 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin {
}
});
- statusBar.addView(lockView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ return lockView;
}
/**
diff --git a/OsmAnd/src/net/osmand/plus/views/ImageViewControl.java b/OsmAnd/src/net/osmand/plus/views/ImageViewControl.java
new file mode 100644
index 0000000000..0ef8cc89d4
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/views/ImageViewControl.java
@@ -0,0 +1,12 @@
+package net.osmand.plus.views;
+
+import android.content.Context;
+import android.widget.ImageView;
+
+public abstract class ImageViewControl extends ImageView implements MapControlUpdateable {
+
+ public ImageViewControl(Context context) {
+ super(context);
+ }
+
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlUpdateable.java b/OsmAnd/src/net/osmand/plus/views/MapControlUpdateable.java
new file mode 100644
index 0000000000..58f11e152b
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/views/MapControlUpdateable.java
@@ -0,0 +1,9 @@
+package net.osmand.plus.views;
+
+
+public interface MapControlUpdateable {
+
+ public boolean updateInfo();
+
+
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoControl.java b/OsmAnd/src/net/osmand/plus/views/MapInfoControl.java
index 97f117ebf7..95ec0a40d7 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapInfoControl.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapInfoControl.java
@@ -7,7 +7,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
-public abstract class MapInfoControl extends View {
+public abstract class MapInfoControl extends View implements MapControlUpdateable {
int width = 0;
int height = 0;
Rect padding = new Rect();
@@ -56,6 +56,7 @@ public abstract class MapInfoControl extends View {
canvas.clipRect(0, 0, getWWidth(),getWHeight());
}
+ @Override
public boolean updateInfo() { return false; }
protected boolean updateVisibility(boolean visible) {
diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoControls.java b/OsmAnd/src/net/osmand/plus/views/MapInfoControls.java
index 0861d856a4..fed8fd24bb 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapInfoControls.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapInfoControls.java
@@ -1,5 +1,6 @@
package net.osmand.plus.views;
+import java.util.Comparator;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -7,27 +8,30 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.LinearLayout.LayoutParams;
+
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.activities.ApplicationMode;
-import android.graphics.Paint;
public class MapInfoControls {
private Set left = new TreeSet();
private Set right = new TreeSet();
+ private Set topleft = new TreeSet();
+ private Set topright = new TreeSet(new Comparator() {
+ @Override
+ public int compare(MapInfoControlRegInfo object1, MapInfoControlRegInfo object2) {
+ return -object1.compareTo(object2);
+ }
+ });
private Map> visibleElements = new LinkedHashMap>();
private final OsmandSettings settings;
- public interface MapInfoControlFactoryMethod {
-
- /**
- * @param mapView
- * @param paints array of paints (4) 0 - normal, 1 - subtext, 2 - small, 3 - small subtext
- */
- public MapInfoControl createControl(OsmandMapTileView mapView, Paint[] paints);
- }
-
public MapInfoControls(OsmandSettings settings) {
this.settings = settings;
@@ -46,6 +50,36 @@ public class MapInfoControls {
}
+ public MapInfoControlRegInfo registerTopWidget(View m, int drawable, int messageId, String key, boolean left,
+ EnumSet appDefaultModes, int priorityOrder) {
+ 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 set = visibleElements.get(ms);
+ if(set != null) {
+ def = set.contains(key);
+ }
+ if(def){
+ ii.visibleModes.add(ms);
+ }
+ }
+ ii.drawable = drawable;
+ ii.messageId = messageId;
+ ii.m = m;
+ ii.priorityOrder = priorityOrder;
+ if(left) {
+ this.topleft.add(ii);
+ } else {
+ this.topright.add(ii);
+ }
+ return ii;
+ }
+
public void registerSideWidget(MapInfoControl m, int drawable, int messageId, String key, boolean left,
@@ -85,7 +119,7 @@ public class MapInfoControls {
for(MapInfoControlRegInfo m : mi){
if(m.visibleModes.contains(mode)) {
set.add(m.key) ;
- } else if(m.visibleCollapsible.contains(mode)) {
+ } else if(m.visibleCollapsible != null && m.visibleCollapsible.contains(mode)) {
set.add("+"+m.key) ;
}
}
@@ -97,14 +131,18 @@ public class MapInfoControls {
LinkedHashSet set = new LinkedHashSet();
restoreModes(set, left, mode);
restoreModes(set, right, mode);
+ restoreModes(set, topleft, mode);
+ restoreModes(set, topright, mode);
this.visibleElements.put(mode, set);
}
this.visibleElements.get(mode).remove(m.key);
this.visibleElements.get(mode).remove("+" + m.key);
m.visibleModes.remove(mode);
- m.visibleCollapsible.remove(mode);
+ if(m.visibleCollapsible != null) {
+ m.visibleCollapsible.remove(mode);
+ }
if(visible) {
- if(collapse) {
+ if(collapse && m.visibleCollapsible != null) {
m.visibleCollapsible.add(mode);
this.visibleElements.get(mode).add("+" + m.key);
} else {
@@ -128,28 +166,51 @@ public class MapInfoControls {
return right;
}
- public void registerTopBarButton(MapInfoControlFactoryMethod m, int drawable, int messageId, boolean left,
- EnumSet appModes, int priorityOrder) {
-
+ public Set getTopLeft() {
+ return topleft;
+ }
+
+ public Set getTopRight() {
+ return topright;
}
public void populateStackControl(MapStackControl stack, OsmandMapTileView v, boolean left){
ApplicationMode appMode = settings.getApplicationMode();
Set st = left ? this.left : this.right;
for (MapInfoControlRegInfo r : st) {
- if (r.visibleCollapsible.contains(appMode)) {
- stack.addCollapsedView(r.m);
+ if (r.visibleCollapsible != null && r.visibleCollapsible.contains(appMode)) {
+ stack.addCollapsedView((MapInfoControl) r.m);
} else if (r.visibleModes.contains(appMode)) {
- stack.addStackView(r.m);
+ stack.addStackView((MapInfoControl) r.m);
+ }
+ }
+ }
+
+ public void populateStatusBar(ViewGroup statusBar, TextView topView){
+ ApplicationMode appMode = settings.getApplicationMode();
+ for (MapInfoControlRegInfo r : topleft) {
+ if (r.visibleModes.contains(appMode)) {
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ statusBar.addView((View) r.m, params);
+ }
+ }
+ LayoutParams pms = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT, 1);
+ statusBar.addView(topView, pms);
+ for (MapInfoControlRegInfo r : topright) {
+ if (r.visibleModes.contains(appMode)) {
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ statusBar.addView((View) r.m, params);
}
}
}
private void resetDefault(ApplicationMode mode, Set set ){
for(MapInfoControlRegInfo ri : set) {
- ri.visibleCollapsible.remove(mode);
+ if(ri.visibleCollapsible != null) {
+ ri.visibleCollapsible.remove(mode);
+ }
ri.visibleModes.remove(mode);
- if(ri.defaultCollapsible.contains(mode)) {
+ if(ri.defaultCollapsible != null && ri.defaultCollapsible.contains(mode)) {
ri.visibleCollapsible.add(mode);
}
if(ri.defaultModes.contains(mode)) {
@@ -162,6 +223,8 @@ public class MapInfoControls {
ApplicationMode appMode = settings.getApplicationMode();
resetDefault(appMode, left);
resetDefault(appMode, right);
+ resetDefault(appMode, topleft);
+ resetDefault(appMode, topright);
this.visibleElements.put(appMode, null);
settings.MAP_INFO_CONTROLS.set("");
}
@@ -176,7 +239,7 @@ public class MapInfoControls {
public static class MapInfoControlRegInfo implements Comparable {
- public MapInfoControl m;
+ public View m;
public int drawable;
public int messageId;
private String key;
@@ -187,12 +250,24 @@ public class MapInfoControls {
public int priorityOrder;
public boolean visibleCollapsed(ApplicationMode mode){
- return visibleCollapsible.contains(mode);
+ return visibleCollapsible != null && visibleCollapsible.contains(mode);
+ }
+
+ public boolean collapseEnabled(ApplicationMode mode){
+ return visibleCollapsible != null;
}
public boolean visible(ApplicationMode mode){
return visibleModes.contains(mode);
}
+
+ public MapInfoControlRegInfo required(ApplicationMode... modes){
+ for(ApplicationMode ms : modes) {
+ visibleModes.add(ms);
+ }
+ return this;
+ }
+
@Override
public int hashCode() {
return messageId;
diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
index 3e93e2d724..ef9898e47e 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
@@ -4,12 +4,10 @@ package net.osmand.plus.views;
import java.util.ArrayList;
import java.util.EnumSet;
-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.background.OsmandBackgroundServicePlugin;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.MapInfoControls.MapInfoControlRegInfo;
@@ -59,23 +57,19 @@ public class MapInfoLayer extends OsmandMapLayer {
private Paint paintSmallSubText;
private Paint paintImg;
- private float cachedRotate = 0;
-
// layout pseudo-constants
private int STATUS_BAR_MARGIN_X = -4;
private ImageView backToLocation;
- private ImageView compassView;
private View progressBar;
// groups
private MapStackControl rightStack;
private MapStackControl leftStack;
- private ViewGroup statusBar;
+ private LinearLayout statusBar;
private MapInfoControl lanesControl;
private MapInfoControl alarmControl;
private TextView topText;
-
private MapInfoControls mapInfoControls;
public MapInfoLayer(MapActivity map, RouteLayer layer){
@@ -150,10 +144,8 @@ public class MapInfoLayer extends OsmandMapLayer {
@Override
public void initLayer(final OsmandMapTileView view) {
this.view = view;
-
registerAllControls();
createControls();
- applyTheme();
}
public void applyTheme() {
@@ -179,7 +171,8 @@ public class MapInfoLayer extends OsmandMapLayer {
}
public void registerAllControls(){
- statusBar = createStatusBar();
+ statusBar = new LinearLayout(view.getContext());
+ statusBar.setOrientation(LinearLayout.HORIZONTAL);
RouteInfoControls ric = new RouteInfoControls(scaleCoefficient);
lanesControl = ric.createLanesControl(view.getApplication().getRoutingHelper(), view);
lanesControl.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));
@@ -212,6 +205,15 @@ 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);
+ ImageViewControl compassView = createCompassView(map);
+ mapInfoControls.registerTopWidget(compassView, R.drawable.compass, R.string.map_widget_compass, "compass", true, all, 5);
+ backToLocation = createBackToLocation(map);
+ mapInfoControls.registerTopWidget(backToLocation, R.drawable.default_mode_small, R.string.map_widget_back_to_loc, "back_to_location", false, all, 5);
+
+ View globusAndProgress = createGlobusAndProgress();
+ mapInfoControls.registerTopWidget(globusAndProgress, R.drawable.globus, R.string.map_widget_map_select, "progress", false, all, 10).required(ApplicationMode.values());
+
+ topText = new TopTextView(routingHelper, map);
}
public void recreateControls(){
@@ -222,6 +224,9 @@ public class MapInfoLayer extends OsmandMapLayer {
mapInfoControls.populateStackControl(leftStack, view, true);
leftStack.requestLayout();
rightStack.requestLayout();
+
+ statusBar.removeAllViews();
+ mapInfoControls.populateStatusBar(statusBar, topText);
}
public void createControls() {
@@ -233,7 +238,8 @@ public class MapInfoLayer extends OsmandMapLayer {
// 2. Preparations
Rect topRectPadding = new Rect();
view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);
-
+ // for measurement
+ statusBar.addView(backToLocation);
STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
Rect statusBarPadding = new Rect();
@@ -284,6 +290,8 @@ public class MapInfoLayer extends OsmandMapLayer {
parent.addView(alarmControl);
alarmControl.setVisibility(View.GONE);
lanesControl.setVisibility(View.GONE);
+
+ // update and create controls
applyTheme();
recreateControls();
}
@@ -293,6 +301,9 @@ public class MapInfoLayer extends OsmandMapLayer {
final ArrayList