Settings second part

This commit is contained in:
Chumva 2019-08-08 15:57:43 +03:00
parent e54ab110c5
commit 9180a996f8
19 changed files with 282 additions and 149 deletions

View file

@ -8,7 +8,7 @@
android:layout="@layout/preference_with_descr"
android:summary="@string/general_settings_profile_descr"
android:title="@string/general_settings_2"
app:fragment="net.osmand.plus.settings.GeneralProfileSettings"
app:fragment="net.osmand.plus.settings.ProfileGeneralSettings"
tools:icon="@drawable/ic_action_settings" />
<Preference
@ -16,7 +16,7 @@
android:layout="@layout/preference_with_descr"
android:summary="@string/configure_navigation"
android:title="@string/routing_settings_2"
app:fragment="net.osmand.plus.settings.SettingsNavigationFragment"
app:fragment="net.osmand.plus.settings.NavigationFragment"
tools:icon="@drawable/ic_action_gdirections_dark" />
<Preference
@ -24,7 +24,7 @@
android:layout="@layout/preference_with_descr"
android:summary="@string/map_look_descr"
android:title="@string/map_look"
app:fragment="net.osmand.plus.settings.SettingsRouteParametersFragment"
app:fragment="net.osmand.plus.settings.RouteParametersFragment"
tools:icon="@drawable/ic_action_layers_dark" />
<Preference

View file

@ -18,12 +18,14 @@
android:key="rotate_map"
android:layout="@layout/preference_with_descr"
android:summary="@string/rotate_map_to_bearing_descr"
android:defaultValue="0"
android:title="@string/rotate_map_to_bearing" />
<net.osmand.plus.views.ListIntPreference
android:key="map_screen_orientation"
android:layout="@layout/preference_with_descr"
android:summary="@string/map_screen_orientation_descr"
android:defaultValue="-1"
android:title="@string/map_screen_orientation" />
<Preference
@ -62,4 +64,29 @@
android:selectable="false"
android:title="@string/shared_string_other" />
<SwitchPreference
android:key="use_kalman_filter_compass"
android:layout="@layout/preference_fragment_and_switch"
android:title="@string/use_kalman_filter_compass" />
<SwitchPreference
android:key="use_magnetic_field_sensor_compass"
android:layout="@layout/preference_fragment_and_switch"
android:title="@string/use_magnetic_sensor" />
<SwitchPreference
android:key="full_screen_mode"
android:layout="@layout/preference_fragment_and_switch"
android:title="@string/use_kalman_filter_compass" />
<SwitchPreference
android:key="do_not_use_animations"
android:layout="@layout/preference_fragment_and_switch"
android:title="@string/do_not_use_animations" />
<net.osmand.plus.views.ListIntPreference
android:key="external_input_device"
android:layout="@layout/preference_fragment_and_switch"
android:title="@string/external_input_device" />
</PreferenceScreen>

View file

@ -8,7 +8,7 @@
android:layout="@layout/preference_with_descr"
android:summary="@string/route_parameters_descr"
android:title="@string/route_parameters"
app:fragment="net.osmand.plus.settings.SettingsRouteParametersFragment"
app:fragment="net.osmand.plus.settings.RouteParametersFragment"
tools:icon="@drawable/ic_action_track_16" />
<net.osmand.plus.views.SwitchFragmentPreference
@ -17,7 +17,7 @@
android:switchTextOff="@string/shared_string_off"
android:switchTextOn="@string/shared_string_on"
android:title="@string/screen_alerts"
app:fragment="net.osmand.plus.settings.SettingsScreenAlertsFragment"
app:fragment="net.osmand.plus.settings.ScreenAlertsFragment"
tools:icon="@drawable/ic_action_alert" />
<net.osmand.plus.views.SwitchFragmentPreference
@ -25,7 +25,7 @@
android:layout="@layout/preference_fragment_and_switch"
android:summary="@string/voice_announces_descr"
android:title="@string/voice_announces"
app:fragment="net.osmand.plus.settings.SettingsVoiceAnnouncesFragment"
app:fragment="net.osmand.plus.settings.VoiceAnnouncesFragment"
tools:icon="@drawable/ic_action_volume_up" />
<Preference
@ -33,7 +33,7 @@
android:layout="@layout/preference_with_descr"
android:summary="@string/vehicle_parameters_descr"
android:title="@string/vehicle_parameters"
app:fragment="net.osmand.plus.settings.SettingsVehicleParametersFragment"
app:fragment="net.osmand.plus.settings.VehicleParametersFragment"
tools:icon="@drawable/ic_action_car_dark" />
<Preference
@ -47,7 +47,7 @@
android:layout="@layout/preference_with_descr"
android:summary="@string/map_during_navigation"
android:title="@string/map_during_navigation"
app:fragment="net.osmand.plus.settings.SettingsMapDuringNavigationFragment"
app:fragment="net.osmand.plus.settings.MapDuringNavigationFragment"
tools:icon="@drawable/ic_action_copy" />
<net.osmand.plus.views.SwitchFragmentPreference
@ -56,7 +56,7 @@
android:switchTextOff="@string/shared_string_off"
android:switchTextOn="@string/shared_string_on"
android:title="@string/turn_screen_on"
app:fragment="net.osmand.plus.settings.SettingsTurnScreenOnFragment"
app:fragment="net.osmand.plus.settings.TurnScreenOnFragment"
tools:icon="@drawable/ic_action_copy" />
<Preference

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<Preference
android:key="personal_account"
android:layout="@layout/preference_with_descr"
android:summary="@string/personal_account_descr"
android:title="@string/personal_account"
app:fragment="net.osmand.plus.settings.ProfileGeneralSettings"
tools:icon="@drawable/ic_person" />
<Preference
android:key="global_settings"
android:layout="@layout/preference_with_descr"
android:summary="@string/osmand_settings_descr"
android:title="@string/osmand_settings"
app:fragment="net.osmand.plus.settings.NavigationFragment"
tools:icon="@drawable/ic_action_settings" />
<Preference
android:key="application_profiles"
android:layout="@layout/simple_preference_category"
android:selectable="false"
android:title="@string/application_profiles" />
<Preference
android:key="browse_map"
android:layout="@layout/preference_with_descr"
android:summary="@string/map_look_descr"
android:title="@string/rendering_value_browse_map_name"
app:fragment="net.osmand.plus.settings.RouteParametersFragment"
tools:icon="@drawable/ic_world_globe_dark" />
<Preference
android:key="configure_profile"
android:layout="@layout/preference_with_descr"
android:title="@string/configure_profile"
app:fragment="net.osmand.plus.settings.ConfigureProfileFragment"
tools:icon="@drawable/ic_action_car_dark" />
<Preference
android:key="manage_profiles"
android:layout="@layout/preference_with_descr"
android:summary="@string/manage_profiles_descr"
android:title="@string/manage_profiles"
app:fragment="net.osmand.plus.profiles.SettingsProfileFragment"
tools:icon="@drawable/ic_action_manage_profiles" />
</PreferenceScreen>

