Create a long-press menu for sending screenshots to bubbles.
Test: Manual. Enable the long-press bubble menu with "adb shell settings set secure allow_bubble_menu 1". Then, long-press on a bubble to show a menu and tap the screenshot button to send a screenshot to the selected bubble. This won't work when the bubble is expanded.
Change-Id: I35380a8a4775e568699cf4527c6071bf932eb715
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java
new file mode 100644
index 0000000..e8eb72e
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.bubbles;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+
+import com.android.systemui.R;
+
+/**
+ * Menu which allows users to take actions on bubbles, ex. screenshots.
+ */
+public class BubbleMenuView extends FrameLayout {
+ private FrameLayout mMenu;
+ private boolean mShowing = false;
+
+ public BubbleMenuView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public BubbleMenuView(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mMenu = findViewById(R.id.bubble_menu_view);
+ ImageView icon = findViewById(com.android.internal.R.id.icon);
+ icon.setImageDrawable(mContext.getDrawable(com.android.internal.R.drawable.ic_screenshot));
+ }
+
+ /**
+ * Get the bubble menu view.
+ */
+ public View getMenuView() {
+ return mMenu;
+ }
+
+ /**
+ * Checks whether the bubble menu is currently displayed.
+ */
+ public boolean isShowing() {
+ return mShowing;
+ }
+
+ /**
+ * Show the bubble menu at the specified position on the screen.
+ */
+ public void show(float x, float y) {
+ mShowing = true;
+ this.setVisibility(VISIBLE);
+ mMenu.setTranslationX(x);
+ mMenu.setTranslationY(y);
+ }
+
+ /**
+ * Hide the bubble menu.
+ */
+ public void hide() {
+ mShowing = false;
+ this.setVisibility(GONE);
+ }
+}