reset configure map item if hidden

This commit is contained in:
veliymolfar 2020-05-05 15:50:33 +03:00
parent b140ac4392
commit edbb876830
10 changed files with 146 additions and 20 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="reset_hidden_items">Reset hidden items?</string>
<string name="shared_string_add_edit">Add / Edit</string> <string name="shared_string_add_edit">Add / Edit</string>
<string name="parking_positions">Parking positions</string> <string name="parking_positions">Parking positions</string>
<string name="create_edit_poi">Create/Edit POI</string> <string name="create_edit_poi">Create/Edit POI</string>

View file

@ -278,7 +278,7 @@ public class ContextMenuItem {
private ContextMenuAdapter.ItemClickListener mItemClickListener = null; private ContextMenuAdapter.ItemClickListener mItemClickListener = null;
private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null; private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;
private ContextMenuAdapter.ProgressListener mProgressListener = null; private ContextMenuAdapter.ProgressListener mProgressListener = null;
private OnItemDeleteAction itemDeleteAction; private OnItemDeleteAction mItemDeleteAction = null;
private boolean mSkipPaintingWithoutColor; private boolean mSkipPaintingWithoutColor;
private boolean mHideDivider; private boolean mHideDivider;
private boolean mHideCompoundButton; private boolean mHideCompoundButton;
@ -380,8 +380,9 @@ public class ContextMenuItem {
return this; return this;
} }
public void setItemDeleteAction(OnItemDeleteAction itemDeleteAction) { public ItemBuilder setItemDeleteAction(OnItemDeleteAction itemDeleteAction) {
this.itemDeleteAction = itemDeleteAction; this.mItemDeleteAction = itemDeleteAction;
return this;
} }
public ItemBuilder hideDivider(boolean hideDivider) { public ItemBuilder hideDivider(boolean hideDivider) {
@ -416,14 +417,13 @@ public class ContextMenuItem {
public ContextMenuItem createItem() { public ContextMenuItem createItem() {
return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon, return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor, mSelected, mProgress, mLayout, mLoading, mIsCategory, mIsClickable, mSkipPaintingWithoutColor,
mPosition, mOrder, mDescription, mItemClickListener, mIntegerListener, mProgressListener, itemDeleteAction, mPosition, mOrder, mDescription, mItemClickListener, mIntegerListener, mProgressListener, mItemDeleteAction,
mHideDivider, mHideCompoundButton, mMinHeight, mTag, mId); mHideDivider, mHideCompoundButton, mMinHeight, mTag, mId);
} }
} }
// when action is deleted or reset // when action is deleted or reset
public interface OnItemDeleteAction { public interface OnItemDeleteAction {
boolean itemWasDeleted(boolean profileOnly); void itemWasDeleted(ApplicationMode appMode, boolean profileOnly);
} }
} }

View file

@ -61,6 +61,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.TabActivity.TabItem; import net.osmand.plus.activities.TabActivity.TabItem;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
@ -652,6 +653,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
.setSelected(SHOW_RECORDINGS.get()) .setSelected(SHOW_RECORDINGS.get())
.setIcon(R.drawable.ic_action_micro_dark) .setIcon(R.drawable.ic_action_micro_dark)
.setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(SHOW_RECORDINGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandPreference>asList(SHOW_RECORDINGS)))
.setListener(listener).createItem()); .setListener(listener).createItem());
} }

View file

@ -31,6 +31,7 @@ import net.osmand.CallbackWithObject;
import net.osmand.GPXUtilities; import net.osmand.GPXUtilities;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.core.android.MapRendererContext; import net.osmand.core.android.MapRendererContext;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
@ -40,6 +41,7 @@ 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.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.ListStringPreference; import net.osmand.plus.OsmandSettings.ListStringPreference;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -53,7 +55,6 @@ 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.ConfigureMenuRootFragment.ScreenType;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.corenative.NativeCoreContext; import net.osmand.plus.views.corenative.NativeCoreContext;
@ -317,6 +318,32 @@ public class ConfigureMapMenu {
} }
} }
public static final class ItemResetListener implements ContextMenuItem.OnItemDeleteAction {
private List<OsmandPreference> prefs;
public ItemResetListener(@NonNull List<OsmandPreference> prefs) {
this.prefs = prefs;
}
@Override
public void itemWasDeleted(@NonNull ApplicationMode appMode, boolean profileOnly) {
for (OsmandSettings.OsmandPreference pref : prefs) {
resetSetting(appMode, pref, profileOnly);
}
}
private void resetSetting(ApplicationMode appMode, OsmandPreference preference, boolean profileOnly) {
if (profileOnly) {
preference.resetModeToDefault(appMode);
} else {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
preference.resetModeToDefault(mode);
}
}
}
}
private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter, private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter,
final MapActivity activity, final int themeRes, final boolean nightMode) { final MapActivity activity, final int themeRes, final boolean nightMode) {
final OsmandApplication app = activity.getMyApplication(); final OsmandApplication app = activity.getMyApplication();
@ -336,7 +363,9 @@ public class ConfigureMapMenu {
.setSelected(settings.SHOW_FAVORITES.get()) .setSelected(settings.SHOW_FAVORITES.get())
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_fav_dark) .setIcon(R.drawable.ic_action_fav_dark)
.setListener(l).createItem()); .setItemDeleteAction(new ItemResetListener(Arrays.<OsmandPreference>asList(settings.SHOW_FAVORITES)))
.setListener(l)
.createItem());
selected = app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.POI); selected = app.getPoiFilters().isShowingAnyPoi(PoiTemplateList.POI);
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(POI_OVERLAY_ID) .setId(POI_OVERLAY_ID)
@ -354,6 +383,7 @@ public class ConfigureMapMenu {
.setSelected(settings.SHOW_POI_LABEL.get()) .setSelected(settings.SHOW_POI_LABEL.get())
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_text_dark) .setIcon(R.drawable.ic_action_text_dark)
.setItemDeleteAction(new ItemResetListener(Arrays.<OsmandPreference>asList(settings.SHOW_POI_LABEL)))
.setListener(l).createItem()); .setListener(l).createItem());
/* /*
@ -392,6 +422,7 @@ public class ConfigureMapMenu {
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setSelected(transportSelected) .setSelected(transportSelected)
.setColor(transportSelected ? selectedProfileColorRes : ContextMenuItem.INVALID_ID) .setColor(transportSelected ? selectedProfileColorRes : ContextMenuItem.INVALID_ID)
.setItemDeleteAction(new ItemResetListener(new ArrayList<OsmandPreference>(transportPrefs)))
.setListener(new ContextMenuAdapter.OnRowItemClick() { .setListener(new ContextMenuAdapter.OnRowItemClick() {
ArrayAdapter<CharSequence> adapter; ArrayAdapter<CharSequence> adapter;
boolean transportSelectedInner = transportSelected; boolean transportSelectedInner = transportSelected;
@ -557,6 +588,7 @@ public class ConfigureMapMenu {
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_plugin_wikipedia) .setIcon(R.drawable.ic_plugin_wikipedia)
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setItemDeleteAction(new ItemResetListener(Arrays.<OsmandPreference>asList(settings.SHOW_WIKIPEDIA_POI)))
.setListener(l).createItem()); .setListener(l).createItem());
selected = settings.SHOW_MAP_MARKERS.get(); selected = settings.SHOW_MAP_MARKERS.get();
@ -566,6 +598,7 @@ public class ConfigureMapMenu {
.setSelected(selected) .setSelected(selected)
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_flag_dark) .setIcon(R.drawable.ic_action_flag_dark)
.setItemDeleteAction(new ItemResetListener(Arrays.<OsmandPreference>asList(settings.SHOW_MAP_MARKERS)))
.setListener(l).createItem()); .setListener(l).createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
@ -573,6 +606,7 @@ public class ConfigureMapMenu {
.setTitleId(R.string.layer_map, activity) .setTitleId(R.string.layer_map, activity)
.setIcon(R.drawable.ic_world_globe_dark) .setIcon(R.drawable.ic_world_globe_dark)
.setDescription(settings.MAP_ONLINE_DATA.get() ? settings.MAP_TILE_SOURCES.get() : null) .setDescription(settings.MAP_ONLINE_DATA.get() ? settings.MAP_TILE_SOURCES.get() : null)
.setItemDeleteAction(new ItemResetListener(Arrays.<OsmandPreference>asList(settings.MAP_ONLINE_DATA, settings.MAP_TILE_SOURCES)))
.setListener(l).createItem()); .setListener(l).createItem());
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity); OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);
@ -615,7 +649,9 @@ public class ConfigureMapMenu {
SelectMapStyleBottomSheetDialogFragment.TAG); SelectMapStyleBottomSheetDialogFragment.TAG);
return false; return false;
} }
}).createItem()); })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.RENDERER)))
.createItem());
String description = ""; String description = "";
SunriseSunset sunriseSunset = activity.getMyApplication().getDaynightHelper().getSunriseSunset(); SunriseSunset sunriseSunset = activity.getMyApplication().getDaynightHelper().getSunriseSunset();
@ -670,7 +706,9 @@ public class ConfigureMapMenu {
dialogAdapter.setDialog(bld.show()); dialogAdapter.setDialog(bld.show());
return false; return false;
} }
}).createItem()); })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.DAYNIGHT_MODE)))
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(MAP_MAGNIFIER_ID) .setId(MAP_MAGNIFIER_ID)
@ -734,7 +772,9 @@ public class ConfigureMapMenu {
dialogAdapter.setDialog(bld.show()); dialogAdapter.setDialog(bld.show());
return false; return false;
} }
}).createItem()); })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.MAP_DENSITY)))
.createItem());
ContextMenuItem props; ContextMenuItem props;
props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID, app, selectedProfileColor, nightMode, themeRes); props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID, app, selectedProfileColor, nightMode, themeRes);
@ -778,7 +818,9 @@ public class ConfigureMapMenu {
dialogAdapter.setDialog(b.show()); dialogAdapter.setDialog(b.show());
return false; return false;
} }
}).createItem()); })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.TEXT_SCALE)))
.createItem());
String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get(); String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get();
localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names) localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names)
@ -876,7 +918,9 @@ public class ConfigureMapMenu {
b.show(); b.show();
return false; return false;
} }
}).createItem()); })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.MAP_PREFERRED_LOCALE)))
.createItem());
props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_transport_bus, props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_transport_bus,
"transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID, themeRes, nightMode, selectedProfileColor); "transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID, themeRes, nightMode, selectedProfileColor);
@ -1063,6 +1107,7 @@ public class ConfigureMapMenu {
builder.setSecondaryIcon(R.drawable.ic_action_additional_option); builder.setSecondaryIcon(R.drawable.ic_action_additional_option);
builder.setSelected(selected); builder.setSelected(selected);
} }
builder.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(new ArrayList<OsmandPreference>(prefs)));
return builder.createItem(); return builder.createItem();
// createCustomRenderingProperties(adapter, activity, ps); // createCustomRenderingProperties(adapter, activity, ps);
} }
@ -1399,6 +1444,7 @@ public class ConfigureMapMenu {
} }
}) })
.setDescription(descr) .setDescription(descr)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(pref)))
.setLayout(R.layout.list_item_single_line_descrition_narrow); .setLayout(R.layout.list_item_single_line_descrition_narrow);
if (icon != 0) { if (icon != 0) {
builder.setIcon(icon); builder.setIcon(icon);

View file

@ -31,6 +31,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
@ -39,6 +40,7 @@ import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static android.content.Intent.ACTION_VIEW; import static android.content.Intent.ACTION_VIEW;
@ -185,6 +187,7 @@ public class MapillaryPlugin extends OsmandPlugin {
.setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_mapillary) .setIcon(R.drawable.ic_action_mapillary)
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.SHOW_MAPILLARY)))
.setListener(listener) .setListener(listener)
.createItem()); .createItem());
} }

View file

@ -38,6 +38,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TabActivity; import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo; import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
@ -50,6 +51,7 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_CREATE_POI; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_CREATE_POI;
@ -364,6 +366,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
return true; return true;
} }
}) })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.SHOW_OSM_BUGS)))
.createItem()); .createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
@ -385,6 +388,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
return true; return true;
} }
}) })
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.SHOW_OSM_EDITS)))
.createItem()); .createItem());
} }

View file

@ -45,6 +45,7 @@ import net.osmand.plus.activities.DownloadTilesDialog;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.RasterMapMenu; import net.osmand.plus.dialogs.RasterMapMenu;
import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.MapTileLayer;
@ -53,6 +54,7 @@ import net.osmand.util.Algorithms;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -358,6 +360,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
.setIcon(R.drawable.ic_layer_top) .setIcon(R.drawable.ic_layer_top)
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener) .setListener(listener)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.MAP_OVERLAY, settings.MAP_OVERLAY_PREVIOUS, settings.MAP_OVERLAY_TRANSPARENCY)))
.createItem()); .createItem());
String underlayMapDescr = settings.MAP_UNDERLAY.get(); String underlayMapDescr = settings.MAP_UNDERLAY.get();
if (underlayMapDescr!=null && underlayMapDescr.contains(".sqlitedb")) { if (underlayMapDescr!=null && underlayMapDescr.contains(".sqlitedb")) {
@ -373,6 +376,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
.setIcon(R.drawable.ic_layer_bottom) .setIcon(R.drawable.ic_layer_bottom)
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener) .setListener(listener)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.MAP_UNDERLAY, settings.MAP_UNDERLAY_PREVIOUS)))
.createItem()); .createItem());
} }

View file

@ -51,7 +51,33 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONTOUR_LINES;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DETAILS_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.FAVORITES_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.GPX_FILES_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.HIDE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAPILLARY;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MORE_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MORE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_LANGUAGE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MAGNIFIER_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MARKERS_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MODE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_SOURCE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_STYLE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OVERLAY_MAP;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.POI_OVERLAY_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.POI_OVERLAY_LABELS_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.RECORDING_LAYER;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.ROAD_STYLE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.ROUTES_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TERRAIN;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TEXT_SIZE_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_RENDERING_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.WIKIPEDIA_ID;
import static net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItemType.BUTTON; import static net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItemType.BUTTON;
import static net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItemType.DESCRIPTION; import static net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItemType.DESCRIPTION;
import static net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItemType.DIVIDER; import static net.osmand.plus.settings.RearrangeMenuItemsAdapter.AdapterItemType.DIVIDER;
@ -239,7 +265,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
} }
} }
FragmentManager fm = getFragmentManager(); FragmentManager fm = getFragmentManager();
OsmandSettings.ContextMenuItemsSettings prefToSave; final OsmandSettings.ContextMenuItemsSettings prefToSave;
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) { if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
prefToSave = new OsmandSettings.MapContextMenuItemsSettings(mainActionItems, hiddenMenuItems, ids); prefToSave = new OsmandSettings.MapContextMenuItemsSettings(mainActionItems, hiddenMenuItems, ids);
} else { } else {
@ -254,9 +280,13 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
appMode, appMode,
new ChangeGeneralProfilesPrefBottomSheet.OnChangeSettingListener() { new ChangeGeneralProfilesPrefBottomSheet.OnChangeSettingListener() {
@Override @Override
public void onApplied() { public void onApplied(boolean profileOnly) {
if (screenType == ScreenType.CONFIGURE_MAP && !hiddenMenuItems.isEmpty()) {
showResetConfigureMapItemsDialog(profileOnly);
} else {
dismissFragment(); dismissFragment();
} }
}
@Override @Override
public void onDiscard() { public void onDiscard() {
@ -397,7 +427,9 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
items.addAll(visible); items.addAll(visible);
} }
if (!hiddenItems.isEmpty()) { if (!hiddenItems.isEmpty()) {
items.add(new RearrangeMenuAdapterItem(HEADER, new RearrangeMenuItemsAdapter.HeaderItem(R.string.shared_string_hidden, R.string.hidden_items_descr))); items.add(new RearrangeMenuAdapterItem(HEADER,
new RearrangeMenuItemsAdapter.HeaderItem(R.string.shared_string_hidden,
screenType == ScreenType.CONFIGURE_MAP ? R.string.reset_items_descr : R.string.hidden_items_descr)));
items.addAll(hiddenItems); items.addAll(hiddenItems);
} }
items.add(new RearrangeMenuAdapterItem(DIVIDER, 1)); items.add(new RearrangeMenuAdapterItem(DIVIDER, 1));
@ -478,6 +510,27 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
dismissDialog.show(); dismissDialog.show();
} }
public void showResetConfigureMapItemsDialog(final boolean profileOnly) {
Context themedContext = UiUtilities.getThemedContext(getActivity(), nightMode);
final AlertDialog.Builder dismissDialog = new AlertDialog.Builder(themedContext);
dismissDialog.setTitle(getString(R.string.shared_string_reset));
dismissDialog.setMessage(getString(R.string.reset_hidden_items));
dismissDialog.setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dismissFragment();
}
});
dismissDialog.setPositiveButton(R.string.shared_string_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
resetHiddenItems(profileOnly);
dismissFragment();
}
});
dismissDialog.show();
}
private void dismissFragment() { private void dismissFragment() {
FragmentManager fm = getFragmentManager(); FragmentManager fm = getFragmentManager();
if (fm != null && !fm.isStateSaved()) { if (fm != null && !fm.isStateSaved()) {
@ -548,4 +601,14 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
} }
}); });
} }
private void resetHiddenItems(boolean profileOnly) {
for (ContextMenuItem item : contextMenuAdapter.getItems()) {
if (hiddenMenuItems.contains(item.getId())) {
if (item.getItemDeleteAction() != null) {
item.getItemDeleteAction().itemWasDeleted(appMode, profileOnly);
}
}
}
}
} }

View file

@ -69,7 +69,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
app.getSettings().setPreferenceForAllModes(prefId, newValue); app.getSettings().setPreferenceForAllModes(prefId, newValue);
updateTargetSettings(false, true); updateTargetSettings(false, true);
if (listener != null) { if (listener != null) {
listener.onApplied(); listener.onApplied(false);
} }
dismiss(); dismiss();
} }
@ -89,7 +89,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
app.getSettings().setPreference(prefId, newValue, getAppMode()); app.getSettings().setPreference(prefId, newValue, getAppMode());
updateTargetSettings(false, false); updateTargetSettings(false, false);
if (listener != null) { if (listener != null) {
listener.onApplied(); listener.onApplied(true);
} }
dismiss(); dismiss();
} }
@ -195,7 +195,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
} }
public interface OnChangeSettingListener { public interface OnChangeSettingListener {
void onApplied(); void onApplied(boolean profileOnly);
void onDiscard(); void onDiscard();
} }

View file

@ -27,6 +27,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.DownloadResources;
@ -347,6 +348,7 @@ public class SRTMPlugin extends OsmandPlugin {
.setIcon(R.drawable.ic_plugin_srtm) .setIcon(R.drawable.ic_plugin_srtm)
.setDescription(app.getString(R.string.display_zoom_level, descr)) .setDescription(app.getString(R.string.display_zoom_level, descr))
.setColor(contourLinesSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(contourLinesSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.CONTOUR_LINES_ZOOM)))
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(listener).createItem()); .setListener(listener).createItem());
} }
@ -362,6 +364,7 @@ public class SRTMPlugin extends OsmandPlugin {
.setColor(terrainEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(terrainEnabled ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setIcon(R.drawable.ic_action_hillshade_dark) .setIcon(R.drawable.ic_action_hillshade_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setItemDeleteAction(new ConfigureMapMenu.ItemResetListener(Arrays.<OsmandSettings.OsmandPreference>asList(settings.TERRAIN, settings.TERRAIN_MODE)))
.setListener(listener) .setListener(listener)
.createItem() .createItem()
); );