Add select all row in options menu in landscape
This commit is contained in:
parent
2d2d758001
commit
a03d93ff81
3 changed files with 89 additions and 18 deletions
|
@ -32,6 +32,38 @@
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
osmand:typeface="@string/font_roboto_medium"/>
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/select_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||||
|
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||||
|
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/select_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
tools:src="@drawable/ic_action_select_all"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/select_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
tools:text="Select all"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/navigate_row"
|
android:id="@+id/navigate_row"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -128,9 +128,11 @@ public class PlanRouteFragment extends Fragment {
|
||||||
if (snapToRoadFragment != null) {
|
if (snapToRoadFragment != null) {
|
||||||
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
|
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
|
||||||
}
|
}
|
||||||
Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
Fragment optionsFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||||
if (sortByFragment != null) {
|
if (optionsFragment != null) {
|
||||||
((PlanRouteOptionsBottomSheetDialogFragment) sortByFragment).setListener(createOptionsFragmentListener());
|
PlanRouteOptionsBottomSheetDialogFragment fragment = (PlanRouteOptionsBottomSheetDialogFragment) optionsFragment;
|
||||||
|
fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
|
||||||
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
|
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
|
||||||
|
@ -172,21 +174,8 @@ public class PlanRouteFragment extends Fragment {
|
||||||
mainView.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
int activeMarkersCount = markersHelper.getMapMarkers().size();
|
selectAllOnClick();
|
||||||
if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
|
|
||||||
markersHelper.deselectAllActiveMarkers();
|
|
||||||
markersHelper.setStartFromMyLocation(false);
|
|
||||||
selectedCount = 0;
|
|
||||||
} else {
|
|
||||||
markersHelper.selectAllActiveMarkers();
|
|
||||||
markersHelper.setStartFromMyLocation(true);
|
|
||||||
selectedCount = activeMarkersCount;
|
|
||||||
}
|
|
||||||
adapter.calculateStartAndFinishPos();
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
updateSelectButton();
|
updateSelectButton();
|
||||||
planRouteContext.recreateSnapTrkSegment();
|
|
||||||
mapActivity.refreshMap();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -322,6 +311,26 @@ public class PlanRouteFragment extends Fragment {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectAllOnClick() {
|
||||||
|
int activeMarkersCount = markersHelper.getMapMarkers().size();
|
||||||
|
if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
|
||||||
|
markersHelper.deselectAllActiveMarkers();
|
||||||
|
markersHelper.setStartFromMyLocation(false);
|
||||||
|
selectedCount = 0;
|
||||||
|
} else {
|
||||||
|
markersHelper.selectAllActiveMarkers();
|
||||||
|
markersHelper.setStartFromMyLocation(true);
|
||||||
|
selectedCount = activeMarkersCount;
|
||||||
|
}
|
||||||
|
adapter.calculateStartAndFinishPos();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
planRouteContext.recreateSnapTrkSegment();
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
@ -375,6 +384,11 @@ public class PlanRouteFragment extends Fragment {
|
||||||
|
|
||||||
private MapActivity mapActivity = getMapActivity();
|
private MapActivity mapActivity = getMapActivity();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectOnClick() {
|
||||||
|
selectAllOnClick();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void navigateOnClick() {
|
public void navigateOnClick() {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
@ -385,7 +399,7 @@ public class PlanRouteFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void makeRoundTripOnClick() {
|
public void makeRoundTripOnClick() {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
Toast.makeText(mapActivity, "mare round trip", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mapActivity, "make round trip", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,6 +545,7 @@ public class PlanRouteFragment extends Fragment {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
|
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
|
||||||
|
fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
|
||||||
fragment.setListener(createOptionsFragmentListener());
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,16 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
||||||
private boolean portrait;
|
private boolean portrait;
|
||||||
private boolean night;
|
private boolean night;
|
||||||
private PlanRouteOptionsFragmentListener listener;
|
private PlanRouteOptionsFragmentListener listener;
|
||||||
|
private boolean selectAll;
|
||||||
|
|
||||||
public void setListener(PlanRouteOptionsFragmentListener listener) {
|
public void setListener(PlanRouteOptionsFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSelectAll(boolean selectAll) {
|
||||||
|
this.selectAll = selectAll;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -54,6 +59,23 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
||||||
((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door));
|
((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door));
|
||||||
((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
|
((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
|
||||||
|
|
||||||
|
if (!portrait) {
|
||||||
|
((ImageView) mainView.findViewById(R.id.select_icon))
|
||||||
|
.setImageDrawable(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all));
|
||||||
|
|
||||||
|
((TextView) mainView.findViewById(R.id.select_title))
|
||||||
|
.setText(getString(selectAll ? R.string.shared_string_select_all : R.string.shared_string_deselect_all));
|
||||||
|
|
||||||
|
View selectRow = mainView.findViewById(R.id.select_row);
|
||||||
|
selectRow.setVisibility(View.VISIBLE);
|
||||||
|
selectRow.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
listener.selectOnClick();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -155,6 +177,8 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
||||||
|
|
||||||
interface PlanRouteOptionsFragmentListener {
|
interface PlanRouteOptionsFragmentListener {
|
||||||
|
|
||||||
|
void selectOnClick();
|
||||||
|
|
||||||
void navigateOnClick();
|
void navigateOnClick();
|
||||||
|
|
||||||
void makeRoundTripOnClick();
|
void makeRoundTripOnClick();
|
||||||
|
|
Loading…
Reference in a new issue