Merge pull request #7899 from osmandapp/preferences_fixes

Preferences fixes
This commit is contained in:
max-klaus 2019-11-11 17:09:36 +03:00 committed by GitHub
commit 5bb7839e62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 13 deletions

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="shared_string_revert">Revert</string>
<string name="track_saved">Track saved</string>
<string name="empty_filename">File name is empty</string>
<string name="default_speed_dialog_msg">Used to estimate arrival time for unknown type of roads and to limit speed for all roads (could change the route)</string>

View file

@ -107,4 +107,11 @@
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:title="@string/external_input_device" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="use_trackball_for_movements"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_off"
android:summaryOn="@string/shared_string_on"
android:title="@string/use_trackball" />
</PreferenceScreen>

View file

@ -1368,7 +1368,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
new BooleanPreference("use_trackball_for_movements", true).makeGlobal();
new BooleanPreference("use_trackball_for_movements", true).makeProfile().makeGeneral();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> ACCESSIBILITY_SMART_AUTOANNOUNCE =

View file

@ -796,7 +796,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setNeutralButton("Revert", new OnClickListener() {
builder.setNeutralButton(R.string.shared_string_revert, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mode.resetDefaultSpeed(app);

View file

@ -16,6 +16,7 @@ import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.util.SunriseSunset;
@ -29,23 +30,25 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
@SuppressLint("SimpleDateFormat")
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
OsmandApplication app = getMyApplication();
app.applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.debugging_and_development);
PreferenceScreen cat = getPreferenceScreen();
Preference pref;
cat.addPreference(createCheckBoxPreference(settings.USE_OPENGL_RENDER,
R.string.use_opengl_render,R.string.use_opengl_render_descr));
R.string.use_opengl_render, R.string.use_opengl_render_descr));
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode,
R.string.safe_mode_description);
if (!Version.isBlackberry(app)) {
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode, R.string.safe_mode_description);
// disable the checkbox if the library cannot be used
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
nativeCheckbox.setEnabled(false);
nativeCheckbox.setChecked(true);
}
cat.addPreference(nativeCheckbox);
}
PreferenceCategory navigation = new PreferenceCategory(this);
navigation.setTitle(R.string.routing_settings);

View file

@ -26,10 +26,10 @@ import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceGroupAdapter;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.SwitchPreferenceCompat;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@ -123,6 +123,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
@Override
@SuppressLint("RestrictedApi")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
nightMode = !settings.isLightContent();
themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
@ -130,7 +131,16 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
if (getPreferenceScreen() != null) {
PreferenceManager prefManager = getPreferenceManager();
PreferenceScreen preferenceScreen = prefManager.inflateFromResource(prefManager.getContext(), currentScreenType.preferencesResId, null);
if (prefManager.setPreferences(preferenceScreen)) {
setupPreferences();
registerPreferences(preferenceScreen);
}
} else {
updateAllSettings();
}
createToolbar(inflater, view);
setDivider(null);
view.setBackgroundColor(ContextCompat.getColor(app, getBackgroundColorRes()));

View file

@ -3,6 +3,7 @@ package net.osmand.plus.settings;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
@ -28,6 +29,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
@ -61,6 +63,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
setupMagneticFieldSensorPref();
setupMapEmptyStateAllowedPref();
setupExternalInputDevicePref();
setupTrackballForMovementsPref();
}
@Override
@ -277,6 +280,20 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
);
}
private void setupTrackballForMovementsPref() {
SwitchPreferenceEx mapEmptyStateAllowedPref = (SwitchPreferenceEx) findPreference(settings.USE_TRACKBALL_FOR_MOVEMENTS.getId());
mapEmptyStateAllowedPref.setTitle(getString(R.string.use_trackball));
mapEmptyStateAllowedPref.setDescription(getString(R.string.use_trackball_descr));
boolean visible = false;
if (!Version.isBlackberry(app)) {
int nav = getResources().getConfiguration().navigation;
visible = nav == Configuration.NAVIGATION_DPAD || nav == Configuration.NAVIGATION_TRACKBALL ||
nav == Configuration.NAVIGATION_WHEEL || nav == Configuration.NAVIGATION_UNDEFINED;
}
mapEmptyStateAllowedPref.setVisible(visible);
}
private void showDrivingRegionDialog() {
Context themedContext = UiUtilities.getThemedContext(getActivity(), isNightMode());
AlertDialog.Builder b = new AlertDialog.Builder(themedContext);

View file

@ -286,6 +286,8 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
}
recalculateRoute();
return true;
} else if ("prouting_short_way".equals(key) && newValue instanceof Boolean) {
return app.getSettings().FAST_ROUTE_MODE.setModeValue(getSelectedAppMode(), !(Boolean) newValue);
}
return super.onPreferenceChange(preference, newValue);