[android] move share button in place page

Also adds a close button and reworks the direction arrow design

Signed-off-by: Arnaud Vergnet <arnaud.vergnet@mailo.com>
This commit is contained in:
Arnaud Vergnet 2023-04-16 11:31:48 +02:00 committed by Alexander Borsuk
parent c19f9bc315
commit b3d0b03178
15 changed files with 183 additions and 152 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>

View file

@ -1,9 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77l-7.13,-4.15c0.05,-0.23 0.09,-0.46 0.09,-0.7 0,-0.24 -0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3 0,-1.66 -1.34,-3 -3,-3 -1.66,0 -3,1.34 -3,3 0,0.24 0.04,0.47 0.09,0.7l-7.05,4.11c-0.54,-0.5 -1.25,-0.81 -2.04,-0.81 -1.66,0 -3,1.34 -3,3 0,1.66 1.34,3 3,3 0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92 0,-1.61 -1.31,-2.92 -2.92,-2.92Z"
android:fillColor="#FFF"/>
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92s2.92,-1.31 2.92,-2.92c0,-1.61 -1.31,-2.92 -2.92,-2.92zM18,4c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM6,13c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM18,20.02c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z"/>
</vector>

View file

@ -1,145 +1,166 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="?ppBackground"
android:orientation="vertical"
android:paddingBottom="@dimen/margin_quarter">
<include
android:id="@+id/pull_icon_container"
layout="@layout/bottom_sheet_handle" />
<include
android:id="@+id/downloader_status_frame"
android:layout_below="@id/pull_icon_container"
layout="@layout/downloader_status"
android:layout_width="@dimen/downloader_status_size"
android:layout_height="@dimen/downloader_status_size"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginTop="@dimen/margin_base_plus"
android:visibility="gone"
tools:visibility="visible"/>
<LinearLayout
android:id="@+id/title_container"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignWithParentIfMissing="true"
android:layout_below="@id/pull_icon_container"
android:layout_marginTop="@dimen/margin_base"
android:layout_marginEnd="@dimen/margin_base"
android:layout_marginStart="@dimen/margin_base"
android:layout_toEndOf="@id/downloader_status_frame"
android:layout_toStartOf="@id/direction_frame">
<TextView
android:id="@+id/tv__title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@string/robotoMedium"
android:maxLines="@integer/pp_title_lines"
android:textAppearance="@style/MwmTextAppearance.Title"
tools:background="#C0800000"
tools:ignore="UnusedAttribute"
tools:text="Title"/>
<TextView
android:id="@+id/tv__secondary_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:ellipsize="end"
android:fontFamily="@string/robotoMedium"
android:maxLines="@integer/pp_title_lines"
android:textAppearance="@style/MwmTextAppearance.Body1"
tools:background="#C0800000"
tools:ignore="UnusedAttribute"
tools:text="Secondary Title"/>
<TextView
android:id="@+id/tv__subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:maxLines="2"
android:textAppearance="@style/MwmTextAppearance.Body3"
android:ellipsize="end"
tools:background="#300000F0"
tools:text="Subtitle, very very very very very very very long"/>
<TextView
android:id="@+id/tv__downloader_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:textAppearance="@style/MwmTextAppearance.Body1.Secondary"
android:baselineAligned="false"
android:orientation="horizontal">
<include
android:id="@+id/downloader_status_frame"
layout="@layout/downloader_status"
android:layout_width="@dimen/downloader_status_size"
android:layout_height="@dimen/downloader_status_size"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginTop="@dimen/margin_half"
android:visibility="gone"
tools:background="#8000F000"
tools:text="2.4 GB • Maps: 1"
tools:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:id="@+id/direction_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_base"
android:paddingEnd="@dimen/margin_quarter"
android:paddingStart="@dimen/margin_quarter"
android:layout_alignParentEnd="true"
android:layout_alignWithParentIfMissing="true"
android:layout_alignBottom="@id/title_container"
android:background="?selectableItemBackground"
android:layout_below="@id/pull_icon_container"
android:gravity="center"
android:orientation="vertical"
tools:background="#111111F0">
<app.organicmaps.widget.ArrowView
android:id="@+id/av__direction"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/title_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginEnd="@dimen/margin_base"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tv__title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@string/robotoMedium"
android:maxLines="@integer/pp_title_lines"
android:textAppearance="@style/MwmTextAppearance.Title"
tools:background="#C0800000"
tools:ignore="UnusedAttribute"
tools:text="Title" />
<TextView
android:id="@+id/tv__secondary_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:ellipsize="end"
android:fontFamily="@string/robotoMedium"
android:maxLines="@integer/pp_title_lines"
android:textAppearance="@style/MwmTextAppearance.Body1"
tools:background="#C0800000"
tools:ignore="UnusedAttribute"
tools:text="Secondary Title" />
<TextView
android:id="@+id/tv__subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:ellipsize="end"
android:maxLines="2"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:background="#300000F0"
tools:text="Subtitle, very very very very very very very long" />
<TextView
android:id="@+id/tv__address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:background="#60000000"
tools:text="Lenina str, 10" />
<TextView
android:id="@+id/tv__downloader_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_quarter"
android:textAppearance="@style/MwmTextAppearance.Body1.Secondary"
android:visibility="gone"
tools:background="#8000F000"
tools:text="2.4 GB • Maps: 1"
tools:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:tint="?colorAccent"
android:scaleType="center"
android:src="@drawable/ic_direction_pagepreview"/>
<TextView
android:id="@+id/tv__straight_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
android:textSize="@dimen/text_size_body_3"
tools:text="2000 km"/>
android:layout_marginEnd="@dimen/margin_half"
android:gravity="end"
android:orientation="vertical">
<LinearLayout
android:id="@+id/buttons_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/share_button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="@dimen/place_page_top_button"
android:layout_height="@dimen/place_page_top_button"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/share"
android:insetLeft="0dp"
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:padding="0dp"
app:icon="@drawable/ic_share"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:iconSize="20dp"
app:iconTint="?iconTint"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Button.Round" />
<com.google.android.material.button.MaterialButton
android:id="@+id/close_button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="@dimen/place_page_top_button"
android:layout_height="@dimen/place_page_top_button"
android:layout_marginStart="@dimen/margin_quarter"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/close"
android:insetLeft="0dp"
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:padding="0dp"
app:icon="@drawable/ic_close"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:iconSize="24dp"
app:iconTint="?iconTint"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Button.Round" />
</LinearLayout>
<LinearLayout
android:id="@+id/direction_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_half_plus"
android:layout_marginBottom="@dimen/margin_quarter"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="@dimen/margin_quarter"
android:paddingEnd="@dimen/margin_half">
<app.organicmaps.widget.ArrowView
android:id="@+id/av__direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="center"
android:src="@drawable/ic_direction_pagepreview"
app:tint="?colorAccent" />
<TextView
android:id="@+id/tv__straight_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
android:textSize="@dimen/text_size_body_3"
tools:text="2000 km" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tv__address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_below="@id/direction_frame"
android:layout_marginTop="@dimen/margin_quarter"
android:layout_marginEnd="@dimen/margin_base"
android:layout_marginStart="@dimen/margin_base"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:background="#60000000"
tools:text="Lenina str, 10"/>
<FrameLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_below="@id/tv__address"
android:layout_marginStart="@dimen/margin_quarter"
android:layout_marginTop="@dimen/margin_half_plus"
android:layout_marginEnd="@dimen/margin_quarter"
android:visibility="gone"
tools:visibility="visible" />
</RelativeLayout>
</LinearLayout>

