forked from organicmaps/organicmaps
[android] make all map buttons independent
Signed-off-by: Arnaud Vergnet <arnaud.vergnet@mailo.com>
This commit is contained in:
parent
59532504ff
commit
8b6c184ff1
12 changed files with 140 additions and 93 deletions
|
@ -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">
|
||||
<View
|
||||
android:id="@+id/touch_interceptor"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -24,9 +25,27 @@
|
|||
android:padding="@dimen/nav_frame_padding"
|
||||
android:theme="?navButtonsTheme">
|
||||
<include
|
||||
layout="@layout/layout_nav_search"
|
||||
layout="@layout/map_navigation_buttons_bookmarks"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btn_search"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_search_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btn_search"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_search" />
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="56dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<include
|
||||
|
@ -37,27 +56,27 @@
|
|||
android:layout_marginBottom="@dimen/margin_half"
|
||||
app:layout_constraintBottom_toTopOf="@+id/layers_button"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/layers_button"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_layers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:contentDescription="@string/layers_title"
|
||||
android:src="@drawable/ic_layers"
|
||||
app:layout_constraintBottom_toTopOf="@+id/my_position"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/my_position"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:contentDescription="@string/core_my_position"
|
||||
android:tint="@null"
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_myposition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/menu_button" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/menu_button"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:src="@drawable/ic_menu_open"
|
||||
app:layout_constraintBottom_toTopOf="@+id/menu_button"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -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">
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/btn_bookmarks"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:contentDescription="@string/bookmarks"
|
||||
android:src="@drawable/ic_bookmarks" />
|
||||
android:theme="?navButtonsTheme">
|
||||
<LinearLayout
|
||||
android:id="@+id/search_frame"
|
||||
android:layout_width="286dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_below="@id/btn_bookmarks"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="-4dp"
|
||||
android:background="?searchLayoutBackground"
|
||||
android:elevation="6dp"
|
||||
android:elevation="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/margin_quarter"
|
||||
android:visibility="invisible"
|
||||
|
@ -67,11 +57,4 @@
|
|||
android:contentDescription="@string/atm"
|
||||
android:src="@drawable/ic_routing_atm_on" />
|
||||
</LinearLayout>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/btn_search"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:layout_below="@id/btn_bookmarks"
|
||||
android:layout_alignParentStart="true"
|
||||
android:contentDescription="@string/search"
|
||||
android:src="@drawable/ic_search" />
|
||||
</RelativeLayout>
|
|
@ -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">
|
||||
<View
|
||||
android:id="@+id/touch_interceptor"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -24,9 +25,27 @@
|
|||
android:padding="@dimen/nav_frame_padding"
|
||||
android:theme="?navButtonsTheme">
|
||||
<include
|
||||
layout="@layout/layout_nav_search"
|
||||
layout="@layout/map_navigation_buttons_bookmarks"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btn_search"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_search_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/btn_search"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/btn_search" />
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="56dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<include
|
||||
|
@ -37,27 +56,27 @@
|
|||
android:layout_marginBottom="@dimen/margin_half"
|
||||
app:layout_constraintBottom_toTopOf="@+id/layers_button"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/layers_button"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_layers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:contentDescription="@string/layers_title"
|
||||
android:src="@drawable/ic_layers"
|
||||
app:layout_constraintBottom_toTopOf="@+id/my_position"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/my_position"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_myposition"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:contentDescription="@string/core_my_position"
|
||||
android:tint="@null"
|
||||
app:layout_constraintBottom_toTopOf="@+id/menu_button"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/menu_button"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:src="@drawable/ic_menu_open"
|
||||
<include
|
||||
layout="@layout/map_navigation_buttons_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
7
android/res/layout/map_navigation_buttons_bookmarks.xml
Normal file
7
android/res/layout/map_navigation_buttons_bookmarks.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/btn_bookmarks"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:contentDescription="@string/bookmarks"
|
||||
android:src="@drawable/ic_bookmarks" />
|
7
android/res/layout/map_navigation_buttons_layers.xml
Normal file
7
android/res/layout/map_navigation_buttons_layers.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layers_button"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:contentDescription="@string/layers_title"
|
||||
android:src="@drawable/ic_layers" />
|
6
android/res/layout/map_navigation_buttons_menu.xml
Normal file
6
android/res/layout/map_navigation_buttons_menu.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/menu_button"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:src="@drawable/ic_menu_open" />
|
7
android/res/layout/map_navigation_buttons_myposition.xml
Normal file
7
android/res/layout/map_navigation_buttons_myposition.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/my_position"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:contentDescription="@string/core_my_position"
|
||||
android:tint="@null" />
|
7
android/res/layout/map_navigation_buttons_search.xml
Normal file
7
android/res/layout/map_navigation_buttons_search.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/btn_search"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:contentDescription="@string/search"
|
||||
android:src="@drawable/ic_search" />
|
|
@ -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">
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/btn_bookmarks"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginBottom="@dimen/margin_half"
|
||||
android:contentDescription="@string/bookmarks"
|
||||
android:src="@drawable/ic_bookmarks" />
|
||||
android:theme="?navButtonsTheme">
|
||||
<RelativeLayout
|
||||
android:id="@+id/search_frame"
|
||||
android:layout_width="160dp"
|
||||
|
@ -24,7 +17,7 @@
|
|||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="-56dp"
|
||||
android:background="?searchLayoutBackground"
|
||||
android:elevation="6dp"
|
||||
android:elevation="5dp"
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible">
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
|
@ -69,11 +62,4 @@
|
|||
android:contentDescription="@string/atm"
|
||||
android:src="@drawable/ic_routing_atm_on" />
|
||||
</RelativeLayout>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/btn_search"
|
||||
style="@style/MwmWidget.MapButton"
|
||||
android:layout_below="@id/btn_bookmarks"
|
||||
android:layout_alignParentStart="true"
|
||||
android:contentDescription="@string/search"
|
||||
android:src="@drawable/ic_search" />
|
||||
</RelativeLayout>
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
Loading…
Add table
Reference in a new issue