Merge branch 'r3.7'

This commit is contained in:
Victor Shcherb 2020-05-22 14:58:11 +02:00
commit 4f89a04ea3
5 changed files with 62 additions and 31 deletions

View file

@ -29,6 +29,7 @@ import java.util.TreeSet;
public class MapPoiTypes { public class MapPoiTypes {
private static final String OTHER_MAP_CATEGORY = "Other";
private static MapPoiTypes DEFAULT_INSTANCE = null; private static MapPoiTypes DEFAULT_INSTANCE = null;
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class); private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
private String resourceName; private String resourceName;
@ -96,7 +97,7 @@ public class MapPoiTypes {
public PoiCategory getOtherMapCategory() { public PoiCategory getOtherMapCategory() {
if (otherMapCategory == null) { if (otherMapCategory == null) {
otherMapCategory = getPoiCategoryByName("Other", true); otherMapCategory = getPoiCategoryByName(OTHER_MAP_CATEGORY, true);
} }
return otherMapCategory; return otherMapCategory;
} }
@ -111,7 +112,8 @@ public class MapPoiTypes {
public List<AbstractPoiType> getTopVisibleFilters() { public List<AbstractPoiType> getTopVisibleFilters() {
List<AbstractPoiType> lf = new ArrayList<AbstractPoiType>(); List<AbstractPoiType> lf = new ArrayList<AbstractPoiType>();
for (PoiCategory pc : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
if (pc.isTopVisible()) { if (pc.isTopVisible()) {
lf.add(pc); lf.add(pc);
} }
@ -131,7 +133,8 @@ public class MapPoiTypes {
} }
public PoiCategory getOsmwiki() { public PoiCategory getOsmwiki() {
for (PoiCategory category : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory category = categories.get(i);
if (category.isWiki()) { if (category.isWiki()) {
return category; return category;
} }
@ -167,7 +170,8 @@ public class MapPoiTypes {
} }
public PoiType getPoiTypeByKey(String name) { public PoiType getPoiTypeByKey(String name) {
for (PoiCategory pc : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
PoiType pt = pc.getPoiTypeByKeyName(name); PoiType pt = pc.getPoiTypeByKeyName(name);
if (pt != null && !pt.isReference()) { if (pt != null && !pt.isReference()) {
return pt; return pt;
@ -184,7 +188,8 @@ public class MapPoiTypes {
} }
public AbstractPoiType getAnyPoiTypeByKey(String name) { public AbstractPoiType getAnyPoiTypeByKey(String name) {
for (PoiCategory pc : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
if (pc.getKeyName().equals(name)) { if (pc.getKeyName().equals(name)) {
return pc; return pc;
} }
@ -203,7 +208,8 @@ public class MapPoiTypes {
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) { public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
Map<String, PoiType> translation = new HashMap<String, PoiType>(); Map<String, PoiType> translation = new HashMap<String, PoiType>();
for (PoiCategory pc : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
if (skipNonEditable && pc.isNotEditableOsm()) { if (skipNonEditable && pc.isNotEditableOsm()) {
continue; continue;
} }
@ -231,7 +237,8 @@ public class MapPoiTypes {
public List<AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) { public List<AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
List<AbstractPoiType> tm = new ArrayList<AbstractPoiType>(); List<AbstractPoiType> tm = new ArrayList<AbstractPoiType>();
for (PoiCategory pc : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
if (pc == otherMapCategory) { if (pc == otherMapCategory) {
continue; continue;
} }
@ -294,7 +301,7 @@ public class MapPoiTypes {
} }
if (create) { if (create) {
PoiCategory lastCategory = new PoiCategory(this, name, categories.size()); PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
if (!lastCategory.getKeyName().equals("Other")) { if (!lastCategory.getKeyName().equals(OTHER_MAP_CATEGORY)) {
lastCategory.setTopVisible(true); lastCategory.setTopVisible(true);
} }
addCategory(lastCategory); addCategory(lastCategory);
@ -365,6 +372,8 @@ public class MapPoiTypes {
PoiType lastType = null; PoiType lastType = null;
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<String>(); Set<String> lastTypePoiAdditionalsCategories = new TreeSet<String>();
String lastPoiAdditionalCategory = null; String lastPoiAdditionalCategory = null;
PoiCategory localOtherMapCategory = new PoiCategory(this, OTHER_MAP_CATEGORY, categoriesList.size());
categoriesList.add(localOtherMapCategory);
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) { while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (tok == XmlPullParser.START_TAG) { if (tok == XmlPullParser.START_TAG) {
String name = parser.getName(); String name = parser.getName();
@ -404,7 +413,7 @@ public class MapPoiTypes {
lastCategory.addPoiType(tp); lastCategory.addPoiType(tp);
} else if (name.equals("poi_additional")) { } else if (name.equals("poi_additional")) {
if (lastCategory == null) { if (lastCategory == null) {
lastCategory = getOtherMapCategory(); lastCategory = localOtherMapCategory;
} }
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null, lastPoiAdditionalCategory); PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null, lastPoiAdditionalCategory);
if ("true".equals(parser.getAttributeValue("", "lang"))) { if ("true".equals(parser.getAttributeValue("", "lang"))) {
@ -433,7 +442,7 @@ public class MapPoiTypes {
} else if (name.equals("poi_type")) { } else if (name.equals("poi_type")) {
if (lastCategory == null) { if (lastCategory == null) {
lastCategory = getOtherMapCategory(); lastCategory = localOtherMapCategory;
} }
if(!Algorithms.isEmpty(parser.getAttributeValue("", "deprecated_of"))){ if(!Algorithms.isEmpty(parser.getAttributeValue("", "deprecated_of"))){
String vl = parser.getAttributeValue("", "name"); String vl = parser.getAttributeValue("", "name");
@ -705,7 +714,8 @@ public class MapPoiTypes {
public AbstractPoiType getAnyPoiAdditionalTypeByKey(String name) { public AbstractPoiType getAnyPoiAdditionalTypeByKey(String name) {
PoiType add = null; PoiType add = null;
for (PoiCategory pc : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
add = getPoiAdditionalByKey(pc, name); add = getPoiAdditionalByKey(pc, name);
if (add != null) { if (add != null) {
return add; return add;
@ -811,7 +821,8 @@ public class MapPoiTypes {
if (!poiTypesByTag.isEmpty()) { if (!poiTypesByTag.isEmpty()) {
return; return;
} }
for (PoiCategory poic : categories) { for (int i = 0; i < categories.size(); i++) {
PoiCategory poic = categories.get(i);
for (PoiType p : poic.getPoiTypes()) { for (PoiType p : poic.getPoiTypes()) {
initPoiType(p); initPoiType(p);
for (PoiType pts : p.getPoiAdditionals()) { for (PoiType pts : p.getPoiAdditionals()) {

View file

@ -7,8 +7,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/dashboard_map_toolbar" android:layout_height="@dimen/dashboard_map_toolbar"
android:background="@color/app_bar_color_light" android:background="@color/app_bar_color_light"
app:contentInsetLeft="4dp" app:contentInsetLeft="0dp"
app:contentInsetStart="4dp" app:contentInsetStart="0dp"
app:contentInsetRight="0dp" app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"> app:contentInsetEnd="0dp">
@ -25,15 +25,16 @@
android:gravity="start" android:gravity="start"
android:orientation="horizontal"> android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView <ImageButton
android:id="@+id/toolbar_back" android:id="@+id/toolbar_back"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/acceptable_touch_radius"
android:layout_height="@dimen/acceptable_touch_radius"
android:layout_marginStart="@dimen/list_item_button_padding"
android:layout_marginLeft="@dimen/list_item_button_padding"
android:layout_marginEnd="@dimen/list_item_button_padding"
android:layout_marginRight="@dimen/list_item_button_padding"
android:contentDescription="@string/back_to_map" android:contentDescription="@string/back_to_map"
android:layout_marginLeft="@dimen/multi_selection_menu_padding_top"
android:layout_marginRight="@dimen/multi_selection_menu_padding_top"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="match_parent"
android:background="@drawable/dashboard_button_light"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_arrow_back" app:srcCompat="@drawable/ic_arrow_back"
tools:visibility="visible" /> tools:visibility="visible" />
@ -53,6 +54,7 @@
android:id="@+id/toolbar_text" android:id="@+id/toolbar_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:scaleType="center" android:scaleType="center"
android:textColor="@color/abc_primary_text_material_dark" android:textColor="@color/abc_primary_text_material_dark"
android:textSize="@dimen/abc_text_size_large_material" android:textSize="@dimen/abc_text_size_large_material"

View file

@ -24,6 +24,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ImageView.ScaleType; import android.widget.ImageView.ScaleType;
import android.widget.ListView; import android.widget.ListView;
@ -49,13 +50,11 @@ import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.ValueHolder; import net.osmand.ValueHolder;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -78,6 +77,8 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.srtmplugin.ContourLinesMenu; import net.osmand.plus.srtmplugin.ContourLinesMenu;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.srtmplugin.TerrainFragment; import net.osmand.plus.srtmplugin.TerrainFragment;
@ -340,7 +341,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities(); UiUtilities iconsCache = mapActivity.getMyApplication().getUIUtilities();
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list); ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
lst.setVisibility(View.GONE); lst.setVisibility(View.GONE);
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back); ImageButton back = (ImageButton) dashboardView.findViewById(R.id.toolbar_back);
Drawable icBack = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(mapActivity)); Drawable icBack = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(mapActivity));
back.setImageDrawable(icBack); back.setImageDrawable(icBack);
back.setOnClickListener(new View.OnClickListener() { back.setOnClickListener(new View.OnClickListener() {

View file

@ -37,9 +37,6 @@ import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings.ListStringPreference;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -51,6 +48,9 @@ import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings.ListStringPreference;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.transport.TransportLinesMenu; import net.osmand.plus.transport.TransportLinesMenu;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
@ -529,6 +529,9 @@ public class ConfigureMapMenu {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) { final int pos, boolean isChecked, int[] viewCoordinates) {
if (!AndroidUtils.isActivityNotDestroyed(activity)) {
return false;
}
final OsmandMapTileView view = activity.getMapView(); final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes)); AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
bld.setTitle(R.string.daynight); bld.setTitle(R.string.daynight);
@ -570,6 +573,9 @@ public class ConfigureMapMenu {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) { final int pos, boolean isChecked, int[] viewCoordinates) {
if (!AndroidUtils.isActivityNotDestroyed(activity)) {
return false;
}
final OsmandMapTileView view = activity.getMapView(); final OsmandMapTileView view = activity.getMapView();
final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY; final OsmandSettings.OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes)); AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
@ -638,6 +644,9 @@ public class ConfigureMapMenu {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) { final int pos, boolean isChecked, int[] viewCoordinates) {
if (!AndroidUtils.isActivityNotDestroyed(activity)) {
return false;
}
final OsmandMapTileView view = activity.getMapView(); final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes)); AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
// test old descr as title // test old descr as title
@ -682,6 +691,9 @@ public class ConfigureMapMenu {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, int itemId,
final int pos, boolean isChecked, int[] viewCoordinates) { final int pos, boolean isChecked, int[] viewCoordinates) {
if (!AndroidUtils.isActivityNotDestroyed(activity)) {
return false;
}
final OsmandMapTileView view = activity.getMapView(); final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes)); AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
@ -991,7 +1003,9 @@ public class ConfigureMapMenu {
final int themeRes, final int themeRes,
final boolean nightMode, final boolean nightMode,
@ColorInt final int selectedProfileColor) { @ColorInt final int selectedProfileColor) {
if (!AndroidUtils.isActivityNotDestroyed(activity)) {
return;
}
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes)); AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
boolean[] checkedItems = new boolean[prefs.size()]; boolean[] checkedItems = new boolean[prefs.size()];
final boolean[] tempPrefs = new boolean[prefs.size()]; final boolean[] tempPrefs = new boolean[prefs.size()];
@ -1246,6 +1260,9 @@ public class ConfigureMapMenu {
@Override @Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad, public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> ad,
final int itemId, final int pos, boolean isChecked, int[] viewCoordinates) { final int itemId, final int pos, boolean isChecked, int[] viewCoordinates) {
if (!AndroidUtils.isActivityNotDestroyed(activity)) {
return false;
}
AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes)); AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
// test old descr as title // test old descr as title
b.setTitle(propertyDescr); b.setTitle(propertyDescr);

View file

@ -393,7 +393,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight()); canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
contextMarker.draw(canvas); contextMarker.draw(canvas);
} }
if (this.nightMode != nightMode) { if (this.nightMode != nightMode && currentWidgetState != null) {
this.nightMode = nightMode; this.nightMode = nightMode;
updateQuickActionButton(currentWidgetState); updateQuickActionButton(currentWidgetState);
} }