Fix flicker in Dark theme
Currently, when schedule sets to "Turns on at bedtime", the footer will show a slid up animation when entering the page, this is because the "Start time" & "End time" preferences are hidden in onResume(). This is because these 2 preferences always return AVAILABLE in getAvailabilityStatus(), and manually update visibility in refreshSummary(), which is called each time updateState() is called. Usually the controller not set the visibility explicitly, but return CONDITIONALLY_UNAVAILABLE in getAvailabilityStatus() when they want to hide the preference. Because getAvailabilityStatus() is called in onCreate(), by using this, we can fix the flicker. Fix: 234399017 Test: visual & robo test Change-Id: I4cb7dd95d2985bd1ca4c8cb30aaebdc21a5415f8
This commit is contained in:
@@ -21,6 +21,7 @@ import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -43,9 +44,6 @@ public class DarkModeSettingsFragment extends DashboardFragment {
|
||||
private DarkModeObserver mContentObserver;
|
||||
private DarkModeCustomPreferenceController mCustomStartController;
|
||||
private DarkModeCustomPreferenceController mCustomEndController;
|
||||
private Runnable mCallback = () -> {
|
||||
updatePreferenceStates();
|
||||
};
|
||||
private static final int DIALOG_START_TIME = 0;
|
||||
private static final int DIALOG_END_TIME = 1;
|
||||
|
||||
@@ -60,7 +58,12 @@ public class DarkModeSettingsFragment extends DashboardFragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
// Listen for changes only while visible.
|
||||
mContentObserver.subscribe(mCallback);
|
||||
mContentObserver.subscribe(() -> {
|
||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
mCustomStartController.displayPreference(preferenceScreen);
|
||||
mCustomEndController.displayPreference(preferenceScreen);
|
||||
updatePreferenceStates();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user