Add select navigation type on the Navigation setting fragment
This commit is contained in:
parent
81ae45adaa
commit
bef023d3aa
3 changed files with 34 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="select_nav_profile_dialog_message">Navigation type affects the rules for route calculations.</string>
|
||||
<string name="add_new_profile_q">Add new profile \'%1$s\'?</string>
|
||||
<string name="save_heading">Include heading</string>
|
||||
<string name="save_heading_descr">Save heading to each trackpoint while recording.</string>
|
||||
|
|
|
@ -135,6 +135,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
|
||||
} else if (type.equals(TYPE_NAV_PROFILE)){
|
||||
items.add(new TitleItem(getString(R.string.select_nav_profile_dialog_title)));
|
||||
items.add(new LongDescriptionItem(getString(R.string.select_nav_profile_dialog_message)));
|
||||
for (int i = 0; i < profiles.size(); i++) {
|
||||
final int pos = i;
|
||||
final ProfileDataObject profile = profiles.get(i);
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.profiles.EditProfileFragment.RoutingProfilesResources;
|
||||
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
||||
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.DIALOG_TYPE;
|
||||
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY;
|
||||
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
|
||||
|
||||
public class NavigationFragment extends BaseSettingsFragment {
|
||||
|
||||
|
@ -20,7 +28,10 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
|
||||
SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId());
|
||||
|
||||
navigationType.setIcon(getContentIcon(R.drawable.ic_action_car_dark));
|
||||
GeneralRouter gr = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile());
|
||||
RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(gr.getProfileName().toUpperCase());
|
||||
navigationType.setSummary(routingProfilesResources.getStringRes());
|
||||
navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes()));
|
||||
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
|
||||
showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert));
|
||||
speakRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_volume_up));
|
||||
|
@ -42,6 +53,26 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
return super.onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals("navigation_type")) {
|
||||
if (getSelectedAppMode().isCustomProfile()) {
|
||||
final SelectProfileBottomSheetDialogFragment dialog = new SelectProfileBottomSheetDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
if (getSelectedAppMode() != null) {
|
||||
bundle.putString(SELECTED_KEY, getSelectedAppMode().getRoutingProfile());
|
||||
}
|
||||
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
|
||||
dialog.setArguments(bundle);
|
||||
if (getActivity() != null) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.add(dialog, "select_nav_type").commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setupVehicleParametersPref() {
|
||||
Preference vehicleParameters = findPreference("vehicle_parameters");
|
||||
int iconRes = getSelectedAppMode().getIconRes();
|
||||
|
|
Loading…
Reference in a new issue