View file

@ -44,6 +44,7 @@
<dimen name="place_page_width">320dp</dimen>
<dimen name="place_page_buttons_height">56dp</dimen>
<dimen name="place_page_top_button">36dp</dimen>
<dimen name="downloader_status_size">40dp</dimen>
<dimen name="search_progress_size">32dp</dimen>

View file

@ -112,6 +112,12 @@
<item name="android:elevation">@dimen/appbar_elevation</item>
</style>
<style name="ShapeAppearanceOverlay.Button.Round" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
<style name="MwmWidget.PlacePage.EditText" parent="Widget.AppCompat.EditText">
<item name="android:imeOptions">actionDone</item>
<item name="android:textAppearance">@style/MwmTextAppearance.PlacePage</item>

View file

@ -44,6 +44,7 @@
<attr name="transitPedestrianBackground" format="color" />
<attr name="colorBtnHighlight" format="color" />
<attr name="transitStepDivider" format="reference" />
<attr name="colorAccentTransparent" format="reference" />
</declare-styleable>
<declare-styleable name="ThemeAttrs.Downloader">
<attr name="status_done" format="reference" />

View file

@ -29,6 +29,7 @@
<item name="colorPrimary">@color/bg_primary</item>
<item name="colorControlNormal">?secondary</item>
<item name="colorAccent">@color/base_accent</item>
<item name="colorAccentTransparent">@color/base_accent_transparent</item>
<item name="colorBtnHighlight">@color/white_38</item>
<item name="panel">@color/bg_panel</item>
<item name="colorLogo">@color/bg_primary</item>
@ -164,6 +165,7 @@
<item name="colorPrimary">@color/bg_primary_night</item>
<item name="colorControlNormal">?secondary</item>
<item name="colorAccent">@color/base_accent_night</item>
<item name="colorAccentTransparent">@color/base_accent_transparent</item>
<item name="colorBtnHighlight">@color/white_24</item>
<item name="panel">@color/bg_panel_night</item>
<item name="colorLogo">@color/white_primary</item>

View file

@ -57,10 +57,6 @@ public class PlacePageButtonFactory
titleId = R.string.avoid_ferry_crossing_placepage;
iconId = R.drawable.ic_avoid_ferry;
break;
case SHARE:
titleId = R.string.share;
iconId = R.drawable.ic_share;
break;
case MORE:
titleId = R.string.placepage_more_button;
iconId = R.drawable.ic_more;

View file

@ -142,7 +142,6 @@ public final class PlacePageButtons extends Fragment implements Observer<List<Pl
ROUTE_AVOID_TOLL,
ROUTE_AVOID_FERRY,
ROUTE_AVOID_UNPAVED,
SHARE,
MORE
}

View file

@ -352,6 +352,12 @@ public class PlacePageController extends Fragment implements
mPlacePageBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
@Override
public void onPlacePageRequestClose()
{
mPlacePageBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
}
@Override
public void onPlacePageButtonClick(PlacePageButtons.ButtonType item)
{
@ -362,10 +368,6 @@ public class PlacePageController extends Fragment implements
onBookmarkBtnClicked();
break;
case SHARE:
onShareBtnClicked();
break;
case BACK:
onBackBtnClicked();
break;
@ -413,12 +415,6 @@ public class PlacePageController extends Fragment implements
BookmarkManager.INSTANCE.addNewBookmark(mMapObject.getLat(), mMapObject.getLon());
}
private void onShareBtnClicked()
{
if (mMapObject != null)
SharingUtils.shareMapObject(requireContext(), mMapObject);
}
private void onBackBtnClicked()
{
if (mMapObject == null)
@ -581,7 +577,6 @@ public class PlacePageController extends Fragment implements
? PlacePageButtons.ButtonType.BOOKMARK_DELETE
: PlacePageButtons.ButtonType.BOOKMARK_SAVE);
}
buttons.add(PlacePageButtons.ButtonType.SHARE);
}
mViewModel.setCurrentButtons(buttons);
}

View file

@ -37,6 +37,7 @@ import app.organicmaps.editor.Editor;
import app.organicmaps.location.LocationHelper;
import app.organicmaps.location.LocationListener;
import app.organicmaps.routing.RoutingController;
import app.organicmaps.util.SharingUtils;
import app.organicmaps.util.StringUtils;
import app.organicmaps.util.UiUtils;
import app.organicmaps.util.concurrency.UiThread;
@ -46,6 +47,7 @@ import app.organicmaps.widget.placepage.sections.PlacePageLinksFragment;
import app.organicmaps.widget.placepage.sections.PlacePageOpeningHoursFragment;
import app.organicmaps.widget.placepage.sections.PlacePagePhoneFragment;
import app.organicmaps.widget.placepage.sections.PlacePageWikipediaFragment;
import com.google.android.material.button.MaterialButton;
import java.util.ArrayList;
import java.util.Arrays;
@ -210,6 +212,12 @@ public class PlacePageView extends Fragment implements View.OnClickListener,
mTvAddress.setOnLongClickListener(this);
mTvAddress.setOnClickListener(this);
MaterialButton shareButton = mPreview.findViewById(R.id.share_button);
shareButton.setOnClickListener((v) -> SharingUtils.shareMapObject(requireContext(), mMapObject));
final MaterialButton closeButton = mPreview.findViewById(R.id.close_button);
closeButton.setOnClickListener((v) -> mPlacePageViewListener.onPlacePageRequestClose());
RelativeLayout address = mFrame.findViewById(R.id.ll__place_name);
LinearLayout latlon = mFrame.findViewById(R.id.ll__place_latlon);
@ -671,5 +679,6 @@ public class PlacePageView extends Fragment implements View.OnClickListener,
void onPlacePageContentChanged(int previewHeight, int frameHeight);
void onPlacePageRequestToggleState();
void onPlacePageRequestClose();
}
}