Make map movable while gpx detail is displaying

This commit is contained in:
Alexey Kulish 2017-03-06 20:17:25 +03:00
parent fafb1136a7
commit 424b400f18
7 changed files with 104 additions and 117 deletions

View file

@ -220,7 +220,13 @@
<include layout="@layout/recording_note_fragment" <include layout="@layout/recording_note_fragment"
tools:visibility="gone"/> tools:visibility="gone"/>
<include layout="@layout/move_marker_bottom_sheet"/> <include layout="@layout/move_marker_bottom_sheet"
tools:visibility="gone"/>
<FrameLayout
android:id="@+id/bottomFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout <LinearLayout
android:id="@+id/map_context_menu_layout" android:id="@+id/map_context_menu_layout"

View file

@ -6,69 +6,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/color_transparent" android:background="@color/color_transparent"
android:clickable="true" android:clickable="true"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools">
xmlns:osmand="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="@+id/top_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/dashboard_map_toolbar"
android:gravity="center_vertical"
android:clickable="true"
android:background="@drawable/gradient_toolbar"
android:orientation="horizontal">
<ImageButton
android:id="@+id/top_bar_back_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="top"
android:contentDescription="@string/back_to_search"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
<LinearLayout
android:id="@+id/top_bar_title_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/top_bar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:singleLine="true"
android:textColor="@color/color_white"
android:textSize="@dimen/abc_text_size_medium_material"
osmand:typeface="@string/font_roboto_medium"
android:text="@string/rendering_category_details"/>
<TextView
android:id="@+id/widget_top_bar_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:ellipsize="end"
android:gravity="center_vertical"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_sub_text_size"
android:visibility="gone"
tools:text="New version of OsmAnd+ with 50% discount"/>
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/main_view"

View file

@ -33,6 +33,8 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet; import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,6 +46,7 @@ public class TrackDetailsMenu {
private OsmandMapTileView mapView; private OsmandMapTileView mapView;
private MapControlsLayer mapControlsLayer; private MapControlsLayer mapControlsLayer;
private GpxDisplayItem gpxItem; private GpxDisplayItem gpxItem;
private TrackDetailsBarController toolbarController;
private static boolean VISIBLE; private static boolean VISIBLE;
private boolean nightMode; private boolean nightMode;
@ -72,13 +75,22 @@ public class TrackDetailsMenu {
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if (!portrait) { if (!portrait) {
mapActivity.getMapView().setMapPositionX(1); mapActivity.getMapView().setMapPositionX(1);
} else {
toolbarController = new TrackDetailsBarController();
toolbarController.setTitle(mapActivity.getString(R.string.rendering_category_details));
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.onBackPressed();
}
});
mapActivity.showTopToolbar(toolbarController);
} }
mapActivity.refreshMap(); mapActivity.refreshMap();
TrackDetailsMenuFragment.showInstance(mapActivity); TrackDetailsMenuFragment.showInstance(mapActivity);
mapActivity.getMapLayers().getContextMenuLayer().enterGpxDetailsMode();
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
} }
} }
@ -109,10 +121,13 @@ public class TrackDetailsMenu {
public void onDismiss() { public void onDismiss() {
VISIBLE = false; VISIBLE = false;
if (toolbarController != null) {
mapActivity.hideTopToolbar(toolbarController);
}
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(null); mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(null);
mapActivity.getMapView().setMapPositionX(0); mapActivity.getMapView().setMapPositionX(0);
mapActivity.getMapView().refreshMap(); mapActivity.getMapView().refreshMap();
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
} }
public void updateInfo(final View main) { public void updateInfo(final View main) {
@ -334,4 +349,24 @@ public class TrackDetailsMenu {
chart.highlightValue(null); chart.highlightValue(null);
} }
} }
private static class TrackDetailsBarController extends TopToolbarController {
TrackDetailsBarController() {
super(MapInfoWidgetsFactory.TopToolbarControllerType.TRACK_DETAILS);
setBackBtnIconClrIds(0, 0);
setCloseBtnIconClrIds(0, 0);
setTitleTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
setDescrTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
setBgIds(R.drawable.gradient_toolbar, R.drawable.gradient_toolbar,
R.drawable.gradient_toolbar, R.drawable.gradient_toolbar);
}
@Override
public void updateToolbar(MapInfoWidgetsFactory.TopToolbarView view) {
super.updateToolbar(view);
view.getCloseButton().setVisibility(View.GONE);
view.getShadowView().setVisibility(View.GONE);
}
}
} }

View file

@ -7,7 +7,6 @@ import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -21,7 +20,6 @@ public class TrackDetailsMenuFragment extends Fragment {
private TrackDetailsMenu menu; private TrackDetailsMenu menu;
private View mainView; private View mainView;
private View topBar;
private MapActivity getMapActivity() { private MapActivity getMapActivity() {
return (MapActivity) getActivity(); return (MapActivity) getActivity();
@ -38,24 +36,7 @@ public class TrackDetailsMenuFragment extends Fragment {
return view; return view;
} }
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity.clearPrevActivityIntent();
dismiss();
}
});
mainView = view.findViewById(R.id.main_view); mainView = view.findViewById(R.id.main_view);
topBar = view.findViewById(R.id.top_bar_layout);
ImageButton backButton = (ImageButton) topBar.findViewById(R.id.top_bar_back_button);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
updateInfo(); updateInfo();
@ -100,11 +81,7 @@ public class TrackDetailsMenuFragment extends Fragment {
} }
public void show(MapActivity mapActivity) { public void show(MapActivity mapActivity) {
int slideInAnim = R.anim.slide_in_bottom;
int slideOutAnim = R.anim.slide_out_bottom;
mapActivity.getSupportFragmentManager().beginTransaction() mapActivity.getSupportFragmentManager().beginTransaction()
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
.add(R.id.routeMenuContainer, this, TAG) .add(R.id.routeMenuContainer, this, TAG)
.addToBackStack(TAG) .addToBackStack(TAG)
.commitAllowingStateLoss(); .commitAllowingStateLoss();
@ -131,8 +108,6 @@ public class TrackDetailsMenuFragment extends Fragment {
} else { } else {
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark); AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} }
ImageButton backButton = (ImageButton) topBar.findViewById(R.id.top_bar_back_button);
backButton.setImageDrawable(ctx.getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha, R.color.color_white));
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.y_axis_title), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.y_axis_title), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.x_axis_title), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.x_axis_title), nightMode);
@ -145,21 +120,9 @@ public class TrackDetailsMenuFragment extends Fragment {
public static boolean showInstance(final MapActivity mapActivity) { public static boolean showInstance(final MapActivity mapActivity) {
try { try {
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
int slideInAnim;
int slideOutAnim;
if (portrait) {
slideInAnim = R.anim.slide_in_bottom;
slideOutAnim = R.anim.slide_out_bottom;
} else {
slideInAnim = R.anim.slide_in_left;
slideOutAnim = R.anim.slide_out_left;
}
TrackDetailsMenuFragment fragment = new TrackDetailsMenuFragment(); TrackDetailsMenuFragment fragment = new TrackDetailsMenuFragment();
mapActivity.getSupportFragmentManager().beginTransaction() mapActivity.getSupportFragmentManager().beginTransaction()
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim) .add(R.id.bottomFragmentContainer, fragment, TAG)
.add(R.id.routeMenuContainer, fragment, TAG)
.addToBackStack(TAG).commitAllowingStateLoss(); .addToBackStack(TAG).commitAllowingStateLoss();
return true; return true;

View file

@ -78,6 +78,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
private boolean cancelApplyingNewMarkerPosition; private boolean cancelApplyingNewMarkerPosition;
private LatLon applyingMarkerLatLon; private LatLon applyingMarkerLatLon;
private boolean wasCollapseButtonVisible; private boolean wasCollapseButtonVisible;
private boolean mInGpxDetailsMode;
private List<String> publicTransportTypes; private List<String> publicTransportTypes;
@ -240,6 +241,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
return mInChangeMarkerPositionMode; return mInChangeMarkerPositionMode;
} }
public boolean isInGpxDetailsMode() {
return mInGpxDetailsMode;
}
public boolean isObjectMoveable(Object o) { public boolean isObjectMoveable(Object o) {
if (o == null) { if (o == null) {
return true; return true;
@ -305,6 +310,34 @@ public class ContextMenuLayer extends OsmandMapLayer {
}); });
} }
public void enterGpxDetailsMode() {
menu.updateMapCenter(null);
menu.hide();
mInGpxDetailsMode = true;
mark(View.INVISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
View collapseButton = activity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
wasCollapseButtonVisible = true;
collapseButton.setVisibility(View.INVISIBLE);
} else {
wasCollapseButtonVisible = false;
}
}
public void exitGpxDetailsMode() {
mInGpxDetailsMode = false;
mark(View.VISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
View collapseButton = activity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && wasCollapseButtonVisible) {
collapseButton.setVisibility(View.VISIBLE);
}
}
private void quitMovingMarker() { private void quitMovingMarker() {
mInChangeMarkerPositionMode = false; mInChangeMarkerPositionMode = false;
mark(View.VISIBLE, R.id.map_ruler_layout, mark(View.VISIBLE, R.id.map_ruler_layout,
@ -314,7 +347,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (collapseButton != null && wasCollapseButtonVisible) { if (collapseButton != null && wasCollapseButtonVisible) {
collapseButton.setVisibility(View.VISIBLE); collapseButton.setVisibility(View.VISIBLE);
} }
} }
private void enterMovingMode(RotatedTileBox tileBox) { private void enterMovingMode(RotatedTileBox tileBox) {
@ -500,7 +532,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
} }
public boolean disableLongPressOnMap() { public boolean disableLongPressOnMap() {
if (mInChangeMarkerPositionMode) { if (mInChangeMarkerPositionMode || mInGpxDetailsMode) {
return true; return true;
} }
boolean res = false; boolean res = false;
@ -574,7 +606,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
@Override @Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
if (mInChangeMarkerPositionMode) { if (mInChangeMarkerPositionMode || mInGpxDetailsMode) {
return true; return true;
} }
@ -673,7 +705,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
switch (event.getAction()) { switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
if (!mInChangeMarkerPositionMode) { if (!mInChangeMarkerPositionMode && !mInGpxDetailsMode) {
selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true); selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true);
if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) { if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) {
view.refreshMap(); view.refreshMap();

View file

@ -632,11 +632,12 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningMode = true; routePlanningMode = true;
} }
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean dialogOpened = MapRouteInfoMenu.isVisible(); boolean routeDialogOpened = MapRouteInfoMenu.isVisible();
boolean showRouteCalculationControls = routePlanningMode || boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, dialogOpened); updateMyLocation(rh, routeDialogOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !isInChangeMarkerPositionMode(); boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInChangeMarkerPositionMode() && !isInGpxDetailsMode();
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) { if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation); routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
@ -651,15 +652,15 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningBtn.updateVisibility(showButtons); routePlanningBtn.updateVisibility(showButtons);
menuControl.updateVisibility(showButtons); menuControl.updateVisibility(showButtons);
mapZoomIn.updateVisibility(!dialogOpened); mapZoomIn.updateVisibility(!routeDialogOpened);
mapZoomOut.updateVisibility(!dialogOpened); mapZoomOut.updateVisibility(!routeDialogOpened);
compassHud.updateVisibility(!dialogOpened && shouldShowCompass()); compassHud.updateVisibility(!routeDialogOpened && shouldShowCompass());
if (layersHud.setIconResId(settings.getApplicationMode().getSmallIconDark())) { if (layersHud.setIconResId(settings.getApplicationMode().getSmallIconDark())) {
layersHud.update(app, isNight); layersHud.update(app, isNight);
} }
layersHud.updateVisibility(!dialogOpened); layersHud.updateVisibility(!routeDialogOpened);
quickSearchHud.updateVisibility(!dialogOpened); quickSearchHud.updateVisibility(!routeDialogOpened);
if (!routePlanningMode && !routeFollowingMode) { if (!routePlanningMode && !routeFollowingMode) {
if (mapView.isZooming()) { if (mapView.isZooming()) {
@ -1046,6 +1047,10 @@ public class MapControlsLayer extends OsmandMapLayer {
mapQuickActionLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode(); mapQuickActionLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode();
} }
private boolean isInGpxDetailsMode() {
return contextMenuLayer.isInGpxDetailsMode();
}
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) { public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
return new View.OnLongClickListener() { return new View.OnLongClickListener() {

View file

@ -48,6 +48,7 @@ public class MapInfoWidgetsFactory {
public enum TopToolbarControllerType { public enum TopToolbarControllerType {
QUICK_SEARCH, QUICK_SEARCH,
CONTEXT_MENU, CONTEXT_MENU,
TRACK_DETAILS,
DISCOUNT, DISCOUNT,
} }
@ -291,6 +292,7 @@ public class MapInfoWidgetsFactory {
} else { } else {
view.updateVisibility(descrView, false); view.updateVisibility(descrView, false);
} }
view.getShadowView().setVisibility(View.VISIBLE);
} }
} }
@ -305,6 +307,7 @@ public class MapInfoWidgetsFactory {
private TextView titleView; private TextView titleView;
private TextView descrView; private TextView descrView;
private ImageButton closeButton; private ImageButton closeButton;
private View shadowView;
private boolean nightMode; private boolean nightMode;
public TopToolbarView(final MapActivity map) { public TopToolbarView(final MapActivity map) {
@ -317,6 +320,7 @@ public class MapInfoWidgetsFactory {
closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button); closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button);
titleView = (TextView) map.findViewById(R.id.widget_top_bar_title); titleView = (TextView) map.findViewById(R.id.widget_top_bar_title);
descrView = (TextView) map.findViewById(R.id.widget_top_bar_description); descrView = (TextView) map.findViewById(R.id.widget_top_bar_description);
shadowView = map.findViewById(R.id.widget_top_bar_shadow);
updateVisibility(false); updateVisibility(false);
} }
@ -348,6 +352,10 @@ public class MapInfoWidgetsFactory {
return closeButton; return closeButton;
} }
public View getShadowView() {
return shadowView;
}
public TopToolbarController getTopController() { public TopToolbarController getTopController() {
if (controllers.size() > 0) { if (controllers.size() > 0) {
return controllers.get(controllers.size() - 1); return controllers.get(controllers.size() - 1);