summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2019-02-13 14:32:12 -0800
committer Mark Renouf <mrenouf@google.com> 2019-02-14 17:38:42 +0000
commitcfd06c1e5a05e2427a5d76938a60199c47c4a65b (patch)
tree82737fdd938d61b28764221b188db76996ddf66a
parent6d00203188a5dbdf1f927b2da613f0da77aeda32 (diff)
Make BubbleData @Inject
Follow up comments from ag/6274141 Test: atest BubbleControllerTest Bug: 123543995 Change-Id: Id9e74557e7b1a91f5fbf05bf9b94aeaf3e2d17be
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java13
4 files changed, 20 insertions, 22 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index a67e1b7032c6..be2dd679bba5 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -150,7 +150,8 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
}
@Inject
- public BubbleController(Context context, StatusBarWindowController statusBarWindowController) {
+ public BubbleController(Context context, StatusBarWindowController statusBarWindowController,
+ BubbleData data) {
mContext = context;
mNotificationEntryManager = Dependency.get(NotificationEntryManager.class);
@@ -171,7 +172,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
mTaskStackListener = new BubbleTaskStackListener();
ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
- mBubbleData = BubbleData.getInstance();
+ mBubbleData = data;
}
/**
@@ -253,7 +254,7 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe
mStackView.updateBubble(notif, updatePosition);
} else {
if (mStackView == null) {
- mStackView = new BubbleStackView(mContext);
+ mStackView = new BubbleStackView(mContext, mBubbleData);
ViewGroup sbv = mStatusBarWindowController.getStatusBarView();
// XXX: Bug when you expand the shade on top of expanded bubble, there is no scrim
// between bubble and the shade
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
index 89b0de85e18d..5002f5cce751 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java
@@ -22,23 +22,19 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import java.util.Collection;
import java.util.HashMap;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Keeps track of active bubbles.
*/
+@Singleton
class BubbleData {
private HashMap<String, Bubble> mBubbles = new HashMap<>();
- private static BubbleData sBubbleData = null;
-
- private BubbleData() {}
-
- public static BubbleData getInstance() {
- if (sBubbleData == null) {
- sBubbleData = new BubbleData();
- }
- return sBubbleData;
- }
+ @Inject
+ BubbleData() {}
/**
* The set of bubbles.
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 6c1b93bd099f..fec475932cca 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -85,6 +85,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
private final SpringAnimation mExpandedViewXAnim;
private final SpringAnimation mExpandedViewYAnim;
+ private final BubbleData mBubbleData;
private PhysicsAnimationLayout mBubbleContainer;
private StackAnimationController mStackAnimationController;
@@ -92,7 +93,6 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
private FrameLayout mExpandedViewContainer;
- private BubbleData mBubbleData;
private int mBubbleSize;
private int mBubblePadding;
@@ -140,10 +140,10 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
}
};
- public BubbleStackView(Context context) {
+ public BubbleStackView(Context context, BubbleData data) {
super(context);
- mBubbleData = BubbleData.getInstance();
+ mBubbleData = data;
mInflater = LayoutInflater.from(context);
mTouchHandler = new BubbleTouchHandler(context);
setOnTouchListener(mTouchHandler);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index d9315f937867..ca72602f2c2b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -82,6 +82,8 @@ public class BubbleControllerTest extends SysuiTestCase {
@Mock
private BubbleController.BubbleExpandListener mBubbleExpandListener;
+ private BubbleData mBubbleData;
+
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -104,7 +106,9 @@ public class BubbleControllerTest extends SysuiTestCase {
when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel);
when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null);
- mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController);
+ mBubbleData = new BubbleData();
+ mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController,
+ mBubbleData);
mBubbleController.setBubbleStateChangeListener(mBubbleStateChangeListener);
mBubbleController.setExpandListener(mBubbleExpandListener);
@@ -112,9 +116,6 @@ public class BubbleControllerTest extends SysuiTestCase {
verify(mNotificationEntryManager, atLeastOnce())
.addNotificationEntryListener(mEntryListenerCaptor.capture());
mEntryListener = mEntryListenerCaptor.getValue();
-
- // Reset the data
- BubbleData.getInstance().clear();
}
@Test
@@ -300,8 +301,8 @@ public class BubbleControllerTest extends SysuiTestCase {
static class TestableBubbleController extends BubbleController {
TestableBubbleController(Context context,
- StatusBarWindowController statusBarWindowController) {
- super(context, statusBarWindowController);
+ StatusBarWindowController statusBarWindowController, BubbleData data) {
+ super(context, statusBarWindowController, data);
}
@Override