Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +19 −12 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.pip.phone; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_ACTIONS; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_ALLOW_TIMEOUT; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_CONTROLLER_MESSENGER; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_DISMISS_FRACTION; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_MOVEMENT_BOUNDS; Loading Loading @@ -75,8 +76,8 @@ public class PipMenuActivity extends Activity { public static final int MESSAGE_UPDATE_ACTIONS = 4; public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; private static final long INITIAL_DISMISS_DELAY = 2000; private static final long POST_INTERACTION_DISMISS_DELAY = 1500; private static final long INITIAL_DISMISS_DELAY = 3500; private static final long POST_INTERACTION_DISMISS_DELAY = 2000; private static final long MENU_FADE_DURATION = 125; private static final float MENU_BACKGROUND_ALPHA = 0.3f; Loading Loading @@ -116,7 +117,8 @@ public class PipMenuActivity extends Activity { case MESSAGE_SHOW_MENU: { final Bundle data = (Bundle) msg.obj; showMenu(data.getParcelable(EXTRA_STACK_BOUNDS), data.getParcelable(EXTRA_MOVEMENT_BOUNDS)); data.getParcelable(EXTRA_MOVEMENT_BOUNDS), data.getBoolean(EXTRA_ALLOW_TIMEOUT)); break; } case MESSAGE_POKE_MENU: Loading Loading @@ -252,7 +254,7 @@ public class PipMenuActivity extends Activity { // Do nothing } private void showMenu(Rect stackBounds, Rect movementBounds) { private void showMenu(Rect stackBounds, Rect movementBounds, boolean allowMenuTimeout) { if (!mMenuVisible) { updateActionViews(stackBounds); if (mMenuContainerAnimator != null) { Loading @@ -265,18 +267,22 @@ public class PipMenuActivity extends Activity { mMenuContainer.getAlpha(), 1f); mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_IN); mMenuContainerAnimator.setDuration(MENU_FADE_DURATION); if (allowMenuTimeout) { mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { repostDelayedFinish(INITIAL_DISMISS_DELAY); } }); } mMenuContainerAnimator.addUpdateListener(mMenuBgUpdateListener); mMenuContainerAnimator.start(); } else { // If we are already visible, then just start the delayed dismiss and unregister any // existing input consumers from the previous drag if (allowMenuTimeout) { repostDelayedFinish(POST_INTERACTION_DISMISS_DELAY); } notifyUnregisterInputConsumer(); } } Loading Loading @@ -320,7 +326,8 @@ public class PipMenuActivity extends Activity { if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) { Rect stackBounds = intent.getParcelableExtra(EXTRA_STACK_BOUNDS); Rect movementBounds = intent.getParcelableExtra(EXTRA_MOVEMENT_BOUNDS); showMenu(stackBounds, movementBounds); boolean allowMenuTimeout = intent.getBooleanExtra(EXTRA_ALLOW_TIMEOUT, true); showMenu(stackBounds, movementBounds, allowMenuTimeout); } } Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java +21 −17 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.os.Messenger; import android.os.RemoteException; import android.os.UserHandle; import android.util.Log; import android.util.Pair; import android.view.IWindowManager; import com.android.systemui.pip.phone.PipMediaController.ActionListener; Loading @@ -56,6 +55,7 @@ public class PipMenuActivityController { public static final String EXTRA_ACTIONS = "actions"; public static final String EXTRA_STACK_BOUNDS = "stack_bounds"; public static final String EXTRA_MOVEMENT_BOUNDS = "movement_bounds"; public static final String EXTRA_ALLOW_TIMEOUT = "allow_timeout"; public static final String EXTRA_SHOW_MENU = "show_menu"; public static final String EXTRA_DISMISS_FRACTION = "dismiss_fraction"; Loading Loading @@ -105,7 +105,8 @@ public class PipMenuActivityController { private ParceledListSlice mMediaActions; private boolean mMenuVisible; private Bundle mTmpData = new Bundle(); // The dismiss fraction update is sent frequently, so use a temporary bundle for the message private Bundle mTmpDismissFractionData = new Bundle(); private boolean mStartActivityRequested; private Messenger mToActivityMessenger; Loading Loading @@ -195,11 +196,11 @@ public class PipMenuActivityController { */ public void setDismissFraction(float fraction) { if (mToActivityMessenger != null) { mTmpData.clear(); mTmpData.putFloat(EXTRA_DISMISS_FRACTION, fraction); mTmpDismissFractionData.clear(); mTmpDismissFractionData.putFloat(EXTRA_DISMISS_FRACTION, fraction); Message m = Message.obtain(); m.what = PipMenuActivity.MESSAGE_UPDATE_DISMISS_FRACTION; m.obj = mTmpData; m.obj = mTmpDismissFractionData; try { mToActivityMessenger.send(m); } catch (RemoteException e) { Loading @@ -207,28 +208,29 @@ public class PipMenuActivityController { } } else if (!mStartActivityRequested) { startMenuActivity(null /* stackBounds */, null /* movementBounds */, false /* showMenu */); false /* showMenu */, false /* allowMenuTimeout */); } } /** * Shows the menu activity. */ public void showMenu(Rect stackBounds, Rect movementBounds) { public void showMenu(Rect stackBounds, Rect movementBounds, boolean allowMenuTimeout) { if (mToActivityMessenger != null) { mTmpData.clear(); mTmpData.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); mTmpData.putParcelable(EXTRA_MOVEMENT_BOUNDS, movementBounds); Bundle data = new Bundle(); data.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); data.putParcelable(EXTRA_MOVEMENT_BOUNDS, movementBounds); data.putBoolean(EXTRA_ALLOW_TIMEOUT, allowMenuTimeout); Message m = Message.obtain(); m.what = PipMenuActivity.MESSAGE_SHOW_MENU; m.obj = mTmpData; m.obj = data; try { mToActivityMessenger.send(m); } catch (RemoteException e) { Log.e(TAG, "Could not notify menu to show", e); } } else if (!mStartActivityRequested) { startMenuActivity(stackBounds, movementBounds, true /* showMenu */); startMenuActivity(stackBounds, movementBounds, true /* showMenu */, allowMenuTimeout); } } Loading Loading @@ -290,7 +292,8 @@ public class PipMenuActivityController { /** * Starts the menu activity on the top task of the pinned stack. */ private void startMenuActivity(Rect stackBounds, Rect movementBounds, boolean showMenu) { private void startMenuActivity(Rect stackBounds, Rect movementBounds, boolean showMenu, boolean allowMenuTimeout) { try { StackInfo pinnedStackInfo = mActivityManager.getStackInfo(PINNED_STACK_ID); if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null && Loading @@ -305,6 +308,7 @@ public class PipMenuActivityController { intent.putExtra(EXTRA_MOVEMENT_BOUNDS, movementBounds); } intent.putExtra(EXTRA_SHOW_MENU, showMenu); intent.putExtra(EXTRA_ALLOW_TIMEOUT, allowMenuTimeout); ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0); options.setLaunchTaskId( pinnedStackInfo.taskIds[pinnedStackInfo.taskIds.length - 1]); Loading Loading @@ -336,12 +340,12 @@ public class PipMenuActivityController { Log.e(TAG, "Error showing PIP menu activity", e); } mTmpData.clear(); mTmpData.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); mTmpData.putParcelable(EXTRA_ACTIONS, resolveMenuActions()); Bundle data = new Bundle(); data.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); data.putParcelable(EXTRA_ACTIONS, resolveMenuActions()); Message m = Message.obtain(); m.what = PipMenuActivity.MESSAGE_UPDATE_ACTIONS; m.obj = mTmpData; m.obj = data; try { mToActivityMessenger.send(m); } catch (RemoteException e) { Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +6 −3 Original line number Diff line number Diff line Loading @@ -288,7 +288,8 @@ public class PipTouchHandler implements TunerService.Tunable { } private void onAccessibilityShowMenu() { mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds); mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds, false /* allowMenuTimeout */); } private boolean handleTouchEvent(MotionEvent ev) { Loading Loading @@ -617,7 +618,8 @@ public class PipTouchHandler implements TunerService.Tunable { // If the menu is still visible, and we aren't minimized, then just poke the menu // so that it will timeout after the user stops touching it if (mMenuController.isMenuVisible()) { mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds); mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds, true /* allowMenuTimeout */); } if (isFling) { Loading @@ -631,7 +633,8 @@ public class PipTouchHandler implements TunerService.Tunable { mMotionHelper.animateToClosestSnapTarget(mMovementBounds, null /* listener */); setMinimizedStateInternal(false); } else if (!mIsMenuVisible) { mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds); mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds, true /* allowMenuTimeout */); } else { mMotionHelper.expandPip(); } Loading Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java +19 −12 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.pip.phone; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_ACTIONS; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_ALLOW_TIMEOUT; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_CONTROLLER_MESSENGER; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_DISMISS_FRACTION; import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_MOVEMENT_BOUNDS; Loading Loading @@ -75,8 +76,8 @@ public class PipMenuActivity extends Activity { public static final int MESSAGE_UPDATE_ACTIONS = 4; public static final int MESSAGE_UPDATE_DISMISS_FRACTION = 5; private static final long INITIAL_DISMISS_DELAY = 2000; private static final long POST_INTERACTION_DISMISS_DELAY = 1500; private static final long INITIAL_DISMISS_DELAY = 3500; private static final long POST_INTERACTION_DISMISS_DELAY = 2000; private static final long MENU_FADE_DURATION = 125; private static final float MENU_BACKGROUND_ALPHA = 0.3f; Loading Loading @@ -116,7 +117,8 @@ public class PipMenuActivity extends Activity { case MESSAGE_SHOW_MENU: { final Bundle data = (Bundle) msg.obj; showMenu(data.getParcelable(EXTRA_STACK_BOUNDS), data.getParcelable(EXTRA_MOVEMENT_BOUNDS)); data.getParcelable(EXTRA_MOVEMENT_BOUNDS), data.getBoolean(EXTRA_ALLOW_TIMEOUT)); break; } case MESSAGE_POKE_MENU: Loading Loading @@ -252,7 +254,7 @@ public class PipMenuActivity extends Activity { // Do nothing } private void showMenu(Rect stackBounds, Rect movementBounds) { private void showMenu(Rect stackBounds, Rect movementBounds, boolean allowMenuTimeout) { if (!mMenuVisible) { updateActionViews(stackBounds); if (mMenuContainerAnimator != null) { Loading @@ -265,18 +267,22 @@ public class PipMenuActivity extends Activity { mMenuContainer.getAlpha(), 1f); mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_IN); mMenuContainerAnimator.setDuration(MENU_FADE_DURATION); if (allowMenuTimeout) { mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { repostDelayedFinish(INITIAL_DISMISS_DELAY); } }); } mMenuContainerAnimator.addUpdateListener(mMenuBgUpdateListener); mMenuContainerAnimator.start(); } else { // If we are already visible, then just start the delayed dismiss and unregister any // existing input consumers from the previous drag if (allowMenuTimeout) { repostDelayedFinish(POST_INTERACTION_DISMISS_DELAY); } notifyUnregisterInputConsumer(); } } Loading Loading @@ -320,7 +326,8 @@ public class PipMenuActivity extends Activity { if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) { Rect stackBounds = intent.getParcelableExtra(EXTRA_STACK_BOUNDS); Rect movementBounds = intent.getParcelableExtra(EXTRA_MOVEMENT_BOUNDS); showMenu(stackBounds, movementBounds); boolean allowMenuTimeout = intent.getBooleanExtra(EXTRA_ALLOW_TIMEOUT, true); showMenu(stackBounds, movementBounds, allowMenuTimeout); } } Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java +21 −17 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.os.Messenger; import android.os.RemoteException; import android.os.UserHandle; import android.util.Log; import android.util.Pair; import android.view.IWindowManager; import com.android.systemui.pip.phone.PipMediaController.ActionListener; Loading @@ -56,6 +55,7 @@ public class PipMenuActivityController { public static final String EXTRA_ACTIONS = "actions"; public static final String EXTRA_STACK_BOUNDS = "stack_bounds"; public static final String EXTRA_MOVEMENT_BOUNDS = "movement_bounds"; public static final String EXTRA_ALLOW_TIMEOUT = "allow_timeout"; public static final String EXTRA_SHOW_MENU = "show_menu"; public static final String EXTRA_DISMISS_FRACTION = "dismiss_fraction"; Loading Loading @@ -105,7 +105,8 @@ public class PipMenuActivityController { private ParceledListSlice mMediaActions; private boolean mMenuVisible; private Bundle mTmpData = new Bundle(); // The dismiss fraction update is sent frequently, so use a temporary bundle for the message private Bundle mTmpDismissFractionData = new Bundle(); private boolean mStartActivityRequested; private Messenger mToActivityMessenger; Loading Loading @@ -195,11 +196,11 @@ public class PipMenuActivityController { */ public void setDismissFraction(float fraction) { if (mToActivityMessenger != null) { mTmpData.clear(); mTmpData.putFloat(EXTRA_DISMISS_FRACTION, fraction); mTmpDismissFractionData.clear(); mTmpDismissFractionData.putFloat(EXTRA_DISMISS_FRACTION, fraction); Message m = Message.obtain(); m.what = PipMenuActivity.MESSAGE_UPDATE_DISMISS_FRACTION; m.obj = mTmpData; m.obj = mTmpDismissFractionData; try { mToActivityMessenger.send(m); } catch (RemoteException e) { Loading @@ -207,28 +208,29 @@ public class PipMenuActivityController { } } else if (!mStartActivityRequested) { startMenuActivity(null /* stackBounds */, null /* movementBounds */, false /* showMenu */); false /* showMenu */, false /* allowMenuTimeout */); } } /** * Shows the menu activity. */ public void showMenu(Rect stackBounds, Rect movementBounds) { public void showMenu(Rect stackBounds, Rect movementBounds, boolean allowMenuTimeout) { if (mToActivityMessenger != null) { mTmpData.clear(); mTmpData.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); mTmpData.putParcelable(EXTRA_MOVEMENT_BOUNDS, movementBounds); Bundle data = new Bundle(); data.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); data.putParcelable(EXTRA_MOVEMENT_BOUNDS, movementBounds); data.putBoolean(EXTRA_ALLOW_TIMEOUT, allowMenuTimeout); Message m = Message.obtain(); m.what = PipMenuActivity.MESSAGE_SHOW_MENU; m.obj = mTmpData; m.obj = data; try { mToActivityMessenger.send(m); } catch (RemoteException e) { Log.e(TAG, "Could not notify menu to show", e); } } else if (!mStartActivityRequested) { startMenuActivity(stackBounds, movementBounds, true /* showMenu */); startMenuActivity(stackBounds, movementBounds, true /* showMenu */, allowMenuTimeout); } } Loading Loading @@ -290,7 +292,8 @@ public class PipMenuActivityController { /** * Starts the menu activity on the top task of the pinned stack. */ private void startMenuActivity(Rect stackBounds, Rect movementBounds, boolean showMenu) { private void startMenuActivity(Rect stackBounds, Rect movementBounds, boolean showMenu, boolean allowMenuTimeout) { try { StackInfo pinnedStackInfo = mActivityManager.getStackInfo(PINNED_STACK_ID); if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null && Loading @@ -305,6 +308,7 @@ public class PipMenuActivityController { intent.putExtra(EXTRA_MOVEMENT_BOUNDS, movementBounds); } intent.putExtra(EXTRA_SHOW_MENU, showMenu); intent.putExtra(EXTRA_ALLOW_TIMEOUT, allowMenuTimeout); ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0); options.setLaunchTaskId( pinnedStackInfo.taskIds[pinnedStackInfo.taskIds.length - 1]); Loading Loading @@ -336,12 +340,12 @@ public class PipMenuActivityController { Log.e(TAG, "Error showing PIP menu activity", e); } mTmpData.clear(); mTmpData.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); mTmpData.putParcelable(EXTRA_ACTIONS, resolveMenuActions()); Bundle data = new Bundle(); data.putParcelable(EXTRA_STACK_BOUNDS, stackBounds); data.putParcelable(EXTRA_ACTIONS, resolveMenuActions()); Message m = Message.obtain(); m.what = PipMenuActivity.MESSAGE_UPDATE_ACTIONS; m.obj = mTmpData; m.obj = data; try { mToActivityMessenger.send(m); } catch (RemoteException e) { Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +6 −3 Original line number Diff line number Diff line Loading @@ -288,7 +288,8 @@ public class PipTouchHandler implements TunerService.Tunable { } private void onAccessibilityShowMenu() { mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds); mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds, false /* allowMenuTimeout */); } private boolean handleTouchEvent(MotionEvent ev) { Loading Loading @@ -617,7 +618,8 @@ public class PipTouchHandler implements TunerService.Tunable { // If the menu is still visible, and we aren't minimized, then just poke the menu // so that it will timeout after the user stops touching it if (mMenuController.isMenuVisible()) { mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds); mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds, true /* allowMenuTimeout */); } if (isFling) { Loading @@ -631,7 +633,8 @@ public class PipTouchHandler implements TunerService.Tunable { mMotionHelper.animateToClosestSnapTarget(mMovementBounds, null /* listener */); setMinimizedStateInternal(false); } else if (!mIsMenuVisible) { mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds); mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds, true /* allowMenuTimeout */); } else { mMotionHelper.expandPip(); } Loading