Merge branch 'r3.3'
This commit is contained in:
commit
abcaa6595e
6 changed files with 131 additions and 110 deletions
|
@ -57,6 +57,23 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
||||||
public static final String FAVOURITES = "favourites";
|
public static final String FAVOURITES = "favourites";
|
||||||
|
|
||||||
private PointType pointType = PointType.START;
|
private PointType pointType = PointType.START;
|
||||||
|
private DialogListener listener;
|
||||||
|
|
||||||
|
public interface DialogListener {
|
||||||
|
void onSelectOnMap(AddPointBottomSheetDialog dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DialogListener getListener() {
|
||||||
|
return listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListener(DialogListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointType getPointType() {
|
||||||
|
return pointType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
@ -249,6 +266,10 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu();
|
MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu();
|
||||||
menu.selectOnScreen(pointType);
|
menu.selectOnScreen(pointType);
|
||||||
|
DialogListener listener = getListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onSelectOnMap(AddPointBottomSheetDialog.this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
public static final String ROUTE_INDEX_KEY = "route_index_key";
|
public static final String ROUTE_INDEX_KEY = "route_index_key";
|
||||||
public static final String ROUTE_INFO_STATE_KEY = "route_info_state_key";
|
public static final String ROUTE_INFO_STATE_KEY = "route_info_state_key";
|
||||||
public static final String INITIAL_MENU_STATE_KEY = "initial_menu_state_key";
|
public static final String INITIAL_MENU_STATE_KEY = "initial_menu_state_key";
|
||||||
|
public static final String USE_ROUTE_INFO_MENU_KEY = "use_route_info_menu_key";
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private LockableViewPager viewPager;
|
private LockableViewPager viewPager;
|
||||||
|
@ -98,7 +99,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
private int routesCount;
|
private int routesCount;
|
||||||
|
|
||||||
private boolean publicTransportMode;
|
private boolean publicTransportMode;
|
||||||
private int routeInfoMenuState = -1;
|
private boolean useRouteInfoMenu;
|
||||||
private boolean openingAnalyseOnMap = false;
|
private boolean openingAnalyseOnMap = false;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -115,7 +116,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
routeIndex = args.getInt(ROUTE_INDEX_KEY);
|
routeIndex = args.getInt(ROUTE_INDEX_KEY);
|
||||||
routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1);
|
useRouteInfoMenu = args.getBoolean(USE_ROUTE_INFO_MENU_KEY, false);
|
||||||
initialMenuState = args.getInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
initialMenuState = args.getInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
||||||
}
|
}
|
||||||
routesCount = 1;
|
routesCount = 1;
|
||||||
|
@ -218,10 +219,16 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
if (!wasDrawerDisabled) {
|
if (!wasDrawerDisabled) {
|
||||||
mapActivity.enableDrawer();
|
mapActivity.enableDrawer();
|
||||||
}
|
}
|
||||||
updateControlsVisibility(true, routeInfoMenuState != -1);
|
updateControlsVisibility(true, useRouteInfoMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
outState.putBoolean(USE_ROUTE_INFO_MENU_KEY, useRouteInfoMenu);
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatusBarColorId() {
|
public int getStatusBarColorId() {
|
||||||
View view = getView();
|
View view = getView();
|
||||||
|
@ -270,8 +277,8 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||||
if (routeInfoMenuState != -1 && !openingAnalyseOnMap) {
|
if (useRouteInfoMenu && !openingAnalyseOnMap) {
|
||||||
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(routeInfoMenuState);
|
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -837,12 +844,12 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex,
|
static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex,
|
||||||
int routeInfoState, int initialMenuState) {
|
boolean useRouteInfoMenu, int initialMenuState) {
|
||||||
try {
|
try {
|
||||||
ChooseRouteFragment fragment = new ChooseRouteFragment();
|
ChooseRouteFragment fragment = new ChooseRouteFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ROUTE_INDEX_KEY, routeIndex);
|
args.putInt(ROUTE_INDEX_KEY, routeIndex);
|
||||||
args.putInt(ROUTE_INFO_STATE_KEY, routeInfoState);
|
args.putBoolean(USE_ROUTE_INFO_MENU_KEY, useRouteInfoMenu);
|
||||||
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
|
|
|
@ -116,9 +116,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
private boolean selectFromMapTouch;
|
private boolean selectFromMapTouch;
|
||||||
private PointType selectFromMapPointType;
|
private PointType selectFromMapPointType;
|
||||||
private int selectFromMapMenuState = MenuState.HEADER_ONLY;
|
private int selectFromMapMenuState = MenuState.HEADER_ONLY;
|
||||||
|
private boolean selectFromMapWaypoints;
|
||||||
|
|
||||||
private boolean showMenu = false;
|
private boolean showMenu = false;
|
||||||
private int showMenuState = DEFAULT_MENU_STATE;
|
private int showMenuState = DEFAULT_MENU_STATE;
|
||||||
|
private int lastMenuState = MenuState.HEADER_ONLY;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
|
@ -234,8 +236,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||||
OsmandApplication app = getApp();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (app != null) {
|
if (mapActivity != null) {
|
||||||
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
if (selectFromMapTouch) {
|
if (selectFromMapTouch) {
|
||||||
LatLon latlon = tileBox.getLatLonFromPixel(point.x, point.y);
|
LatLon latlon = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||||
selectFromMapTouch = false;
|
selectFromMapTouch = false;
|
||||||
|
@ -257,7 +260,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
targets.setWorkPoint(latlon, null);
|
targets.setWorkPoint(latlon, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
show(selectFromMapMenuState);
|
if (selectFromMapWaypoints) {
|
||||||
|
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager(), true);
|
||||||
|
} else {
|
||||||
|
show(selectFromMapMenuState);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +336,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
if (fragmentRef != null) {
|
if (fragmentRef != null) {
|
||||||
return fragmentRef.get().getCurrentMenuState();
|
return fragmentRef.get().getCurrentMenuState();
|
||||||
}
|
}
|
||||||
return 0;
|
return lastMenuState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSupportedMenuStates() {
|
public int getSupportedMenuStates() {
|
||||||
|
@ -348,6 +355,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showHideMenu() {
|
||||||
|
showHideMenu(lastMenuState);
|
||||||
|
}
|
||||||
|
|
||||||
public void showHideMenu(int menuState) {
|
public void showHideMenu(int menuState) {
|
||||||
intermediateRequestsLatLon.clear();
|
intermediateRequestsLatLon.clear();
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
|
@ -593,7 +604,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
if (card instanceof SimpleRouteCard) {
|
if (card instanceof SimpleRouteCard) {
|
||||||
hide();
|
hide();
|
||||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, getCurrentMenuState(), MenuState.FULL_SCREEN);
|
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, true, MenuState.FULL_SCREEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,7 +629,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
if (buttonIndex == PublicTransportCard.DETAILS_BUTTON_INDEX) {
|
if (buttonIndex == PublicTransportCard.DETAILS_BUTTON_INDEX) {
|
||||||
hide();
|
hide();
|
||||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||||
((PublicTransportCard) card).getRouteId(), getCurrentMenuState(), MenuState.FULL_SCREEN);
|
((PublicTransportCard) card).getRouteId(), true, MenuState.FULL_SCREEN);
|
||||||
} else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) {
|
} else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) {
|
||||||
setupCards();
|
setupCards();
|
||||||
openMenuHeaderOnly();
|
openMenuHeaderOnly();
|
||||||
|
@ -626,7 +637,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
} else if (card instanceof SimpleRouteCard) {
|
} else if (card instanceof SimpleRouteCard) {
|
||||||
hide();
|
hide();
|
||||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0,
|
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0,
|
||||||
getCurrentMenuState(), MenuState.FULL_SCREEN);
|
true, MenuState.FULL_SCREEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1301,7 +1312,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
if (app.getRoutingHelper().isPublicTransportMode()) {
|
if (app.getRoutingHelper().isPublicTransportMode()) {
|
||||||
if (isTransportRouteCalculated()) {
|
if (isTransportRouteCalculated()) {
|
||||||
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
|
||||||
app.getTransportRoutingHelper().getCurrentRoute(), getCurrentMenuState(), MenuState.HEADER_ONLY);
|
app.getTransportRoutingHelper().getCurrentRoute(), true, MenuState.HEADER_ONLY);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
|
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();
|
||||||
|
@ -1353,7 +1364,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && mapActivity.getMyApplication().getTargetPointsHelper().checkPointToNavigateShort()) {
|
if (mapActivity != null && mapActivity.getMyApplication().getTargetPointsHelper().checkPointToNavigateShort()) {
|
||||||
hide();
|
hide();
|
||||||
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager(), getCurrentMenuState());
|
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1618,9 +1629,18 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectOnScreen(PointType pointType) {
|
public void selectOnScreen(PointType pointType) {
|
||||||
|
selectOnScreen(pointType, getCurrentMenuState(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectOnScreen(PointType pointType, boolean waypointsMenu) {
|
||||||
|
selectOnScreen(pointType, getCurrentMenuState(), waypointsMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectOnScreen(PointType pointType, int menuState, boolean waypointsMenu) {
|
||||||
selectFromMapTouch = true;
|
selectFromMapTouch = true;
|
||||||
selectFromMapPointType = pointType;
|
selectFromMapPointType = pointType;
|
||||||
selectFromMapMenuState = getCurrentMenuState();
|
selectFromMapMenuState = menuState;
|
||||||
|
selectFromMapWaypoints = waypointsMenu;
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1901,10 +1921,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
||||||
public void routeWasFinished() {
|
public void routeWasFinished() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDismiss() {
|
public void onDismiss(int currentMenuState) {
|
||||||
cancelButtonsAnimations();
|
cancelButtonsAnimations();
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
lastMenuState = currentMenuState;
|
||||||
mapActivity.getMapView().setMapPositionX(0);
|
mapActivity.getMapView().setMapPositionX(0);
|
||||||
mapActivity.getMapView().refreshMap();
|
mapActivity.getMapView().refreshMap();
|
||||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false);
|
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false);
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
if (menu != null) {
|
if (menu != null) {
|
||||||
menu.onDismiss();
|
menu.onDismiss(getCurrentMenuState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ import net.osmand.plus.views.controls.DynamicListView;
|
||||||
import net.osmand.plus.views.controls.DynamicListViewCallbacks;
|
import net.osmand.plus.views.controls.DynamicListViewCallbacks;
|
||||||
import net.osmand.plus.views.controls.StableArrayAdapter;
|
import net.osmand.plus.views.controls.StableArrayAdapter;
|
||||||
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
|
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
|
||||||
|
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
|
||||||
|
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.plus.widgets.TextViewExProgress;
|
import net.osmand.plus.widgets.TextViewExProgress;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -58,12 +60,12 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.helpers.WaypointDialogHelper.showOnMap;
|
import static net.osmand.plus.helpers.WaypointDialogHelper.showOnMap;
|
||||||
import static net.osmand.plus.routepreparationmenu.ChooseRouteFragment.ROUTE_INFO_STATE_KEY;
|
|
||||||
|
|
||||||
public class WaypointsFragment extends BaseOsmAndFragment implements ObservableScrollViewCallbacks,
|
public class WaypointsFragment extends BaseOsmAndFragment implements ObservableScrollViewCallbacks,
|
||||||
DynamicListViewCallbacks, WaypointDialogHelper.WaypointDialogHelperCallback {
|
DynamicListViewCallbacks, WaypointDialogHelper.WaypointDialogHelperCallback, AddPointBottomSheetDialog.DialogListener {
|
||||||
|
|
||||||
public static final String TAG = "WaypointsFragment";
|
public static final String TAG = "WaypointsFragment";
|
||||||
|
public static final String USE_ROUTE_INFO_MENU_KEY = "use_route_info_menu_key";
|
||||||
|
|
||||||
private View view;
|
private View view;
|
||||||
private View mainView;
|
private View mainView;
|
||||||
|
@ -83,11 +85,11 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private boolean wasDrawerDisabled;
|
private boolean wasDrawerDisabled;
|
||||||
|
|
||||||
private int routeInfoMenuState = -1;
|
private boolean useRouteInfoMenu;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, final Bundle savedInstanceState) {
|
||||||
MapActivity mapActivity = (MapActivity) requireActivity();
|
MapActivity mapActivity = (MapActivity) requireActivity();
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||||
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
|
@ -99,7 +101,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
AndroidUtils.addStatusBarPadding21v(mapActivity, view);
|
AndroidUtils.addStatusBarPadding21v(mapActivity, view);
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1);
|
useRouteInfoMenu = args.getBoolean(USE_ROUTE_INFO_MENU_KEY, false);
|
||||||
}
|
}
|
||||||
mainView = view.findViewById(R.id.main_view);
|
mainView = view.findViewById(R.id.main_view);
|
||||||
|
|
||||||
|
@ -174,95 +176,44 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
swipeDismissListener = new SwipeDismissListViewTouchListener(
|
swipeDismissListener = new SwipeDismissListViewTouchListener(
|
||||||
mapActivity,
|
mapActivity,
|
||||||
listView,
|
listView,
|
||||||
new SwipeDismissListViewTouchListener.DismissCallbacks() {
|
new DismissCallbacks() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDismiss(int position) {
|
public boolean canDismiss(int position) {
|
||||||
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
|
StableArrayAdapter stableAdapter = listAdapter;
|
||||||
Object obj = listAdapter.getItem(position);
|
if (stableAdapter != null) {
|
||||||
if (obj instanceof LocationPointWrapper) {
|
List<Object> activeObjects = stableAdapter.getActiveObjects();
|
||||||
LocationPointWrapper w = (LocationPointWrapper) obj;
|
Object obj = stableAdapter.getItem(position);
|
||||||
if (w.getPoint() instanceof TargetPoint) {
|
if (obj instanceof LocationPointWrapper) {
|
||||||
return !((TargetPoint) w.getPoint()).start;
|
LocationPointWrapper w = (LocationPointWrapper) obj;
|
||||||
|
if (w.getPoint() instanceof TargetPoint) {
|
||||||
|
return !((TargetPoint) w.getPoint()).start;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return activeObjects.contains(obj);
|
||||||
}
|
}
|
||||||
return activeObjects.contains(obj);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SwipeDismissListViewTouchListener.Undoable onDismiss(final int position) {
|
public Undoable onDismiss(final int position) {
|
||||||
final Object item;
|
StableArrayAdapter stableAdapter = listAdapter;
|
||||||
final StableArrayAdapter stableAdapter;
|
if (stableAdapter != null) {
|
||||||
final int activeObjPos;
|
Object item = stableAdapter.getItem(position);
|
||||||
stableAdapter = (StableArrayAdapter) listAdapter;
|
stableAdapter.setNotifyOnChange(false);
|
||||||
item = stableAdapter.getItem(position);
|
stableAdapter.remove(item);
|
||||||
|
stableAdapter.getObjects().remove(item);
|
||||||
stableAdapter.setNotifyOnChange(false);
|
stableAdapter.getActiveObjects().remove(item);
|
||||||
stableAdapter.remove(item);
|
stableAdapter.refreshData();
|
||||||
stableAdapter.getObjects().remove(item);
|
stableAdapter.notifyDataSetChanged();
|
||||||
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
|
}
|
||||||
stableAdapter.getActiveObjects().remove(item);
|
cancelTimer();
|
||||||
stableAdapter.refreshData();
|
startTimer();
|
||||||
stableAdapter.notifyDataSetChanged();
|
return null;
|
||||||
|
|
||||||
return new SwipeDismissListViewTouchListener.Undoable() {
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (item != null) {
|
|
||||||
stableAdapter.setNotifyOnChange(false);
|
|
||||||
stableAdapter.insert(item, position);
|
|
||||||
stableAdapter.getObjects().add(position, item);
|
|
||||||
stableAdapter.getActiveObjects().add(activeObjPos, item);
|
|
||||||
stableAdapter.refreshData();
|
|
||||||
applyPointsChanges();
|
|
||||||
updateTitle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
List<Object> activeObjects;
|
|
||||||
if ((mapActivity.getRoutingHelper().isRoutePlanningMode() || mapActivity.getRoutingHelper().isFollowingMode())
|
|
||||||
&& item != null
|
|
||||||
&& ((activeObjects = stableAdapter.getActiveObjects()).isEmpty() || isContainsOnlyStart(activeObjects))) {
|
|
||||||
return mapActivity.getResources().getString(R.string.cancel_navigation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHidePopup() {
|
public void onHidePopup() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
|
|
||||||
stableAdapter.refreshData();
|
|
||||||
applyPointsChanges();
|
|
||||||
updateTitle();
|
|
||||||
List<Object> activeObjects = stableAdapter.getActiveObjects();
|
|
||||||
if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) {
|
|
||||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
|
||||||
mapActivity.getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
|
|
||||||
mapActivity.getMapRouteInfoMenu().hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isContainsOnlyStart(List<Object> items) {
|
|
||||||
if (items.size() == 1) {
|
|
||||||
Object item = items.get(0);
|
|
||||||
if (item instanceof LocationPointWrapper) {
|
|
||||||
LocationPointWrapper w = (LocationPointWrapper) item;
|
|
||||||
if (w.getPoint() instanceof TargetPoint) {
|
|
||||||
return ((TargetPoint) w.getPoint()).start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -277,6 +228,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragment.setUsedOnMap(true);
|
fragment.setUsedOnMap(true);
|
||||||
|
fragment.setListener(WaypointsFragment.this);
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,10 +316,16 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
if (!wasDrawerDisabled) {
|
if (!wasDrawerDisabled) {
|
||||||
mapActivity.enableDrawer();
|
mapActivity.enableDrawer();
|
||||||
}
|
}
|
||||||
updateControlsVisibility(true, routeInfoMenuState != -1);
|
updateControlsVisibility(true, useRouteInfoMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
outState.putBoolean(USE_ROUTE_INFO_MENU_KEY, useRouteInfoMenu);
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
|
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
|
||||||
|
|
||||||
|
@ -385,8 +343,8 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reloadAdapter() {
|
public void reloadAdapter() {
|
||||||
if (listAdapter != null) {
|
StableArrayAdapter stableAdapter = listAdapter;
|
||||||
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
|
if (stableAdapter != null) {
|
||||||
reloadListAdapter(stableAdapter);
|
reloadListAdapter(stableAdapter);
|
||||||
setDynamicListItems(listView, stableAdapter);
|
setDynamicListItems(listView, stableAdapter);
|
||||||
}
|
}
|
||||||
|
@ -737,7 +695,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
cTimer.cancel();
|
cTimer.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
private View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
||||||
final MapActivity mapActivity, View v,
|
final MapActivity mapActivity, View v,
|
||||||
final LocationPointWrapper point,
|
final LocationPointWrapper point,
|
||||||
final ArrayAdapter adapter, final boolean nightMode,
|
final ArrayAdapter adapter, final boolean nightMode,
|
||||||
|
@ -931,15 +889,15 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||||
return WaypointsFragment.showInstance(fragmentManager, -1);
|
return WaypointsFragment.showInstance(fragmentManager, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(FragmentManager fragmentManager, int routeInfoState) {
|
public static boolean showInstance(FragmentManager fragmentManager, boolean useRouteInfoMenu) {
|
||||||
try {
|
try {
|
||||||
WaypointsFragment fragment = new WaypointsFragment();
|
WaypointsFragment fragment = new WaypointsFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ROUTE_INFO_STATE_KEY, routeInfoState);
|
args.putBoolean(USE_ROUTE_INFO_MENU_KEY, useRouteInfoMenu);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
|
@ -958,12 +916,22 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
||||||
MapActivity mapActivity = (MapActivity) getActivity();
|
MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||||
if (routeInfoMenuState != -1) {
|
if (useRouteInfoMenu) {
|
||||||
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(routeInfoMenuState);
|
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelectOnMap(AddPointBottomSheetDialog dialog) {
|
||||||
|
MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.getMapRouteInfoMenu().selectOnScreen(dialog.getPointType(), true);
|
||||||
|
useRouteInfoMenu = false;
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -319,6 +319,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showRouteInfoControlDialog() {
|
||||||
|
mapRouteInfoMenu.showHideMenu();
|
||||||
|
}
|
||||||
|
|
||||||
public void showRouteInfoControlDialog(int menuState) {
|
public void showRouteInfoControlDialog(int menuState) {
|
||||||
mapRouteInfoMenu.showHideMenu(menuState);
|
mapRouteInfoMenu.showHideMenu(menuState);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue