Make map movable while gpx detail is displaying
This commit is contained in:
parent
fafb1136a7
commit
424b400f18
7 changed files with 104 additions and 117 deletions
|
@ -220,7 +220,13 @@
|
|||
<include layout="@layout/recording_note_fragment"
|
||||
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
|
||||
android:id="@+id/map_context_menu_layout"
|
||||
|
|
|
@ -6,69 +6,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/color_transparent"
|
||||
android:clickable="true"
|
||||
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>
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_view"
|
||||
|
|
|
@ -33,6 +33,8 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
|||
import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
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.util.ArrayList;
|
||||
|
@ -44,6 +46,7 @@ public class TrackDetailsMenu {
|
|||
private OsmandMapTileView mapView;
|
||||
private MapControlsLayer mapControlsLayer;
|
||||
private GpxDisplayItem gpxItem;
|
||||
private TrackDetailsBarController toolbarController;
|
||||
|
||||
private static boolean VISIBLE;
|
||||
private boolean nightMode;
|
||||
|
@ -72,13 +75,22 @@ public class TrackDetailsMenu {
|
|||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
if (!portrait) {
|
||||
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();
|
||||
|
||||
TrackDetailsMenuFragment.showInstance(mapActivity);
|
||||
|
||||
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
|
||||
mapActivity.getMapLayers().getContextMenuLayer().enterGpxDetailsMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,10 +121,13 @@ public class TrackDetailsMenu {
|
|||
|
||||
public void onDismiss() {
|
||||
VISIBLE = false;
|
||||
if (toolbarController != null) {
|
||||
mapActivity.hideTopToolbar(toolbarController);
|
||||
}
|
||||
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
|
||||
mapActivity.getMapLayers().getGpxLayer().setSelectedPointLatLon(null);
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void updateInfo(final View main) {
|
||||
|
@ -334,4 +349,24 @@ public class TrackDetailsMenu {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.support.v4.app.FragmentManager;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -21,7 +20,6 @@ public class TrackDetailsMenuFragment extends Fragment {
|
|||
|
||||
private TrackDetailsMenu menu;
|
||||
private View mainView;
|
||||
private View topBar;
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
|
@ -38,24 +36,7 @@ public class TrackDetailsMenuFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
|
||||
|
@ -100,11 +81,7 @@ public class TrackDetailsMenuFragment extends Fragment {
|
|||
}
|
||||
|
||||
public void show(MapActivity mapActivity) {
|
||||
int slideInAnim = R.anim.slide_in_bottom;
|
||||
int slideOutAnim = R.anim.slide_out_bottom;
|
||||
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.routeMenuContainer, this, TAG)
|
||||
.addToBackStack(TAG)
|
||||
.commitAllowingStateLoss();
|
||||
|
@ -131,8 +108,6 @@ public class TrackDetailsMenuFragment extends Fragment {
|
|||
} else {
|
||||
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.x_axis_title), nightMode);
|
||||
|
@ -145,21 +120,9 @@ public class TrackDetailsMenuFragment extends Fragment {
|
|||
|
||||
public static boolean showInstance(final MapActivity mapActivity) {
|
||||
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();
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.routeMenuContainer, fragment, TAG)
|
||||
.add(R.id.bottomFragmentContainer, fragment, TAG)
|
||||
.addToBackStack(TAG).commitAllowingStateLoss();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -78,6 +78,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private boolean cancelApplyingNewMarkerPosition;
|
||||
private LatLon applyingMarkerLatLon;
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean mInGpxDetailsMode;
|
||||
|
||||
private List<String> publicTransportTypes;
|
||||
|
||||
|
@ -240,6 +241,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
return mInChangeMarkerPositionMode;
|
||||
}
|
||||
|
||||
public boolean isInGpxDetailsMode() {
|
||||
return mInGpxDetailsMode;
|
||||
}
|
||||
|
||||
public boolean isObjectMoveable(Object o) {
|
||||
if (o == null) {
|
||||
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() {
|
||||
mInChangeMarkerPositionMode = false;
|
||||
mark(View.VISIBLE, R.id.map_ruler_layout,
|
||||
|
@ -314,7 +347,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
if (collapseButton != null && wasCollapseButtonVisible) {
|
||||
collapseButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void enterMovingMode(RotatedTileBox tileBox) {
|
||||
|
@ -500,7 +532,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public boolean disableLongPressOnMap() {
|
||||
if (mInChangeMarkerPositionMode) {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode) {
|
||||
return true;
|
||||
}
|
||||
boolean res = false;
|
||||
|
@ -574,7 +606,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if (mInChangeMarkerPositionMode) {
|
||||
if (mInChangeMarkerPositionMode || mInGpxDetailsMode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -673,7 +705,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (!mInChangeMarkerPositionMode) {
|
||||
if (!mInChangeMarkerPositionMode && !mInGpxDetailsMode) {
|
||||
selectObjectsForContextMenu(tileBox, new PointF(event.getX(), event.getY()), true);
|
||||
if (pressedLatLonFull.size() > 0 || pressedLatLonSmall.size() > 0) {
|
||||
view.refreshMap();
|
||||
|
|
|
@ -632,11 +632,12 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
routePlanningMode = true;
|
||||
}
|
||||
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
|
||||
boolean dialogOpened = MapRouteInfoMenu.isVisible();
|
||||
boolean routeDialogOpened = MapRouteInfoMenu.isVisible();
|
||||
boolean showRouteCalculationControls = routePlanningMode ||
|
||||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
updateMyLocation(rh, dialogOpened);
|
||||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !isInChangeMarkerPositionMode();
|
||||
updateMyLocation(rh, routeDialogOpened);
|
||||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
|
||||
&& !isInChangeMarkerPositionMode() && !isInGpxDetailsMode();
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
|
||||
if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
|
@ -651,15 +652,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
routePlanningBtn.updateVisibility(showButtons);
|
||||
menuControl.updateVisibility(showButtons);
|
||||
|
||||
mapZoomIn.updateVisibility(!dialogOpened);
|
||||
mapZoomOut.updateVisibility(!dialogOpened);
|
||||
compassHud.updateVisibility(!dialogOpened && shouldShowCompass());
|
||||
mapZoomIn.updateVisibility(!routeDialogOpened);
|
||||
mapZoomOut.updateVisibility(!routeDialogOpened);
|
||||
compassHud.updateVisibility(!routeDialogOpened && shouldShowCompass());
|
||||
|
||||
if (layersHud.setIconResId(settings.getApplicationMode().getSmallIconDark())) {
|
||||
layersHud.update(app, isNight);
|
||||
}
|
||||
layersHud.updateVisibility(!dialogOpened);
|
||||
quickSearchHud.updateVisibility(!dialogOpened);
|
||||
layersHud.updateVisibility(!routeDialogOpened);
|
||||
quickSearchHud.updateVisibility(!routeDialogOpened);
|
||||
|
||||
if (!routePlanningMode && !routeFollowingMode) {
|
||||
if (mapView.isZooming()) {
|
||||
|
@ -1046,6 +1047,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapQuickActionLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode();
|
||||
}
|
||||
|
||||
private boolean isInGpxDetailsMode() {
|
||||
return contextMenuLayer.isInGpxDetailsMode();
|
||||
}
|
||||
|
||||
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
|
||||
return new View.OnLongClickListener() {
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public class MapInfoWidgetsFactory {
|
|||
public enum TopToolbarControllerType {
|
||||
QUICK_SEARCH,
|
||||
CONTEXT_MENU,
|
||||
TRACK_DETAILS,
|
||||
DISCOUNT,
|
||||
}
|
||||
|
||||
|
@ -291,6 +292,7 @@ public class MapInfoWidgetsFactory {
|
|||
} else {
|
||||
view.updateVisibility(descrView, false);
|
||||
}
|
||||
view.getShadowView().setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,6 +307,7 @@ public class MapInfoWidgetsFactory {
|
|||
private TextView titleView;
|
||||
private TextView descrView;
|
||||
private ImageButton closeButton;
|
||||
private View shadowView;
|
||||
private boolean nightMode;
|
||||
|
||||
public TopToolbarView(final MapActivity map) {
|
||||
|
@ -317,6 +320,7 @@ public class MapInfoWidgetsFactory {
|
|||
closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button);
|
||||
titleView = (TextView) map.findViewById(R.id.widget_top_bar_title);
|
||||
descrView = (TextView) map.findViewById(R.id.widget_top_bar_description);
|
||||
shadowView = map.findViewById(R.id.widget_top_bar_shadow);
|
||||
updateVisibility(false);
|
||||
}
|
||||
|
||||
|
@ -348,6 +352,10 @@ public class MapInfoWidgetsFactory {
|
|||
return closeButton;
|
||||
}
|
||||
|
||||
public View getShadowView() {
|
||||
return shadowView;
|
||||
}
|
||||
|
||||
public TopToolbarController getTopController() {
|
||||
if (controllers.size() > 0) {
|
||||
return controllers.get(controllers.size() - 1);
|
||||
|
|
Loading…
Reference in a new issue