Merge "Fix the problem that when the MainSwitchPreference is gone, there will be a blank area." into sc-dev am: 371f699681
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15173151 Change-Id: I0c6616ba04ce29e43a7040f56851aa084bc17ac5
This commit is contained in:
@@ -50,7 +50,6 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
||||
|
||||
private SettingsMainSwitchBar mMainSwitchBar;
|
||||
private CharSequence mTitle;
|
||||
private boolean mIsVisible;
|
||||
private EnforcedAdmin mEnforcedAdmin;
|
||||
private RestrictedPreferenceHelper mRestrictedHelper;
|
||||
|
||||
@@ -87,7 +86,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
||||
}
|
||||
mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
|
||||
initMainSwitchBar();
|
||||
if (mIsVisible) {
|
||||
if (isVisible()) {
|
||||
mMainSwitchBar.show();
|
||||
if (mMainSwitchBar.isChecked() != isChecked()) {
|
||||
setChecked(isChecked());
|
||||
@@ -101,7 +100,6 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
||||
private void init(Context context, AttributeSet attrs) {
|
||||
setLayoutResource(R.layout.preference_widget_main_switch);
|
||||
mSwitchChangeListeners.add(this);
|
||||
mIsVisible = true;
|
||||
|
||||
if (attrs != null) {
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
@@ -151,7 +149,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
||||
* Show the MainSwitchBar
|
||||
*/
|
||||
public void show() {
|
||||
mIsVisible = true;
|
||||
setVisible(true);
|
||||
if (mMainSwitchBar != null) {
|
||||
mMainSwitchBar.show();
|
||||
}
|
||||
@@ -161,7 +159,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
||||
* Hide the MainSwitchBar
|
||||
*/
|
||||
public void hide() {
|
||||
mIsVisible = false;
|
||||
setVisible(false);
|
||||
if (mMainSwitchBar != null) {
|
||||
mMainSwitchBar.hide();
|
||||
}
|
||||
|
@@ -76,6 +76,7 @@ public class SettingsMainSwitchPreferenceTest {
|
||||
mPreference.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mPreference.isShowing()).isTrue();
|
||||
assertThat(mPreference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,5 +86,6 @@ public class SettingsMainSwitchPreferenceTest {
|
||||
mPreference.onBindViewHolder(mHolder);
|
||||
|
||||
assertThat(mPreference.isShowing()).isFalse();
|
||||
assertThat(mPreference.isVisible()).isFalse();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user