OSDN Git Service

Make all TogglePreferenceController slice-able.
authorYi-Ling Chuang <emilychuang@google.com>
Wed, 27 Nov 2019 08:09:34 +0000 (16:09 +0800)
committerYi-Ling Chuang <emilychuang@google.com>
Thu, 28 Nov 2019 06:12:41 +0000 (14:12 +0800)
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

src/com/android/settings/core/TogglePreferenceController.java
tests/robotests/src/com/android/settings/core/TogglePreferenceControllerTest.java

index 165d7eb..7abe6e0 100644 (file)
@@ -70,4 +70,13 @@ public abstract class TogglePreferenceController extends BasePreferenceControlle
         return SliceData.SliceType.SWITCH;
     }
 
+    @Override
+    public boolean isSliceable() {
+        return true;
+    }
+
+    @Override
+    public boolean isPublicSlice() {
+        return false;
+    }
 }
\ No newline at end of file
index 7cda34a..541f0c4 100644 (file)
@@ -90,6 +90,16 @@ public class TogglePreferenceControllerTest {
                 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 boolean checkedFlag;