Fix back stack (380)

This commit is contained in:
Alexey Kulish 2016-02-06 18:04:30 +03:00
parent cace34ce32
commit c5ef6bc4f4
3 changed files with 25 additions and 4 deletions

View file

@ -409,6 +409,12 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
setIntent(intent); setIntent(intent);
} }
@Override
public void startActivity(Intent intent) {
clearPrevActivityIntent();
super.startActivity(intent);
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (dashboardOnMap.onBackPressed()) { if (dashboardOnMap.onBackPressed()) {
@ -1035,7 +1041,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
} }
} }
public static void clearPrevActivityIntent() {
prevActivityIntent = null;
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {

View file

@ -559,6 +559,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.closeDrawer(); mapActivity.closeDrawer();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
return true; return true;
@ -568,6 +569,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
return false; return false;
} }
@ -576,6 +578,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
enterRoutePlanningMode(null, null); enterRoutePlanningMode(null, null);
} else { } else {
@ -622,6 +625,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true); mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true);
return true; return true;
} }
@ -631,6 +635,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
return false; return false;
} }
@ -640,6 +645,7 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
return false; return false;
} }
@ -658,7 +664,7 @@ public class MapActivityActions implements DialogProvider {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadActivity()); .getDownloadActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent); mapActivity.startActivity(newIntent);
return true; return true;
} }
@ -669,6 +675,7 @@ public class MapActivityActions implements DialogProvider {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent intent = new Intent(mapActivity, OsmLiveActivity.class); Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent); mapActivity.startActivity(intent);
return false; return false;
} }
@ -680,7 +687,7 @@ public class MapActivityActions implements DialogProvider {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization() Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getPluginsActivity()); .getPluginsActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent); mapActivity.startActivity(newIntent);
return true; return true;
} }
@ -693,6 +700,7 @@ public class MapActivityActions implements DialogProvider {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization() final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
.getSettingsActivity()); .getSettingsActivity());
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(settings); mapActivity.startActivity(settings);
return true; return true;
} }
@ -701,7 +709,9 @@ public class MapActivityActions implements DialogProvider {
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { 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; return true;
} }
}).reg(); }).reg();

View file

@ -187,6 +187,7 @@ public class MapControlsLayer extends OsmandMapLayer {
configureMap.setOnClickListener(new View.OnClickListener() { configureMap.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
} }
}); });
@ -329,6 +330,7 @@ public class MapControlsLayer extends OsmandMapLayer {
backToMenuButton.setOnClickListener(new View.OnClickListener() { backToMenuButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
MapActivity.clearPrevActivityIntent();
if (dash) { if (dash) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
} else { } else {
@ -375,6 +377,7 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
private void onNavigationClick() { private void onNavigationClick() {
MapActivity.clearPrevActivityIntent();
RoutingHelper routingHelper = mapActivity.getRoutingHelper(); RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) { if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
mapActivity.getMapActions().enterRoutePlanningMode(null, null); mapActivity.getMapActions().enterRoutePlanningMode(null, null);