From e98193c29d56c1f7cf12148e94a8882673c84cb5 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Sun, 9 Feb 2020 17:53:28 +0300 Subject: [PATCH] Fix back from conf map/screen --- .../src/net/osmand/plus/activities/MapActivity.java | 13 +++++++++++++ .../net/osmand/plus/dashboard/DashboardOnMap.java | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 909fac0b92..8de45d0011 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -26,6 +26,7 @@ import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentManager.BackStackEntry; import android.support.v4.content.ContextCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.AlertDialog; @@ -136,6 +137,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; import net.osmand.plus.settings.BaseSettingsFragment; import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType; +import net.osmand.plus.settings.ConfigureProfileFragment; import net.osmand.plus.settings.DataStorageFragment; import net.osmand.plus.settings.ProfileAppearanceFragment; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -2509,6 +2511,17 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(QuickActionListFragment.TAG); } + public void backToConfigureProfileFragment() { + FragmentManager fragmentManager = getSupportFragmentManager(); + int backStackEntryCount = fragmentManager.getBackStackEntryCount(); + if (backStackEntryCount > 0) { + BackStackEntry entry = fragmentManager.getBackStackEntryAt(backStackEntryCount - 1); + if (ConfigureProfileFragment.TAG.equals(entry.getName())) { + fragmentManager.popBackStack(); + } + } + } + T getFragment(String fragmentTag){ Fragment fragment = getSupportFragmentManager().findFragmentByTag(fragmentTag); return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (T) fragment : null; diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index ef138846b8..5b3d0d0b83 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1041,22 +1041,22 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo public boolean onBackPressed() { if (isVisible()) { - return backPressed(); + backPressed(); + return true; } return false; } - private boolean backPressed() { + private void backPressed() { if (previousVisibleType != visibleType && previousVisibleType != null) { if (visibleType == DashboardType.MAPILLARY) { hideKeyboard(); } visibleType = null; setDashboardVisibility(true, previousVisibleType); - return true; } else { hideDashboard(); - return false; + mapActivity.backToConfigureProfileFragment(); } }