show route on map from another screen

This commit is contained in:
Emin 2024-06-07 20:15:38 +05:00
parent ba0f2bb041
commit dce2313723
4 changed files with 43 additions and 0 deletions

View file

@ -54,6 +54,7 @@ if (googleFirebaseServicesEnabled) {
apply plugin: 'com.github.triplet.play'
apply plugin: 'ru.cian.huawei-publish-gradle-plugin'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'kotlin-parcelize'
def run(cmd) {
def stdout = new ByteArrayOutputStream()

View file

@ -12,6 +12,8 @@ import android.location.Location;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.KeyEvent;
@ -46,6 +48,7 @@ import app.organicmaps.base.BaseMwmFragmentActivity;
import app.organicmaps.base.OnBackPressListener;
import app.organicmaps.bookmarks.BookmarkCategoriesActivity;
import app.organicmaps.bookmarks.data.BookmarkManager;
import app.organicmaps.bookmarks.data.FeatureId;
import app.organicmaps.bookmarks.data.MapObject;
import app.organicmaps.display.DisplayChangedListener;
import app.organicmaps.display.DisplayManager;
@ -107,6 +110,8 @@ import app.organicmaps.widget.menu.MainMenu;
import app.organicmaps.widget.placepage.PlacePageController;
import app.organicmaps.widget.placepage.PlacePageData;
import app.organicmaps.widget.placepage.PlacePageViewModel;
import app.tourism.data.dto.SiteLocation;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.ArrayList;
@ -544,6 +549,25 @@ public class MwmActivity extends BaseMwmFragmentActivity
*/
if (Map.isEngineCreated())
onRenderingInitializationFinished();
routeForSiteFromMainActivityHandling();
}
private void routeForSiteFromMainActivityHandling() {
Handler handler = new Handler(Looper.getMainLooper());
Runnable delayedAction = new Runnable() {
@Override
public void run() {
showRouteForSiteFromMainActivity();
}
};
handler.postDelayed(delayedAction, 1000);
}
private void showRouteForSiteFromMainActivity() {
SiteLocation endPoint = getIntent().getParcelableExtra("end_point");
startLocationToPoint(endPoint.toMapObject());
}
private void refreshLightStatusBar()

View file

@ -17,6 +17,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.core.content.ContextCompat.startActivity
import app.organicmaps.DownloadResourcesLegacyActivity
import app.tourism.data.dto.SiteLocation
import app.tourism.ui.theme.OrganicMapsTheme
@ -48,6 +49,10 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
Button(
onClick = {
val intent = Intent(context, DownloadResourcesLegacyActivity::class.java)
intent.putExtra(
"end_point",
SiteLocation("Name", 38.573, 68.807)
)
startActivity(context, intent, null)
},
) {

View file

@ -0,0 +1,13 @@
package app.tourism.data.dto
import android.os.Parcelable
import app.organicmaps.bookmarks.data.FeatureId
import app.organicmaps.bookmarks.data.MapObject
import kotlinx.parcelize.Parcelize
@Parcelize
data class SiteLocation(val name: String, val lat: Double, val lon: Double) : Parcelable {
fun toMapObject() = MapObject.createMapObject(
FeatureId.EMPTY, MapObject.POI, name, "", lat, lon
);
}