copy ids prefs rom another profile fix

This commit is contained in:
veliymolfar 2020-05-06 14:54:51 +03:00
parent 9c7597f0cb
commit 8a60632ee8

View file

@ -144,12 +144,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
mainActionItems = savedInstanceState.getStringArrayList(MAIN_ACTIONS_ITEMS_KEY); mainActionItems = savedInstanceState.getStringArrayList(MAIN_ACTIONS_ITEMS_KEY);
} }
} else { } else {
hiddenMenuItems = new ArrayList<>(getSettingForScreen(app, screenType).getModeValue(appMode).getHiddenIds()); initSavedIds(appMode);
menuItemsOrder = new HashMap<>();
List<String> orderIds = getSettingForScreen(app, screenType).getModeValue(appMode).getOrderIds();
for (int i = 0; i < orderIds.size(); i++) {
menuItemsOrder.put(orderIds.get(i), i);
}
} }
nightMode = !app.getSettings().isLightContentForMode(appMode); nightMode = !app.getSettings().isLightContentForMode(appMode);
mInflater = UiUtilities.getInflater(app, nightMode); mInflater = UiUtilities.getInflater(app, nightMode);
@ -157,7 +152,16 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
activity = getActivity(); activity = getActivity();
} }
private void initDefaultMainActions() { private void initSavedIds(ApplicationMode appMode) {
hiddenMenuItems = new ArrayList<>(getSettingForScreen(app, screenType).getModeValue(appMode).getHiddenIds());
menuItemsOrder = new HashMap<>();
List<String> orderIds = getSettingForScreen(app, screenType).getModeValue(appMode).getOrderIds();
for (int i = 0; i < orderIds.size(); i++) {
menuItemsOrder.put(orderIds.get(i), i);
}
}
private void initMainActionsIds(ApplicationMode appMode) {
List<ContextMenuItem> defItems = getCustomizableDefaultItems(contextMenuAdapter.getDefaultItems()); List<ContextMenuItem> defItems = getCustomizableDefaultItems(contextMenuAdapter.getDefaultItems());
OsmandSettings.ContextMenuItemsSettings pref = getSettingForScreen(app, screenType).getModeValue(appMode); OsmandSettings.ContextMenuItemsSettings pref = getSettingForScreen(app, screenType).getModeValue(appMode);
if (pref instanceof OsmandSettings.MainContextMenuItemsSettings) { if (pref instanceof OsmandSettings.MainContextMenuItemsSettings) {
@ -295,7 +299,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
} }
} }
if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) { if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
initDefaultMainActions(); initMainActionsIds(appMode);
} }
recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width)); recyclerView.setPadding(0, 0, 0, (int) app.getResources().getDimension(R.dimen.dialog_button_ex_min_width));
rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems(), nightMode); rearrangeAdapter = new RearrangeMenuItemsAdapter(app, getAdapterItems(), nightMode);
@ -486,7 +490,7 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
mainActionItems.clear(); mainActionItems.clear();
} }
instantiateContextMenuAdapter(); instantiateContextMenuAdapter();
initDefaultMainActions(); initMainActionsIds(appMode);
rearrangeAdapter.updateItems(getAdapterItems()); rearrangeAdapter.updateItems(getAdapterItems());
} }
}); });
@ -507,10 +511,12 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
@Override @Override
public void copyAppModePrefs(ApplicationMode appMode) { public void copyAppModePrefs(ApplicationMode appMode) {
if (appMode != null) { if (appMode != null) {
List<OsmandSettings.OsmandPreference> prefs = new ArrayList<>(); isChanged = true;
prefs.add(getSettingForScreen(app, screenType)); initSavedIds(appMode);
app.getSettings().copyProfilePreferences(appMode, this.appMode, prefs); if (screenType == ScreenType.CONTEXT_MENU_ACTIONS) {
dismissFragment(); initMainActionsIds(appMode);
}
rearrangeAdapter.updateItems(getAdapterItems());
} }
} }