Disable power button pref in UI

This commit is contained in:
Vitaliy 2020-05-29 20:16:13 +03:00
parent cbead067b7
commit b7820fdbcd
2 changed files with 3 additions and 1 deletions

View file

@ -58,6 +58,7 @@
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="turn_screen_on_power_button"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:persistent="false"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/turn_screen_on_power_button" />

View file

@ -97,11 +97,12 @@ public class TurnScreenOnFragment extends BaseSettingsFragment implements OnPref
private void setupTurnScreenOnPowerButtonPref() {
ApplicationMode appMode = getSelectedAppMode();
boolean enabled = settings.TURN_SCREEN_ON_TIME_INT.getModeValue(appMode) == 0 || settings.USE_SYSTEM_SCREEN_TIMEOUT.getModeValue(appMode);
boolean enabled = settings.TURN_SCREEN_ON_TIME_INT.get() == 0 || settings.USE_SYSTEM_SCREEN_TIMEOUT.get();
SwitchPreferenceEx turnScreenOnPowerButton = (SwitchPreferenceEx) findPreference(settings.TURN_SCREEN_ON_POWER_BUTTON.getId());
turnScreenOnPowerButton.setEnabled(enabled);
turnScreenOnPowerButton.setDescription(R.string.turn_screen_on_power_button_descr);
turnScreenOnPowerButton.setIcon(getPersistentPrefIcon(R.drawable.ic_action_power_button));
turnScreenOnPowerButton.setChecked(enabled && settings.TURN_SCREEN_ON_POWER_BUTTON.getModeValue(appMode));
}
@Override