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) {
|
public void copyProfilePreferences(ApplicationMode modeFrom, ApplicationMode modeTo, List<OsmandPreference> profilePreferences) {
|
||||||
for (OsmandPreference pref : profilePreferences) {
|
for (OsmandPreference pref : profilePreferences) {
|
||||||
if (prefCanBeCopiedOrReset(pref)) {
|
if (prefCanBeCopiedOrReset(pref) && !USER_PROFILE_NAME.getId().equals(pref.getId())) {
|
||||||
CommonPreference profilePref = (CommonPreference) pref;
|
CommonPreference profilePref = (CommonPreference) pref;
|
||||||
if (PARENT_APP_MODE.getId().equals(pref.getId())) {
|
if (PARENT_APP_MODE.getId().equals(pref.getId())) {
|
||||||
if (modeTo.isCustomProfile()) {
|
if (modeTo.isCustomProfile()) {
|
||||||
|
@ -459,7 +459,7 @@ public class OsmandSettings {
|
||||||
|
|
||||||
private boolean prefCanBeCopiedOrReset(OsmandPreference pref) {
|
private boolean prefCanBeCopiedOrReset(OsmandPreference pref) {
|
||||||
return pref instanceof CommonPreference && !((CommonPreference) pref).global
|
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;
|
public ApplicationMode LAST_ROUTING_APPLICATION_MODE = null;
|
||||||
|
|
|
@ -172,6 +172,8 @@ public class ConfigureProfileFragment extends BaseSettingsFragment implements Co
|
||||||
private void updateCopiedOrResetPrefs() {
|
private void updateCopiedOrResetPrefs() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
app.getPoiFilters().loadSelectedPoiFilters();
|
||||||
|
mapActivity.getMapLayers().getMapWidgetRegistry().updateVisibleWidgets();
|
||||||
mapActivity.updateApplicationModeSettings();
|
mapActivity.updateApplicationModeSettings();
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
updateAllSettings();
|
updateAllSettings();
|
||||||
|
|
|
@ -14,11 +14,11 @@ import android.widget.LinearLayout;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuItem;
|
import net.osmand.plus.ContextMenuItem;
|
||||||
import net.osmand.plus.UiUtilities;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||||
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment;
|
import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment;
|
||||||
|
@ -74,17 +74,7 @@ public class MapWidgetRegistry {
|
||||||
public MapWidgetRegistry(OsmandApplication app) {
|
public MapWidgetRegistry(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.settings = app.getSettings();
|
this.settings = app.getSettings();
|
||||||
|
loadVisibleElementsFromSettings();
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateStackControl(LinearLayout stack,
|
public void populateStackControl(LinearLayout stack,
|
||||||
|
@ -237,6 +227,9 @@ public class MapWidgetRegistry {
|
||||||
ii.visibleModes.add(ms);
|
ii.visibleModes.add(ms);
|
||||||
} else if (collapse) {
|
} else if (collapse) {
|
||||||
ii.visibleCollapsible.add(ms);
|
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) {
|
private void saveVisibleElementsToSettings(ApplicationMode mode) {
|
||||||
StringBuilder bs = new StringBuilder();
|
StringBuilder bs = new StringBuilder();
|
||||||
for (String ks : this.visibleElementsFromSettings.get(mode)) {
|
for (String ks : this.visibleElementsFromSettings.get(mode)) {
|
||||||
|
|
Loading…
Reference in a new issue