diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 4d36ea9073..590e04fb19 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -133,6 +133,7 @@ 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.DataStorageFragment; +import net.osmand.plus.settings.MainSettingsFragment; import net.osmand.plus.settings.ProfileAppearanceFragment; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; import net.osmand.plus.views.AnimateDraggingMapThread; @@ -683,6 +684,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return; } } + MainSettingsFragment mainSettingsFragment = getMainSettingsFragment(); + if (mainSettingsFragment != null) { + mainSettingsFragment.close(); + } if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) { if (mapContextMenu.getCurrentMenuState() != MenuState.HEADER_ONLY && !isLandscapeLayout()) { mapContextMenu.openMenuHeaderOnly(); @@ -2415,6 +2420,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(QuickActionListFragment.TAG); } + public MainSettingsFragment getMainSettingsFragment() { + return getFragment(MainSettingsFragment.TAG); + } + 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/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 6430a68197..c9d8445948 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -59,7 +59,6 @@ import net.osmand.plus.mapmarkers.MapMarkersDialogFragment; import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; -import net.osmand.plus.profiles.SettingsProfileActivity; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.WaypointsFragment; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; @@ -706,9 +705,7 @@ public class MapActivityActions implements DialogProvider { .setListener(new ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) { - Intent intent = new Intent(app, SettingsProfileActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - app.startActivity(intent); + BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS); return true; } }) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index c263554288..3e4569d956 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -19,7 +19,6 @@ import android.support.transition.Transition; import android.support.transition.TransitionListenerAdapter; import android.support.transition.TransitionManager; import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; import android.support.v4.content.ContextCompat; import android.support.v7.widget.AppCompatImageView; import android.view.View; @@ -70,9 +69,6 @@ import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenuFragment; import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment; import net.osmand.plus.poi.PoiUIFilter; -import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment; -import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener; -import net.osmand.plus.profiles.ConfigureAppModesBottomSheetDialogFragment; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter; @@ -98,6 +94,7 @@ import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.search.QuickSearchHelper; +import net.osmand.plus.settings.BaseSettingsFragment; import net.osmand.plus.widgets.TextViewExProgress; import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter.RoutingParameter; @@ -796,16 +793,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener } private void showProfileBottomSheetDialog() { - final AppModesBottomSheetDialogFragment fragment = new ConfigureAppModesBottomSheetDialogFragment(); - fragment.setUsedOnMap(true); - fragment.setUpdateMapRouteMenuListener(new UpdateMapRouteMenuListener() { - @Override - public void updateAppModeMenu() { - updateApplicationModes(); - } - }); - getMapActivity().getSupportFragmentManager().beginTransaction() - .add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss(); + BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS); } private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) { diff --git a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java index fc21889ed7..00aecf503d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/MainSettingsFragment.java @@ -16,6 +16,7 @@ import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment; import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener; @@ -38,7 +39,7 @@ public class MainSettingsFragment extends BaseSettingsFragment { private static final String APP_PROFILES = "app_profiles"; private static final String SELECTED_PROFILE = "selected_profile"; private static final String CREATE_PROFILE = "create_profile"; - private static final String IMPORT_PROFILE = "import_profile"; + // private static final String IMPORT_PROFILE = "import_profile"; private static final String REORDER_PROFILES = "reorder_profiles"; private List allAppModes; @@ -136,7 +137,7 @@ public class MainSettingsFragment extends BaseSettingsFragment { Preference createProfile = findPreference(CREATE_PROFILE); createProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_plus, isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); - Preference importProfile = findPreference(IMPORT_PROFILE); +// Preference importProfile = findPreference(IMPORT_PROFILE); // importProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_import, // isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light)); Preference reorderProfiles = findPreference(REORDER_PROFILES); @@ -198,4 +199,11 @@ public class MainSettingsFragment extends BaseSettingsFragment { } return selectProfileListener; } + + public void close() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMapRouteInfoMenu().updateMenu(); + } + } } \ No newline at end of file