From 8b6c184ff148e8960a0b04a4f4f7ba85e5c743e4 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Mon, 11 Jul 2022 17:52:04 +0200 Subject: [PATCH] [android] make all map buttons independent Signed-off-by: Arnaud Vergnet --- .../layout-land/map_navigation_buttons.xml | 57 ++++++++++++------- ...> map_navigation_buttons_search_frame.xml} | 25 ++------ android/res/layout/map_navigation_buttons.xml | 53 +++++++++++------ .../map_navigation_buttons_bookmarks.xml | 7 +++ .../layout/map_navigation_buttons_layers.xml | 7 +++ .../layout/map_navigation_buttons_menu.xml | 6 ++ .../map_navigation_buttons_myposition.xml | 7 +++ .../layout/map_navigation_buttons_search.xml | 7 +++ ...> map_navigation_buttons_search_frame.xml} | 20 +------ .../src/com/mapswithme/maps/MwmActivity.java | 4 +- .../maps/maplayer/MapButtonsController.java | 29 +++++----- .../{routing => maplayer}/SearchWheel.java | 11 +++- 12 files changed, 140 insertions(+), 93 deletions(-) rename android/res/layout-land/{layout_nav_search.xml => map_navigation_buttons_search_frame.xml} (73%) create mode 100644 android/res/layout/map_navigation_buttons_bookmarks.xml create mode 100644 android/res/layout/map_navigation_buttons_layers.xml create mode 100644 android/res/layout/map_navigation_buttons_menu.xml create mode 100644 android/res/layout/map_navigation_buttons_myposition.xml create mode 100644 android/res/layout/map_navigation_buttons_search.xml rename android/res/layout/{layout_nav_search.xml => map_navigation_buttons_search_frame.xml} (78%) rename android/src/com/mapswithme/maps/{routing => maplayer}/SearchWheel.java (97%) diff --git a/android/res/layout-land/map_navigation_buttons.xml b/android/res/layout-land/map_navigation_buttons.xml index 981fc2b1d6..93366d046e 100644 --- a/android/res/layout-land/map_navigation_buttons.xml +++ b/android/res/layout-land/map_navigation_buttons.xml @@ -5,7 +5,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/navigation_buttons" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + tools:background="@color/bg_primary"> + + - - - + diff --git a/android/res/layout-land/layout_nav_search.xml b/android/res/layout-land/map_navigation_buttons_search_frame.xml similarity index 73% rename from android/res/layout-land/layout_nav_search.xml rename to android/res/layout-land/map_navigation_buttons_search_frame.xml index a2aed3137d..e3b287bf54 100644 --- a/android/res/layout-land/layout_nav_search.xml +++ b/android/res/layout-land/map_navigation_buttons_search_frame.xml @@ -7,26 +7,16 @@ android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" + android:elevation="6dp" android:layoutDirection="ltr" - android:padding="@dimen/nav_frame_padding" - android:theme="?navButtonsTheme" - tools:background="@color/bg_primary"> - + android:theme="?navButtonsTheme"> - diff --git a/android/res/layout/map_navigation_buttons.xml b/android/res/layout/map_navigation_buttons.xml index fdf4ccf8bc..566dbfb792 100644 --- a/android/res/layout/map_navigation_buttons.xml +++ b/android/res/layout/map_navigation_buttons.xml @@ -5,7 +5,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/navigation_buttons" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + tools:background="@color/bg_primary"> + + - - - diff --git a/android/res/layout/map_navigation_buttons_bookmarks.xml b/android/res/layout/map_navigation_buttons_bookmarks.xml new file mode 100644 index 0000000000..2bda88abd1 --- /dev/null +++ b/android/res/layout/map_navigation_buttons_bookmarks.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/android/res/layout/map_navigation_buttons_layers.xml b/android/res/layout/map_navigation_buttons_layers.xml new file mode 100644 index 0000000000..c9128c90bf --- /dev/null +++ b/android/res/layout/map_navigation_buttons_layers.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/android/res/layout/map_navigation_buttons_menu.xml b/android/res/layout/map_navigation_buttons_menu.xml new file mode 100644 index 0000000000..ad74c08273 --- /dev/null +++ b/android/res/layout/map_navigation_buttons_menu.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/android/res/layout/map_navigation_buttons_myposition.xml b/android/res/layout/map_navigation_buttons_myposition.xml new file mode 100644 index 0000000000..7f8d68ca34 --- /dev/null +++ b/android/res/layout/map_navigation_buttons_myposition.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/android/res/layout/map_navigation_buttons_search.xml b/android/res/layout/map_navigation_buttons_search.xml new file mode 100644 index 0000000000..b63407dbc3 --- /dev/null +++ b/android/res/layout/map_navigation_buttons_search.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/android/res/layout/layout_nav_search.xml b/android/res/layout/map_navigation_buttons_search_frame.xml similarity index 78% rename from android/res/layout/layout_nav_search.xml rename to android/res/layout/map_navigation_buttons_search_frame.xml index 043bc85f8d..a4718f7475 100644 --- a/android/res/layout/layout_nav_search.xml +++ b/android/res/layout/map_navigation_buttons_search_frame.xml @@ -7,16 +7,9 @@ android:layout_height="wrap_content" android:clipChildren="false" android:clipToPadding="false" + android:elevation="6dp" android:layoutDirection="ltr" - android:theme="?navButtonsTheme" - tools:background="@color/bg_primary"> - + android:theme="?navButtonsTheme"> - diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 8a5cf5841a..18e2a8f98b 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -636,10 +636,10 @@ public class MwmActivity extends BaseMwmFragmentActivity case toggleMapLayer: toggleMapLayerBottomSheet(); break; - case navBookmarks: + case bookmarks: showBookmarks(); break; - case navSearch: + case search: showSearch(); break; case menu: diff --git a/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java b/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java index 514d7c09cd..39ff286e21 100644 --- a/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java +++ b/android/src/com/mapswithme/maps/maplayer/MapButtonsController.java @@ -4,7 +4,6 @@ import android.app.Activity; import android.content.res.TypedArray; import android.os.Bundle; import android.view.View; -import android.widget.FrameLayout; import android.widget.RelativeLayout; import androidx.annotation.NonNull; @@ -18,12 +17,10 @@ import com.mapswithme.maps.R; import com.mapswithme.maps.downloader.MapManager; import com.mapswithme.maps.downloader.UpdateInfo; import com.mapswithme.maps.routing.RoutingController; -import com.mapswithme.maps.routing.SearchWheel; import com.mapswithme.maps.widget.menu.MyPositionButton; import com.mapswithme.maps.widget.placepage.PlacePageController; import com.mapswithme.util.Config; import com.mapswithme.util.UiUtils; -import com.mapswithme.util.log.Logger; public class MapButtonsController { @@ -36,9 +33,11 @@ public class MapButtonsController @NonNull private final View myPosition; @NonNull + private final View mBookmarksButton; + @NonNull private final View mMenuButton; @NonNull - private final View mSearchButtonFrame; + private final View mSearchButton; @Nullable private final MyPositionButton mNavMyPosition; @NonNull @@ -64,6 +63,8 @@ public class MapButtonsController .setOnClickListener((v) -> mapButtonClickListener.onClick(MapButtons.zoomIn)); frame.findViewById(R.id.nav_zoom_out) .setOnClickListener((v) -> mapButtonClickListener.onClick(MapButtons.zoomOut)); + mBookmarksButton = frame.findViewById(R.id.btn_bookmarks); + mBookmarksButton.setOnClickListener((v) -> mapButtonClickListener.onClick(MapButtons.bookmarks)); mMenuButton = frame.findViewById(R.id.menu_button); mMenuButton.setOnClickListener((v) -> mapButtonClickListener.onClick(MapButtons.menu)); myPosition = frame.findViewById(R.id.my_position); @@ -73,10 +74,8 @@ public class MapButtonsController mToggleMapLayerController = new MapLayersController(mLayersButton, () -> mapButtonClickListener.onClick(MapButtons.toggleMapLayer), activity); - mSearchButtonFrame = frame.findViewById(R.id.search_button_frame); - mSearchWheel = new SearchWheel(frame, (v) -> mapButtonClickListener.onClick(MapButtons.navSearch), onSearchCanceledListener); - mSearchButtonFrame.findViewById(R.id.btn_bookmarks) - .setOnClickListener((v) -> mapButtonClickListener.onClick(MapButtons.navBookmarks)); + mSearchWheel = new SearchWheel(frame, (v) -> mapButtonClickListener.onClick(MapButtons.search), onSearchCanceledListener); + mSearchButton = frame.findViewById(R.id.btn_search); // Used to get the maximum height the buttons will evolve in frame.addOnLayoutChangeListener(new MapButtonsController.ContentViewLayoutChangeListener(frame)); @@ -103,8 +102,10 @@ public class MapButtonsController if (mNavMyPosition != null) mNavMyPosition.showButton(show); break; - case nav: - UiUtils.showIf(show, mSearchButtonFrame); + case search: + mSearchWheel.show(show); + case bookmarks: + UiUtils.showIf(show, mBookmarksButton); case menu: UiUtils.showIf(show, mMenuButton); } @@ -150,10 +151,11 @@ public class MapButtonsController private void updateButtonsVisibility(final float translation) { showButton(getViewTopOffset(translation, mZoomFrame) > 0, MapButtons.zoom); - showButton(getViewTopOffset(translation, mSearchButtonFrame) > 0, MapButtons.nav); + showButton(getViewTopOffset(translation, mSearchButton) > 0, MapButtons.search); showButton(getViewTopOffset(translation, mLayersButton) > 0, MapButtons.toggleMapLayer); showButton(getViewTopOffset(translation, myPosition) > 0, MapButtons.myPosition); showButton(getViewTopOffset(translation, mMenuButton) > 0, MapButtons.menu); + showButton(getViewTopOffset(translation, mBookmarksButton) > 0, MapButtons.bookmarks); } public void setTopLimit(float limit) @@ -223,9 +225,8 @@ public class MapButtonsController zoomIn, zoomOut, zoom, - nav, - navSearch, - navBookmarks, + search, + bookmarks, menu } diff --git a/android/src/com/mapswithme/maps/routing/SearchWheel.java b/android/src/com/mapswithme/maps/maplayer/SearchWheel.java similarity index 97% rename from android/src/com/mapswithme/maps/routing/SearchWheel.java rename to android/src/com/mapswithme/maps/maplayer/SearchWheel.java index 30a9deaf89..bcb4171338 100644 --- a/android/src/com/mapswithme/maps/routing/SearchWheel.java +++ b/android/src/com/mapswithme/maps/maplayer/SearchWheel.java @@ -1,11 +1,10 @@ -package com.mapswithme.maps.routing; +package com.mapswithme.maps.maplayer; import android.animation.Animator; import android.animation.AnimatorInflater; import android.content.Context; import android.os.Bundle; import android.text.TextUtils; -import android.view.ContextThemeWrapper; import android.view.View; import android.widget.ImageView; @@ -15,8 +14,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; -import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.R; +import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.search.SearchEngine; import com.mapswithme.util.Graphics; import com.mapswithme.util.UiUtils; @@ -126,6 +125,12 @@ public class SearchWheel implements View.OnClickListener refreshSearchVisibility(); } + public void show(boolean show) + { + UiUtils.showIf(show, mSearchButton); + UiUtils.showIf(show && mIsExpanded, mSearchLayout); + } + public void saveState(@NonNull Bundle outState) { outState.putSerializable(EXTRA_CURRENT_OPTION, mCurrentOption);