diff --git a/android/res/layout/fragment_editor_host.xml b/android/res/layout/fragment_editor_host.xml index 91ac58ecd5..22362ef060 100644 --- a/android/res/layout/fragment_editor_host.xml +++ b/android/res/layout/fragment_editor_host.xml @@ -14,6 +14,8 @@ android:theme="@style/MwmWidget.ToolbarTheme"> diff --git a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java index 65b8bb0b08..b21ab3e63c 100644 --- a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java +++ b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java @@ -42,6 +42,10 @@ public class EditorHostFragment extends BaseMwmToolbarFragment implements OnBackPressListener, View.OnClickListener, LanguagesFragment.Listener { private boolean mIsNewObject; + @Nullable + private View mToolbarInnerLayout; + @Nullable + private View mSave; enum Mode { @@ -131,7 +135,10 @@ public class EditorHostFragment extends BaseMwmToolbarFragment { super.onViewCreated(view, savedInstanceState); - getToolbarController().getToolbar().findViewById(R.id.save).setOnClickListener(this); + final View toolbar = getToolbarController().getToolbar(); + mToolbarInnerLayout = toolbar.findViewById(R.id.toolbar_inner_layout); + mSave = toolbar.findViewById(R.id.save); + mSave.setOnClickListener(this); UiUtils.setupHomeUpButtonAsNavigationIcon(getToolbarController().getToolbar(), v -> onBackPressed()); @@ -190,7 +197,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment protected void editMapObject(boolean focusToLastName) { mMode = Mode.MAP_OBJECT; - ((SearchToolbarController) getToolbarController()).showSearchControls(false); + showSearchControls(false); getToolbarController().setTitle(getTitle()); UiUtils.show(getToolbarController().getToolbar().findViewById(R.id.save)); Bundle args = new Bundle(); @@ -243,7 +250,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment mMode = newMode; getToolbarController().setTitle(toolbarTitle); - ((SearchToolbarController) getToolbarController()).showSearchControls(showSearch); + showSearchControls(showSearch); final Fragment fragment = Fragment.instantiate(getActivity(), fragmentClass.getName(), args); getChildFragmentManager().beginTransaction() .replace(R.id.fragment_container, fragment, fragmentClass.getName()) @@ -260,6 +267,18 @@ public class EditorHostFragment extends BaseMwmToolbarFragment startActivity(new Intent(host, FeatureCategoryActivity.class)); } + private void showSearchControls(boolean showSearch) + { + ((SearchToolbarController) getToolbarController()).showSearchControls(showSearch); + if (mToolbarInnerLayout != null && mSave != null) + { + // Make room for the toolbar title if the search controls are hidden. + mToolbarInnerLayout.getLayoutParams().width = showSearch + ? ViewGroup.LayoutParams.MATCH_PARENT + : mSave.getLayoutParams().width; + } + } + private boolean setEdits() { return ((EditorFragment) getChildFragmentManager().findFragmentByTag(EditorFragment.class.getName())).setEdits();