Fix manage profile on road preparation

This commit is contained in:
Dima-1 2019-12-27 19:25:13 +02:00
parent 187390eed5
commit 706f47891c
4 changed files with 22 additions and 16 deletions

View file

@ -1,7 +1,6 @@
package net.osmand.plus.profiles;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@ -9,14 +8,11 @@ import android.view.ContextThemeWrapper;
import android.view.View;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
import net.osmand.plus.settings.BaseSettingsFragment;
public abstract class AppModesBottomSheetDialogFragment<T extends AbstractProfileMenuAdapter> extends MenuBottomSheetDialogFragment
implements AbstractProfileMenuAdapter.ButtonPressedListener, AbstractProfileMenuAdapter.ProfilePressedListener {
@ -79,17 +75,13 @@ public abstract class AppModesBottomSheetDialogFragment<T extends AbstractProfil
@Override
public void onProfilePressed(ApplicationMode item) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
intent.putExtra(IS_USER_PROFILE, item.isCustomProfile());
startActivity(intent);
this.dismiss();
BaseSettingsFragment.showInstance(getActivity(), BaseSettingsFragment.SettingsScreenType.CONFIGURE_PROFILE, item);
}
@Override
public void onButtonPressed() {
OsmandApplication app = requiredMyApplication();
Intent intent = new Intent(app, SettingsProfileActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
this.dismiss();
BaseSettingsFragment.showInstance(getActivity(), BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS);
}
}

View file

@ -69,6 +69,8 @@ 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.ConfigureAppModesBottomSheetDialogFragment;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
@ -94,7 +96,6 @@ 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;
@ -793,7 +794,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
private void showProfileBottomSheetDialog() {
BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS);
final AppModesBottomSheetDialogFragment fragment = new ConfigureAppModesBottomSheetDialogFragment();
fragment.setUsedOnMap(true);
fragment.setUpdateMapRouteMenuListener(new AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener() {
@Override
public void updateAppModeMenu() {
updateApplicationModes();
}
});
getMapActivity().getSupportFragmentManager().beginTransaction()
.add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
}
private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) {

View file

@ -134,6 +134,10 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(isChecked ? R.string.shared_string_on : R.string.shared_string_off);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapRouteInfoMenu().updateMenu();
}
}
@Override

View file

@ -540,7 +540,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (isChanged()) {
AlertDialog.Builder dismissDialog = createWarningDialog(getActivity(),
R.string.shared_string_dismiss, R.string.exit_without_saving, R.string.shared_string_cancel);
dismissDialog.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
dismissDialog.setPositiveButton(R.string.shared_string_exit, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changedProfile = profile;