Changed compass UI behaviour
This commit is contained in:
parent
00f1b7852b
commit
2e64b42727
15 changed files with 254 additions and 132 deletions
|
@ -438,6 +438,7 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/layers_compass_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
7
OsmAnd/res/layout/map_compass_button.xml
Normal file
7
OsmAnd/res/layout/map_compass_button.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ImageButton android:id="@+id/map_compass_button"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="@dimen/map_small_button_size"
|
||||||
|
android:layout_height="@dimen/map_small_button_size"
|
||||||
|
android:background="@drawable/btn_inset_circle_trans"
|
||||||
|
android:contentDescription="@string/map_widget_compass"/>
|
|
@ -450,6 +450,7 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/layers_compass_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
|
@ -14,37 +14,38 @@ import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
public class ApplicationMode {
|
public class ApplicationMode {
|
||||||
private static Map<String, Set<ApplicationMode>> widgets = new LinkedHashMap<String, Set<ApplicationMode>>();
|
private static Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
|
||||||
private static List<ApplicationMode> values = new ArrayList<ApplicationMode>();
|
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
|
||||||
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<ApplicationMode>();
|
private static List<ApplicationMode> values = new ArrayList<>();
|
||||||
|
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
||||||
/*
|
/*
|
||||||
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian");
|
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian");
|
||||||
*/
|
*/
|
||||||
public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
|
public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
|
||||||
icon(R.drawable.ic_browse_map, R.drawable.ic_world_globe_dark).reg();
|
icon(R.drawable.ic_browse_map, R.drawable.ic_world_globe_dark).reg();
|
||||||
|
|
||||||
public static final ApplicationMode CAR = create(R.string.app_mode_car, "car").speed(15.3f, 35).carLocation().
|
public static final ApplicationMode CAR = create(R.string.app_mode_car, "car").speed(15.3f, 35).carLocation().
|
||||||
icon(R.drawable.ic_car, R.drawable.ic_action_car_dark).reg();
|
icon(R.drawable.ic_car, R.drawable.ic_action_car_dark).reg();
|
||||||
|
|
||||||
public static final ApplicationMode BICYCLE = create(R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).bicycleLocation().
|
public static final ApplicationMode BICYCLE = create(R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).bicycleLocation().
|
||||||
icon(R.drawable.ic_bicycle, R.drawable.ic_action_bicycle_dark).reg();
|
icon(R.drawable.ic_bicycle, R.drawable.ic_action_bicycle_dark).reg();
|
||||||
|
|
||||||
public static final ApplicationMode PEDESTRIAN = create(R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).arrivalDistance(45).
|
public static final ApplicationMode PEDESTRIAN = create(R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).arrivalDistance(45).
|
||||||
icon(R.drawable.ic_pedestrian, R.drawable.ic_action_pedestrian_dark).reg();
|
icon(R.drawable.ic_pedestrian, R.drawable.ic_action_pedestrian_dark).reg();
|
||||||
|
|
||||||
public static final ApplicationMode AIRCRAFT = create(R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
|
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).reg();
|
icon(R.drawable.ic_aircraft, R.drawable.ic_action_aircraft).reg();
|
||||||
|
|
||||||
public static final ApplicationMode BOAT = create(R.string.app_mode_boat, "boat").speed(5.5f, 20).carLocation().
|
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_dark).reg();
|
icon(R.drawable.ic_sail_boat, 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).
|
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_dark).reg();
|
icon(R.drawable.ic_trekking, R.drawable.ic_action_trekking_dark).reg();
|
||||||
|
|
||||||
public static final ApplicationMode MOTORCYCLE = create(R.string.app_mode_motorcycle, "motorcycle").speed(15.3f, 40).
|
public static final ApplicationMode MOTORCYCLE = create(R.string.app_mode_motorcycle, "motorcycle").speed(15.3f, 40).
|
||||||
carLocation().parent(CAR).
|
carLocation().parent(CAR).
|
||||||
icon(R.drawable.ic_motorcycle, R.drawable.ic_action_motorcycle_dark).reg();
|
icon(R.drawable.ic_motorcycle, R.drawable.ic_action_motorcycle_dark).reg();
|
||||||
|
|
||||||
public static final ApplicationMode TRUCK = create(R.string.app_mode_truck, "truck").speed(15.3f, 40).
|
public static final ApplicationMode TRUCK = create(R.string.app_mode_truck, "truck").speed(15.3f, 40).
|
||||||
carLocation().parent(CAR).
|
carLocation().parent(CAR).
|
||||||
icon(R.drawable.ic_truck, R.drawable.ic_action_truck_dark).reg();
|
icon(R.drawable.ic_truck, R.drawable.ic_action_truck_dark).reg();
|
||||||
|
@ -55,87 +56,95 @@ public class ApplicationMode {
|
||||||
|
|
||||||
public static final ApplicationMode TRAIN = create(R.string.app_mode_train, "train").speed(25f, 40).
|
public static final ApplicationMode TRAIN = create(R.string.app_mode_train, "train").speed(25f, 40).
|
||||||
carLocation().icon(R.drawable.ic_action_train, R.drawable.ic_action_train).reg();
|
carLocation().icon(R.drawable.ic_action_train, R.drawable.ic_action_train).reg();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ApplicationMode[] exceptDefault = new ApplicationMode[] { CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, BUS, TRAIN };
|
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, BUS, TRAIN};
|
||||||
ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[] { CAR, BICYCLE, BOAT, AIRCRAFT, BUS, TRAIN };
|
ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[]{CAR, BICYCLE, BOAT, AIRCRAFT, BUS, TRAIN};
|
||||||
ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[] { CAR, BICYCLE, PEDESTRIAN };
|
ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN};
|
||||||
ApplicationMode[] pedestrian = new ApplicationMode[] { PEDESTRIAN };
|
ApplicationMode[] pedestrian = new ApplicationMode[]{PEDESTRIAN};
|
||||||
ApplicationMode[] pedestrianBicycle = new ApplicationMode[] { PEDESTRIAN, BICYCLE };
|
ApplicationMode[] pedestrianBicycle = new ApplicationMode[]{PEDESTRIAN, BICYCLE};
|
||||||
|
|
||||||
ApplicationMode[] all = null;
|
ApplicationMode[] all = null;
|
||||||
ApplicationMode[] none = new ApplicationMode[] {};
|
ApplicationMode[] none = new ApplicationMode[]{};
|
||||||
|
|
||||||
// left
|
// left
|
||||||
regWidget("next_turn", exceptPedestrianAndDefault);
|
regWidgetVisibility("next_turn", exceptPedestrianAndDefault);
|
||||||
regWidget("next_turn_small", pedestrian);
|
regWidgetVisibility("next_turn_small", pedestrian);
|
||||||
regWidget("next_next_turn", exceptPedestrianAndDefault);
|
regWidgetVisibility("next_next_turn", exceptPedestrianAndDefault);
|
||||||
|
regWidgetAvailability("next_turn", exceptDefault);
|
||||||
|
regWidgetAvailability("next_turn_small", exceptDefault);
|
||||||
|
regWidgetAvailability("next_next_turn", exceptDefault);
|
||||||
|
|
||||||
// right
|
// right
|
||||||
regWidget("intermediate_distance", exceptDefault);
|
regWidgetVisibility("intermediate_distance", exceptDefault);
|
||||||
regWidget("distance", exceptDefault);
|
regWidgetVisibility("distance", exceptDefault);
|
||||||
regWidget("time", exceptDefault);
|
regWidgetVisibility("time", exceptDefault);
|
||||||
regWidget("speed", exceptPedestrianAndDefault);
|
regWidgetVisibility("speed", exceptPedestrianAndDefault);
|
||||||
regWidget("max_speed", CAR);
|
regWidgetVisibility("max_speed", CAR);
|
||||||
regWidget("altitude", pedestrianBicycle);
|
regWidgetVisibility("altitude", pedestrianBicycle);
|
||||||
regWidget("gps_info", none);
|
regWidgetVisibility("gps_info", none);
|
||||||
|
regWidgetAvailability("intermediate_distance", exceptDefault);
|
||||||
|
regWidgetAvailability("distance", exceptDefault);
|
||||||
|
regWidgetAvailability("time", exceptDefault);
|
||||||
|
regWidgetAvailability("map_marker_1st", none);
|
||||||
|
regWidgetAvailability("map_marker_2nd", none);
|
||||||
|
|
||||||
// top
|
// top
|
||||||
regWidget("config", none);
|
regWidgetVisibility("config", none);
|
||||||
regWidget("layers", none);
|
regWidgetVisibility("layers", none);
|
||||||
regWidget("compass", all);
|
regWidgetVisibility("compass", none);
|
||||||
regWidget("street_name", exceptAirBoatDefault);
|
regWidgetVisibility("street_name", exceptAirBoatDefault);
|
||||||
regWidget("back_to_location", all);
|
regWidgetVisibility("back_to_location", all);
|
||||||
regWidget("monitoring_services", none);
|
regWidgetVisibility("monitoring_services", none);
|
||||||
regWidget("bgService", none);
|
regWidgetVisibility("bgService", none);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ApplicationModeBuilder {
|
private static class ApplicationModeBuilder {
|
||||||
|
|
||||||
|
|
||||||
private ApplicationMode applicationMode;
|
private ApplicationMode applicationMode;
|
||||||
|
|
||||||
public ApplicationMode reg() {
|
public ApplicationMode reg() {
|
||||||
values.add(applicationMode);
|
values.add(applicationMode);
|
||||||
return applicationMode;
|
return applicationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder icon(int bigIcon, int smallIconDark) {
|
public ApplicationModeBuilder icon(int bigIcon, int smallIconDark) {
|
||||||
applicationMode.iconId = bigIcon;
|
applicationMode.iconId = bigIcon;
|
||||||
applicationMode.smallIconDark = smallIconDark;
|
applicationMode.smallIconDark = smallIconDark;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder carLocation(){
|
public ApplicationModeBuilder carLocation() {
|
||||||
applicationMode.bearingIconDay = R.drawable.map_car_bearing;
|
applicationMode.bearingIconDay = R.drawable.map_car_bearing;
|
||||||
applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
|
applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
|
||||||
applicationMode.locationIconDay = R.drawable.map_car_location;
|
applicationMode.locationIconDay = R.drawable.map_car_location;
|
||||||
applicationMode.locationIconNight = R.drawable.map_car_location_night;
|
applicationMode.locationIconNight = R.drawable.map_car_location_night;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder parent(ApplicationMode parent){
|
public ApplicationModeBuilder parent(ApplicationMode parent) {
|
||||||
applicationMode.parent = parent;
|
applicationMode.parent = parent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder bicycleLocation(){
|
public ApplicationModeBuilder bicycleLocation() {
|
||||||
applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing;
|
applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing;
|
||||||
applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
|
applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
|
||||||
applicationMode.locationIconDay = R.drawable.map_bicycle_location;
|
applicationMode.locationIconDay = R.drawable.map_bicycle_location;
|
||||||
applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
|
applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder defLocation(){
|
public ApplicationModeBuilder defLocation() {
|
||||||
applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing;
|
applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing;
|
||||||
applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
|
applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
|
||||||
applicationMode.locationIconDay = R.drawable.map_pedestrian_location;
|
applicationMode.locationIconDay = R.drawable.map_pedestrian_location;
|
||||||
applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
|
applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
|
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
|
||||||
applicationMode.defaultSpeed = defSpeed;
|
applicationMode.defaultSpeed = defSpeed;
|
||||||
applicationMode.minDistanceForTurn = distForTurn;
|
applicationMode.minDistanceForTurn = distForTurn;
|
||||||
|
@ -147,7 +156,7 @@ public class ApplicationMode {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ApplicationModeBuilder create(int key, String stringKey) {
|
private static ApplicationModeBuilder create(int key, String stringKey) {
|
||||||
ApplicationModeBuilder builder = new ApplicationModeBuilder();
|
ApplicationModeBuilder builder = new ApplicationModeBuilder();
|
||||||
builder.applicationMode = new ApplicationMode(key, stringKey);
|
builder.applicationMode = new ApplicationMode(key, stringKey);
|
||||||
|
@ -158,7 +167,7 @@ public class ApplicationMode {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.stringKey = stringKey;
|
this.stringKey = stringKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ApplicationMode> values(OsmandSettings settings) {
|
public static List<ApplicationMode> values(OsmandSettings settings) {
|
||||||
if (cachedFilteredValues.isEmpty()) {
|
if (cachedFilteredValues.isEmpty()) {
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
|
@ -180,66 +189,89 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
return cachedFilteredValues;
|
return cachedFilteredValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ApplicationMode> allPossibleValues() {
|
public static List<ApplicationMode> allPossibleValues() {
|
||||||
return new ArrayList<ApplicationMode>(values);
|
return new ArrayList<ApplicationMode>(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
|
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
|
||||||
public static Set<ApplicationMode> regWidget(String widgetId, ApplicationMode... am) {
|
public static Set<ApplicationMode> regWidgetVisibility(String widgetId, ApplicationMode... am) {
|
||||||
HashSet<ApplicationMode> set = new HashSet<ApplicationMode>();
|
HashSet<ApplicationMode> set = new HashSet<>();
|
||||||
if(am == null) {
|
if (am == null) {
|
||||||
set.addAll(values);
|
set.addAll(values);
|
||||||
} else {
|
} else {
|
||||||
Collections.addAll(set, am);
|
Collections.addAll(set, am);
|
||||||
}
|
}
|
||||||
for(ApplicationMode m : values) {
|
for (ApplicationMode m : values) {
|
||||||
// add derived modes
|
// add derived modes
|
||||||
if(set.contains(m.getParent())) {
|
if (set.contains(m.getParent())) {
|
||||||
set.add(m);
|
set.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
widgets.put(widgetId, set);
|
widgetsVisibilityMap.put(widgetId, set);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWidgetCollapsible(String key) {
|
public boolean isWidgetCollapsible(String key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWidgetVisible(String key) {
|
public boolean isWidgetVisible(String key) {
|
||||||
Set<ApplicationMode> set = widgets.get(key);
|
Set<ApplicationMode> set = widgetsVisibilityMap.get(key);
|
||||||
if(set == null) {
|
if (set == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return set.contains(this);
|
return set.contains(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<ApplicationMode> regWidgetAvailability(String widgetId, ApplicationMode... am) {
|
||||||
|
HashSet<ApplicationMode> set = new HashSet<>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
widgetsAvailabilityMap.put(widgetId, set);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWidgetAvailable(String key) {
|
||||||
|
Set<ApplicationMode> set = widgetsAvailabilityMap.get(key);
|
||||||
|
if (set == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return set.contains(this);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<ApplicationMode> getModesDerivedFrom(ApplicationMode am) {
|
public static List<ApplicationMode> getModesDerivedFrom(ApplicationMode am) {
|
||||||
List<ApplicationMode> list = new ArrayList<ApplicationMode>();
|
List<ApplicationMode> list = new ArrayList<ApplicationMode>();
|
||||||
for(ApplicationMode a : values) {
|
for (ApplicationMode a : values) {
|
||||||
if(a == am || a.getParent() == am) {
|
if (a == am || a.getParent() == am) {
|
||||||
list.add(a);
|
list.add(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationMode getParent() {
|
public ApplicationMode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSmallIconDark() {
|
public int getSmallIconDark() {
|
||||||
return smallIconDark ;
|
return smallIconDark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFastSpeed(){
|
public boolean hasFastSpeed() {
|
||||||
return getDefaultSpeed() > 10;
|
return getDefaultSpeed() > 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResourceBearingDay() {
|
public int getResourceBearingDay() {
|
||||||
return bearingIconDay;
|
return bearingIconDay;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +280,7 @@ public class ApplicationMode {
|
||||||
//return bearingIconDay;
|
//return bearingIconDay;
|
||||||
return bearingIconNight;
|
return bearingIconNight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResourceLocationDay() {
|
public int getResourceLocationDay() {
|
||||||
return locationIconDay;
|
return locationIconDay;
|
||||||
}
|
}
|
||||||
|
@ -257,15 +289,15 @@ public class ApplicationMode {
|
||||||
//return locationIconDay;
|
//return locationIconDay;
|
||||||
return locationIconNight;
|
return locationIconNight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStringKey() {
|
public String getStringKey() {
|
||||||
return stringKey;
|
return stringKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconId() {
|
public int getIconId() {
|
||||||
return iconId;
|
return iconId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStringResource() {
|
public int getStringResource() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
@ -273,24 +305,24 @@ public class ApplicationMode {
|
||||||
public String toHumanString(Context ctx) {
|
public String toHumanString(Context ctx) {
|
||||||
return ctx.getString(key);
|
return ctx.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toHumanStringCtx(Context ctx) {
|
public String toHumanStringCtx(Context ctx) {
|
||||||
return ctx.getString(key);
|
return ctx.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationMode valueOfStringKey(String key, ApplicationMode def) {
|
public static ApplicationMode valueOfStringKey(String key, ApplicationMode def) {
|
||||||
for(ApplicationMode p : values) {
|
for (ApplicationMode p : values) {
|
||||||
if(p.getStringKey().equals(key)) {
|
if (p.getStringKey().equals(key)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDefaultSpeed() {
|
public float getDefaultSpeed() {
|
||||||
return defaultSpeed;
|
return defaultSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinDistanceForTurn() {
|
public int getMinDistanceForTurn() {
|
||||||
return minDistanceForTurn;
|
return minDistanceForTurn;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +340,7 @@ public class ApplicationMode {
|
||||||
|
|
||||||
private ApplicationMode parent;
|
private ApplicationMode parent;
|
||||||
private int iconId = R.drawable.ic_browse_map;
|
private int iconId = R.drawable.ic_browse_map;
|
||||||
private int smallIconDark = R.drawable.ic_world_globe_dark ;
|
private int smallIconDark = R.drawable.ic_world_globe_dark;
|
||||||
private float defaultSpeed = 10f;
|
private float defaultSpeed = 10f;
|
||||||
private int minDistanceForTurn = 50;
|
private int minDistanceForTurn = 50;
|
||||||
private int arrivalDistance = 90;
|
private int arrivalDistance = 90;
|
||||||
|
|
|
@ -505,7 +505,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
public AudioVideoNotesPlugin(OsmandApplication app) {
|
public AudioVideoNotesPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
OsmandSettings settings = app.getSettings();
|
OsmandSettings settings = app.getSettings();
|
||||||
ApplicationMode.regWidget("audionotes", (ApplicationMode[]) null);
|
ApplicationMode.regWidgetVisibility("audionotes", (ApplicationMode[]) null);
|
||||||
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
|
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
|
||||||
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
|
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
|
||||||
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
|
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
|
||||||
|
|
|
@ -127,7 +127,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
|
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
private ImageView actionButton;
|
private ImageView actionButton;
|
||||||
|
private View compassButton;
|
||||||
private FrameLayout dashboardView;
|
private FrameLayout dashboardView;
|
||||||
|
private float cachedRotate = 0;
|
||||||
|
|
||||||
private ArrayAdapter<?> listAdapter;
|
private ArrayAdapter<?> listAdapter;
|
||||||
private OnItemClickListener listAdapterOnClickListener;
|
private OnItemClickListener listAdapterOnClickListener;
|
||||||
|
@ -547,19 +549,19 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FrameLayout.LayoutParams getActionButtonLayoutParams(int btnSizePx) {
|
||||||
|
int topPadPx = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_top_padding);
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(btnSizePx, btnSizePx);
|
||||||
|
int marginRight = btnSizePx / 4;
|
||||||
|
params.setMargins(0, landscape ? 0 : topPadPx - 2 * btnSizePx, marginRight, landscape ? marginRight : 0);
|
||||||
|
params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
private void initActionButtons() {
|
private void initActionButtons() {
|
||||||
actionButton = new ImageView(mapActivity);
|
actionButton = new ImageView(mapActivity);
|
||||||
int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size);
|
int btnSizePx = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_button_size);
|
||||||
int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding);
|
actionButton.setLayoutParams(getActionButtonLayoutParams(btnSizePx));
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
|
||||||
btnSize, btnSize
|
|
||||||
);
|
|
||||||
int marginRight = btnSize / 4;
|
|
||||||
params.setMargins(0, landscape ? 0 : topPad - 2 * btnSize,
|
|
||||||
marginRight, landscape ? marginRight : 0);
|
|
||||||
params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
|
|
||||||
actionButton.setLayoutParams(params);
|
|
||||||
actionButton.setScaleType(ScaleType.CENTER);
|
actionButton.setScaleType(ScaleType.CENTER);
|
||||||
actionButton.setBackgroundResource(R.drawable.btn_circle_blue);
|
actionButton.setBackgroundResource(R.drawable.btn_circle_blue);
|
||||||
hideActionButton();
|
hideActionButton();
|
||||||
|
@ -690,6 +692,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
|
|
||||||
private void hideActionButton() {
|
private void hideActionButton() {
|
||||||
actionButton.setVisibility(View.GONE);
|
actionButton.setVisibility(View.GONE);
|
||||||
|
if (compassButton != null) {
|
||||||
|
compassButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.osmand.Location getMyLocation() {
|
public net.osmand.Location getMyLocation() {
|
||||||
|
@ -784,6 +789,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
actionButton.setVisibility(View.VISIBLE);
|
actionButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
hideActionButton();
|
hideActionButton();
|
||||||
|
if (visibleType == DashboardType.CONFIGURE_MAP) {
|
||||||
|
int btnSizePx = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_small_button_size);
|
||||||
|
compassButton = mapActivity.getMapLayers().getMapControlsLayer()
|
||||||
|
.moveCompassButton(dashboardView, getActionButtonLayoutParams(btnSizePx), nightMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateDownloadBtn();
|
updateDownloadBtn();
|
||||||
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
|
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
|
||||||
|
@ -1111,6 +1121,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hide(View view, boolean animation) {
|
private void hide(View view, boolean animation) {
|
||||||
|
if (compassButton != null) {
|
||||||
|
mapActivity.getMapLayers().getMapControlsLayer().restoreCompassButton(nightMode);
|
||||||
|
compassButton = null;
|
||||||
|
}
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
dashboardView.setVisibility(View.GONE);
|
dashboardView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1281,7 +1295,18 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
lp.topMargin = originalPosition - scrollY;
|
lp.topMargin = originalPosition - scrollY;
|
||||||
((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
|
((FrameLayout) actionButton.getParent()).updateViewLayout(actionButton, lp);
|
||||||
}
|
}
|
||||||
|
} else if (compassButton != null) {
|
||||||
|
double scale = mapActivity.getResources().getDisplayMetrics().density;
|
||||||
|
int originalPosition = mFlexibleSpaceImageHeight - (int) (64 * scale);
|
||||||
|
int minTop = mFlexibleBlurSpaceHeight + (int) (5 * scale);
|
||||||
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) compassButton.getLayoutParams();
|
||||||
|
if (minTop > originalPosition - scrollY) {
|
||||||
|
hideActionButton();
|
||||||
|
} else {
|
||||||
|
compassButton.setVisibility(View.VISIBLE);
|
||||||
|
lp.topMargin = originalPosition - scrollY;
|
||||||
|
((FrameLayout) compassButton.getParent()).updateViewLayout(compassButton, lp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public OsmandDevelopmentPlugin(OsmandApplication app) {
|
public OsmandDevelopmentPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
//ApplicationMode.regWidget("fps", new ApplicationMode[0]);
|
//ApplicationMode.regWidgetVisibility("fps", new ApplicationMode[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
public DistanceCalculatorPlugin(OsmandApplication app) {
|
public DistanceCalculatorPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
ApplicationMode.regWidget("distance.measurement", ApplicationMode.DEFAULT);
|
ApplicationMode.regWidgetVisibility("distance.measurement", ApplicationMode.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
liveMonitoringHelper = new LiveMonitoringHelper(app);
|
liveMonitoringHelper = new LiveMonitoringHelper(app);
|
||||||
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
|
final List<ApplicationMode> am = ApplicationMode.allPossibleValues();
|
||||||
ApplicationMode.regWidget("monitoring", am.toArray(new ApplicationMode[am.size()]));
|
ApplicationMode.regWidgetVisibility("monitoring", am.toArray(new ApplicationMode[am.size()]));
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
||||||
deviceControl = new OsMoControlDevice(app, this, service, tracker);
|
deviceControl = new OsMoControlDevice(app, this, service, tracker);
|
||||||
groups = new OsMoGroups(this, service, tracker, app);
|
groups = new OsMoGroups(this, service, tracker, app);
|
||||||
}
|
}
|
||||||
ApplicationMode.regWidget("osmo_control", (ApplicationMode[]) null);
|
ApplicationMode.regWidgetVisibility("osmo_control", (ApplicationMode[]) null);
|
||||||
if (app.getSettings().OSMO_AUTO_CONNECT.get() ||
|
if (app.getSettings().OSMO_AUTO_CONNECT.get() ||
|
||||||
(System.currentTimeMillis() - app.getSettings().OSMO_LAST_PING.get() < 5 * 60 * 1000)) {
|
(System.currentTimeMillis() - app.getSettings().OSMO_LAST_PING.get() < 5 * 60 * 1000)) {
|
||||||
service.connect(true);
|
service.connect(true);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
public ParkingPositionPlugin(OsmandApplication app) {
|
public ParkingPositionPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
OsmandSettings set = app.getSettings();
|
OsmandSettings set = app.getSettings();
|
||||||
ApplicationMode. regWidget("parking", (ApplicationMode[]) null);
|
ApplicationMode.regWidgetVisibility("parking", (ApplicationMode[]) null);
|
||||||
parkingLat = set.registerFloatPreference(PARKING_POINT_LAT, 0f).makeGlobal();
|
parkingLat = set.registerFloatPreference(PARKING_POINT_LAT, 0f).makeGlobal();
|
||||||
parkingLon = set.registerFloatPreference(PARKING_POINT_LON, 0f).makeGlobal();
|
parkingLon = set.registerFloatPreference(PARKING_POINT_LON, 0f).makeGlobal();
|
||||||
parkingType = set.registerBooleanPreference(PARKING_TYPE, false).makeGlobal();
|
parkingType = set.registerBooleanPreference(PARKING_TYPE, false).makeGlobal();
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
private RoutePointsLayer routePointsLayer;
|
private RoutePointsLayer routePointsLayer;
|
||||||
|
|
||||||
public RoutePointsPlugin(OsmandApplication app) {
|
public RoutePointsPlugin(OsmandApplication app) {
|
||||||
ApplicationMode.regWidget("route_steps", ApplicationMode.CAR, ApplicationMode.DEFAULT);
|
ApplicationMode.regWidgetVisibility("route_steps", ApplicationMode.CAR, ApplicationMode.DEFAULT);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.support.v7.app.AlertDialog;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
@ -96,6 +97,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private long lastZoom;
|
private long lastZoom;
|
||||||
private boolean hasTargets;
|
private boolean hasTargets;
|
||||||
private ContextMenuLayer contextMenuLayer;
|
private ContextMenuLayer contextMenuLayer;
|
||||||
|
private boolean forceShowCompass;
|
||||||
|
|
||||||
public MapControlsLayer(MapActivity activity) {
|
public MapControlsLayer(MapActivity activity) {
|
||||||
this.mapActivity = activity;
|
this.mapActivity = activity;
|
||||||
|
@ -128,6 +130,39 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
initRouteControls();
|
initRouteControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View moveCompassButton(ViewGroup destLayout, ViewGroup.LayoutParams layoutParams, boolean night) {
|
||||||
|
View compassView = compassHud.iv;
|
||||||
|
ViewGroup parent = (ViewGroup) compassView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
forceShowCompass = true;
|
||||||
|
parent.removeView(compassView);
|
||||||
|
compassView.setLayoutParams(layoutParams);
|
||||||
|
destLayout.addView(compassView);
|
||||||
|
updateCompass(night);
|
||||||
|
return compassView;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreCompassButton(boolean night) {
|
||||||
|
View compassView = compassHud.iv;
|
||||||
|
ViewGroup parent = (ViewGroup) compassView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
forceShowCompass = false;
|
||||||
|
parent.removeView(compassView);
|
||||||
|
LinearLayout mapCompassContainer = (LinearLayout) mapActivity.findViewById(R.id.layers_compass_layout);
|
||||||
|
if (mapCompassContainer != null) {
|
||||||
|
int buttonSizePx = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_small_button_size);
|
||||||
|
int topMarginPx = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_small_button_margin);
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(buttonSizePx, buttonSizePx);
|
||||||
|
params.topMargin = topMarginPx;
|
||||||
|
compassView.setLayoutParams(params);
|
||||||
|
mapCompassContainer.addView(compassView);
|
||||||
|
updateCompass(night);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class CompassDrawable extends Drawable {
|
private class CompassDrawable extends Drawable {
|
||||||
|
|
||||||
private Drawable original;
|
private Drawable original;
|
||||||
|
@ -566,8 +601,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void updateControls(@NonNull RotatedTileBox tileBox, DrawSettings nightMode) {
|
private void updateControls(@NonNull RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||||
boolean isNight = nightMode != null && nightMode.isNightMode();
|
boolean isNight = drawSettings != null && drawSettings.isNightMode();
|
||||||
int shadw = isNight ? Color.TRANSPARENT : Color.WHITE;
|
int shadw = isNight ? Color.TRANSPARENT : Color.WHITE;
|
||||||
int textColor = isNight ? mapActivity.getResources().getColor(R.color.widgettext_night) : Color.BLACK;
|
int textColor = isNight ? mapActivity.getResources().getColor(R.color.widgettext_night) : Color.BLACK;
|
||||||
if (shadowColor != shadw) {
|
if (shadowColor != shadw) {
|
||||||
|
@ -634,25 +669,36 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCompass(boolean isNight) {
|
public void updateCompass(boolean isNight) {
|
||||||
float mapRotate = mapActivity.getMapView().getRotate();
|
float mapRotate = mapActivity.getMapView().getRotate();
|
||||||
|
boolean showCompass = forceShowCompass || mapRotate != 0
|
||||||
|
|| settings.ROTATE_MAP.get() != OsmandSettings.ROTATE_MAP_NONE
|
||||||
|
|| mapActivity.getMapLayers().getMapInfoLayer().getMapInfoControls().isVisible("compass");
|
||||||
if (mapRotate != cachedRotate) {
|
if (mapRotate != cachedRotate) {
|
||||||
cachedRotate = mapRotate;
|
cachedRotate = mapRotate;
|
||||||
// Apply animation to image view
|
// Apply animation to image view
|
||||||
compassHud.iv.invalidate();
|
compassHud.iv.invalidate();
|
||||||
|
compassHud.updateVisibility(showCompass);
|
||||||
}
|
}
|
||||||
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE) {
|
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE) {
|
||||||
compassHud.setIconResId(isNight ? R.drawable.map_compass_niu_white : R.drawable.map_compass_niu);
|
compassHud.setIconResId(isNight ? R.drawable.map_compass_niu_white : R.drawable.map_compass_niu);
|
||||||
compassHud.iv.setContentDescription(mapActivity.getString(R.string.rotate_map_none_opt));
|
compassHud.iv.setContentDescription(mapActivity.getString(R.string.rotate_map_none_opt));
|
||||||
|
compassHud.updateVisibility(showCompass);
|
||||||
} else if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING) {
|
} else if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING) {
|
||||||
compassHud.setIconResId(isNight ? R.drawable.map_compass_bearing_white : R.drawable.map_compass_bearing);
|
compassHud.setIconResId(isNight ? R.drawable.map_compass_bearing_white : R.drawable.map_compass_bearing);
|
||||||
compassHud.iv.setContentDescription(mapActivity.getString(R.string.rotate_map_bearing_opt));
|
compassHud.iv.setContentDescription(mapActivity.getString(R.string.rotate_map_bearing_opt));
|
||||||
|
compassHud.updateVisibility(true);
|
||||||
} else {
|
} else {
|
||||||
compassHud.setIconResId(isNight ? R.drawable.map_compass_white : R.drawable.map_compass);
|
compassHud.setIconResId(isNight ? R.drawable.map_compass_white : R.drawable.map_compass);
|
||||||
compassHud.iv.setContentDescription(mapActivity.getString(R.string.rotate_map_compass_opt));
|
compassHud.iv.setContentDescription(mapActivity.getString(R.string.rotate_map_compass_opt));
|
||||||
|
compassHud.updateVisibility(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CompassDrawable getCompassDrawable(Drawable originalDrawable) {
|
||||||
|
return new CompassDrawable(originalDrawable);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) {
|
private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) {
|
||||||
boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
|
boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null;
|
||||||
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||||
|
|
|
@ -137,6 +137,8 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
rulerControl.setVisibility(false);
|
rulerControl.setVisibility(false);
|
||||||
|
|
||||||
// register left stack
|
// register left stack
|
||||||
|
registerSideWidget(null, R.drawable.ic_action_aircraft, R.string.map_widget_compass, "compass", true, 4);
|
||||||
|
|
||||||
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
|
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
|
||||||
registerSideWidget(bigInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn, "next_turn", true, 5);
|
registerSideWidget(bigInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn, "next_turn", true, 5);
|
||||||
NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
|
NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
|
||||||
|
@ -255,7 +257,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateReg(TextState ts, MapWidgetRegInfo reg) {
|
private void updateReg(TextState ts, MapWidgetRegInfo reg) {
|
||||||
View v = reg.widget.getView().findViewById(R.id.widget_bg);
|
View v = reg.widget != null ? reg.widget.getView().findViewById(R.id.widget_bg) : null;
|
||||||
if(v != null) {
|
if(v != null) {
|
||||||
v.setBackgroundResource(reg.left ? ts.leftRes : ts.rightRes);
|
v.setBackgroundResource(reg.left ? ts.leftRes : ts.rightRes);
|
||||||
reg.widget.updateTextColor(ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
|
reg.widget.updateTextColor(ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class MapWidgetRegistry {
|
public class MapWidgetRegistry {
|
||||||
|
|
||||||
|
@ -68,14 +69,13 @@ public class MapWidgetRegistry {
|
||||||
ApplicationMode mode, boolean left, boolean expanded) {
|
ApplicationMode mode, boolean left, boolean expanded) {
|
||||||
Set<MapWidgetRegInfo> s = left ? this.leftWidgetSet : this.rightWidgetSet;
|
Set<MapWidgetRegInfo> s = left ? this.leftWidgetSet : this.rightWidgetSet;
|
||||||
for (MapWidgetRegInfo r : s) {
|
for (MapWidgetRegInfo r : s) {
|
||||||
if (r.visible(mode) || r.widget.isExplicitlyVisible()) {
|
if (r.widget != null && (r.visible(mode) || r.widget.isExplicitlyVisible())) {
|
||||||
stack.addView(r.widget.getView());
|
stack.addView(r.widget.getView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (expanded) {
|
if (expanded) {
|
||||||
for (MapWidgetRegInfo r : s) {
|
for (MapWidgetRegInfo r : s) {
|
||||||
if (r.visibleCollapsed(mode) &&
|
if (r.widget != null && r.visibleCollapsed(mode) && !r.widget.isExplicitlyVisible()) {
|
||||||
!r.widget.isExplicitlyVisible()) {
|
|
||||||
stack.addView(r.widget.getView());
|
stack.addView(r.widget.getView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
private void update(ApplicationMode mode, DrawSettings drawSettings, boolean expanded, Set<MapWidgetRegInfo> l) {
|
private void update(ApplicationMode mode, DrawSettings drawSettings, boolean expanded, Set<MapWidgetRegInfo> l) {
|
||||||
for (MapWidgetRegInfo r : l) {
|
for (MapWidgetRegInfo r : l) {
|
||||||
if (r.visible(mode) || (r.visibleCollapsed(mode) && expanded)) {
|
if (r.widget != null && (r.visible(mode) || (r.visibleCollapsed(mode) && expanded))) {
|
||||||
r.widget.updateInfo(drawSettings);
|
r.widget.updateInfo(drawSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,6 +214,12 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVisible(String key) {
|
||||||
|
ApplicationMode mode = settings.APPLICATION_MODE.get();
|
||||||
|
Set<String> elements = visibleElementsFromSettings.get(mode);
|
||||||
|
return elements != null && elements.contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
private void setVisibility(MapWidgetRegInfo m, boolean visible, boolean collapsed) {
|
private void setVisibility(MapWidgetRegInfo m, boolean visible, boolean collapsed) {
|
||||||
ApplicationMode mode = settings.APPLICATION_MODE.get();
|
ApplicationMode mode = settings.APPLICATION_MODE.get();
|
||||||
defineDefaultSettingsElement(mode);
|
defineDefaultSettingsElement(mode);
|
||||||
|
@ -352,14 +358,15 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
|
|
||||||
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||||
|
// Right panel
|
||||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_right, map)
|
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_right, map)
|
||||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||||
addControls(map, cm, rightWidgetSet, mode);
|
addControls(map, cm, rightWidgetSet, mode);
|
||||||
if (mode != ApplicationMode.DEFAULT) {
|
// Left panel
|
||||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_left, map)
|
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_left, map)
|
||||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||||
addControls(map, cm, leftWidgetSet, mode);
|
addControls(map, cm, leftWidgetSet, mode);
|
||||||
}
|
// Remaining items
|
||||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_appearance_rem, map)
|
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_appearance_rem, map)
|
||||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||||
addControlsAppearance(map, cm, mode);
|
addControlsAppearance(map, cm, mode);
|
||||||
|
@ -380,14 +387,7 @@ public class MapWidgetRegistry {
|
||||||
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
|
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
|
||||||
Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
|
Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
|
||||||
for (final MapWidgetRegInfo r : groupTitle) {
|
for (final MapWidgetRegInfo r : groupTitle) {
|
||||||
if (mode == ApplicationMode.DEFAULT) {
|
if (!mode.isWidgetAvailable(r.key)) {
|
||||||
if ("intermediate_distance".equals(r.key)
|
|
||||||
|| "distance".equals(r.key)
|
|
||||||
|| "time".equals(r.key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("map_marker_1st".equals(r.key) || "map_marker_2nd".equals(r.key)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ public class MapWidgetRegistry {
|
||||||
.setIcon(r.getDrawableMenu())
|
.setIcon(r.getDrawableMenu())
|
||||||
.setSelected(selected)
|
.setSelected(selected)
|
||||||
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
.setSecondaryIcon(r.widget != null ? R.drawable.ic_action_additional_option : ContextMenuItem.INVALID_ID)
|
||||||
.setDescription(r.visibleCollapsed(mode) ? desc : null)
|
.setDescription(r.visibleCollapsed(mode) ? desc : null)
|
||||||
.setListener(new ContextMenuAdapter.OnRowItemClick() {
|
.setListener(new ContextMenuAdapter.OnRowItemClick() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -405,6 +405,10 @@ public class MapWidgetRegistry {
|
||||||
final View view,
|
final View view,
|
||||||
final int itemId,
|
final int itemId,
|
||||||
final int pos) {
|
final int pos) {
|
||||||
|
if (r.widget == null) {
|
||||||
|
setVisibility(adapter, pos, !r.visible(mode), false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
View textWrapper = view.findViewById(R.id.text_wrapper);
|
View textWrapper = view.findViewById(R.id.text_wrapper);
|
||||||
IconPopupMenu popup = new IconPopupMenu(view.getContext(), textWrapper);
|
IconPopupMenu popup = new IconPopupMenu(view.getContext(), textWrapper);
|
||||||
MenuInflater inflater = popup.getMenuInflater();
|
MenuInflater inflater = popup.getMenuInflater();
|
||||||
|
@ -686,11 +690,15 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int getMenuTitleId();
|
public abstract int getMenuTitleId();
|
||||||
|
|
||||||
public abstract int getMenuIconId();
|
public abstract int getMenuIconId();
|
||||||
|
|
||||||
public abstract int getMenuItemId();
|
public abstract int getMenuItemId();
|
||||||
|
|
||||||
public abstract int[] getMenuTitleIds();
|
public abstract int[] getMenuTitleIds();
|
||||||
|
|
||||||
public abstract int[] getMenuIconIds();
|
public abstract int[] getMenuIconIds();
|
||||||
|
|
||||||
public abstract int[] getMenuItemIds();
|
public abstract int[] getMenuItemIds();
|
||||||
|
|
||||||
public abstract void changeState(int stateId);
|
public abstract void changeState(int stateId);
|
||||||
|
|
Loading…
Reference in a new issue