Make all TogglePreferenceController slice-able.

All the descendants of TogglePreferenceController are now slice-able by
default, where every controller can still disable it by overriding this
value. Though all of them are now slice-able, doesn't necessarily means
they are exposed publicly as we set the default value of isPublicSlice()
to false. For those that want to be public ones will have to override
this value.

Bug: 141088937
Test: robotests
Change-Id: I2ea529c11f0177cd6c55754b632cd1fea1dcc48f
This commit is contained in:
Yi-Ling Chuang
2019-11-27 16:09:34 +08:00
parent e7ff0891bb
commit 617458b07c
2 changed files with 19 additions and 0 deletions

View File

@@ -70,4 +70,13 @@ public abstract class TogglePreferenceController extends BasePreferenceControlle
return SliceData.SliceType.SWITCH; return SliceData.SliceType.SWITCH;
} }
@Override
public boolean isSliceable() {
return true;
}
@Override
public boolean isPublicSlice() {
return false;
}
} }

View File

@@ -90,6 +90,16 @@ public class TogglePreferenceControllerTest {
SliceData.SliceType.SWITCH); SliceData.SliceType.SWITCH);
} }
@Test
public void isSliceable_returnTrue() {
assertThat(mToggleController.isSliceable()).isTrue();
}
@Test
public void isPublicSlice_returnFalse() {
assertThat(mToggleController.isPublicSlice()).isFalse();
}
private static class FakeToggle extends TogglePreferenceController { private static class FakeToggle extends TogglePreferenceController {
private boolean checkedFlag; private boolean checkedFlag;