Fix update widgets visibility after reset
This commit is contained in:
parent
9397ab62a6
commit
826eba624d
3 changed files with 33 additions and 14 deletions
|
@ -430,7 +430,7 @@ public class OsmandSettings {
|
|||
|
||||
public void copyProfilePreferences(ApplicationMode modeFrom, ApplicationMode modeTo, List<OsmandPreference> profilePreferences) {
|
||||
for (OsmandPreference pref : profilePreferences) {
|
||||
if (prefCanBeCopiedOrReset(pref)) {
|
||||
if (prefCanBeCopiedOrReset(pref) && !USER_PROFILE_NAME.getId().equals(pref.getId())) {
|
||||
CommonPreference profilePref = (CommonPreference) pref;
|
||||
if (PARENT_APP_MODE.getId().equals(pref.getId())) {
|
||||
if (modeTo.isCustomProfile()) {
|
||||
|
@ -459,7 +459,7 @@ public class OsmandSettings {
|
|||
|
||||
private boolean prefCanBeCopiedOrReset(OsmandPreference pref) {
|
||||
return pref instanceof CommonPreference && !((CommonPreference) pref).global
|
||||
&& !USER_PROFILE_NAME.getId().equals(pref.getId()) && !APP_MODE_ORDER.getId().equals(pref.getId());
|
||||
&& !APP_MODE_ORDER.getId().equals(pref.getId());
|
||||
}
|
||||
|
||||
public ApplicationMode LAST_ROUTING_APPLICATION_MODE = null;
|
||||
|
|
|
@ -172,6 +172,8 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
|
|||
private void updateCopiedOrResetPrefs() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
app.getPoiFilters().loadSelectedPoiFilters();
|
||||
mapActivity.getMapLayers().getMapWidgetRegistry().updateVisibleWidgets();
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
updateToolbar();
|
||||
updateAllSettings();
|
||||
|
|
|
@ -14,11 +14,11 @@ import android.widget.LinearLayout;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment;
|
||||
|
@ -74,17 +74,7 @@ public class MapWidgetRegistry {
|
|||
public MapWidgetRegistry(OsmandApplication app) {
|
||||
this.app = app;
|
||||
this.settings = app.getSettings();
|
||||
|
||||
for (ApplicationMode ms : ApplicationMode.values(app)) {
|
||||
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
|
||||
if (mpf.equals(SHOW_PREFIX)) {
|
||||
visibleElementsFromSettings.put(ms, null);
|
||||
} else {
|
||||
LinkedHashSet<String> set = new LinkedHashSet<>();
|
||||
visibleElementsFromSettings.put(ms, set);
|
||||
Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
|
||||
}
|
||||
}
|
||||
loadVisibleElementsFromSettings();
|
||||
}
|
||||
|
||||
public void populateStackControl(LinearLayout stack,
|
||||
|
@ -237,6 +227,9 @@ public class MapWidgetRegistry {
|
|||
ii.visibleModes.add(ms);
|
||||
} else if (collapse) {
|
||||
ii.visibleCollapsible.add(ms);
|
||||
} else {
|
||||
ii.visibleModes.remove(ms);
|
||||
ii.visibleCollapsible.remove(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,6 +292,30 @@ public class MapWidgetRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateVisibleWidgets() {
|
||||
loadVisibleElementsFromSettings();
|
||||
for (MapWidgetRegInfo ri : leftWidgetSet) {
|
||||
processVisibleModes(ri.key, ri);
|
||||
}
|
||||
for (MapWidgetRegInfo ri : rightWidgetSet) {
|
||||
processVisibleModes(ri.key, ri);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadVisibleElementsFromSettings() {
|
||||
visibleElementsFromSettings.clear();
|
||||
for (ApplicationMode ms : ApplicationMode.values(app)) {
|
||||
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
|
||||
if (mpf.equals(SHOW_PREFIX)) {
|
||||
visibleElementsFromSettings.put(ms, null);
|
||||
} else {
|
||||
LinkedHashSet<String> set = new LinkedHashSet<>();
|
||||
visibleElementsFromSettings.put(ms, set);
|
||||
Collections.addAll(set, mpf.split(SETTINGS_SEPARATOR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveVisibleElementsToSettings(ApplicationMode mode) {
|
||||
StringBuilder bs = new StringBuilder();
|
||||
for (String ks : this.visibleElementsFromSettings.get(mode)) {
|
||||
|
|
Loading…
Reference in a new issue