Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +20 −7 Original line number Original line Diff line number Diff line Loading @@ -89,6 +89,8 @@ public class PipMenuActivity extends Activity { private static final String TAG = "PipMenuActivity"; private static final String TAG = "PipMenuActivity"; private static final int MESSAGE_INVALID_TYPE = -1; public static final int MESSAGE_SHOW_MENU = 1; public static final int MESSAGE_SHOW_MENU = 1; public static final int MESSAGE_POKE_MENU = 2; public static final int MESSAGE_POKE_MENU = 2; public static final int MESSAGE_HIDE_MENU = 3; public static final int MESSAGE_HIDE_MENU = 3; Loading @@ -96,6 +98,7 @@ public class PipMenuActivity extends Activity { public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; public static final int MESSAGE_ANIMATION_ENDED = 6; public static final int MESSAGE_ANIMATION_ENDED = 6; public static final int MESSAGE_POINTER_EVENT = 7; public static final int MESSAGE_POINTER_EVENT = 7; public static final int MESSAGE_MENU_EXPANDED = 8; private static final int INITIAL_DISMISS_DELAY = 3500; private static final int INITIAL_DISMISS_DELAY = 3500; private static final int POST_INTERACTION_DISMISS_DELAY = 2000; private static final int POST_INTERACTION_DISMISS_DELAY = 2000; Loading Loading @@ -170,12 +173,15 @@ public class PipMenuActivity extends Activity { mAllowTouches = true; mAllowTouches = true; break; break; } } case MESSAGE_POINTER_EVENT: { case MESSAGE_POINTER_EVENT: { final MotionEvent ev = (MotionEvent) msg.obj; final MotionEvent ev = (MotionEvent) msg.obj; dispatchPointerEvent(ev); dispatchPointerEvent(ev); break; break; } } case MESSAGE_MENU_EXPANDED : { mMenuContainerAnimator.start(); break; } } } } } }; }; Loading Loading @@ -389,9 +395,9 @@ public class PipMenuActivity extends Activity { } } if (withDelay) { if (withDelay) { // starts the menu container animation after window expansion is completed // starts the menu container animation after window expansion is completed notifyMenuStateChange(menuState, resizeMenuOnShow, mMenuContainerAnimator::start); notifyMenuStateChange(menuState, resizeMenuOnShow, MESSAGE_MENU_EXPANDED); } else { } else { notifyMenuStateChange(menuState, resizeMenuOnShow, null /* callback */); notifyMenuStateChange(menuState, resizeMenuOnShow, MESSAGE_INVALID_TYPE); mMenuContainerAnimator.start(); mMenuContainerAnimator.start(); } } } else { } else { Loading @@ -417,7 +423,7 @@ public class PipMenuActivity extends Activity { if (mMenuState != MENU_STATE_NONE) { if (mMenuState != MENU_STATE_NONE) { cancelDelayedFinish(); cancelDelayedFinish(); if (notifyMenuVisibility) { if (notifyMenuVisibility) { notifyMenuStateChange(MENU_STATE_NONE, mResize, null /* callback */); notifyMenuStateChange(MENU_STATE_NONE, mResize, MESSAGE_INVALID_TYPE); } } mMenuContainerAnimator = new AnimatorSet(); mMenuContainerAnimator = new AnimatorSet(); ObjectAnimator menuAnim = ObjectAnimator.ofFloat(mMenuContainer, View.ALPHA, ObjectAnimator menuAnim = ObjectAnimator.ofFloat(mMenuContainer, View.ALPHA, Loading Loading @@ -579,14 +585,21 @@ public class PipMenuActivity extends Activity { mBackgroundDrawable.setAlpha(alpha); mBackgroundDrawable.setAlpha(alpha); } } private void notifyMenuStateChange(int menuState, boolean resize, Runnable callback) { private void notifyMenuStateChange(int menuState, boolean resize, int callbackWhat) { mMenuState = menuState; mMenuState = menuState; mResize = resize; mResize = resize; Message m = Message.obtain(); Message m = Message.obtain(); m.what = PipMenuActivityController.MESSAGE_MENU_STATE_CHANGED; m.what = PipMenuActivityController.MESSAGE_MENU_STATE_CHANGED; m.arg1 = menuState; m.arg1 = menuState; m.arg2 = resize ? 1 : 0; m.arg2 = resize ? 1 : 0; m.obj = callback; if (callbackWhat != MESSAGE_INVALID_TYPE) { // This message could be sent across processes when in secondary user. // Make the receiver end sending back via our own Messenger m.replyTo = mMessenger; final Bundle data = new Bundle(1); data.putInt(PipMenuActivityController.EXTRA_MESSAGE_CALLBACK_WHAT, callbackWhat); m.obj = data; } sendMessage(m, "Could not notify controller of PIP menu visibility"); sendMessage(m, "Could not notify controller of PIP menu visibility"); } } Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java +24 −5 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.pip.phone; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import android.annotation.Nullable; import android.app.ActivityManager.StackInfo; import android.app.ActivityManager.StackInfo; import android.app.ActivityOptions; import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.ActivityTaskManager; Loading Loading @@ -66,6 +67,7 @@ public class PipMenuActivityController { public static final String EXTRA_MENU_STATE = "menu_state"; public static final String EXTRA_MENU_STATE = "menu_state"; public static final String EXTRA_SHOW_MENU_WITH_DELAY = "show_menu_with_delay"; public static final String EXTRA_SHOW_MENU_WITH_DELAY = "show_menu_with_delay"; public static final String EXTRA_SHOW_RESIZE_HANDLE = "show_resize_handle"; public static final String EXTRA_SHOW_RESIZE_HANDLE = "show_resize_handle"; public static final String EXTRA_MESSAGE_CALLBACK_WHAT = "message_callback_what"; public static final int MESSAGE_MENU_STATE_CHANGED = 100; public static final int MESSAGE_MENU_STATE_CHANGED = 100; public static final int MESSAGE_EXPAND_PIP = 101; public static final int MESSAGE_EXPAND_PIP = 101; Loading Loading @@ -129,9 +131,10 @@ public class PipMenuActivityController { public void handleMessage(Message msg) { public void handleMessage(Message msg) { switch (msg.what) { switch (msg.what) { case MESSAGE_MENU_STATE_CHANGED: { case MESSAGE_MENU_STATE_CHANGED: { int menuState = msg.arg1; final int menuState = msg.arg1; boolean resize = msg.arg2 != 0; final boolean resize = msg.arg2 != 0; onMenuStateChanged(menuState, resize, (Runnable) msg.obj); onMenuStateChanged(menuState, resize, getMenuStateChangeFinishedCallback(msg.replyTo, (Bundle) msg.obj)); break; break; } } case MESSAGE_EXPAND_PIP: { case MESSAGE_EXPAND_PIP: { Loading Loading @@ -254,8 +257,8 @@ public class PipMenuActivityController { } } /** /** * Similar to {@link #showMenu(int, Rect, boolean, boolean)} but only show the menu upon * Similar to {@link #showMenu(int, Rect, boolean, boolean, boolean)} but only show the menu * PiP window transition is finished. * upon PiP window transition is finished. */ */ public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout, public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout, boolean willResizeMenu, boolean showResizeHandle) { boolean willResizeMenu, boolean showResizeHandle) { Loading @@ -272,6 +275,22 @@ public class PipMenuActivityController { false /* withDelay */, showResizeHandle); false /* withDelay */, showResizeHandle); } } private Runnable getMenuStateChangeFinishedCallback(@Nullable Messenger replyTo, @Nullable Bundle data) { if (replyTo == null || data == null) { return null; } return () -> { try { final Message m = Message.obtain(); m.what = data.getInt(EXTRA_MESSAGE_CALLBACK_WHAT); replyTo.send(m); } catch (RemoteException e) { // ignored } }; } private void showMenuInternal(int menuState, Rect stackBounds, boolean allowMenuTimeout, private void showMenuInternal(int menuState, Rect stackBounds, boolean allowMenuTimeout, boolean willResizeMenu, boolean withDelay, boolean showResizeHandle) { boolean willResizeMenu, boolean withDelay, boolean showResizeHandle) { if (DEBUG) { if (DEBUG) { Loading Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +20 −7 Original line number Original line Diff line number Diff line Loading @@ -89,6 +89,8 @@ public class PipMenuActivity extends Activity { private static final String TAG = "PipMenuActivity"; private static final String TAG = "PipMenuActivity"; private static final int MESSAGE_INVALID_TYPE = -1; public static final int MESSAGE_SHOW_MENU = 1; public static final int MESSAGE_SHOW_MENU = 1; public static final int MESSAGE_POKE_MENU = 2; public static final int MESSAGE_POKE_MENU = 2; public static final int MESSAGE_HIDE_MENU = 3; public static final int MESSAGE_HIDE_MENU = 3; Loading @@ -96,6 +98,7 @@ public class PipMenuActivity extends Activity { public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; public static final int MESSAGE_ANIMATION_ENDED = 6; public static final int MESSAGE_ANIMATION_ENDED = 6; public static final int MESSAGE_POINTER_EVENT = 7; public static final int MESSAGE_POINTER_EVENT = 7; public static final int MESSAGE_MENU_EXPANDED = 8; private static final int INITIAL_DISMISS_DELAY = 3500; private static final int INITIAL_DISMISS_DELAY = 3500; private static final int POST_INTERACTION_DISMISS_DELAY = 2000; private static final int POST_INTERACTION_DISMISS_DELAY = 2000; Loading Loading @@ -170,12 +173,15 @@ public class PipMenuActivity extends Activity { mAllowTouches = true; mAllowTouches = true; break; break; } } case MESSAGE_POINTER_EVENT: { case MESSAGE_POINTER_EVENT: { final MotionEvent ev = (MotionEvent) msg.obj; final MotionEvent ev = (MotionEvent) msg.obj; dispatchPointerEvent(ev); dispatchPointerEvent(ev); break; break; } } case MESSAGE_MENU_EXPANDED : { mMenuContainerAnimator.start(); break; } } } } } }; }; Loading Loading @@ -389,9 +395,9 @@ public class PipMenuActivity extends Activity { } } if (withDelay) { if (withDelay) { // starts the menu container animation after window expansion is completed // starts the menu container animation after window expansion is completed notifyMenuStateChange(menuState, resizeMenuOnShow, mMenuContainerAnimator::start); notifyMenuStateChange(menuState, resizeMenuOnShow, MESSAGE_MENU_EXPANDED); } else { } else { notifyMenuStateChange(menuState, resizeMenuOnShow, null /* callback */); notifyMenuStateChange(menuState, resizeMenuOnShow, MESSAGE_INVALID_TYPE); mMenuContainerAnimator.start(); mMenuContainerAnimator.start(); } } } else { } else { Loading @@ -417,7 +423,7 @@ public class PipMenuActivity extends Activity { if (mMenuState != MENU_STATE_NONE) { if (mMenuState != MENU_STATE_NONE) { cancelDelayedFinish(); cancelDelayedFinish(); if (notifyMenuVisibility) { if (notifyMenuVisibility) { notifyMenuStateChange(MENU_STATE_NONE, mResize, null /* callback */); notifyMenuStateChange(MENU_STATE_NONE, mResize, MESSAGE_INVALID_TYPE); } } mMenuContainerAnimator = new AnimatorSet(); mMenuContainerAnimator = new AnimatorSet(); ObjectAnimator menuAnim = ObjectAnimator.ofFloat(mMenuContainer, View.ALPHA, ObjectAnimator menuAnim = ObjectAnimator.ofFloat(mMenuContainer, View.ALPHA, Loading Loading @@ -579,14 +585,21 @@ public class PipMenuActivity extends Activity { mBackgroundDrawable.setAlpha(alpha); mBackgroundDrawable.setAlpha(alpha); } } private void notifyMenuStateChange(int menuState, boolean resize, Runnable callback) { private void notifyMenuStateChange(int menuState, boolean resize, int callbackWhat) { mMenuState = menuState; mMenuState = menuState; mResize = resize; mResize = resize; Message m = Message.obtain(); Message m = Message.obtain(); m.what = PipMenuActivityController.MESSAGE_MENU_STATE_CHANGED; m.what = PipMenuActivityController.MESSAGE_MENU_STATE_CHANGED; m.arg1 = menuState; m.arg1 = menuState; m.arg2 = resize ? 1 : 0; m.arg2 = resize ? 1 : 0; m.obj = callback; if (callbackWhat != MESSAGE_INVALID_TYPE) { // This message could be sent across processes when in secondary user. // Make the receiver end sending back via our own Messenger m.replyTo = mMessenger; final Bundle data = new Bundle(1); data.putInt(PipMenuActivityController.EXTRA_MESSAGE_CALLBACK_WHAT, callbackWhat); m.obj = data; } sendMessage(m, "Could not notify controller of PIP menu visibility"); sendMessage(m, "Could not notify controller of PIP menu visibility"); } } Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java +24 −5 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.pip.phone; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import android.annotation.Nullable; import android.app.ActivityManager.StackInfo; import android.app.ActivityManager.StackInfo; import android.app.ActivityOptions; import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.ActivityTaskManager; Loading Loading @@ -66,6 +67,7 @@ public class PipMenuActivityController { public static final String EXTRA_MENU_STATE = "menu_state"; public static final String EXTRA_MENU_STATE = "menu_state"; public static final String EXTRA_SHOW_MENU_WITH_DELAY = "show_menu_with_delay"; public static final String EXTRA_SHOW_MENU_WITH_DELAY = "show_menu_with_delay"; public static final String EXTRA_SHOW_RESIZE_HANDLE = "show_resize_handle"; public static final String EXTRA_SHOW_RESIZE_HANDLE = "show_resize_handle"; public static final String EXTRA_MESSAGE_CALLBACK_WHAT = "message_callback_what"; public static final int MESSAGE_MENU_STATE_CHANGED = 100; public static final int MESSAGE_MENU_STATE_CHANGED = 100; public static final int MESSAGE_EXPAND_PIP = 101; public static final int MESSAGE_EXPAND_PIP = 101; Loading Loading @@ -129,9 +131,10 @@ public class PipMenuActivityController { public void handleMessage(Message msg) { public void handleMessage(Message msg) { switch (msg.what) { switch (msg.what) { case MESSAGE_MENU_STATE_CHANGED: { case MESSAGE_MENU_STATE_CHANGED: { int menuState = msg.arg1; final int menuState = msg.arg1; boolean resize = msg.arg2 != 0; final boolean resize = msg.arg2 != 0; onMenuStateChanged(menuState, resize, (Runnable) msg.obj); onMenuStateChanged(menuState, resize, getMenuStateChangeFinishedCallback(msg.replyTo, (Bundle) msg.obj)); break; break; } } case MESSAGE_EXPAND_PIP: { case MESSAGE_EXPAND_PIP: { Loading Loading @@ -254,8 +257,8 @@ public class PipMenuActivityController { } } /** /** * Similar to {@link #showMenu(int, Rect, boolean, boolean)} but only show the menu upon * Similar to {@link #showMenu(int, Rect, boolean, boolean, boolean)} but only show the menu * PiP window transition is finished. * upon PiP window transition is finished. */ */ public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout, public void showMenuWithDelay(int menuState, Rect stackBounds, boolean allowMenuTimeout, boolean willResizeMenu, boolean showResizeHandle) { boolean willResizeMenu, boolean showResizeHandle) { Loading @@ -272,6 +275,22 @@ public class PipMenuActivityController { false /* withDelay */, showResizeHandle); false /* withDelay */, showResizeHandle); } } private Runnable getMenuStateChangeFinishedCallback(@Nullable Messenger replyTo, @Nullable Bundle data) { if (replyTo == null || data == null) { return null; } return () -> { try { final Message m = Message.obtain(); m.what = data.getInt(EXTRA_MESSAGE_CALLBACK_WHAT); replyTo.send(m); } catch (RemoteException e) { // ignored } }; } private void showMenuInternal(int menuState, Rect stackBounds, boolean allowMenuTimeout, private void showMenuInternal(int menuState, Rect stackBounds, boolean allowMenuTimeout, boolean willResizeMenu, boolean withDelay, boolean showResizeHandle) { boolean willResizeMenu, boolean withDelay, boolean showResizeHandle) { if (DEBUG) { if (DEBUG) { Loading