Add second button to BottomSheetMenu bottom row

This commit is contained in:
Alexander Sytnyk 2018-03-15 11:26:31 +02:00
parent f906b3441a
commit f16f1a3ac8
13 changed files with 78 additions and 40 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -22,28 +23,65 @@
</ScrollView>
<View
android:id="@+id/close_row_divider"
android:id="@+id/bottom_row_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/close_row"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
android:layout_height="@dimen/bottom_sheet_cancel_button_height">
<TextView
android:id="@+id/close_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"
tools:text="@string/shared_string_cancel"/>
<FrameLayout
android:id="@+id/dismiss_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
</FrameLayout>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/dismiss_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Cancel"/>
</FrameLayout>
<View
android:id="@+id/bottom_buttons_divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"
android:visibility="gone"
tools:visibility="visible"/>
<FrameLayout
android:id="@+id/right_bottom_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:visibility="gone"
tools:visibility="visible">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/right_bottom_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Some Action"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -127,7 +127,7 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -68,18 +68,18 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
item.inflate(app, itemsContainer, nightMode);
}
int closeRowDividerColorId = getCloseRowDividerColorId();
if (closeRowDividerColorId != -1) {
mainView.findViewById(R.id.close_row_divider).setBackgroundColor(getResolvedColor(closeRowDividerColorId));
int bottomDividerColorId = getBottomDividerColorId();
if (bottomDividerColorId != -1) {
mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId));
}
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onCloseRowClickAction();
onDismissButtonClickAction();
dismiss();
}
});
((TextView) mainView.findViewById(R.id.close_row_text)).setText(getCloseRowTextId());
((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId());
setupHeightAndBackground(mainView);
@ -140,8 +140,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
final View scrollView = mainView.findViewById(R.id.scroll_view);
int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
int bottomRowHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - bottomRowHeight;
if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView;
scrollView.requestLayout();
@ -166,16 +166,16 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
}
@ColorRes
protected int getCloseRowDividerColorId() {
protected int getBottomDividerColorId() {
return -1;
}
@StringRes
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_cancel;
}
protected void onCloseRowClickAction() {
protected void onDismissButtonClickAction() {
}

View file

@ -75,7 +75,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
.create();
items.add(replaceStartItem);
items.add(new DividerHalfItem(getContext(), getCloseRowDividerColorId()));
items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.subsequent_dest_description))
@ -135,7 +135,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
}
@Override
protected int getCloseRowDividerColorId() {
protected int getBottomDividerColorId() {
return nightMode ? R.color.route_info_bottom_view_bg_dark : -1;
}

View file

@ -1068,7 +1068,7 @@ public class WaypointDialogHelper {
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -141,7 +141,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -92,7 +92,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -116,7 +116,7 @@ public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -121,7 +121,7 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -60,7 +60,7 @@ public class SelectionMarkersGroupBottomSheetDialogFragment extends MenuBottomSh
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -124,7 +124,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}

View file

@ -130,12 +130,12 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}
@Override
protected void onCloseRowClickAction() {
protected void onDismissButtonClickAction() {
if (listener != null) {
listener.onClearSelection();
}

View file

@ -119,7 +119,7 @@ public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDial
}
@Override
protected int getCloseRowTextId() {
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}