Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java +3 −3 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu List<Slot> allSlots = getSlots(); for (int i = 0; i < allSlots.size(); i++) { Slot slot = allSlots.get(i); List<StatusBarIconHolder> holders = slot.getHolderList(); List<StatusBarIconHolder> holders = slot.getHolderListInViewOrder(); boolean blocked = mIconBlacklist.contains(slot.getName()); for (StatusBarIconHolder holder : holders) { Loading Loading @@ -121,7 +121,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu // Remove all the icons. for (int i = currentSlots.size() - 1; i >= 0; i--) { Slot s = currentSlots.get(i); slotsToReAdd.put(s, s.getHolderList()); slotsToReAdd.put(s, s.getHolderListInViewOrder()); removeAllIconsForSlot(s.getName()); } Loading Loading @@ -281,7 +281,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu mIconLogger.onIconHidden(slotName); int slotIndex = getSlotIndex(slotName); List<StatusBarIconHolder> iconsToRemove = slot.getHolderList(); List<StatusBarIconHolder> iconsToRemove = slot.getHolderListInViewOrder(); for (StatusBarIconHolder holder : iconsToRemove) { int viewIndex = getViewIndex(slotIndex, holder.getTag()); slot.removeForTag(holder.getTag()); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java +14 −6 Original line number Diff line number Diff line Loading @@ -211,7 +211,7 @@ public class StatusBarIconList { } /** * View index is backwards from regular index * View index is inverted from regular index, because they are laid out back-to-front * @param tag the tag of the holder being viewed * @return (1 + mSubSlots.size() - indexOfTag) */ Loading @@ -228,14 +228,22 @@ public class StatusBarIconList { return subSlots - getIndexForTag(tag) - 1; } public List<StatusBarIconHolder> getHolderList() { /** * Build a list of the {@link StatusBarIconHolder}s in the same order they appear in their * view group. This provides a safe list that can be iterated and inserted into its group. * * @return all holders contained here, in view order */ public List<StatusBarIconHolder> getHolderListInViewOrder() { ArrayList<StatusBarIconHolder> holders = new ArrayList<>(); if (mHolder != null) { holders.add(mHolder); if (mSubSlots != null) { for (int i = mSubSlots.size() - 1; i >= 0; i--) { holders.add(mSubSlots.get(i)); } } if (mSubSlots != null) { holders.addAll(mSubSlots); if (mHolder != null) { holders.add(mHolder); } return holders; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconListTest.java +10 −9 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class StatusBarIconListTest extends SysuiTestCase { */ @Test public void testSlot_OrderIsPreserved() { public void testSlot_ViewOrder() { Slot testSlot = new Slot("test_name", null); // no tag bc it defaults to 0 Loading @@ -144,17 +144,18 @@ public class StatusBarIconListTest extends SysuiTestCase { int sb3Tag = 2; when(sbHolder3.getTag()).thenReturn(sb3Tag); // Add 3 icons in the same slot, and verify that the list we get is equal to what we gave testSlot.addHolder(sbHolder1); testSlot.addHolder(sbHolder2); testSlot.addHolder(sbHolder3); // View order is reverse of the order added ArrayList<StatusBarIconHolder> expected = new ArrayList<>(); expected.add(sbHolder1); expected.add(sbHolder2); expected.add(sbHolder3); expected.add(sbHolder2); expected.add(sbHolder1); // Add 3 icons in the same slot, and verify that the list we get is equal to what we gave for (StatusBarIconHolder holder : expected) { testSlot.addHolder(holder); } assertTrue(listsEqual(expected, testSlot.getHolderList())); assertTrue(listsEqual(expected, testSlot.getHolderListInViewOrder())); } private boolean listsEqual(List<StatusBarIconHolder> list1, List<StatusBarIconHolder> list2) { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java +3 −3 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu List<Slot> allSlots = getSlots(); for (int i = 0; i < allSlots.size(); i++) { Slot slot = allSlots.get(i); List<StatusBarIconHolder> holders = slot.getHolderList(); List<StatusBarIconHolder> holders = slot.getHolderListInViewOrder(); boolean blocked = mIconBlacklist.contains(slot.getName()); for (StatusBarIconHolder holder : holders) { Loading Loading @@ -121,7 +121,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu // Remove all the icons. for (int i = currentSlots.size() - 1; i >= 0; i--) { Slot s = currentSlots.get(i); slotsToReAdd.put(s, s.getHolderList()); slotsToReAdd.put(s, s.getHolderListInViewOrder()); removeAllIconsForSlot(s.getName()); } Loading Loading @@ -281,7 +281,7 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu mIconLogger.onIconHidden(slotName); int slotIndex = getSlotIndex(slotName); List<StatusBarIconHolder> iconsToRemove = slot.getHolderList(); List<StatusBarIconHolder> iconsToRemove = slot.getHolderListInViewOrder(); for (StatusBarIconHolder holder : iconsToRemove) { int viewIndex = getViewIndex(slotIndex, holder.getTag()); slot.removeForTag(holder.getTag()); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java +14 −6 Original line number Diff line number Diff line Loading @@ -211,7 +211,7 @@ public class StatusBarIconList { } /** * View index is backwards from regular index * View index is inverted from regular index, because they are laid out back-to-front * @param tag the tag of the holder being viewed * @return (1 + mSubSlots.size() - indexOfTag) */ Loading @@ -228,14 +228,22 @@ public class StatusBarIconList { return subSlots - getIndexForTag(tag) - 1; } public List<StatusBarIconHolder> getHolderList() { /** * Build a list of the {@link StatusBarIconHolder}s in the same order they appear in their * view group. This provides a safe list that can be iterated and inserted into its group. * * @return all holders contained here, in view order */ public List<StatusBarIconHolder> getHolderListInViewOrder() { ArrayList<StatusBarIconHolder> holders = new ArrayList<>(); if (mHolder != null) { holders.add(mHolder); if (mSubSlots != null) { for (int i = mSubSlots.size() - 1; i >= 0; i--) { holders.add(mSubSlots.get(i)); } } if (mSubSlots != null) { holders.addAll(mSubSlots); if (mHolder != null) { holders.add(mHolder); } return holders; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconListTest.java +10 −9 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class StatusBarIconListTest extends SysuiTestCase { */ @Test public void testSlot_OrderIsPreserved() { public void testSlot_ViewOrder() { Slot testSlot = new Slot("test_name", null); // no tag bc it defaults to 0 Loading @@ -144,17 +144,18 @@ public class StatusBarIconListTest extends SysuiTestCase { int sb3Tag = 2; when(sbHolder3.getTag()).thenReturn(sb3Tag); // Add 3 icons in the same slot, and verify that the list we get is equal to what we gave testSlot.addHolder(sbHolder1); testSlot.addHolder(sbHolder2); testSlot.addHolder(sbHolder3); // View order is reverse of the order added ArrayList<StatusBarIconHolder> expected = new ArrayList<>(); expected.add(sbHolder1); expected.add(sbHolder2); expected.add(sbHolder3); expected.add(sbHolder2); expected.add(sbHolder1); // Add 3 icons in the same slot, and verify that the list we get is equal to what we gave for (StatusBarIconHolder holder : expected) { testSlot.addHolder(holder); } assertTrue(listsEqual(expected, testSlot.getHolderList())); assertTrue(listsEqual(expected, testSlot.getHolderListInViewOrder())); } private boolean listsEqual(List<StatusBarIconHolder> list1, List<StatusBarIconHolder> list2) { Loading