View file

@ -1819,6 +1819,22 @@ public class OsmandAidlApi {
return res;
}
public void updateConnectedApps() {
try {
JSONArray array = new JSONArray(app.getSettings().API_CONNECTED_APPS_JSON.get());
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);
String pack = obj.optString(ConnectedApp.PACK_KEY, "");
ConnectedApp connectedApp = connectedApps.get(pack);
if (connectedApp != null) {
connectedApp.enabled = obj.optBoolean(ConnectedApp.ENABLED_KEY, true);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public boolean switchEnabled(@NonNull ConnectedApp app) {
app.enabled = !app.enabled;
return saveConnectedApps();

View file

@ -203,6 +203,16 @@ public class OsmandSettings {
return settingsAPI.getPreferenceObject(getSharedPreferencesName(mode));
}
public void updateCachedPreference(String key) {
OsmandSettings.OsmandPreference pref = registeredPreferences.get(key);
if (pref instanceof OsmandSettings.CommonPreference) {
OsmandSettings.CommonPreference commonPreference = (OsmandSettings.CommonPreference) pref;
if (commonPreference.cache && commonPreference.cachedValue != null) {
commonPreference.cachedValue = null;
}
}
}
public boolean setPreference(String key, Object value) {
OsmandPreference<?> preference = registeredPreferences.get(key);
if (preference != null) {
@ -1060,11 +1070,11 @@ public class OsmandSettings {
new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeGlobal();
// magnetic field doesn'torkmost of the time on some phones
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeGlobal().cache();
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache();
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeProfile().cache();
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeProfile().cache();
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache();
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeGlobal().cache();
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeProfile().cache();
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache();
public final OsmandPreference<Boolean> SEND_ANONYMOUS_APP_USAGE_DATA = new BooleanPreference("send_anonymous_app_usage_data", false).makeGlobal().cache();
public final OsmandPreference<Boolean> SEND_ANONYMOUS_DATA_REQUEST_PROCESSED = new BooleanPreference("send_anonymous_data_request_processed", false).makeGlobal().cache();
@ -1515,8 +1525,7 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> ANIMATE_MY_LOCATION = new BooleanPreference("animate_my_location", true).makeGlobal().cache();
public final OsmandPreference<Integer> EXTERNAL_INPUT_DEVICE =
new IntPreference("external_input_device", 0).makeGlobal();
public final OsmandPreference<Integer> EXTERNAL_INPUT_DEVICE = new IntPreference("external_input_device", 0).makeProfile();
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_START_MY_LOC = new BooleanPreference("route_map_markers_start_my_loc", false).makeGlobal().cache();
public final OsmandPreference<Boolean> ROUTE_MAP_MARKERS_ROUND_TRIP = new BooleanPreference("route_map_markers_round_trip", false).makeGlobal().cache();

View file

@ -125,7 +125,7 @@ import net.osmand.plus.routing.TransportRoutingHelper.TransportRouteCalculationP
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.settings.SettingsBaseProfileDependentFragment;
import net.osmand.plus.settings.BaseProfileSettingsFragment;
import net.osmand.plus.settings.SettingsMainFragment;
import net.osmand.plus.settings.profiles.EditProfileFragment;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
@ -1408,6 +1408,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public void updateApplicationModeSettings() {
updateMapSettings();
OsmandPlugin.updateActivatedPlugins(app);
getMyApplication().getAidlApi().updateConnectedApps();
mapViewTrackingUtilities.updateSettings();
//app.getRoutingHelper().setAppMode(settings.getApplicationMode());
if (mapLayers.getMapInfoLayer() != null) {
@ -1925,8 +1926,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
if (caller instanceof SettingsBaseProfileDependentFragment) {
SettingsBaseProfileDependentFragment baseFragment = (SettingsBaseProfileDependentFragment) caller;
if (caller instanceof BaseProfileSettingsFragment) {
BaseProfileSettingsFragment baseFragment = (BaseProfileSettingsFragment) caller;
ApplicationMode mode = baseFragment.getSelectedMode();
if (mode != null) {

View file

@ -19,11 +19,11 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceGroup;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageView;
import android.widget.TextView;
@ -33,18 +33,20 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.profiles.AppProfileArrayAdapter;
import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.views.SwitchFragmentPreference;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public abstract class SettingsBaseProfileDependentFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
public abstract class BaseProfileSettingsFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
protected OsmandApplication app;
protected OsmandSettings settings;
@ -53,6 +55,7 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
protected ApplicationMode selectedAppMode = null;
private boolean nightMode;
private boolean wasDrawerDisabled;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -86,6 +89,27 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
return view;
}
@Override
public void onResume() {
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
wasDrawerDisabled = mapActivity.isDrawerDisabled();
if (!wasDrawerDisabled) {
mapActivity.disableDrawer();
}
}
}
@Override
public void onPause() {
super.onPause();
MapActivity mapActivity = getMapActivity();
if (!wasDrawerDisabled && mapActivity != null) {
mapActivity.enableDrawer();
}
}
private void createToolbar(LayoutInflater inflater, View view) {
AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.appbar);
@ -182,6 +206,18 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
return -1;
}
protected Preference findAndRegisterPreference(String key) {
Preference preference = getPreferenceScreen().findPreference(key);
registerPreference(preference);
return preference;
}
protected void registerPreference(Preference preference) {
if (preference != null) {
preference.setOnPreferenceChangeListener(this);
}
}
public ApplicationMode getSelectedMode() {
return selectedAppMode;
}
@ -190,6 +226,16 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
return nightMode;
}
@Nullable
public MapActivity getMapActivity() {
FragmentActivity activity = getActivity();
if (activity instanceof MapActivity) {
return (MapActivity) activity;
} else {
return null;
}
}
@Nullable
protected OsmandApplication getMyApplication() {
FragmentActivity activity = getActivity();
@ -277,14 +323,17 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
// ------------------------------------------------------------------------------------------------
public SwitchPreference registerBooleanPreference(OsmandSettings.OsmandPreference<Boolean> b, PreferenceGroup screen) {
SwitchPreference p = (SwitchPreference) screen.findPreference(b.getId());
public SwitchPreference createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary) {
SwitchPreference p = new SwitchPreference(getContext());
p.setTitle(title);
p.setKey(b.getId());
p.setSummary(summary);
p.setOnPreferenceChangeListener(this);
return p;
}
public SwitchPreference createSwitchPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary) {
SwitchPreference p = new SwitchPreference(getContext());
public SwitchPreference createSwitchFragmentPreference(OsmandSettings.OsmandPreference<Boolean> b, int title, int summary) {
SwitchFragmentPreference p = new SwitchFragmentPreference(getContext());
p.setTitle(title);
p.setKey(b.getId());
p.setSummary(summary);
@ -300,22 +349,13 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
return p;
}
public <T> ListPreference createListPreference(OsmandSettings.OsmandPreference<T> b, String[] names, T[] values, int title, int summary) {
ListPreference p = new ListPreference(getContext());
p.setTitle(title);
p.setKey(b.getId());
p.setDialogTitle(title);
p.setSummary(summary);
prepareListPreference(b, names, values, p);
return p;
}
public <T> ListPreference createListPreference(OsmandSettings.OsmandPreference<T> b, String[] names, T[] values, String title, String summary) {
ListPreference p = new ListPreference(getContext());
p.setTitle(title);
p.setKey(b.getId());
p.setDialogTitle(title);
p.setSummary(summary);
p.setOnPreferenceChangeListener(this);
prepareListPreference(b, names, values, p);
return p;
}
@ -409,6 +449,10 @@ public abstract class SettingsBaseProfileDependentFragment extends PreferenceFra
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// handle boolean preferences
String key = preference.getKey();
if (preference.isPersistent()) {
settings.updateCachedPreference(key);
}
return true;
}

View file

@ -22,9 +22,9 @@ import java.util.List;
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class SettingsConfigureProfileFragment extends SettingsBaseProfileDependentFragment {
public class ConfigureProfileFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsConfigureProfileFragment";
public static final String TAG = "ConfigureProfileFragment";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -56,13 +56,12 @@ public class SettingsConfigureProfileFragment extends SettingsBaseProfileDepende
for (ConnectedApp connectedApp : connectedApps) {
SwitchPreference preference = new SwitchPreference(getContext());
preference.setKey(connectedApp.getPack());
preference.setTitle(connectedApp.getName());
preference.setIcon(connectedApp.getIcon());
preference.setChecked(connectedApp.isEnabled());
preference.setLayoutResource(R.layout.preference_fragment_and_switch);
preference.setOnPreferenceChangeListener(this);
registerPreference(preference);
screen.addPreference(preference);
}
@ -73,8 +72,8 @@ public class SettingsConfigureProfileFragment extends SettingsBaseProfileDepende
preference.setTitle(plugin.getName());
preference.setIcon(getContentIcon(plugin.getLogoResourceId()));
preference.setChecked(plugin.isActive());
preference.setOnPreferenceChangeListener(this);
preference.setLayoutResource(R.layout.preference_fragment_and_switch);
registerPreference(preference);
Intent intent = new Intent(getContext(), PluginActivity.class);
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
@ -111,12 +110,12 @@ public class SettingsConfigureProfileFragment extends SettingsBaseProfileDepende
Bundle args = new Bundle();
args.putString(PROFILE_STRING_KEY, mode.getStringKey());
SettingsConfigureProfileFragment settingsConfigureProfileFragment = new SettingsConfigureProfileFragment();
settingsConfigureProfileFragment.setArguments(args);
ConfigureProfileFragment configureProfileFragment = new ConfigureProfileFragment();
configureProfileFragment.setArguments(args);
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsConfigureProfileFragment, SettingsConfigureProfileFragment.TAG)
.addToBackStack(SettingsConfigureProfileFragment.TAG)
.add(R.id.fragmentContainer, configureProfileFragment, ConfigureProfileFragment.TAG)
.addToBackStack(ConfigureProfileFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -15,9 +15,9 @@ import net.osmand.plus.R;
import net.osmand.plus.views.ListFloatPreference;
import net.osmand.plus.views.ListIntPreference;
public class SettingsMapDuringNavigationFragment extends SettingsBaseProfileDependentFragment {
public class MapDuringNavigationFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsMapDuringNavigationFragment";
public static final String TAG = "MapDuringNavigationFragment";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -49,14 +49,14 @@ public class SettingsMapDuringNavigationFragment extends SettingsBaseProfileDepe
for (int i = 1; i < intValues.length; i++) {
entries[i] = intValues[i] + " " + getString(R.string.int_seconds);
}
ListIntPreference autoFollowRoute = (ListIntPreference) screen.findPreference(settings.AUTO_FOLLOW_ROUTE.getId());
ListIntPreference autoFollowRoute = (ListIntPreference) findAndRegisterPreference(settings.AUTO_FOLLOW_ROUTE.getId());
autoFollowRoute.setEntries(entries);
autoFollowRoute.setEntryValues(intValues);
Preference autoZoomMap = screen.findPreference(settings.AUTO_ZOOM_MAP.getId());
Preference autoZoomMap = findAndRegisterPreference(settings.AUTO_ZOOM_MAP.getId());
autoZoomMap.setOnPreferenceClickListener(this);
SwitchPreference snapToRoad = (SwitchPreference) screen.findPreference(settings.SNAP_TO_ROAD.getId());
SwitchPreference snapToRoad = (SwitchPreference) findAndRegisterPreference(settings.SNAP_TO_ROAD.getId());
String[] speedNamesPos;
float[] speedLimitsPos;
@ -80,7 +80,7 @@ public class SettingsMapDuringNavigationFragment extends SettingsBaseProfileDepe
}
}
ListFloatPreference switchMapDirectionToCompass = (ListFloatPreference) screen.findPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS.getId());
ListFloatPreference switchMapDirectionToCompass = (ListFloatPreference) findAndRegisterPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS.getId());
switchMapDirectionToCompass.setEntries(speedNamesPos);
switchMapDirectionToCompass.setEntryValues(speedLimitsPos);
}
@ -105,10 +105,10 @@ public class SettingsMapDuringNavigationFragment extends SettingsBaseProfileDepe
public static boolean showInstance(FragmentManager fragmentManager) {
try {
SettingsMapDuringNavigationFragment settingsNavigationFragment = new SettingsMapDuringNavigationFragment();
MapDuringNavigationFragment settingsNavigationFragment = new MapDuringNavigationFragment();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsMapDuringNavigationFragment.TAG)
.addToBackStack(SettingsMapDuringNavigationFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, MapDuringNavigationFragment.TAG)
.addToBackStack(MapDuringNavigationFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -13,12 +13,11 @@ import android.widget.Toast;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R;
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.settings.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class SettingsNavigationFragment extends SettingsBaseProfileDependentFragment {
public class NavigationFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsNavigationFragment";
public static final String TAG = "NavigationFragment";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -46,21 +45,14 @@ public class SettingsNavigationFragment extends SettingsBaseProfileDependentFrag
protected void createUI() {
PreferenceScreen screen = getPreferenceScreen();
Preference route_parameters = screen.findPreference("route_parameters");
Preference route_parameters = findAndRegisterPreference("route_parameters");
SwitchPreference show_routing_alarms = (SwitchPreference) screen.findPreference("show_routing_alarms");
SwitchPreference speak_routing_alarms = (SwitchPreference) screen.findPreference("speak_routing_alarms");
Preference vehicle_parameters = screen.findPreference("vehicle_parameters");
Preference map_during_navigation = screen.findPreference("map_during_navigation");
SwitchPreference turn_screen_on = (SwitchPreference) screen.findPreference("turn_screen_on");
Preference reset_to_default = screen.findPreference("reset_to_default");
route_parameters.setOnPreferenceChangeListener(this);
show_routing_alarms.setOnPreferenceChangeListener(this);
speak_routing_alarms.setOnPreferenceChangeListener(this);
vehicle_parameters.setOnPreferenceChangeListener(this);
map_during_navigation.setOnPreferenceChangeListener(this);
turn_screen_on.setOnPreferenceChangeListener(this);
SwitchPreference show_routing_alarms = (SwitchPreference) findAndRegisterPreference("show_routing_alarms");
SwitchPreference speak_routing_alarms = (SwitchPreference) findAndRegisterPreference("speak_routing_alarms");
Preference vehicle_parameters = findAndRegisterPreference("vehicle_parameters");
Preference map_during_navigation = findAndRegisterPreference("map_during_navigation");
SwitchPreference turn_screen_on = (SwitchPreference) findAndRegisterPreference("turn_screen_on");
Preference reset_to_default = findAndRegisterPreference("reset_to_default");
route_parameters.setIcon(getContentIcon(R.drawable.ic_action_track_16));
show_routing_alarms.setIcon(getContentIcon(R.drawable.ic_action_alert));
@ -88,12 +80,12 @@ public class SettingsNavigationFragment extends SettingsBaseProfileDependentFrag
Bundle args = new Bundle();
args.putString(PROFILE_STRING_KEY, mode.getStringKey());
SettingsNavigationFragment settingsNavigationFragment = new SettingsNavigationFragment();
NavigationFragment settingsNavigationFragment = new NavigationFragment();
settingsNavigationFragment.setArguments(args);
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsNavigationFragment.TAG)
.addToBackStack(SettingsNavigationFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, NavigationFragment.TAG)
.addToBackStack(NavigationFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -14,9 +14,9 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.views.ListIntPreference;
public class GeneralProfileSettings extends SettingsBaseProfileDependentFragment {
public class ProfileGeneralSettings extends BaseProfileSettingsFragment {
public static final String TAG = "GeneralProfileSettings";
public static final String TAG = "ProfileGeneralSettings";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -42,15 +42,15 @@ public class GeneralProfileSettings extends SettingsBaseProfileDependentFragment
protected void createUI() {
PreferenceScreen screen = getPreferenceScreen();
ListIntPreference appTheme = (ListIntPreference) screen.findPreference(settings.OSMAND_THEME.getId());
ListIntPreference appTheme = (ListIntPreference) findAndRegisterPreference(settings.OSMAND_THEME.getId());
appTheme.setEntries(new String[]{getString(R.string.dark_theme), getString(R.string.light_theme)});
appTheme.setEntryValues(new int[]{OsmandSettings.OSMAND_DARK_THEME, OsmandSettings.OSMAND_LIGHT_THEME});
ListIntPreference rotateMap = (ListIntPreference) screen.findPreference(settings.ROTATE_MAP.getId());
ListIntPreference rotateMap = (ListIntPreference) findAndRegisterPreference(settings.ROTATE_MAP.getId());
rotateMap.setEntries(new String[]{getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)});
rotateMap.setEntryValues(new int[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS});
ListIntPreference mapScreenOrientation = (ListIntPreference) screen.findPreference(settings.MAP_SCREEN_ORIENTATION.getId());
ListIntPreference mapScreenOrientation = (ListIntPreference) findAndRegisterPreference(settings.MAP_SCREEN_ORIENTATION.getId());
mapScreenOrientation.setEntries(new String[]{getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default)});
mapScreenOrientation.setEntryValues(new int[]{ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED});
@ -70,7 +70,7 @@ public class GeneralProfileSettings extends SettingsBaseProfileDependentFragment
entries[3] = PointDescription.formatToHumanString(getContext(), PointDescription.UTM_FORMAT);
entries[4] = PointDescription.formatToHumanString(getContext(), PointDescription.OLC_FORMAT);
ListIntPreference coordinatesFormat = (ListIntPreference) screen.findPreference(settings.COORDINATES_FORMAT.getId());
ListIntPreference coordinatesFormat = (ListIntPreference) findAndRegisterPreference(settings.COORDINATES_FORMAT.getId());
coordinatesFormat.setEntries(entries);
coordinatesFormat.setEntryValues(cvls);
}
@ -91,10 +91,10 @@ public class GeneralProfileSettings extends SettingsBaseProfileDependentFragment
public static boolean showInstance(FragmentManager fragmentManager) {
try {
GeneralProfileSettings generalProfileSettings = new GeneralProfileSettings();
ProfileGeneralSettings profileGeneralSettingsSettings = new ProfileGeneralSettings();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, generalProfileSettings, GeneralProfileSettings.TAG)
.addToBackStack(GeneralProfileSettings.TAG)
.add(R.id.fragmentContainer, profileGeneralSettingsSettings, ProfileGeneralSettings.TAG)
.addToBackStack(ProfileGeneralSettings.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -26,9 +26,9 @@ import java.util.Map;
import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
public class SettingsRouteParametersFragment extends SettingsBaseProfileDependentFragment {
public class RouteParametersFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsRouteParametersFragment";
public static final String TAG = "RouteParametersFragment";
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
private List<GeneralRouter.RoutingParameter> preferParameters = new ArrayList<GeneralRouter.RoutingParameter>();
private List<GeneralRouter.RoutingParameter> reliefFactorParameters = new ArrayList<GeneralRouter.RoutingParameter>();
@ -56,10 +56,10 @@ public class SettingsRouteParametersFragment extends SettingsBaseProfileDependen
public static boolean showInstance(FragmentManager fragmentManager) {
try {
SettingsRouteParametersFragment settingsNavigationFragment = new SettingsRouteParametersFragment();
RouteParametersFragment settingsNavigationFragment = new RouteParametersFragment();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsRouteParametersFragment.TAG)
.addToBackStack(SettingsRouteParametersFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, RouteParametersFragment.TAG)
.addToBackStack(RouteParametersFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {
@ -71,7 +71,7 @@ public class SettingsRouteParametersFragment extends SettingsBaseProfileDependen
protected void createUI() {
PreferenceScreen screen = getPreferenceScreen();
SwitchPreference fastRoute = (SwitchPreference) screen.findPreference(settings.FAST_ROUTE_MODE.getId());
SwitchPreference fastRoute = (SwitchPreference) findAndRegisterPreference(settings.FAST_ROUTE_MODE.getId());
fastRoute.setIcon(getContentIcon(R.drawable.ic_action_fastest_route));
if (settings.getApplicationMode().getRouteService() != RouteProvider.RouteService.OSMAND) {
screen.addPreference(fastRoute);
@ -102,14 +102,14 @@ public class SettingsRouteParametersFragment extends SettingsBaseProfileDependen
others.add(routingParameter);
}
}
Preference avoidRouting = screen.findPreference("avoid_in_routing");
Preference avoidRouting = findAndRegisterPreference("avoid_in_routing");
if (avoidParameters.size() > 0) {
avoidRouting.setOnPreferenceClickListener(this);
avoidRouting.setIcon(getContentIcon(R.drawable.ic_action_alert));
} else {
screen.removePreference(avoidRouting);
}
Preference preferRouting = screen.findPreference("prefer_in_routing");
Preference preferRouting = findAndRegisterPreference("prefer_in_routing");
if (preferParameters.size() > 0) {
preferRouting.setOnPreferenceClickListener(this);
} else {
@ -155,13 +155,13 @@ public class SettingsRouteParametersFragment extends SettingsBaseProfileDependen
switch (key) {
case "avoid_in_routing": {
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(false);
avoidRoadsFragment.setTargetFragment(SettingsRouteParametersFragment.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.setTargetFragment(RouteParametersFragment.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.show(getActivity().getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
return true;
}
case "prefer_in_routing": {
// AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true);
// avoidRoadsFragment.setTargetFragment(SettingsRouteParametersFragment.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
// avoidRoadsFragment.setTargetFragment(RouteParametersFragment.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
// avoidRoadsFragment.show(getActivity().getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
Toast.makeText(getContext(), "prefer_in_routing", Toast.LENGTH_LONG).show();
return true;

View file

@ -11,9 +11,9 @@ import android.view.ViewGroup;
import net.osmand.plus.R;
public class SettingsScreenAlertsFragment extends SettingsBaseProfileDependentFragment {
public class ScreenAlertsFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsScreenAlertsFragment";
public static final String TAG = "ScreenAlertsFragment";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -40,20 +40,13 @@ public class SettingsScreenAlertsFragment extends SettingsBaseProfileDependentFr
protected void createUI() {
PreferenceScreen screen = getPreferenceScreen();
SwitchPreference SHOW_ROUTING_ALARMS = (SwitchPreference) screen.findPreference(settings.SHOW_ROUTING_ALARMS.getId());
Preference SHOW_TRAFFIC_WARNINGS_DESCR = screen.findPreference("show_routing_alarms_descr");
SwitchPreference SHOW_TRAFFIC_WARNINGS = (SwitchPreference) screen.findPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
SwitchPreference SHOW_PEDESTRIAN = (SwitchPreference) screen.findPreference(settings.SHOW_PEDESTRIAN.getId());
SwitchPreference SHOW_CAMERAS = (SwitchPreference) screen.findPreference(settings.SHOW_CAMERAS.getId());
SwitchPreference SHOW_LANES = (SwitchPreference) screen.findPreference(settings.SHOW_LANES.getId());
SwitchPreference SHOW_TUNNELS = (SwitchPreference) screen.findPreference(settings.SHOW_TUNNELS.getId());
SHOW_ROUTING_ALARMS.setOnPreferenceChangeListener(this);
SHOW_TRAFFIC_WARNINGS.setOnPreferenceChangeListener(this);
SHOW_PEDESTRIAN.setOnPreferenceChangeListener(this);
SHOW_CAMERAS.setOnPreferenceChangeListener(this);
SHOW_LANES.setOnPreferenceChangeListener(this);
SHOW_TUNNELS.setOnPreferenceChangeListener(this);
SwitchPreference SHOW_ROUTING_ALARMS = (SwitchPreference) findAndRegisterPreference(settings.SHOW_ROUTING_ALARMS.getId());
Preference SHOW_TRAFFIC_WARNINGS_DESCR = findAndRegisterPreference("show_routing_alarms_descr");
SwitchPreference SHOW_TRAFFIC_WARNINGS = (SwitchPreference) findAndRegisterPreference(settings.SHOW_TRAFFIC_WARNINGS.getId());
SwitchPreference SHOW_PEDESTRIAN = (SwitchPreference) findAndRegisterPreference(settings.SHOW_PEDESTRIAN.getId());
SwitchPreference SHOW_CAMERAS = (SwitchPreference) findAndRegisterPreference(settings.SHOW_CAMERAS.getId());
SwitchPreference SHOW_LANES = (SwitchPreference) findAndRegisterPreference(settings.SHOW_LANES.getId());
SwitchPreference SHOW_TUNNELS = (SwitchPreference) findAndRegisterPreference(settings.SHOW_TUNNELS.getId());
SHOW_TRAFFIC_WARNINGS_DESCR.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
SHOW_TRAFFIC_WARNINGS.setIcon(getIcon(R.drawable.list_warnings_traffic_calming));
@ -65,10 +58,10 @@ public class SettingsScreenAlertsFragment extends SettingsBaseProfileDependentFr
public static boolean showInstance(FragmentManager fragmentManager) {
try {
SettingsScreenAlertsFragment settingsNavigationFragment = new SettingsScreenAlertsFragment();
ScreenAlertsFragment settingsNavigationFragment = new ScreenAlertsFragment();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsScreenAlertsFragment.TAG)
.addToBackStack(SettingsScreenAlertsFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, ScreenAlertsFragment.TAG)
.addToBackStack(ScreenAlertsFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -94,7 +94,7 @@ public class SettingsMainFragment extends BaseOsmAndFragment {
configure_profile_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SettingsConfigureProfileFragment.showInstance(getActivity().getSupportFragmentManager(), selectedMode);
ConfigureProfileFragment.showInstance(getActivity().getSupportFragmentManager(), selectedMode);
}
});
View manage_profiles_container = view.findViewById(R.id.manage_profiles_container);

View file

@ -11,9 +11,9 @@ import android.view.ViewGroup;
import net.osmand.plus.R;
import net.osmand.plus.views.ListIntPreference;
public class SettingsTurnScreenOnFragment extends SettingsBaseProfileDependentFragment {
public class TurnScreenOnFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsTurnScreenOnFragment";
public static final String TAG = "TurnScreenOnFragment";
@Override
protected int getPreferenceResId() {
@ -40,7 +40,7 @@ public class SettingsTurnScreenOnFragment extends SettingsBaseProfileDependentFr
protected void createUI() {
PreferenceScreen screen = getPreferenceScreen();
SwitchPreference turnScreenOn = (SwitchPreference) screen.findPreference(settings.TURN_SCREEN_ON.getId());
SwitchPreference turnScreenOn = (SwitchPreference) findAndRegisterPreference(settings.TURN_SCREEN_ON.getId());
int[] screenPowerSaveValues = new int[]{0, 5, 10, 15, 20, 30, 45, 60};
String[] screenPowerSaveNames = new String[screenPowerSaveValues.length];
@ -49,19 +49,19 @@ public class SettingsTurnScreenOnFragment extends SettingsBaseProfileDependentFr
screenPowerSaveNames[i] = screenPowerSaveValues[i] + " " + getString(R.string.int_seconds);
}
ListIntPreference turnScreenOnTime = (ListIntPreference) screen.findPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
ListIntPreference turnScreenOnTime = (ListIntPreference) findAndRegisterPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
turnScreenOnTime.setEntries(screenPowerSaveNames);
turnScreenOnTime.setEntryValues(screenPowerSaveValues);
SwitchPreference turnScreenOnSensor = (SwitchPreference) screen.findPreference(settings.TURN_SCREEN_ON_SENSOR.getId());
SwitchPreference turnScreenOnSensor = (SwitchPreference) findAndRegisterPreference(settings.TURN_SCREEN_ON_SENSOR.getId());
}
public static boolean showInstance(FragmentManager fragmentManager) {
try {
SettingsTurnScreenOnFragment settingsNavigationFragment = new SettingsTurnScreenOnFragment();
TurnScreenOnFragment settingsNavigationFragment = new TurnScreenOnFragment();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsTurnScreenOnFragment.TAG)
.addToBackStack(SettingsTurnScreenOnFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, TurnScreenOnFragment.TAG)
.addToBackStack(TurnScreenOnFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -27,9 +27,9 @@ import java.util.Map;
import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
import static net.osmand.plus.activities.SettingsNavigationActivity.setupSpeedSlider;
public class SettingsVehicleParametersFragment extends SettingsBaseProfileDependentFragment {
public class VehicleParametersFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsVehicleParametersFragment";
public static final String TAG = "VehicleParametersFragment";
@Override
protected int getPreferenceResId() {
@ -94,7 +94,7 @@ public class SettingsVehicleParametersFragment extends SettingsBaseProfileDepend
screen.addPreference(basePref);
}
GeneralRouter.GeneralRouterProfile routerProfile = router.getProfile();
Preference defaultSpeed = screen.findPreference("default_speed");
Preference defaultSpeed = findAndRegisterPreference("default_speed");
if (routerProfile != GeneralRouter.GeneralRouterProfile.PUBLIC_TRANSPORT) {
defaultSpeed.setOnPreferenceClickListener(this);
} else {
@ -176,10 +176,10 @@ public class SettingsVehicleParametersFragment extends SettingsBaseProfileDepend
public static boolean showInstance(FragmentManager fragmentManager) {
try {
SettingsVehicleParametersFragment settingsNavigationFragment = new SettingsVehicleParametersFragment();
VehicleParametersFragment settingsNavigationFragment = new VehicleParametersFragment();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsVehicleParametersFragment.TAG)
.addToBackStack(SettingsVehicleParametersFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, VehicleParametersFragment.TAG)
.addToBackStack(VehicleParametersFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -25,9 +25,9 @@ import java.util.Set;
import static net.osmand.plus.activities.SettingsNavigationActivity.MORE_VALUE;
public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependentFragment {
public class VoiceAnnouncesFragment extends BaseProfileSettingsFragment {
public static final String TAG = "SettingsVoiceAnnouncesFragment";
public static final String TAG = "VoiceAnnouncesFragment";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -53,20 +53,20 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
protected void createUI() {
PreferenceScreen screen = getPreferenceScreen();
SwitchPreference SPEAK_ROUTING_ALARMS = (SwitchPreference) screen.findPreference(settings.SPEAK_ROUTING_ALARMS.getId());
SwitchPreference SPEAK_ROUTING_ALARMS = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_ROUTING_ALARMS.getId());
Preference voiceAnnouncesInfo = screen.findPreference("voice_announces_info");
Preference voiceAnnouncesInfo = findAndRegisterPreference("voice_announces_info");
voiceAnnouncesInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
SwitchPreference SPEAK_STREET_NAMES = (SwitchPreference) screen.findPreference(settings.SPEAK_STREET_NAMES.getId());
SwitchPreference SPEAK_TRAFFIC_WARNINGS = (SwitchPreference) screen.findPreference(settings.SPEAK_TRAFFIC_WARNINGS.getId());
SwitchPreference SPEAK_PEDESTRIAN = (SwitchPreference) screen.findPreference(settings.SPEAK_PEDESTRIAN.getId());
SwitchPreference SPEAK_SPEED_LIMIT = (SwitchPreference) screen.findPreference(settings.SPEAK_SPEED_LIMIT.getId());
SwitchPreference SPEAK_SPEED_CAMERA = (SwitchPreference) screen.findPreference(settings.SPEAK_SPEED_CAMERA.getId());
SwitchPreference SPEAK_TUNNELS = (SwitchPreference) screen.findPreference(settings.SPEAK_TUNNELS.getId());
SwitchPreference ANNOUNCE_WPT = (SwitchPreference) screen.findPreference(settings.ANNOUNCE_WPT.getId());
SwitchPreference ANNOUNCE_NEARBY_FAVORITES = (SwitchPreference) screen.findPreference(settings.ANNOUNCE_NEARBY_FAVORITES.getId());
SwitchPreference ANNOUNCE_NEARBY_POI = (SwitchPreference) screen.findPreference(settings.ANNOUNCE_NEARBY_POI.getId());
SwitchPreference SPEAK_STREET_NAMES = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_STREET_NAMES.getId());
SwitchPreference SPEAK_TRAFFIC_WARNINGS = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_TRAFFIC_WARNINGS.getId());
SwitchPreference SPEAK_PEDESTRIAN = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_PEDESTRIAN.getId());
SwitchPreference SPEAK_SPEED_LIMIT = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_SPEED_LIMIT.getId());
SwitchPreference SPEAK_SPEED_CAMERA = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_SPEED_CAMERA.getId());
SwitchPreference SPEAK_TUNNELS = (SwitchPreference) findAndRegisterPreference(settings.SPEAK_TUNNELS.getId());
SwitchPreference ANNOUNCE_WPT = (SwitchPreference) findAndRegisterPreference(settings.ANNOUNCE_WPT.getId());
SwitchPreference ANNOUNCE_NEARBY_FAVORITES = (SwitchPreference) findAndRegisterPreference(settings.ANNOUNCE_NEARBY_FAVORITES.getId());
SwitchPreference ANNOUNCE_NEARBY_POI = (SwitchPreference) findAndRegisterPreference(settings.ANNOUNCE_NEARBY_POI.getId());
String[] speedNames;
float[] speedLimits;
@ -83,7 +83,7 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
speedNames[i] = (int) speedLimits[i] + " " + getString(R.string.mile_per_hour);
}
}
ListFloatPreference SPEED_LIMIT_EXCEED = (ListFloatPreference) screen.findPreference(settings.SPEED_LIMIT_EXCEED.getId());
ListFloatPreference SPEED_LIMIT_EXCEED = (ListFloatPreference) findAndRegisterPreference(settings.SPEED_LIMIT_EXCEED.getId());
SPEED_LIMIT_EXCEED.setEntries(speedNames);
SPEED_LIMIT_EXCEED.setEntryValues(speedLimits);
@ -94,7 +94,7 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
for (int i = 1; i < keepInformingValues.length; i++) {
keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
}
ListIntPreference KEEP_INFORMING = (ListIntPreference) screen.findPreference(settings.KEEP_INFORMING.getId());
ListIntPreference KEEP_INFORMING = (ListIntPreference) findAndRegisterPreference(settings.KEEP_INFORMING.getId());
KEEP_INFORMING.setEntries(keepInformingNames);
KEEP_INFORMING.setEntryValues(keepInformingValues);
@ -106,7 +106,7 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
getString(R.string.arrival_distance_factor_at_last)
};
ListFloatPreference ARRIVAL_DISTANCE_FACTOR = (ListFloatPreference) screen.findPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId());
ListFloatPreference ARRIVAL_DISTANCE_FACTOR = (ListFloatPreference) findAndRegisterPreference(settings.ARRIVAL_DISTANCE_FACTOR.getId());
ARRIVAL_DISTANCE_FACTOR.setEntries(arrivalNames);
ARRIVAL_DISTANCE_FACTOR.setEntryValues(arrivalValues);
@ -132,7 +132,7 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
}
entrieValues[k] = MORE_VALUE;
entries[k] = getString(R.string.install_more);
ListPreference voiceProvider = (ListPreference) screen.findPreference(settings.VOICE_PROVIDER.getId());
ListPreference voiceProvider = (ListPreference) findAndRegisterPreference(settings.VOICE_PROVIDER.getId());
voiceProvider.setEntries(entries);
voiceProvider.setEntryValues(entrieValues);
voiceProvider.setIcon(getContentIcon(R.drawable.ic_action_volume_mute));
@ -155,12 +155,13 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
lp.setSummary(R.string.choose_audio_stream_descr);
lp.setEntries(streamTypes);
lp.setEntryValues(streamIntTypesStr);
// final Preference.OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
registerPreference(lp);
final Preference.OnPreferenceChangeListener prev = lp.getOnPreferenceChangeListener();
lp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// prev.onPreferenceChange(preference, newValue);
prev.onPreferenceChange(preference, newValue);
CommandPlayer player = getMyApplication().getPlayer();
if (player != null) {
player.updateAudioStream(settings.AUDIO_STREAM_GUIDANCE.get());
@ -190,10 +191,10 @@ public class SettingsVoiceAnnouncesFragment extends SettingsBaseProfileDependent
public static boolean showInstance(FragmentManager fragmentManager) {
try {
SettingsVoiceAnnouncesFragment settingsNavigationFragment = new SettingsVoiceAnnouncesFragment();
VoiceAnnouncesFragment settingsNavigationFragment = new VoiceAnnouncesFragment();
fragmentManager.beginTransaction()
.add(R.id.fragmentContainer, settingsNavigationFragment, SettingsVoiceAnnouncesFragment.TAG)
.addToBackStack(SettingsVoiceAnnouncesFragment.TAG)
.add(R.id.fragmentContainer, settingsNavigationFragment, VoiceAnnouncesFragment.TAG)
.addToBackStack(VoiceAnnouncesFragment.TAG)
.commitAllowingStateLoss();
return true;
} catch (Exception e) {

View file

@ -48,7 +48,7 @@ import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.profiles.RoutingProfileDataObject;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.settings.SettingsNavigationFragment;
import net.osmand.plus.settings.NavigationFragment;
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.router.GeneralRouter;
import net.osmand.util.Algorithms;
@ -410,7 +410,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} else if (getSettings() != null) {
activateMode(mode);
getSettings().APPLICATION_MODE.set(mode);
SettingsNavigationFragment.showInstance(getActivity().getSupportFragmentManager(), mode);
NavigationFragment.showInstance(getActivity().getSupportFragmentManager(), mode);
}
}
});