Loading packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +14 −1 Original line number Diff line number Diff line Loading @@ -355,10 +355,23 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D } public void addTile(ComponentName tile) { addTile(tile, /* end */ false); } /** * Adds a custom tile to the set of current tiles. * @param tile the component name of the {@link android.service.quicksettings.TileService} * @param end if true, the tile will be added at the end. If false, at the beginning. */ public void addTile(ComponentName tile, boolean end) { String spec = CustomTile.toSpec(tile); if (!mTileSpecs.contains(spec)) { List<String> newSpecs = new ArrayList<>(mTileSpecs); if (end) { newSpecs.add(spec); } else { newSpecs.add(0, spec); } changeTiles(mTileSpecs, newSpecs); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -274,7 +274,7 @@ public class AutoTileManager { } if (value != 0) { if (mSpec.startsWith(CustomTile.PREFIX)) { mHost.addTile(CustomTile.getComponentFromSpec(mSpec)); mHost.addTile(CustomTile.getComponentFromSpec(mSpec), /* end */ true); } else { mHost.addTile(mSpec); } Loading packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java +31 −1 Original line number Diff line number Diff line Loading @@ -219,12 +219,42 @@ public class QSTileHostTest extends SysuiTestCase { public void testNoRepeatedSpecs_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, CUSTOM_TILE_SPEC); mQSTileHost.addTile(CUSTOM_TILE); mQSTileHost.addTile(CUSTOM_TILE, /* end */ false); assertEquals(1, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(0)); } @Test public void testAddedAtBeginningOnDefault_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "spec1"); // seed mQSTileHost.addTile(CUSTOM_TILE); assertEquals(2, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(0)); } @Test public void testAddedAtBeginning_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "spec1"); // seed mQSTileHost.addTile(CUSTOM_TILE, /* end */ false); assertEquals(2, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(0)); } @Test public void testAddedAtEnd_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "spec1"); // seed mQSTileHost.addTile(CUSTOM_TILE, /* end */ true); assertEquals(2, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(1)); } @Test public void testLoadTileSpec_repeated() { List<String> specs = QSTileHost.loadTileSpecs(mContext, "spec1,spec1,spec2"); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -172,11 +172,12 @@ public class AutoTileManagerTest extends SysuiTestCase { } @Test public void testSettingTileAddedComponent_onChanged() { public void testSettingTileAddedComponentAtEnd_onChanged() { changeValue(TEST_SETTING_COMPONENT, 1); waitForIdleSync(); verify(mAutoAddTracker).setTileAdded(TEST_CUSTOM_SPEC); verify(mQsTileHost).addTile(ComponentName.unflattenFromString(TEST_COMPONENT)); verify(mQsTileHost).addTile(ComponentName.unflattenFromString(TEST_COMPONENT) , /* end */ true); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +14 −1 Original line number Diff line number Diff line Loading @@ -355,10 +355,23 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D } public void addTile(ComponentName tile) { addTile(tile, /* end */ false); } /** * Adds a custom tile to the set of current tiles. * @param tile the component name of the {@link android.service.quicksettings.TileService} * @param end if true, the tile will be added at the end. If false, at the beginning. */ public void addTile(ComponentName tile, boolean end) { String spec = CustomTile.toSpec(tile); if (!mTileSpecs.contains(spec)) { List<String> newSpecs = new ArrayList<>(mTileSpecs); if (end) { newSpecs.add(spec); } else { newSpecs.add(0, spec); } changeTiles(mTileSpecs, newSpecs); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/AutoTileManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -274,7 +274,7 @@ public class AutoTileManager { } if (value != 0) { if (mSpec.startsWith(CustomTile.PREFIX)) { mHost.addTile(CustomTile.getComponentFromSpec(mSpec)); mHost.addTile(CustomTile.getComponentFromSpec(mSpec), /* end */ true); } else { mHost.addTile(mSpec); } Loading
packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java +31 −1 Original line number Diff line number Diff line Loading @@ -219,12 +219,42 @@ public class QSTileHostTest extends SysuiTestCase { public void testNoRepeatedSpecs_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, CUSTOM_TILE_SPEC); mQSTileHost.addTile(CUSTOM_TILE); mQSTileHost.addTile(CUSTOM_TILE, /* end */ false); assertEquals(1, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(0)); } @Test public void testAddedAtBeginningOnDefault_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "spec1"); // seed mQSTileHost.addTile(CUSTOM_TILE); assertEquals(2, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(0)); } @Test public void testAddedAtBeginning_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "spec1"); // seed mQSTileHost.addTile(CUSTOM_TILE, /* end */ false); assertEquals(2, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(0)); } @Test public void testAddedAtEnd_customTile() { mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "spec1"); // seed mQSTileHost.addTile(CUSTOM_TILE, /* end */ true); assertEquals(2, mQSTileHost.mTileSpecs.size()); assertEquals(CUSTOM_TILE_SPEC, mQSTileHost.mTileSpecs.get(1)); } @Test public void testLoadTileSpec_repeated() { List<String> specs = QSTileHost.loadTileSpecs(mContext, "spec1,spec1,spec2"); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -172,11 +172,12 @@ public class AutoTileManagerTest extends SysuiTestCase { } @Test public void testSettingTileAddedComponent_onChanged() { public void testSettingTileAddedComponentAtEnd_onChanged() { changeValue(TEST_SETTING_COMPONENT, 1); waitForIdleSync(); verify(mAutoAddTracker).setTileAdded(TEST_CUSTOM_SPEC); verify(mQsTileHost).addTile(ComponentName.unflattenFromString(TEST_COMPONENT)); verify(mQsTileHost).addTile(ComponentName.unflattenFromString(TEST_COMPONENT) , /* end */ true); } @Test Loading