Added description as indication that view is collapsed.
This commit is contained in:
parent
2600377b9a
commit
88cffc0740
4 changed files with 105 additions and 109 deletions
|
@ -19,14 +19,28 @@
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
tools:src="@drawable/ic_action_gabout_dark"/>
|
tools:src="@drawable/ic_action_gabout_dark"/>
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatTextView
|
<LinearLayout
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:orientation="vertical">
|
||||||
tools:text="Some title text"/>
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="Some title text"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
tools:text="Some title text"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatImageView
|
<android.support.v7.widget.AppCompatImageView
|
||||||
android:id="@+id/secondary_icon"
|
android:id="@+id/secondary_icon"
|
||||||
|
|
|
@ -247,9 +247,15 @@ public class ContextMenuAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String itemDescr = item.getDescription();
|
View descriptionTextView = convertView.findViewById(R.id.description);
|
||||||
if (convertView.findViewById(R.id.description) != null) {
|
if (descriptionTextView != null) {
|
||||||
((TextView) convertView.findViewById(R.id.description)).setText(itemDescr);
|
String itemDescr = item.getDescription();
|
||||||
|
if (itemDescr != null) {
|
||||||
|
((TextView) descriptionTextView).setText(itemDescr);
|
||||||
|
descriptionTextView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
descriptionTextView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -20,17 +27,10 @@ import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.AlarmWidget;
|
||||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.LanesControl;
|
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.LanesControl;
|
||||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.RulerWidget;
|
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.RulerWidget;
|
||||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
import java.lang.reflect.Field;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
public class MapInfoLayer extends OsmandMapLayer {
|
public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
|
||||||
private final MapActivity map;
|
private final MapActivity map;
|
||||||
private final RouteLayer routeLayer;
|
private final RouteLayer routeLayer;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
@ -49,7 +49,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
private DrawSettings drawSettings;
|
private DrawSettings drawSettings;
|
||||||
private TopTextView streetNameView;
|
private TopTextView streetNameView;
|
||||||
|
|
||||||
|
|
||||||
public MapInfoLayer(MapActivity map, RouteLayer layer){
|
public MapInfoLayer(MapActivity map, RouteLayer layer){
|
||||||
this.map = map;
|
this.map = map;
|
||||||
settings = map.getMyApplication().getSettings();
|
settings = map.getMyApplication().getSettings();
|
||||||
|
@ -141,8 +140,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
TextInfoWidget plainTime = ric.createPlainTimeControl(map);
|
TextInfoWidget plainTime = ric.createPlainTimeControl(map);
|
||||||
registerSideWidget(plainTime, R.drawable.ic_action_time, R.string.map_widget_plain_time, "plain_time", false, 25);
|
registerSideWidget(plainTime, R.drawable.ic_action_time, R.string.map_widget_plain_time, "plain_time", false, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void recreateControls() {
|
public void recreateControls() {
|
||||||
rightStack.removeAllViews();
|
rightStack.removeAllViews();
|
||||||
|
@ -182,17 +179,17 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
private int themeId = -1;
|
private int themeId = -1;
|
||||||
public void updateColorShadowsOfText() {
|
public void updateColorShadowsOfText() {
|
||||||
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
|
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
|
||||||
boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
|
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
||||||
boolean following = routeLayer.getHelper().isFollowingMode();
|
boolean following = routeLayer.getHelper().isFollowingMode();
|
||||||
int calcThemeId = (transparent ? 4 : 0) | (nightMode ? 2 : 0) | (following ? 1 : 0);
|
int calcThemeId = (transparent ? 4 : 0) | (nightMode ? 2 : 0) | (following ? 1 : 0);
|
||||||
if (themeId != calcThemeId) {
|
if (themeId != calcThemeId) {
|
||||||
themeId = calcThemeId;
|
themeId = calcThemeId;
|
||||||
TextState ts = calculateTextState();
|
TextState ts = calculateTextState();
|
||||||
map.findViewById(R.id.map_center_info).setBackgroundResource(ts.boxFree);
|
map.findViewById(R.id.map_center_info).setBackgroundResource(ts.boxFree);
|
||||||
for (MapWidgetRegInfo reg : mapInfoControls.getLeft()) {
|
for (MapWidgetRegInfo reg : mapInfoControls.getLeftWidgetSet()) {
|
||||||
updateReg(ts, reg);
|
updateReg(ts, reg);
|
||||||
}
|
}
|
||||||
for (MapWidgetRegInfo reg : mapInfoControls.getRight()) {
|
for (MapWidgetRegInfo reg : mapInfoControls.getRightWidgetSet()) {
|
||||||
updateReg(ts, reg);
|
updateReg(ts, reg);
|
||||||
}
|
}
|
||||||
updateStreetName(nightMode, ts);
|
updateStreetName(nightMode, ts);
|
||||||
|
@ -221,16 +218,15 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private TextState calculateTextState() {
|
private TextState calculateTextState() {
|
||||||
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
|
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
|
||||||
boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
|
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
|
||||||
boolean following = routeLayer.getHelper().isFollowingMode();
|
boolean following = routeLayer.getHelper().isFollowingMode();
|
||||||
TextState ts = new TextState();
|
TextState ts = new TextState();
|
||||||
ts.textBold = following;
|
ts.textBold = following;
|
||||||
ts.night = nightMode;
|
ts.night = nightMode;
|
||||||
ts.textColor = nightMode ? view.getResources().getColor(R.color.widgettext_night) : Color.BLACK;
|
ts.textColor = nightMode ? ContextCompat.getColor(view.getContext(), R.color.widgettext_night) : Color.BLACK;
|
||||||
// Night shadowColor always use widgettext_shadow_night, same as widget background color for non-transparent
|
// Night shadowColor always use widgettext_shadow_night, same as widget background color for non-transparent
|
||||||
ts.textShadowColor = nightMode ? view.getResources().getColor(R.color.widgettext_shadow_night) : Color.WHITE;
|
ts.textShadowColor = nightMode ? ContextCompat.getColor(view.getContext(), R.color.widgettext_shadow_night) : Color.WHITE;
|
||||||
if (!transparent && !nightMode) {
|
if (!transparent && !nightMode) {
|
||||||
// ts.textShadowColor = Color.TRANSPARENT;
|
|
||||||
ts.textShadowRadius = 0;
|
ts.textShadowRadius = 0;
|
||||||
} else {
|
} else {
|
||||||
ts.textShadowRadius = (int) (4 * view.getDensity());
|
ts.textShadowRadius = (int) (4 * view.getDensity());
|
||||||
|
@ -256,9 +252,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||||
|
@ -273,7 +266,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroyLayer() {
|
public void destroyLayer() {
|
||||||
}
|
}
|
||||||
|
@ -283,13 +275,11 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public View getProgressBar() {
|
public View getProgressBar() {
|
||||||
// currently no progress on info layer
|
// currently no progress on info layer
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getStringPropertyName(Context ctx, String propertyName, String defValue) {
|
public static String getStringPropertyName(Context ctx, String propertyName, String defValue) {
|
||||||
try {
|
try {
|
||||||
Field f = R.string.class.getField("rendering_attr_" + propertyName + "_name");
|
Field f = R.string.class.getField("rendering_attr_" + propertyName + "_name");
|
||||||
|
@ -316,11 +306,4 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
return defValue;
|
return defValue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.support.annotation.ColorRes;
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
@ -42,9 +43,9 @@ public class MapWidgetRegistry {
|
||||||
public static final String HIDE_PREFIX = "-";
|
public static final String HIDE_PREFIX = "-";
|
||||||
public static final String SHOW_PREFIX = "";
|
public static final String SHOW_PREFIX = "";
|
||||||
public static final String SETTINGS_SEPARATOR = ";";
|
public static final String SETTINGS_SEPARATOR = ";";
|
||||||
private Set<MapWidgetRegInfo> left = new TreeSet<>();
|
private Set<MapWidgetRegInfo> leftWidgetSet = new TreeSet<>();
|
||||||
private Set<MapWidgetRegInfo> right = new TreeSet<>();
|
private Set<MapWidgetRegInfo> rightWidgetSet = new TreeSet<>();
|
||||||
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<ApplicationMode, Set<String>>();
|
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<>();
|
||||||
private final OsmandSettings settings;
|
private final OsmandSettings settings;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class MapWidgetRegistry {
|
||||||
if (mpf.equals(SHOW_PREFIX)) {
|
if (mpf.equals(SHOW_PREFIX)) {
|
||||||
visibleElementsFromSettings.put(ms, null);
|
visibleElementsFromSettings.put(ms, null);
|
||||||
} else {
|
} else {
|
||||||
LinkedHashSet<String> set = new LinkedHashSet<String>();
|
LinkedHashSet<String> set = new LinkedHashSet<>();
|
||||||
visibleElementsFromSettings.put(ms, set);
|
visibleElementsFromSettings.put(ms, set);
|
||||||
Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
|
Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,7 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
public void populateStackControl(LinearLayout stack,
|
public void populateStackControl(LinearLayout stack,
|
||||||
ApplicationMode mode, boolean left, boolean expanded) {
|
ApplicationMode mode, boolean left, boolean expanded) {
|
||||||
Set<MapWidgetRegInfo> s = left ? this.left : this.right;
|
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.visible(mode) || r.widget.isExplicitlyVisible()) {
|
||||||
stack.addView(r.widget.getView());
|
stack.addView(r.widget.getView());
|
||||||
|
@ -82,12 +83,12 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCollapsibles(ApplicationMode mode) {
|
public boolean hasCollapsibles(ApplicationMode mode) {
|
||||||
for (MapWidgetRegInfo r : left) {
|
for (MapWidgetRegInfo r : leftWidgetSet) {
|
||||||
if (r.visibleCollapsed(mode)) {
|
if (r.visibleCollapsed(mode)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (MapWidgetRegInfo r : right) {
|
for (MapWidgetRegInfo r : rightWidgetSet) {
|
||||||
if (r.visibleCollapsed(mode)) {
|
if (r.visibleCollapsed(mode)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -97,8 +98,8 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
|
|
||||||
public void updateInfo(ApplicationMode mode, DrawSettings drawSettings, boolean expanded) {
|
public void updateInfo(ApplicationMode mode, DrawSettings drawSettings, boolean expanded) {
|
||||||
update(mode, drawSettings, expanded, left);
|
update(mode, drawSettings, expanded, leftWidgetSet);
|
||||||
update(mode, drawSettings, expanded, right);
|
update(mode, drawSettings, expanded, rightWidgetSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(ApplicationMode mode, DrawSettings drawSettings, boolean expanded, Set<MapWidgetRegInfo> l) {
|
private void update(ApplicationMode mode, DrawSettings drawSettings, boolean expanded, Set<MapWidgetRegInfo> l) {
|
||||||
|
@ -111,13 +112,13 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
|
|
||||||
public void removeSideWidgetInternal(TextInfoWidget widget) {
|
public void removeSideWidgetInternal(TextInfoWidget widget) {
|
||||||
Iterator<MapWidgetRegInfo> it = left.iterator();
|
Iterator<MapWidgetRegInfo> it = leftWidgetSet.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
if (it.next().widget == widget) {
|
if (it.next().widget == widget) {
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it = right.iterator();
|
it = rightWidgetSet.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
if (it.next().widget == widget) {
|
if (it.next().widget == widget) {
|
||||||
it.remove();
|
it.remove();
|
||||||
|
@ -126,12 +127,12 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TextInfoWidget> T getSideWidget(Class<T> cl) {
|
public <T extends TextInfoWidget> T getSideWidget(Class<T> cl) {
|
||||||
for (MapWidgetRegInfo ri : left) {
|
for (MapWidgetRegInfo ri : leftWidgetSet) {
|
||||||
if (cl.isInstance(ri)) {
|
if (cl.isInstance(ri)) {
|
||||||
return (T) ri.widget;
|
return (T) ri.widget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (MapWidgetRegInfo ri : right) {
|
for (MapWidgetRegInfo ri : rightWidgetSet) {
|
||||||
if (cl.isInstance(ri)) {
|
if (cl.isInstance(ri)) {
|
||||||
return (T) ri.widget;
|
return (T) ri.widget;
|
||||||
}
|
}
|
||||||
|
@ -171,9 +172,9 @@ public class MapWidgetRegistry {
|
||||||
widget.setContentTitle(messageId);
|
widget.setContentTitle(messageId);
|
||||||
}
|
}
|
||||||
if (left) {
|
if (left) {
|
||||||
this.left.add(ii);
|
this.leftWidgetSet.add(ii);
|
||||||
} else {
|
} else {
|
||||||
this.right.add(ii);
|
this.rightWidgetSet.add(ii);
|
||||||
}
|
}
|
||||||
return ii;
|
return ii;
|
||||||
}
|
}
|
||||||
|
@ -219,9 +220,9 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
private void defineDefaultSettingsElement(ApplicationMode mode) {
|
private void defineDefaultSettingsElement(ApplicationMode mode) {
|
||||||
if (this.visibleElementsFromSettings.get(mode) == null) {
|
if (this.visibleElementsFromSettings.get(mode) == null) {
|
||||||
LinkedHashSet<String> set = new LinkedHashSet<String>();
|
LinkedHashSet<String> set = new LinkedHashSet<>();
|
||||||
restoreModes(set, left, mode);
|
restoreModes(set, leftWidgetSet, mode);
|
||||||
restoreModes(set, right, mode);
|
restoreModes(set, rightWidgetSet, mode);
|
||||||
this.visibleElementsFromSettings.put(mode, set);
|
this.visibleElementsFromSettings.put(mode, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,8 +252,8 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
public void resetToDefault() {
|
public void resetToDefault() {
|
||||||
ApplicationMode appMode = settings.getApplicationMode();
|
ApplicationMode appMode = settings.getApplicationMode();
|
||||||
resetDefault(appMode, left);
|
resetDefault(appMode, leftWidgetSet);
|
||||||
resetDefault(appMode, right);
|
resetDefault(appMode, rightWidgetSet);
|
||||||
resetDefaultAppearance(appMode);
|
resetDefaultAppearance(appMode);
|
||||||
this.visibleElementsFromSettings.put(appMode, null);
|
this.visibleElementsFromSettings.put(appMode, null);
|
||||||
settings.MAP_INFO_CONTROLS.set(SHOW_PREFIX);
|
settings.MAP_INFO_CONTROLS.set(SHOW_PREFIX);
|
||||||
|
@ -293,7 +294,7 @@ public class MapWidgetRegistry {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]);
|
settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]);
|
||||||
for (MapWidgetRegInfo info : right) {
|
for (MapWidgetRegInfo info : rightWidgetSet) {
|
||||||
if ("map_marker_1st".equals(info.key) || "map_marker_2nd".equals(info.key)) {
|
if ("map_marker_1st".equals(info.key) || "map_marker_2nd".equals(info.key)) {
|
||||||
setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets(), false);
|
setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets(), false);
|
||||||
}
|
}
|
||||||
|
@ -322,46 +323,19 @@ public class MapWidgetRegistry {
|
||||||
.setListener(new ApearanceItemClickListener(pref, map)).createItem());
|
.setListener(new ApearanceItemClickListener(pref, map)).createItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApearanceItemClickListener implements ContextMenuAdapter.ItemClickListener {
|
|
||||||
|
|
||||||
private MapActivity map;
|
|
||||||
private OsmandPreference<Boolean> pref;
|
|
||||||
|
|
||||||
public ApearanceItemClickListener(OsmandPreference<Boolean> pref, MapActivity map) {
|
|
||||||
this.pref = pref;
|
|
||||||
this.map = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> a,
|
|
||||||
int itemId, int pos, boolean isChecked) {
|
|
||||||
pref.set(!pref.get());
|
|
||||||
map.updateApplicationModeSettings();
|
|
||||||
a.notifyDataSetChanged();
|
|
||||||
;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean distChanged(int oldDist, int dist) {
|
public static boolean distChanged(int oldDist, int dist) {
|
||||||
if (oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist) / oldDist) < 0.01) {
|
return !(oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist) / oldDist) < 0.01);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||||
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, right, mode);
|
addControls(map, cm, rightWidgetSet, mode);
|
||||||
if (mode != ApplicationMode.DEFAULT) {
|
if (mode != ApplicationMode.DEFAULT) {
|
||||||
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, left, mode);
|
addControls(map, cm, leftWidgetSet, mode);
|
||||||
}
|
}
|
||||||
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());
|
||||||
|
@ -372,18 +346,18 @@ public class MapWidgetRegistry {
|
||||||
return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.messageId);
|
return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MapWidgetRegInfo> getRight() {
|
public Set<MapWidgetRegInfo> getRightWidgetSet() {
|
||||||
return right;
|
return rightWidgetSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MapWidgetRegInfo> getLeft() {
|
public Set<MapWidgetRegInfo> getLeftWidgetSet() {
|
||||||
return left;
|
return leftWidgetSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
|
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
|
||||||
Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
|
Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
|
||||||
@ColorRes final int defaultColor = IconsCache.getDefaultColorRes(mapActivity);
|
@ColorRes final int defaultColor = IconsCache.getDefaultColorRes(mapActivity);
|
||||||
for (final MapWidgetRegInfo r : top) {
|
for (final MapWidgetRegInfo r : groupTitle) {
|
||||||
if (mode == ApplicationMode.DEFAULT) {
|
if (mode == ApplicationMode.DEFAULT) {
|
||||||
if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) {
|
if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -448,7 +422,9 @@ public class MapWidgetRegistry {
|
||||||
}
|
}
|
||||||
ContextMenuItem item = adapter.getItem(position);
|
ContextMenuItem item = adapter.getItem(position);
|
||||||
item.setSelected(visible);
|
item.setSelected(visible);
|
||||||
item.setColorRes(visible || collapsed ? R.color.osmand_orange : defaultColor);
|
item.setColorRes(visible ? R.color.osmand_orange : defaultColor);
|
||||||
|
String desc = mapActivity.getString(R.string.shared_string_collapse);
|
||||||
|
item.setDescription(visible && collapsed ? desc : null);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
@ -465,8 +441,8 @@ public class MapWidgetRegistry {
|
||||||
public final String key;
|
public final String key;
|
||||||
public final boolean left;
|
public final boolean left;
|
||||||
public final int priorityOrder;
|
public final int priorityOrder;
|
||||||
private final Set<ApplicationMode> visibleCollapsible = new LinkedHashSet<ApplicationMode>();
|
private final Set<ApplicationMode> visibleCollapsible = new LinkedHashSet<>();
|
||||||
private final Set<ApplicationMode> visibleModes = new LinkedHashSet<ApplicationMode>();
|
private final Set<ApplicationMode> visibleModes = new LinkedHashSet<>();
|
||||||
private Runnable stateChangeListener = null;
|
private Runnable stateChangeListener = null;
|
||||||
|
|
||||||
public MapWidgetRegInfo(String key, TextInfoWidget widget, @DrawableRes int drawableMenu,
|
public MapWidgetRegInfo(String key, TextInfoWidget widget, @DrawableRes int drawableMenu,
|
||||||
|
@ -504,20 +480,19 @@ public class MapWidgetRegistry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
if (obj == null)
|
} else if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
} else if (getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
MapWidgetRegInfo other = (MapWidgetRegInfo) obj;
|
MapWidgetRegInfo other = (MapWidgetRegInfo) obj;
|
||||||
if (messageId != other.messageId)
|
return messageId == other.messageId;
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(MapWidgetRegInfo another) {
|
public int compareTo(@NonNull MapWidgetRegInfo another) {
|
||||||
if (messageId == another.messageId) {
|
if (messageId == another.messageId) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -545,4 +520,22 @@ public class MapWidgetRegistry {
|
||||||
return cm;
|
return cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ApearanceItemClickListener implements ContextMenuAdapter.ItemClickListener {
|
||||||
|
private MapActivity map;
|
||||||
|
private OsmandPreference<Boolean> pref;
|
||||||
|
|
||||||
|
public ApearanceItemClickListener(OsmandPreference<Boolean> pref, MapActivity map) {
|
||||||
|
this.pref = pref;
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> a,
|
||||||
|
int itemId, int pos, boolean isChecked) {
|
||||||
|
pref.set(!pref.get());
|
||||||
|
map.updateApplicationModeSettings();
|
||||||
|
a.notifyDataSetChanged();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue