Move map to fit gpx in track appearance screen
This commit is contained in:
parent
ae850bde77
commit
d8de7a25db
4 changed files with 50 additions and 8 deletions
|
@ -90,6 +90,10 @@
|
||||||
|
|
||||||
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
|
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/map_hud_controls"
|
||||||
|
tools:visibility="invisible" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/control_buttons"
|
android:id="@+id/control_buttons"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -112,8 +116,4 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/map_hud_controls"
|
|
||||||
tools:visibility="invisible" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -1244,6 +1244,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
mapRouteInfoMenu.updateMenu();
|
mapRouteInfoMenu.updateMenu();
|
||||||
MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude());
|
MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude());
|
||||||
} else if (toShow instanceof GPXFile) {
|
} else if (toShow instanceof GPXFile) {
|
||||||
|
hideContextAndRouteInfoMenues();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(TRACK_FILE_PATH, ((GPXFile) toShow).path);
|
args.putString(TRACK_FILE_PATH, ((GPXFile) toShow).path);
|
||||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuController.MenuState.HALF_SCREEN);
|
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuController.MenuState.HALF_SCREEN);
|
||||||
|
|
|
@ -54,12 +54,12 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.NewGpxData;
|
||||||
import net.osmand.plus.track.SplitIntervalCard;
|
|
||||||
import net.osmand.plus.track.SplitTrackAsyncTask;
|
|
||||||
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
|
||||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.track.GpxSplitType;
|
import net.osmand.plus.track.GpxSplitType;
|
||||||
|
import net.osmand.plus.track.SplitIntervalCard;
|
||||||
|
import net.osmand.plus.track.SplitTrackAsyncTask;
|
||||||
|
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
||||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||||
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||||
|
@ -363,7 +363,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTemporaryObjectOnMap(Object toShow){
|
private void showTemporaryObjectOnMap(Object toShow) {
|
||||||
TrackActivity activity = getTrackActivity();
|
TrackActivity activity = getTrackActivity();
|
||||||
GpxDataItem gpxDataItem = getGpxDataItem();
|
GpxDataItem gpxDataItem = getGpxDataItem();
|
||||||
GPXFile gpx = getGpx();
|
GPXFile gpx = getGpx();
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
@ -25,6 +26,8 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
|
@ -226,6 +229,12 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
adjustMapPosition(getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
@ -315,6 +324,15 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int applyPosY(int currentY, boolean needCloseMenu, boolean needMapAdjust, int previousMenuState, int newMenuState, int dZoom, boolean animated) {
|
||||||
|
int y = super.applyPosY(currentY, needCloseMenu, needMapAdjust, previousMenuState, newMenuState, dZoom, animated);
|
||||||
|
if (needMapAdjust) {
|
||||||
|
adjustMapPosition(y);
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
private void buildZoomButtons(@NonNull View view) {
|
private void buildZoomButtons(@NonNull View view) {
|
||||||
OsmandApplication app = requireMyApplication();
|
OsmandApplication app = requireMyApplication();
|
||||||
this.zoomButtonsView = view.findViewById(R.id.map_hud_controls);
|
this.zoomButtonsView = view.findViewById(R.id.map_hud_controls);
|
||||||
|
@ -444,6 +462,28 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
appearanceIcon.setImageDrawable(icon);
|
appearanceIcon.setImageDrawable(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void adjustMapPosition(int y) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null && mapActivity.getMapView() != null) {
|
||||||
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
|
QuadRect r = gpxFile.getRect();
|
||||||
|
|
||||||
|
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
|
||||||
|
int tileBoxWidthPx = 0;
|
||||||
|
int tileBoxHeightPx = 0;
|
||||||
|
|
||||||
|
if (!isPortrait()) {
|
||||||
|
tileBoxWidthPx = tb.getPixWidth() - getWidth();
|
||||||
|
} else {
|
||||||
|
int fHeight = getViewHeight() - y - AndroidUtils.getStatusBarHeight(mapActivity);
|
||||||
|
tileBoxHeightPx = tb.getPixHeight() - fHeight;
|
||||||
|
}
|
||||||
|
if (r.left != 0 && r.right != 0) {
|
||||||
|
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable getTrackIcon(OsmandApplication app, String widthAttr, boolean showArrows, @ColorInt int color) {
|
public Drawable getTrackIcon(OsmandApplication app, String widthAttr, boolean showArrows, @ColorInt int color) {
|
||||||
int widthIconId = getWidthIconId(widthAttr);
|
int widthIconId = getWidthIconId(widthAttr);
|
||||||
Drawable widthIcon = app.getUIUtilities().getPaintedIcon(widthIconId, color);
|
Drawable widthIcon = app.getUIUtilities().getPaintedIcon(widthIconId, color);
|
||||||
|
|
Loading…
Reference in a new issue