[routing] Add possibility to save routes as tracks

Signed-off-by: cyber-toad <the.cyber.toad@proton.me>
This commit is contained in:
cyber-toad
2025-03-11 10:13:57 +01:00
committed by Konstantin Pastbin
parent 9e8accc8f5
commit 45bba5fb5e
16 changed files with 165 additions and 18 deletions

View File

@@ -1143,6 +1143,12 @@ Java_app_organicmaps_Framework_nativeShowTrackRect(JNIEnv * env, jclass, jlong t
frm()->ShowTrack(static_cast<kml::TrackId>(track));
}
JNIEXPORT void JNICALL
Java_app_organicmaps_Framework_nativeSaveRoute(JNIEnv *, jclass)
{
frm()->SaveRoute();
}
JNIEXPORT jstring JNICALL
Java_app_organicmaps_Framework_nativeGetBookmarkDir(JNIEnv * env, jclass)
{

View File

@@ -356,4 +356,6 @@ public class Framework
public static native void nativeDidCloseProductsPopup(String reason);
public static native void nativeDidSelectProduct(String title, String link);
public static native void nativeSaveRoute();
}

View File

@@ -90,7 +90,7 @@ final class RoutingBottomMenuController implements View.OnClickListener
@NonNull
static RoutingBottomMenuController newInstance(@NonNull Activity activity, @NonNull View frame,
@Nullable RoutingBottomMenuListener listener)
@NonNull RoutingBottomMenuListener listener)
{
View altitudeChartFrame = getViewById(activity, frame, R.id.altitude_chart_panel);
View timeElevationLine = getViewById(activity, frame, R.id.time_elevation_line);
@@ -158,6 +158,9 @@ final class RoutingBottomMenuController implements View.OnClickListener
res.getDimensionPixelSize(R.dimen.margin_half));
Button manageRouteButton = altitudeChartFrame.findViewById(R.id.btn__manage_route);
manageRouteButton.setOnClickListener(this);
Button saveButton = altitudeChartFrame.findViewById(R.id.btn__save);
saveButton.setOnClickListener(this);
}
void showAltitudeChartAndRoutingDetails()
@@ -168,6 +171,9 @@ final class RoutingBottomMenuController implements View.OnClickListener
showRouteAltitudeChart();
showRoutingDetails();
UiUtils.show(mAltitudeChartFrame);
Button saveButton = mAltitudeChartFrame.findViewById(R.id.btn__save);
saveButton.setText(R.string.save);
saveButton.setEnabled(true);
}
void hideAltitudeChartAndRoutingDetails()
@@ -484,14 +490,21 @@ final class RoutingBottomMenuController implements View.OnClickListener
public void onClick(View v)
{
final int id = v.getId();
if (id == R.id.btn__my_position_use && mListener != null)
if (id == R.id.btn__my_position_use)
mListener.onUseMyPositionAsStart();
else if (id == R.id.btn__search_point && mListener != null)
else if (id == R.id.btn__search_point)
{
final RouteMarkType pointType = (RouteMarkType) mActionMessage.getTag();
mListener.onSearchRoutePoint(pointType);
}
else if (id == R.id.btn__manage_route && mListener != null)
else if (id == R.id.btn__manage_route)
mListener.onManageRouteOpen();
else if (id == R.id.btn__save)
{
Framework.nativeSaveRoute();
Button saveButton = v.findViewById(R.id.btn__save);
saveButton.setEnabled(false);
saveButton.setText(R.string.saved);
}
}
}

View File

@@ -86,7 +86,7 @@ public class RoutingPlanController extends ToolbarController
RoutingPlanController(View root, Activity activity,
ActivityResultLauncher<Intent> startDrivingOptionsForResult,
@NonNull RoutingPlanInplaceController.RoutingPlanListener routingPlanListener,
@Nullable RoutingBottomMenuListener listener)
@NonNull RoutingBottomMenuListener listener)
{
super(root, activity);
mFrame = root;

View File

@@ -73,6 +73,17 @@
android:drawableStart="@drawable/ic_manage_route"
android:drawablePadding="6dp"/>
<Button
android:id="@+id/btn__save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/margin_base"
android:minHeight="@dimen/primary_button_min_height"
style="@style/MwmWidget.Button"
android:text="@string/save"/>
<Button
android:id="@+id/start"
style="@style/MwmWidget.Button.Primary"
@@ -80,7 +91,7 @@
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginStart="@dimen/margin_double"
android:minWidth="@dimen/start_button_width"
android:text="@string/p2p_start"
tools:showIn="@layout/menu_route_plan_line" />

View File

@@ -92,6 +92,15 @@
android:drawableStart="@drawable/ic_manage_route"
android:drawablePadding="6dp"/>
<Button
android:id="@+id/btn__save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_base"
style="@style/MwmWidget.Button"
android:minHeight="@dimen/primary_button_min_height"
android:text="@string/save"/>
<Button
android:id="@+id/start"
style="@style/MwmWidget.Button.Primary"
@@ -99,7 +108,7 @@
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/margin_base"
android:layout_marginStart="@dimen/margin_double"
android:minWidth="@dimen/start_button_width"
android:text="@string/p2p_start"
tools:showIn="@layout/menu_route_plan_line" />

View File

@@ -83,13 +83,28 @@
android:layout_gravity="center_vertical" />
</LinearLayout>
<Button
android:id="@+id/btn__manage_route"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MwmWidget.Button"
android:text="@string/planning_route_manage_route"
android:drawableStart="@drawable/ic_manage_route"
android:drawablePadding="6dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical" >
<Button
android:id="@+id/btn__manage_route"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MwmWidget.Button"
android:text="@string/planning_route_manage_route"
android:drawableStart="@drawable/ic_manage_route"
android:drawablePadding="6dp"/>
<Button
android:id="@+id/btn__save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MwmWidget.Button"
android:layout_marginStart="@dimen/margin_base"
android:minHeight="@dimen/primary_button_min_height"
android:text="@string/save"/>
</LinearLayout>
</LinearLayout>

View File

@@ -655,6 +655,7 @@
<string name="button_plan">Plan</string>
<string name="placepage_remove_stop">Remove Stop</string>
<string name="placepage_add_stop">Add Stop</string>
<string name="saved">Saved</string>
<!-- Alert to ask user relogin to OpenStreetMap with OAuth2 flow after OAuth1 authentication is deprecated. -->
<string name="alert_reauth_message">Please login to OpenStreetMap to automatically upload all your map edits. Learn more <a href="https://github.com/organicmaps/organicmaps/issues/6144">here</a>.</string>
<string name="dialog_error_storage_title">Storage access problem</string>