Fix the Night Light page UI shrinking

- This problem causes the TwilightLocationPreferenceController too late
  to decide the preference display or not.
- Move the display criteria into the getAvailabilityStatus

Fixes: 159032276
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.display
Test: manual review
Change-Id: I5850479e8a891f837c0e6772ad1096e702f95e34
This commit is contained in:
Sunny Shao
2020-06-24 17:16:37 +08:00
parent c9310c3156
commit 8d74809e96
2 changed files with 70 additions and 7 deletions

View File

@@ -21,7 +21,6 @@ import android.content.Intent;
import android.location.LocationManager;
import android.view.View;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
@@ -57,13 +56,9 @@ public class TwilightLocationPreferenceController extends BasePreferenceControll
});
}
@Override
public void updateState(Preference preference) {
preference.setVisible(!mLocationManager.isLocationEnabled());
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE_UNSEARCHABLE;
return mLocationManager.isLocationEnabled() ? CONDITIONALLY_UNAVAILABLE
: AVAILABLE_UNSEARCHABLE;
}
}