This commit is contained in:
androiddevkotlin 2021-03-21 15:39:13 +02:00
parent a8719b542f
commit 53c817e811
2 changed files with 25 additions and 28 deletions

View file

@ -158,15 +158,6 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
updateCardsLayout();
}
updateCards();
final LockableScrollView profileContainer = mainView.findViewById(R.id.route_menu_bottom_scroll);
profileContainer.postDelayed(new Runnable() {
@Override
public void run() {
if (snapToRoadAppMode.getOrder() > 4) {
profileContainer.fullScroll(View.FOCUS_DOWN);
}
}
}, 100);
updateButtons(mainView);
progressBar = mainView.findViewById(R.id.progress_bar);
@ -185,6 +176,16 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
calculateGpxApproximation(true);
final LockableScrollView profileView = mainView.findViewById(R.id.route_menu_bottom_scroll);
final LinearLayout profileContainer = mainView.findViewById(R.id.route_menu_cards_container);
profileView.postDelayed(new Runnable() {
@Override
public void run() {
int selectedProfilePosition = profileContainer.getHeight() / ApplicationMode.values(getMyApplication()).size() * snapToRoadAppMode.getOrder();
profileView.scrollTo(0, selectedProfilePosition);
}
}, 100);
return mainView;
}

View file

@ -132,8 +132,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private ImageView mainIcon;
private String fileName;
private OnBackPressedCallback onBackPressedCallback;
private boolean isShowSnapWarning;
private static final String SHOW_SNAP_WARNING = "show_snap_warning";
private boolean showSnapWarning;
private InfoType currentInfoType;
@ -237,11 +236,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
if (mapActivity == null) {
return null;
}
if (savedInstanceState != null) {
restoreState(savedInstanceState);
} else if (getArguments() != null) {
restoreState(getArguments());
}
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
final OsmandApplication app = mapActivity.getMyApplication();
@ -559,12 +554,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
});
isShowSnapWarning = getArguments().getBoolean(SHOW_SNAP_WARNING);
initMeasurementMode(gpxData, savedInstanceState == null);
if (savedInstanceState == null) {
if (fileName != null) {
addNewGpxData(getGpxFile(fileName));
} else if (editingCtx.isApproximationNeeded() && isFollowTrackMode()) {
} else if (editingCtx.isApproximationNeeded() && isFollowTrackMode() && showSnapWarning) {
enterApproximationMode(mapActivity);
}
} else {
@ -673,6 +667,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
this.fileName = fileName;
}
public boolean isShowSnapWarning() {
return this.showSnapWarning;
}
public void setShowSnapWarning(boolean showSnapWarning) {
this.showSnapWarning = showSnapWarning;
}
public MeasurementEditingContext getEditingCtx() {
return editingCtx;
}
@ -1965,13 +1968,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
boolean followTrackMode, boolean isShowSnapWarning) {
boolean followTrackMode, boolean showSnapWarning) {
MeasurementToolFragment fragment = new MeasurementToolFragment();
fragment.setEditingCtx(editingCtx);
fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode);
Bundle bundle = new Bundle();
bundle.putBoolean(SHOW_SNAP_WARNING, isShowSnapWarning);
fragment.setArguments(bundle);
fragment.setShowSnapWarning(showSnapWarning);
return showFragment(fragment, fragmentManager);
}
@ -2114,9 +2115,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
manager.beginTransaction()
.hide(this).commit();
layer.setTapsDisabled(true);
if (isShowSnapWarning) {
SnapTrackWarningFragment.showInstance(mapActivity.getSupportFragmentManager(), this);
}
SnapTrackWarningFragment.showInstance(mapActivity.getSupportFragmentManager(), this);
AndroidUiHelper.setVisibility(mapActivity, View.GONE, R.id.map_ruler_container);
}
}
@ -2142,7 +2141,4 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
void onUpdateInfo();
}
public void restoreState(Bundle bundle) {
isShowSnapWarning = bundle.getBoolean(SHOW_SNAP_WARNING);
}
}