Hide sort by and move to history in options menu
This commit is contained in:
parent
0eb9eed459
commit
1c755ce65a
3 changed files with 65 additions and 30 deletions
|
@ -200,6 +200,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/move_all_to_history_divider"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginBottom="@dimen/measurement_tool_bottom_divider_margin_bottom"
|
android:layout_marginBottom="@dimen/measurement_tool_bottom_divider_margin_bottom"
|
||||||
|
|
|
@ -39,6 +39,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
|
|
||||||
public static final String TAG = "MapMarkersDialogFragment";
|
public static final String TAG = "MapMarkersDialogFragment";
|
||||||
|
|
||||||
|
private static final int ACTIVE_MARKERS_POSITION = 0;
|
||||||
|
private static final int GROUPS_POSITION = 1;
|
||||||
|
private static final int HISTORY_MARKERS_POSITION = 2;
|
||||||
|
|
||||||
private MapMarkersActiveFragment activeFragment;
|
private MapMarkersActiveFragment activeFragment;
|
||||||
private MapMarkersGroupsFragment groupsFragment;
|
private MapMarkersGroupsFragment groupsFragment;
|
||||||
private MapMarkersHistoryFragment historyFragment;
|
private MapMarkersHistoryFragment historyFragment;
|
||||||
|
@ -121,6 +125,11 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
OptionsBottomSheetDialogFragment fragment = new OptionsBottomSheetDialogFragment();
|
||||||
fragment.setListener(createOptionsFragmentListener());
|
fragment.setListener(createOptionsFragmentListener());
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
int pos = viewPager.getCurrentItem();
|
||||||
|
args.putBoolean(OptionsBottomSheetDialogFragment.SHOW_SORT_BY_ROW, pos == ACTIVE_MARKERS_POSITION);
|
||||||
|
args.putBoolean(OptionsBottomSheetDialogFragment.SHOW_MOVE_ALL_TO_HISTORY_ROW, pos != HISTORY_MARKERS_POSITION);
|
||||||
|
fragment.setArguments(args);
|
||||||
fragment.show(getChildFragmentManager(), OptionsBottomSheetDialogFragment.TAG);
|
fragment.show(getChildFragmentManager(), OptionsBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -142,35 +151,35 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
case R.id.action_active:
|
case R.id.action_active:
|
||||||
activeFragment.startLocationUpdate();
|
activeFragment.startLocationUpdate();
|
||||||
groupsFragment.stopLocationUpdate();
|
groupsFragment.stopLocationUpdate();
|
||||||
if (viewPager.getCurrentItem() != 0) {
|
if (viewPager.getCurrentItem() != ACTIVE_MARKERS_POSITION) {
|
||||||
hideSnackbar();
|
hideSnackbar();
|
||||||
activeFragment.updateAdapter();
|
activeFragment.updateAdapter();
|
||||||
historyFragment.hideSnackbar();
|
historyFragment.hideSnackbar();
|
||||||
groupsFragment.hideSnackbar();
|
groupsFragment.hideSnackbar();
|
||||||
}
|
}
|
||||||
viewPager.setCurrentItem(0);
|
viewPager.setCurrentItem(ACTIVE_MARKERS_POSITION);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_groups:
|
case R.id.action_groups:
|
||||||
activeFragment.stopLocationUpdate();
|
activeFragment.stopLocationUpdate();
|
||||||
groupsFragment.startLocationUpdate();
|
groupsFragment.startLocationUpdate();
|
||||||
if (viewPager.getCurrentItem() != 1) {
|
if (viewPager.getCurrentItem() != GROUPS_POSITION) {
|
||||||
hideSnackbar();
|
hideSnackbar();
|
||||||
groupsFragment.updateAdapter();
|
groupsFragment.updateAdapter();
|
||||||
activeFragment.hideSnackbar();
|
activeFragment.hideSnackbar();
|
||||||
historyFragment.hideSnackbar();
|
historyFragment.hideSnackbar();
|
||||||
}
|
}
|
||||||
viewPager.setCurrentItem(1);
|
viewPager.setCurrentItem(GROUPS_POSITION);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_history:
|
case R.id.action_history:
|
||||||
activeFragment.stopLocationUpdate();
|
activeFragment.stopLocationUpdate();
|
||||||
groupsFragment.stopLocationUpdate();
|
groupsFragment.stopLocationUpdate();
|
||||||
if (viewPager.getCurrentItem() != 2) {
|
if (viewPager.getCurrentItem() != HISTORY_MARKERS_POSITION) {
|
||||||
hideSnackbar();
|
hideSnackbar();
|
||||||
historyFragment.updateAdapter();
|
historyFragment.updateAdapter();
|
||||||
groupsFragment.hideSnackbar();
|
groupsFragment.hideSnackbar();
|
||||||
activeFragment.hideSnackbar();
|
activeFragment.hideSnackbar();
|
||||||
}
|
}
|
||||||
viewPager.setCurrentItem(2);
|
viewPager.setCurrentItem(HISTORY_MARKERS_POSITION);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -245,17 +254,21 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
|
final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||||
final List<MapMarkersHelper.MapMarker> markers = new ArrayList<>(helper.getMapMarkers());
|
final List<MapMarkersHelper.MapMarker> markers = new ArrayList<>(helper.getMapMarkers());
|
||||||
helper.moveAllActiveMarkersToHistory();
|
helper.moveAllActiveMarkersToHistory();
|
||||||
|
if (viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION) {
|
||||||
activeFragment.updateAdapter();
|
activeFragment.updateAdapter();
|
||||||
|
} else {
|
||||||
groupsFragment.updateAdapter();
|
groupsFragment.updateAdapter();
|
||||||
historyFragment.updateAdapter();
|
}
|
||||||
snackbar = Snackbar.make(viewPager, R.string.all_markers_moved_to_history, Snackbar.LENGTH_LONG)
|
snackbar = Snackbar.make(viewPager, R.string.all_markers_moved_to_history, Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
helper.restoreMarkersFromHistory(markers);
|
helper.restoreMarkersFromHistory(markers);
|
||||||
|
if (viewPager.getCurrentItem() == ACTIVE_MARKERS_POSITION) {
|
||||||
activeFragment.updateAdapter();
|
activeFragment.updateAdapter();
|
||||||
|
} else {
|
||||||
groupsFragment.updateAdapter();
|
groupsFragment.updateAdapter();
|
||||||
historyFragment.updateAdapter();
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
View snackBarView = snackbar.getView();
|
View snackBarView = snackbar.getView();
|
||||||
|
@ -323,8 +336,6 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
||||||
if (orderByMode != MapMarkersOrderByMode.CUSTOM) {
|
if (orderByMode != MapMarkersOrderByMode.CUSTOM) {
|
||||||
getMyApplication().getMapMarkersHelper().orderMarkers(orderByMode);
|
getMyApplication().getMapMarkersHelper().orderMarkers(orderByMode);
|
||||||
activeFragment.updateAdapter();
|
activeFragment.updateAdapter();
|
||||||
groupsFragment.updateAdapter();
|
|
||||||
historyFragment.updateAdapter();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,26 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "OptionsBottomSheetDialogFragment";
|
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";
|
||||||
|
|
||||||
private MarkerOptionsFragmentListener listener;
|
private MarkerOptionsFragmentListener listener;
|
||||||
private boolean portrait;
|
private boolean portrait;
|
||||||
|
private boolean showSortBy;
|
||||||
|
private boolean showMoveAllToHistory;
|
||||||
|
|
||||||
public void setListener(MarkerOptionsFragmentListener listener) {
|
public void setListener(MarkerOptionsFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Bundle args = getArguments();
|
||||||
|
showSortBy = args.getBoolean(SHOW_SORT_BY_ROW, true);
|
||||||
|
showMoveAllToHistory = args.getBoolean(SHOW_MOVE_ALL_TO_HISTORY_ROW, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -76,7 +88,11 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setTextColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
|
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setTextColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.color_dialog_buttons_dark : R.color.map_widget_blue_pressed));
|
||||||
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText(getMyApplication().getSettings().MAP_MARKERS_MODE.get().toHumanString(getActivity()));
|
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText(getMyApplication().getSettings().MAP_MARKERS_MODE.get().toHumanString(getActivity()));
|
||||||
|
|
||||||
mainView.findViewById(R.id.sort_by_row).setOnClickListener(new View.OnClickListener() {
|
View sortByRow = mainView.findViewById(R.id.sort_by_row);
|
||||||
|
if (!showSortBy) {
|
||||||
|
sortByRow.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
sortByRow.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
@ -85,6 +101,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
mainView.findViewById(R.id.show_direction_row).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.show_direction_row).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -121,7 +138,12 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mainView.findViewById(R.id.move_all_to_history_row).setOnClickListener(new View.OnClickListener() {
|
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);
|
||||||
|
} else {
|
||||||
|
moveAllToHistoryRow.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
@ -130,6 +152,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
|
Loading…
Reference in a new issue