Disable wake time pref if screen timeout enabled

This commit is contained in:
Vitaliy 2020-05-28 12:41:02 +03:00
parent 152e3f1ebb
commit e570176963
2 changed files with 13 additions and 2 deletions

View file

@ -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),
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, ApplyQueryType.BOTTOM_SHEET, 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),

View file

@ -11,7 +11,7 @@ import net.osmand.plus.settings.bottomsheets.ScreenTimeoutBottomSheet;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class TurnScreenOnFragment extends BaseSettingsFragment {
public class TurnScreenOnFragment extends BaseSettingsFragment implements OnPreferenceChanged {
public static final String TAG = TurnScreenOnFragment.class.getSimpleName();
@ -65,6 +65,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
}
ListPreferenceEx turnScreenOnTime = (ListPreferenceEx) findPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
turnScreenOnTime.setEnabled(!settings.USE_SYSTEM_SCREEN_TIMEOUT.getModeValue(getSelectedAppMode()));
turnScreenOnTime.setEntries(entries);
turnScreenOnTime.setEntryValues(entryValues);
turnScreenOnTime.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
@ -87,4 +88,14 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
turnScreenOnPowerButton.setIcon(getPersistentPrefIcon(R.drawable.ic_action_power_button));
turnScreenOnPowerButton.setDescription(R.string.turn_screen_on_power_button_descr);
}
@Override
public void onPreferenceChanged(String prefId) {
if (settings.USE_SYSTEM_SCREEN_TIMEOUT.getId().equals(prefId)) {
Preference turnScreenOnTime = findPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
if (turnScreenOnTime != null) {
turnScreenOnTime.setEnabled(!settings.USE_SYSTEM_SCREEN_TIMEOUT.getModeValue(getSelectedAppMode()));
}
}
}
}