Add ContextMenuScrollFragment
This commit is contained in:
parent
9903021d58
commit
4fb89f78d1
5 changed files with 158 additions and 113 deletions
|
@ -6,7 +6,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/color_transparent">
|
android:background="@color/color_transparent">
|
||||||
|
|
||||||
<net.osmand.plus.mapcontextmenu.InterceptorLinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/main_view"
|
android:id="@+id/main_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/map_controls_container"
|
android:id="@+id/map_controls_container"
|
||||||
|
|
|
@ -62,7 +62,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
public static final int MIDDLE_STATE_MIN_HEIGHT_DP = 520;
|
public static final int MIDDLE_STATE_MIN_HEIGHT_DP = 520;
|
||||||
public static final String MENU_STATE_KEY = "menu_state_key";
|
public static final String MENU_STATE_KEY = "menu_state_key";
|
||||||
|
|
||||||
private InterceptorLinearLayout mainView;
|
private LinearLayout mainView;
|
||||||
private View view;
|
private View view;
|
||||||
private OnLayoutChangeListener containerLayoutListener;
|
private OnLayoutChangeListener containerLayoutListener;
|
||||||
private View topShadow;
|
private View topShadow;
|
||||||
|
@ -163,7 +163,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public InterceptorLinearLayout getMainView() {
|
public LinearLayout getMainView() {
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,6 +282,9 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
bottomContainer = (FrameLayout) view.findViewById(getBottomContainerViewId());
|
bottomContainer = (FrameLayout) view.findViewById(getBottomContainerViewId());
|
||||||
bottomScrollView = (LockableScrollView) view.findViewById(getBottomScrollViewId());
|
bottomScrollView = (LockableScrollView) view.findViewById(getBottomScrollViewId());
|
||||||
|
|
||||||
|
ViewConfiguration vc = ViewConfiguration.get(context);
|
||||||
|
final int touchSlop = vc.getScaledTouchSlop();
|
||||||
|
|
||||||
bottomScrollView.setScrollingEnabled(false);
|
bottomScrollView.setScrollingEnabled(false);
|
||||||
if (getTopViewId() != 0) {
|
if (getTopViewId() != 0) {
|
||||||
View topView = view.findViewById(getTopViewId());
|
View topView = view.findViewById(getTopViewId());
|
||||||
|
@ -349,7 +352,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
if (Math.abs(event.getRawY() - mDownY) > mainView.getTouchSlop()) {
|
if (Math.abs(event.getRawY() - mDownY) > touchSlop) {
|
||||||
moving = true;
|
moving = true;
|
||||||
}
|
}
|
||||||
if (moving) {
|
if (moving) {
|
||||||
|
@ -435,7 +438,9 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
((InterceptorLinearLayout) mainView).setListener(slideTouchListener);
|
if (mainView instanceof InterceptorLinearLayout) {
|
||||||
|
((InterceptorLinearLayout) mainView).setListener(slideTouchListener);
|
||||||
|
}
|
||||||
mainView.setOnTouchListener(slideTouchListener);
|
mainView.setOnTouchListener(slideTouchListener);
|
||||||
|
|
||||||
containerLayoutListener = new OnLayoutChangeListener() {
|
containerLayoutListener = new OnLayoutChangeListener() {
|
||||||
|
@ -618,7 +623,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
InterceptorLinearLayout mainView = getMainView();
|
LinearLayout mainView = getMainView();
|
||||||
if (mainView != null) {
|
if (mainView != null) {
|
||||||
return mainView.getWidth();
|
return mainView.getWidth();
|
||||||
} else {
|
} else {
|
||||||
|
|
142
OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java
Normal file
142
OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
package net.osmand.plus.base;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
|
import net.osmand.plus.base.ContextMenuFragment.ContextMenuFragmentListener;
|
||||||
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.BACK_TO_LOC_HUD_ID;
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.ZOOM_IN_HUD_ID;
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.ZOOM_OUT_HUD_ID;
|
||||||
|
|
||||||
|
public abstract class ContextMenuScrollFragment extends ContextMenuFragment implements ContextMenuFragmentListener {
|
||||||
|
|
||||||
|
public static final String TAG = ContextMenuScrollFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final String ZOOM_IN_BUTTON_ID = ZOOM_IN_HUD_ID + TAG;
|
||||||
|
private static final String ZOOM_OUT_BUTTON_ID = ZOOM_OUT_HUD_ID + TAG;
|
||||||
|
private static final String BACK_TO_LOC_BUTTON_ID = BACK_TO_LOC_HUD_ID + TAG;
|
||||||
|
|
||||||
|
private View mapControlsView;
|
||||||
|
|
||||||
|
private RulerWidget rulerWidget;
|
||||||
|
|
||||||
|
public float getMiddleStateKoef() {
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSupportedMenuStatesPortrait() {
|
||||||
|
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
|
if (view != null) {
|
||||||
|
setListener(this);
|
||||||
|
getBottomScrollView().setScrollingEnabled(true);
|
||||||
|
setupControlButtons(view);
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated) {
|
||||||
|
updateMapControlsPos(fragment, y, animated);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
||||||
|
updateMapControlsVisibility(menuState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||||
|
|
||||||
|
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
|
||||||
|
mapControlsLayer.removeHudButtons(Arrays.asList(ZOOM_IN_BUTTON_ID, ZOOM_OUT_BUTTON_ID, BACK_TO_LOC_BUTTON_ID));
|
||||||
|
|
||||||
|
MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer();
|
||||||
|
mapInfoLayer.removeRulerWidgets(Collections.singletonList(rulerWidget));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupControlButtons(@NonNull View view) {
|
||||||
|
MapActivity mapActivity = requireMapActivity();
|
||||||
|
mapControlsView = view.findViewById(R.id.map_controls_container);
|
||||||
|
|
||||||
|
View zoomInButtonView = mapControlsView.findViewById(R.id.map_zoom_in_button);
|
||||||
|
View zoomOutButtonView = mapControlsView.findViewById(R.id.map_zoom_out_button);
|
||||||
|
View myLocButtonView = mapControlsView.findViewById(R.id.map_my_location_button);
|
||||||
|
View mapRulerView = mapControlsView.findViewById(R.id.map_ruler_layout);
|
||||||
|
|
||||||
|
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||||
|
|
||||||
|
OsmandMapTileView mapTileView = mapActivity.getMapView();
|
||||||
|
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
|
||||||
|
|
||||||
|
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
|
||||||
|
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
|
||||||
|
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID);
|
||||||
|
mapControlsLayer.setupBackToLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID);
|
||||||
|
|
||||||
|
MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer();
|
||||||
|
rulerWidget = mapInfoLayer.setupRulerWidget(mapRulerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMapControlsPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
|
||||||
|
View mapControlsView = this.mapControlsView;
|
||||||
|
if (mapControlsView != null) {
|
||||||
|
int zoomY = y - getMapControlsHeight();
|
||||||
|
if (animated) {
|
||||||
|
fragment.animateView(mapControlsView, zoomY);
|
||||||
|
} else {
|
||||||
|
mapControlsView.setY(zoomY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getMapControlsHeight() {
|
||||||
|
View mapControlsContainer = this.mapControlsView;
|
||||||
|
return mapControlsContainer != null ? mapControlsContainer.getHeight() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMapControlsVisibility(int menuState) {
|
||||||
|
if (mapControlsView != null) {
|
||||||
|
if (menuState == MenuState.HEADER_ONLY) {
|
||||||
|
if (mapControlsView.getVisibility() != View.VISIBLE) {
|
||||||
|
mapControlsView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mapControlsView.getVisibility() == View.VISIBLE) {
|
||||||
|
mapControlsView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,7 +56,6 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
|
@ -67,7 +66,6 @@ import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
|
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.mapcontextmenu.InterceptorLinearLayout;
|
|
||||||
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
import net.osmand.plus.mapcontextmenu.CollapsableView;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||||
import net.osmand.plus.render.MapRenderRepositories;
|
import net.osmand.plus.render.MapRenderRepositories;
|
||||||
|
@ -83,6 +81,7 @@ import net.osmand.plus.routing.RouteCalculationResult;
|
||||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.TransportRoutingHelper;
|
import net.osmand.plus.routing.TransportRoutingHelper;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.transport.TransportStopRoute;
|
import net.osmand.plus.transport.TransportStopRoute;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||||
|
@ -315,7 +314,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
statisticCard = new RouteStatisticCard(mapActivity, gpx, new OnTouchListener() {
|
statisticCard = new RouteStatisticCard(mapActivity, gpx, new OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent ev) {
|
public boolean onTouch(View v, MotionEvent ev) {
|
||||||
InterceptorLinearLayout mainView = getMainView();
|
LinearLayout mainView = getMainView();
|
||||||
if (mainView != null) {
|
if (mainView != null) {
|
||||||
mainView.requestDisallowInterceptTouchEvent(true);
|
mainView.requestDisallowInterceptTouchEvent(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,13 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.MapActivityLayers;
|
import net.osmand.plus.base.ContextMenuScrollFragment;
|
||||||
import net.osmand.plus.base.ContextMenuFragment;
|
|
||||||
import net.osmand.plus.base.ContextMenuFragment.ContextMenuFragmentListener;
|
|
||||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
|
||||||
import net.osmand.plus.views.MapInfoLayer;
|
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
|
||||||
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
|
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -52,29 +46,20 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.BACK_TO_LOC_HUD_ID;
|
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.ZOOM_IN_HUD_ID;
|
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.ZOOM_OUT_HUD_ID;
|
|
||||||
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING;
|
||||||
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME;
|
||||||
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR;
|
||||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD;
|
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD;
|
||||||
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM;
|
||||||
|
|
||||||
public class TrackAppearanceFragment extends ContextMenuFragment implements CardListener, ContextMenuFragmentListener {
|
public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener {
|
||||||
|
|
||||||
public static final String TAG = TrackAppearanceFragment.class.getSimpleName();
|
public static final String TAG = TrackAppearanceFragment.class.getSimpleName();
|
||||||
|
|
||||||
private static final Log log = PlatformUtil.getLog(TrackAppearanceFragment.class);
|
private static final Log log = PlatformUtil.getLog(TrackAppearanceFragment.class);
|
||||||
|
|
||||||
private static final String ZOOM_IN_BUTTON_ID = ZOOM_IN_HUD_ID + TAG;
|
|
||||||
private static final String ZOOM_OUT_BUTTON_ID = ZOOM_OUT_HUD_ID + TAG;
|
|
||||||
private static final String BACK_TO_LOC_BUTTON_ID = BACK_TO_LOC_HUD_ID + TAG;
|
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -90,9 +75,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
private SplitIntervalCard splitIntervalCard;
|
private SplitIntervalCard splitIntervalCard;
|
||||||
|
|
||||||
private ImageView appearanceIcon;
|
private ImageView appearanceIcon;
|
||||||
private View mapControlsView;
|
|
||||||
|
|
||||||
private RulerWidget rulerWidget;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMainLayoutId() {
|
public int getMainLayoutId() {
|
||||||
|
@ -182,7 +164,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
appearanceIcon = view.findViewById(R.id.appearance_icon);
|
appearanceIcon = view.findViewById(R.id.appearance_icon);
|
||||||
setListener(this);
|
|
||||||
|
|
||||||
if (isPortrait()) {
|
if (isPortrait()) {
|
||||||
updateCardsLayout();
|
updateCardsLayout();
|
||||||
|
@ -196,7 +177,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
params.gravity = Gravity.BOTTOM | Gravity.START;
|
params.gravity = Gravity.BOTTOM | Gravity.START;
|
||||||
view.findViewById(R.id.control_buttons).setLayoutParams(params);
|
view.findViewById(R.id.control_buttons).setLayoutParams(params);
|
||||||
}
|
}
|
||||||
setupControlButtons(view);
|
|
||||||
enterTrackAppearanceMode();
|
enterTrackAppearanceMode();
|
||||||
runLayoutListener();
|
runLayoutListener();
|
||||||
}
|
}
|
||||||
|
@ -223,21 +203,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
updateStatusBarColor();
|
updateStatusBarColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated) {
|
|
||||||
updateMapControlsPos(fragment, y, animated);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
|
||||||
updateMapControlsVisibility(menuState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -266,17 +231,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
exitTrackAppearanceMode();
|
exitTrackAppearanceMode();
|
||||||
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
|
||||||
|
|
||||||
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
|
|
||||||
mapControlsLayer.removeHudButtons(Arrays.asList(ZOOM_IN_BUTTON_ID, ZOOM_OUT_BUTTON_ID, BACK_TO_LOC_BUTTON_ID));
|
|
||||||
|
|
||||||
MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer();
|
|
||||||
mapInfoLayer.removeRulerWidgets(Collections.singletonList(rulerWidget));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterTrackAppearanceMode() {
|
private void enterTrackAppearanceMode() {
|
||||||
|
@ -371,61 +325,6 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupControlButtons(@NonNull View view) {
|
|
||||||
MapActivity mapActivity = requireMapActivity();
|
|
||||||
mapControlsView = view.findViewById(R.id.map_controls_container);
|
|
||||||
|
|
||||||
View zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
|
|
||||||
View zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
|
|
||||||
View myLocButtonView = view.findViewById(R.id.map_my_location_button);
|
|
||||||
View mapRulerView = view.findViewById(R.id.map_ruler_layout);
|
|
||||||
|
|
||||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
|
||||||
|
|
||||||
OsmandMapTileView mapTileView = mapActivity.getMapView();
|
|
||||||
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
|
|
||||||
|
|
||||||
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
|
|
||||||
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
|
|
||||||
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID);
|
|
||||||
mapControlsLayer.setupBackToLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID);
|
|
||||||
|
|
||||||
MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer();
|
|
||||||
rulerWidget = mapInfoLayer.setupRulerWidget(mapRulerView);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateMapControlsPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
|
|
||||||
View mapControlsView = this.mapControlsView;
|
|
||||||
if (mapControlsView != null) {
|
|
||||||
int zoomY = y - getMapControlsHeight();
|
|
||||||
if (animated) {
|
|
||||||
fragment.animateView(mapControlsView, zoomY);
|
|
||||||
} else {
|
|
||||||
mapControlsView.setY(zoomY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getMapControlsHeight() {
|
|
||||||
View mapControlsContainer = this.mapControlsView;
|
|
||||||
return mapControlsContainer != null ? mapControlsContainer.getHeight() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateMapControlsVisibility(int menuState) {
|
|
||||||
View mapControlsView = this.mapControlsView;
|
|
||||||
if (mapControlsView != null) {
|
|
||||||
if (menuState == MenuState.HEADER_ONLY) {
|
|
||||||
if (mapControlsView.getVisibility() != View.VISIBLE) {
|
|
||||||
mapControlsView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mapControlsView.getVisibility() == View.VISIBLE) {
|
|
||||||
mapControlsView.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateAppearanceIcon() {
|
private void updateAppearanceIcon() {
|
||||||
Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor());
|
||||||
appearanceIcon.setImageDrawable(icon);
|
appearanceIcon.setImageDrawable(icon);
|
||||||
|
|
Loading…
Reference in a new issue