diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f28cc3ca27..507593ef14 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -409,6 +409,12 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents, setIntent(intent); } + @Override + public void startActivity(Intent intent) { + clearPrevActivityIntent(); + super.startActivity(intent); + } + @Override public void onBackPressed() { if (dashboardOnMap.onBackPressed()) { @@ -1035,7 +1041,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents, } } - + public static void clearPrevActivityIntent() { + prevActivityIntent = null; + } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 66b5921e26..be100fed8d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -559,6 +559,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + MapActivity.clearPrevActivityIntent(); mapActivity.closeDrawer(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); return true; @@ -568,6 +569,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + MapActivity.clearPrevActivityIntent(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); return false; } @@ -576,6 +578,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + MapActivity.clearPrevActivityIntent(); if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { enterRoutePlanningMode(null, null); } else { @@ -622,6 +625,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + MapActivity.clearPrevActivityIntent(); mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true); return true; } @@ -631,6 +635,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + MapActivity.clearPrevActivityIntent(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); return false; } @@ -640,6 +645,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + MapActivity.clearPrevActivityIntent(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN); return false; } @@ -658,7 +664,7 @@ public class MapActivityActions implements DialogProvider { public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getDownloadActivity()); - // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mapActivity.startActivity(newIntent); return true; } @@ -669,6 +675,7 @@ public class MapActivityActions implements DialogProvider { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { Intent intent = new Intent(mapActivity, OsmLiveActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mapActivity.startActivity(intent); return false; } @@ -680,7 +687,7 @@ public class MapActivityActions implements DialogProvider { public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() .getPluginsActivity()); - // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mapActivity.startActivity(newIntent); return true; } @@ -693,6 +700,7 @@ public class MapActivityActions implements DialogProvider { public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization() .getSettingsActivity()); + settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mapActivity.startActivity(settings); return true; } @@ -701,7 +709,9 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - mapActivity.startActivity(new Intent(mapActivity, HelpActivity.class)); + Intent intent = new Intent(mapActivity, HelpActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + mapActivity.startActivity(intent); return true; } }).reg(); diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index ed46b40f1c..42f5852aff 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -187,6 +187,7 @@ public class MapControlsLayer extends OsmandMapLayer { configureMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + MapActivity.clearPrevActivityIntent(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); } }); @@ -329,6 +330,7 @@ public class MapControlsLayer extends OsmandMapLayer { backToMenuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + MapActivity.clearPrevActivityIntent(); if (dash) { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); } else { @@ -375,6 +377,7 @@ public class MapControlsLayer extends OsmandMapLayer { } private void onNavigationClick() { + MapActivity.clearPrevActivityIntent(); RoutingHelper routingHelper = mapActivity.getRoutingHelper(); if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { mapActivity.getMapActions().enterRoutePlanningMode(null, null);