WIP: [Android] Increases touch area of map buttons #10291

Draft
hemanggs wants to merge 2 commits from hemanggs/increase-touch-area into master
8 changed files with 111 additions and 46 deletions

View file

@ -90,6 +90,7 @@ public class MapButtonsController extends Fragment
mInnerRightButtonsFrame = mFrame.findViewById(R.id.map_buttons_inner_right);
mBottomButtonsFrame = mFrame.findViewById(R.id.map_buttons_bottom);
final View helpButtonContainer = mFrame.findViewById(R.id.help_button_container);
final FloatingActionButton helpButton = mFrame.findViewById(R.id.help_button);
if (helpButton != null)
{
@ -107,22 +108,30 @@ public class MapButtonsController extends Fragment
.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.zoomIn));
mFrame.findViewById(R.id.nav_zoom_out)
.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.zoomOut));
final View bookmarksButtonContainer = mFrame.findViewById(R.id.bookmarks_button_container);
final View bookmarksButton = mFrame.findViewById(R.id.btn_bookmarks);
bookmarksButton.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.bookmarks));
bookmarksButtonContainer.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.bookmarks));
final View myPosition = mFrame.findViewById(R.id.my_position);
mNavMyPosition = new MyPositionButton(myPosition, (v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.myPosition));
// Some buttons do not exist in navigation mode
final View layersButtonContainer = mFrame.findViewById(R.id.layers_button_container);
mToggleMapLayerButton = mFrame.findViewById(R.id.layers_button);
if (mToggleMapLayerButton != null)
{
mToggleMapLayerButton.setOnClickListener(view -> mMapButtonClickListener.onMapButtonClick(MapButtons.toggleMapLayer));
layersButtonContainer.setOnClickListener(view -> mMapButtonClickListener.onMapButtonClick(MapButtons.toggleMapLayer));
mToggleMapLayerButton.setVisibility(View.VISIBLE);
}
final View menuButtonContainer = mFrame.findViewById(R.id.menu_button_container);
final View menuButton = mFrame.findViewById(R.id.menu_button);
if (menuButton != null)
{
menuButton.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.menu));
menuButtonContainer.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.menu));
// This hack is needed to show the badge on the initial startup. For some reason, updateMenuBadge does not work from onResume() there.
menuButton.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
@ -134,13 +143,19 @@ public class MapButtonsController extends Fragment
});
}
if (helpButton != null)
{
helpButton.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.help));
helpButtonContainer.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.help));
}
mSearchWheel = new SearchWheel(mFrame,
(v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.search),
(v) -> mMapButtonClickListener.onSearchCanceled(),
mMapButtonsViewModel);
final View searchButton = mFrame.findViewById(R.id.btn_search);
final View searchButtonContainer = mFrame.findViewById(R.id.search_button_container);
final View searchButton = mFrame.findViewById(R.id.btn_search); // no on click listner for seearch button ?
searchButton.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.search));
searchButtonContainer.setOnClickListener((v) -> mMapButtonClickListener.onMapButtonClick(MapButtons.search));
// Used to get the maximum height the buttons will evolve in
mFrame.addOnLayoutChangeListener(new MapButtonsController.ContentViewLayoutChangeListener(mFrame));

View file

@ -13,25 +13,27 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/search_button_container" />
<include
layout="@layout/map_buttons_search_square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_bookmarks"
app:layout_constraintStart_toEndOf="@+id/help_button" />
app:layout_constraintEnd_toStartOf="@+id/bookmarks_button_container"
app:layout_constraintStart_toEndOf="@+id/help_button_container" />
<include
layout="@layout/map_buttons_bookmarks_square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/menu_button"
app:layout_constraintStart_toEndOf="@+id/btn_search" />
app:layout_constraintEnd_toStartOf="@+id/menu_button_container"
app:layout_constraintStart_toEndOf="@+id/search_button_container" />
<include
layout="@layout/map_buttons_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/bookmarks_button_container" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,9 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<FrameLayout android:id="@+id/bookmarks_button_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/btn_bookmarks"
style="@style/MwmWidget.MapButton.Square"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
android:contentDescription="@string/bookmarks"
app:srcCompat="@drawable/ic_bookmarks" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="13dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btn_bookmarks"
style="@style/MwmWidget.MapButton.Square"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:contentDescription="@string/bookmarks"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
app:srcCompat="@drawable/ic_bookmarks" />
</FrameLayout>

View file

@ -16,29 +16,31 @@
layout="@layout/map_buttons_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_half"
android:layout_marginStart="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/help_button_container"/>
<include
layout="@layout/map_buttons_search_square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_bookmarks"
app:layout_constraintStart_toEndOf="@+id/help_button" />
app:layout_constraintEnd_toStartOf="@+id/bookmarks_button_container"
app:layout_constraintStart_toEndOf="@+id/help_button_container"/>
<include
layout="@layout/map_buttons_bookmarks_square"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/menu_button"
app:layout_constraintStart_toEndOf="@+id/btn_search" />
app:layout_constraintEnd_toStartOf="@+id/menu_button_container"
app:layout_constraintStart_toEndOf="@+id/search_button_container"/>
<include
layout="@layout/map_buttons_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_half"
android:layout_marginEnd="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/bookmarks_button_container" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>

View file

@ -1,9 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<FrameLayout android:id="@+id/help_button_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/help_button"
style="@style/MwmWidget.MapButton.Square"
android:contentDescription="@string/help"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
app:srcCompat="@drawable/ic_question_mark" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="13dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/help_button"
style="@style/MwmWidget.MapButton.Square"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:contentDescription="@string/help"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
app:srcCompat="@drawable/ic_question_mark" />
</FrameLayout>

View file

@ -1,9 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<app.organicmaps.maplayer.LayersButton
<FrameLayout
android:id="@+id/layers_button_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layers_button"
style="@style/MwmWidget.MapButton"
android:contentDescription="@string/layers_title"
android:tint="?accentColorSelector"
app:srcCompat="@drawable/ic_layers" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="13dp">
<app.organicmaps.maplayer.LayersButton
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layers_button"
style="@style/MwmWidget.MapButton"
android:contentDescription="@string/layers_title"
android:tint="?accentColorSelector"
app:srcCompat="@drawable/ic_layers" />
</FrameLayout>

View file

@ -1,9 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<FrameLayout android:id="@+id/menu_button_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/menu_button"
style="@style/MwmWidget.MapButton.Square"
android:contentDescription="@string/menu"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
app:srcCompat="@drawable/ic_menu_open" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="13dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/menu_button"
style="@style/MwmWidget.MapButton.Square"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:contentDescription="@string/menu"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
app:srcCompat="@drawable/ic_menu_open" />
</FrameLayout>

View file

@ -1,9 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.floatingactionbutton.FloatingActionButton
<FrameLayout android:id="@+id/search_button_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/btn_search"
style="@style/MwmWidget.MapButton.Square"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
android:contentDescription="@string/search"
app:srcCompat="@drawable/ic_search" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="13dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btn_search"
style="@style/MwmWidget.MapButton.Square"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:contentDescription="@string/search"
app:shapeAppearanceOverlay="@style/MwmWidget.MapButton.Square"
app:srcCompat="@drawable/ic_search" />
</FrameLayout>