Move turn screen on prefs to new screen
This commit is contained in:
parent
7c8e44c95d
commit
80f9bbdc5f
11 changed files with 64 additions and 96 deletions
|
@ -11,6 +11,11 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="turn_screen_on_descr">Those options will work, only if OsmAnd will be on the foreground when the device will be locked.</string>
|
||||
<string name="turn_screen_on_options_descr">Use these options to wake up screen with OsmAnd on the foreground.</string>
|
||||
<string name="system_screen_timeout">Screen timeout</string>
|
||||
<string name="system_screen_timeout_descr">Enable so the screen turns off after a certain period of inactivity, the time specified in the system settings of your device will be used.</string>
|
||||
<string name="screen_control">Screen control</string>
|
||||
<string name="shared_string_always">Always</string>
|
||||
<string name="unsupported_type_error">Unsupported type</string>
|
||||
<string name="index_item_world_basemap_detailed">World overview map (detailed)</string>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?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"
|
||||
android:title="@string/general_settings_2">
|
||||
|
||||
<PreferenceCategory
|
||||
|
@ -30,6 +31,13 @@
|
|||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/map_screen_orientation" />
|
||||
|
||||
<Preference
|
||||
android:key="screen_control"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/screen_control"
|
||||
app:fragment="net.osmand.plus.settings.fragments.TurnScreenOnFragment"
|
||||
tools:icon="@drawable/ic_action_turn_screen_on" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
|
|
@ -60,15 +60,4 @@
|
|||
app:fragment="net.osmand.plus.settings.fragments.ProxySettingsFragment"
|
||||
tools:icon="@drawable/ic_action_proxy" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="use_system_screen_timeout"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/use_system_screen_timeout" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -56,15 +56,6 @@
|
|||
android:title="@string/map_during_navigation"
|
||||
app:fragment="net.osmand.plus.settings.fragments.MapDuringNavigationFragment" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="turn_screen_on_enabled"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_off"
|
||||
android:summaryOn="@string/shared_string_on"
|
||||
android:title="@string/turn_screen_on"
|
||||
app:fragment="net.osmand.plus.settings.fragments.TurnScreenOnFragment"
|
||||
tools:icon="@drawable/ic_action_turn_screen_on" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="animate_my_location"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
|
|
|
@ -1,24 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/turn_screen_on">
|
||||
android:title="@string/screen_control">
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="use_system_screen_timeout"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/system_screen_timeout" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/simple_divider_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="turn_screen_on"
|
||||
android:layout="@layout/preference_category_with_descr"
|
||||
android:title="@string/turn_screen_on" />
|
||||
|
||||
<Preference
|
||||
android:key="turn_screen_on_info"
|
||||
android:layout="@layout/preference_info"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/turn_screen_on_info" />
|
||||
android:title="@string/turn_screen_on_descr" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:key="turn_screen_on_time_int"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/wake_time" />
|
||||
|
||||
<Preference
|
||||
android:layout="@layout/divider_half_item"
|
||||
android:selectable="false" />
|
||||
|
||||
<Preference
|
||||
android:key="turn_screen_on_options_info"
|
||||
android:layout="@layout/preference_info"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/turn_screen_on_options_descr" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||
android:key="turn_screen_on_sensor"
|
||||
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||
android:summaryOff="@string/shared_string_off"
|
||||
android:summaryOn="@string/shared_string_on"
|
||||
android:summaryOff="@string/shared_string_disabled"
|
||||
android:summaryOn="@string/shared_string_enabled"
|
||||
android:title="@string/turn_screen_on_sensor" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -2288,6 +2288,10 @@ public class OsmandSettings {
|
|||
TURN_SCREEN_ON_SENSOR.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
|
||||
}
|
||||
|
||||
public final CommonPreference<Boolean> TURN_SCREEN_ON_NAVIGATION_INSTRUCTIONS = new BooleanPreference("turn_screen_on_navigation_instructions", false).makeProfile();
|
||||
|
||||
public final CommonPreference<Boolean> TURN_SCREEN_ON_POWER_BUTTON = new BooleanPreference("turn_screen_on_power_button", false).makeProfile();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
// try without AUTO_FOLLOW_ROUTE_NAV (see forum discussion 'Simplify our navigation preference menu')
|
||||
//public final CommonPreference<Boolean> AUTO_FOLLOW_ROUTE_NAV = new BooleanPreference("auto_follow_route_navigation", true, false);
|
||||
|
|
|
@ -122,7 +122,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
VOICE_ANNOUNCES(VoiceAnnouncesFragment.class.getName(), true, ApplyQueryType.SNACK_BAR, R.xml.voice_announces, R.layout.profile_preference_toolbar_with_switch),
|
||||
VEHICLE_PARAMETERS(VehicleParametersFragment.class.getName(), true, ApplyQueryType.SNACK_BAR, R.xml.vehicle_parameters, R.layout.profile_preference_toolbar),
|
||||
MAP_DURING_NAVIGATION(MapDuringNavigationFragment.class.getName(), true, ApplyQueryType.SNACK_BAR, R.xml.map_during_navigation, R.layout.profile_preference_toolbar),
|
||||
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, ApplyQueryType.SNACK_BAR, R.xml.turn_screen_on, R.layout.profile_preference_toolbar_with_switch),
|
||||
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, ApplyQueryType.SNACK_BAR, R.xml.turn_screen_on, R.layout.profile_preference_toolbar),
|
||||
DATA_STORAGE(DataStorageFragment.class.getName(), false, null, R.xml.data_storage, R.layout.global_preference_toolbar),
|
||||
DIALOGS_AND_NOTIFICATIONS_SETTINGS(DialogsAndNotificationsSettingsFragment.class.getName(), false, null, R.xml.dialogs_and_notifications_preferences, R.layout.global_preferences_toolbar_with_switch),
|
||||
PROFILE_APPEARANCE(ProfileAppearanceFragment.TAG, true, null, R.xml.profile_appearance, R.layout.profile_preference_toolbar),
|
||||
|
|
|
@ -46,6 +46,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
setupRotateMapPref();
|
||||
setupCenterPositionOnMapPref();
|
||||
setupMapScreenOrientationPref();
|
||||
setupTurnScreenOnPref();
|
||||
|
||||
setupDrivingRegionPref();
|
||||
setupUnitsOfLengthPref();
|
||||
|
@ -137,6 +138,11 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
mapScreenOrientation.setIcon(getMapScreenOrientationIcon());
|
||||
}
|
||||
|
||||
private void setupTurnScreenOnPref() {
|
||||
Preference screenControl = findPreference("screen_control");
|
||||
screenControl.setIcon(getContentIcon(R.drawable.ic_action_turn_screen_on));
|
||||
}
|
||||
|
||||
private Drawable getMapScreenOrientationIcon() {
|
||||
switch (settings.MAP_SCREEN_ORIENTATION.getModeValue(getSelectedAppMode())) {
|
||||
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
|
||||
|
|
|
@ -10,12 +10,12 @@ import androidx.preference.Preference;
|
|||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.SettingsGeneralActivity;
|
||||
import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
|
@ -36,7 +36,6 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
|||
setupSendAnonymousDataPref();
|
||||
setupDialogsAndNotificationsPref();
|
||||
setupEnableProxyPref();
|
||||
setupUseSystemScreenTimeout();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,10 +191,4 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
|
|||
SwitchPreferenceEx enableProxy = (SwitchPreferenceEx) findPreference(settings.ENABLE_PROXY.getId());
|
||||
enableProxy.setIcon(getPersistentPrefIcon(R.drawable.ic_action_proxy));
|
||||
}
|
||||
|
||||
private void setupUseSystemScreenTimeout() {
|
||||
SwitchPreferenceEx useSystemScreenTimeout = (SwitchPreferenceEx) findPreference(settings.USE_SYSTEM_SCREEN_TIMEOUT.getId());
|
||||
useSystemScreenTimeout.setTitle(app.getString(R.string.use_system_screen_timeout));
|
||||
useSystemScreenTimeout.setDescription(app.getString(R.string.use_system_screen_timeout_promo));
|
||||
}
|
||||
}
|
|
@ -57,12 +57,10 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
|
||||
Preference routeParameters = findPreference("route_parameters");
|
||||
SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId());
|
||||
SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
|
||||
SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId());
|
||||
|
||||
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
|
||||
showRoutingAlarms.setIcon(getPersistentPrefIcon(R.drawable.ic_action_alert));
|
||||
turnScreenOn.setIcon(getPersistentPrefIcon(R.drawable.ic_action_turn_screen_on));
|
||||
|
||||
setupSpeakRoutingAlarmsPref();
|
||||
setupVehicleParametersPref();
|
||||
|
|
|
@ -1,54 +1,23 @@
|
|||
package net.osmand.plus.settings.fragments;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
|
||||
|
||||
public class TurnScreenOnFragment extends BaseSettingsFragment {
|
||||
|
||||
public static final String TAG = TurnScreenOnFragment.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void setupPreferences() {
|
||||
Preference turnScreenOnInfo = findPreference("turn_screen_on_info");
|
||||
turnScreenOnInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||
|
||||
setupUseSystemScreenTimeout();
|
||||
setupTurnScreenOnTimePref();
|
||||
setupTurnScreenOnSensorPref();
|
||||
enableDisablePreferences(settings.TURN_SCREEN_ON_ENABLED.getModeValue(getSelectedAppMode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createToolbar(LayoutInflater inflater, View view) {
|
||||
super.createToolbar(inflater, view);
|
||||
|
||||
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApplicationMode selectedMode = getSelectedAppMode();
|
||||
boolean checked = !settings.TURN_SCREEN_ON_ENABLED.getModeValue(selectedMode);
|
||||
onConfirmPreferenceChange(
|
||||
settings.TURN_SCREEN_ON_ENABLED.getId(), checked, ApplyQueryType.SNACK_BAR);
|
||||
updateToolbarSwitch();
|
||||
enableDisablePreferences(checked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,29 +33,10 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateToolbar() {
|
||||
super.updateToolbar();
|
||||
updateToolbarSwitch();
|
||||
}
|
||||
|
||||
private void updateToolbarSwitch() {
|
||||
View view = getView();
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
boolean checked = settings.TURN_SCREEN_ON_ENABLED.getModeValue(getSelectedAppMode());
|
||||
|
||||
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
|
||||
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
|
||||
AndroidUtils.setBackground(switchContainer, new ColorDrawable(color));
|
||||
|
||||
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
|
||||
switchView.setChecked(checked);
|
||||
UiUtilities.setupCompoundButton(switchView, isNightMode(), TOOLBAR);
|
||||
|
||||
TextView title = switchContainer.findViewById(R.id.switchButtonText);
|
||||
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
|
||||
private void setupUseSystemScreenTimeout() {
|
||||
SwitchPreferenceEx useSystemScreenTimeout = (SwitchPreferenceEx) findPreference(settings.USE_SYSTEM_SCREEN_TIMEOUT.getId());
|
||||
useSystemScreenTimeout.setTitle(app.getString(R.string.system_screen_timeout));
|
||||
useSystemScreenTimeout.setDescription(app.getString(R.string.system_screen_timeout_descr));
|
||||
}
|
||||
|
||||
private void setupTurnScreenOnTimePref() {
|
||||
|
@ -106,12 +56,9 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
|||
}
|
||||
|
||||
private void setupTurnScreenOnSensorPref() {
|
||||
String title = getString(R.string.turn_screen_on_sensor);
|
||||
String description = getString(R.string.turn_screen_on_sensor_descr);
|
||||
|
||||
SwitchPreferenceEx turnScreenOnSensor = (SwitchPreferenceEx) findPreference(settings.TURN_SCREEN_ON_SENSOR.getId());
|
||||
turnScreenOnSensor.setIcon(getPersistentPrefIcon(R.drawable.ic_action_sensor_interaction));
|
||||
turnScreenOnSensor.setTitle(title);
|
||||
turnScreenOnSensor.setDescription(description);
|
||||
turnScreenOnSensor.setTitle(R.string.turn_screen_on_sensor);
|
||||
turnScreenOnSensor.setDescription(R.string.turn_screen_on_sensor_descr);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue