Fixes 'no ripple effect' issue for screen attention setting
Preferences shouldn't be initialized at onAttach() because the settings style hasn't been loaded yet. This change defers the preferences initialization so that they comply with the settings style. The change ag/14114425 is reverted due to b/186904496. This change includes a fix for that issue. Test: manually Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.display Bug: 183909540 Bug: 186904496 Change-Id: I317ce251f4d11e62c6592ee587c2919da4d45db3
This commit is contained in:
@@ -71,11 +71,15 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
private CharSequence[] mInitialEntries;
|
||||
private CharSequence[] mInitialValues;
|
||||
private FooterPreference mPrivacyPreference;
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private SensorPrivacyManager mPrivacyManager;
|
||||
|
||||
@VisibleForTesting
|
||||
Context mContext;
|
||||
|
||||
@VisibleForTesting
|
||||
RestrictedLockUtils.EnforcedAdmin mAdmin;
|
||||
|
||||
@VisibleForTesting
|
||||
Preference mDisableOptionsPreference;
|
||||
|
||||
@@ -97,6 +101,7 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mContext = context;
|
||||
mInitialEntries = getResources().getStringArray(R.array.screen_timeout_entries);
|
||||
mInitialValues = getResources().getStringArray(R.array.screen_timeout_values);
|
||||
mAdaptiveSleepController = new AdaptiveSleepPreferenceController(context);
|
||||
@@ -104,11 +109,6 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
context);
|
||||
mAdaptiveSleepCameraStatePreferenceController =
|
||||
new AdaptiveSleepCameraStatePreferenceController(context);
|
||||
mPrivacyPreference = new FooterPreference(context);
|
||||
mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
|
||||
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
|
||||
mPrivacyPreference.setSelectable(false);
|
||||
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
|
||||
mPrivacyManager = SensorPrivacyManager.getInstance(context);
|
||||
mPrivacyManager.addSensorPrivacyListener(CAMERA,
|
||||
(sensor, enabled) -> mAdaptiveSleepController.updatePreference());
|
||||
@@ -167,6 +167,12 @@ public class ScreenTimeoutSettings extends RadioButtonPickerFragment implements
|
||||
preferenceWithLargestTimeout.setChecked(true);
|
||||
}
|
||||
|
||||
mPrivacyPreference = new FooterPreference(mContext);
|
||||
mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
|
||||
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
|
||||
mPrivacyPreference.setSelectable(false);
|
||||
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
|
||||
|
||||
if (isScreenAttentionAvailable(getContext())) {
|
||||
mAdaptiveSleepPermissionController.addToScreen(screen);
|
||||
mAdaptiveSleepCameraStatePreferenceController.addToScreen(screen);
|
||||
|
Reference in New Issue
Block a user