Change dividers order; disable unnecessary menu items instead of hiding
This commit is contained in:
parent
e852eb809e
commit
6c15f8839c
3 changed files with 59 additions and 62 deletions
|
@ -23,10 +23,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:text="@string/shared_string_options"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
@ -37,10 +35,8 @@
|
|||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sort_by_icon"
|
||||
|
@ -60,16 +56,23 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/show_direction_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/show_direction_icon"
|
||||
|
@ -91,25 +94,14 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/coordinate_input_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/coordinate_input_icon"
|
||||
|
@ -135,10 +127,8 @@
|
|||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/build_route_icon"
|
||||
|
@ -158,16 +148,23 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/save_as_new_track_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/save_as_new_track_icon"
|
||||
|
@ -187,26 +184,14 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/move_all_to_history_divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/move_all_to_history_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/move_all_to_history_icon"
|
||||
|
|
|
@ -40,8 +40,8 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.SHOW_MOVE_ALL_TO_HISTORY_ROW;
|
||||
import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.SHOW_SORT_BY_ROW;
|
||||
import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.GROUPS_MARKERS_MENU;
|
||||
import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.HISTORY_MARKERS_MENU;
|
||||
|
||||
public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragment {
|
||||
|
||||
|
@ -269,8 +269,8 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
||||
fragment.setListener(createOptionsFragmentListener());
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(SHOW_SORT_BY_ROW, viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION);
|
||||
args.putBoolean(SHOW_MOVE_ALL_TO_HISTORY_ROW, viewPager.getCurrentItem() != HISTORY_MARKERS_POSITION);
|
||||
args.putBoolean(GROUPS_MARKERS_MENU, viewPager.getCurrentItem() == GROUPS_POSITION);
|
||||
args.putBoolean(HISTORY_MARKERS_MENU, viewPager.getCurrentItem() == HISTORY_MARKERS_POSITION);
|
||||
fragment.setArguments(args);
|
||||
getChildFragmentManager().beginTransaction()
|
||||
.add(R.id.menu_container, fragment, OptionsBottomSheetDialogFragment.TAG)
|
||||
|
|
|
@ -20,12 +20,13 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
||||
public final static String SHOW_SORT_BY_ROW = "show_sort_by_row";
|
||||
public final static String SHOW_MOVE_ALL_TO_HISTORY_ROW = "show_move_to_history_row";
|
||||
public final static String GROUPS_MARKERS_MENU = "groups_markers_menu";
|
||||
public final static String HISTORY_MARKERS_MENU = "history_markers_menu";
|
||||
|
||||
private MarkerOptionsFragmentListener listener;
|
||||
private boolean showSortBy;
|
||||
private boolean showMoveAllToHistory;
|
||||
private boolean disableSortBy;
|
||||
private boolean disableSaveAsTrack;
|
||||
private boolean disableMoveAllToHistory;
|
||||
|
||||
public void setListener(MarkerOptionsFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
|
@ -35,8 +36,10 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle args = getArguments();
|
||||
showSortBy = args == null || args.getBoolean(SHOW_SORT_BY_ROW, true);
|
||||
showMoveAllToHistory = args == null || args.getBoolean(SHOW_MOVE_ALL_TO_HISTORY_ROW, true);
|
||||
boolean groupsMenu = args != null && args.getBoolean(GROUPS_MARKERS_MENU, false);
|
||||
boolean historyMenu = args != null && args.getBoolean(HISTORY_MARKERS_MENU, false);
|
||||
disableSortBy = disableSaveAsTrack = groupsMenu || historyMenu;
|
||||
disableMoveAllToHistory = historyMenu;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -69,8 +72,8 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_history2));
|
||||
|
||||
View sortByRow = mainView.findViewById(R.id.sort_by_row);
|
||||
if (!showSortBy) {
|
||||
sortByRow.setVisibility(View.GONE);
|
||||
if (disableSortBy) {
|
||||
disableView(sortByRow);
|
||||
} else {
|
||||
sortByRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -109,19 +112,23 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.save_as_new_track_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.saveAsNewTrackOnClick();
|
||||
View saveAsTrackRow = mainView.findViewById(R.id.save_as_new_track_row);
|
||||
if (disableSaveAsTrack) {
|
||||
disableView(saveAsTrackRow);
|
||||
} else {
|
||||
saveAsTrackRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.saveAsNewTrackOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
View moveAllToHistoryRow = mainView.findViewById(R.id.move_all_to_history_row);
|
||||
if (!showMoveAllToHistory) {
|
||||
mainView.findViewById(R.id.move_all_to_history_divider).setVisibility(View.GONE);
|
||||
moveAllToHistoryRow.setVisibility(View.GONE);
|
||||
if (disableMoveAllToHistory) {
|
||||
disableView(moveAllToHistoryRow);
|
||||
} else {
|
||||
moveAllToHistoryRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -175,6 +182,11 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
super.dismiss();
|
||||
}
|
||||
|
||||
private void disableView(View view) {
|
||||
view.setEnabled(false);
|
||||
view.setAlpha(.5f);
|
||||
}
|
||||
|
||||
private int getAllowedHeight() {
|
||||
Activity activity = getActivity();
|
||||
int scrH = AndroidUtils.getScreenHeight(activity);
|
||||
|
|
Loading…
Reference in a new issue