3434import android .graphics .drawable .Drawable ;
3535import android .net .Uri ;
3636import android .os .RemoteException ;
37+ import android .os .ServiceManager ;
3738import android .provider .Settings ;
3839import android .util .AttributeSet ;
3940import android .util .Log ;
4041import android .view .Display ;
4142import android .view .KeyEvent ;
43+ import android .view .IWindowManager ;
4244import android .view .LayoutInflater ;
4345import android .view .MenuItem ;
4446import android .view .MotionEvent ;
@@ -86,7 +88,8 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
8688 OnRecentsPanelVisibilityChangedListener mVisibilityChangedListener ;
8789
8890 ImageView mPlaceholderThumbnail ;
89- boolean mHideWindowAfterPlaceholderThumbnailIsHidden ;
91+ View mTransitionBg ;
92+ boolean mHideRecentsAfterThumbnailScaleUpStarted ;
9093
9194 private RecentTasksLoader mRecentTasksLoader ;
9295 private ArrayList <TaskDescription > mRecentTaskDescriptions ;
@@ -97,6 +100,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
97100 private boolean mFitThumbnailToXY ;
98101 private int mRecentItemLayoutId ;
99102 private boolean mFirstScreenful = true ;
103+ private boolean mHighEndGfx ;
100104
101105 public static interface OnRecentsPanelVisibilityChangedListener {
102106 public void onRecentsPanelVisibilityChanged (boolean visible );
@@ -248,7 +252,7 @@ public int numItemsInOneScreenful() {
248252 @ Override
249253 public boolean onKeyUp (int keyCode , KeyEvent event ) {
250254 if (keyCode == KeyEvent .KEYCODE_BACK && !event .isCanceled ()) {
251- show (false , true );
255+ show (false , false );
252256 return true ;
253257 }
254258 return super .onKeyUp (keyCode , event );
@@ -305,10 +309,6 @@ public void show(boolean show, boolean animate,
305309 ArrayList <TaskDescription > recentTaskDescriptions , boolean firstScreenful ) {
306310 sendCloseSystemWindows (mContext , BaseStatusBar .SYSTEM_DIALOG_REASON_RECENT_APPS );
307311
308- // For now, disable animations. We may want to re-enable in the future
309- if (show ) {
310- animate = false ;
311- }
312312 if (show ) {
313313 // Need to update list of recent apps before we set visibility so this view's
314314 // content description is updated before it gets focus for TalkBack mode
@@ -318,6 +318,7 @@ public void show(boolean show, boolean animate,
318318 // quit early
319319 boolean noApps = !mFirstScreenful && (mRecentTaskDescriptions .size () == 0 );
320320 if (mRecentsNoApps != null ) {
321+ mRecentsNoApps .setAlpha (1f );
321322 mRecentsNoApps .setVisibility (noApps ? View .VISIBLE : View .INVISIBLE );
322323 } else {
323324 if (noApps ) {
@@ -339,7 +340,6 @@ public void show(boolean show, boolean animate,
339340 mRecentTasksDirty = true ;
340341 mWaitingToShow = false ;
341342 mReadyToShow = false ;
342- mRecentsNoApps .setVisibility (View .INVISIBLE );
343343 }
344344 if (animate ) {
345345 if (mShowing != show ) {
@@ -488,7 +488,8 @@ protected void onFinishInflate() {
488488 if (mRecentsScrim != null ) {
489489 Display d = ((WindowManager )mContext .getSystemService (Context .WINDOW_SERVICE ))
490490 .getDefaultDisplay ();
491- if (!ActivityManager .isHighEndGfx (d )) {
491+ mHighEndGfx = ActivityManager .isHighEndGfx (d );
492+ if (!mHighEndGfx ) {
492493 mRecentsScrim .setBackground (null );
493494 } else if (mRecentsScrim .getBackground () instanceof BitmapDrawable ) {
494495 // In order to save space, we make the background texture repeat in the Y direction
@@ -704,22 +705,57 @@ private void updateUiElements(Configuration config) {
704705 setContentDescription (recentAppsAccessibilityDescription );
705706 }
706707
708+
709+ boolean mThumbnailScaleUpStarted ;
707710 public void handleOnClick (View view ) {
708711 ViewHolder holder = (ViewHolder )view .getTag ();
709712 TaskDescription ad = holder .taskDescription ;
710713 final Context context = view .getContext ();
711714 final ActivityManager am = (ActivityManager )
712715 context .getSystemService (Context .ACTIVITY_SERVICE );
713- holder .thumbnailViewImage .setDrawingCacheEnabled (true );
714- Bitmap bm = holder .thumbnailViewImage .getDrawingCache ();
715- mPlaceholderThumbnail = (ImageView ) findViewById (R .id .recents_transition_placeholder_icon );
716+ Bitmap bm = holder .thumbnailViewImageBitmap ;
717+ boolean usingDrawingCache ;
718+ if (bm .getWidth () == holder .thumbnailViewImage .getWidth () &&
719+ bm .getHeight () == holder .thumbnailViewImage .getHeight ()) {
720+ usingDrawingCache = false ;
721+ } else {
722+ holder .thumbnailViewImage .setDrawingCacheEnabled (true );
723+ bm = holder .thumbnailViewImage .getDrawingCache ();
724+ usingDrawingCache = true ;
725+ }
726+
727+ if (mPlaceholderThumbnail == null ) {
728+ mPlaceholderThumbnail =
729+ (ImageView ) findViewById (R .id .recents_transition_placeholder_icon );
730+ }
731+ if (mTransitionBg == null ) {
732+ mTransitionBg = (View ) findViewById (R .id .recents_transition_background );
733+
734+ IWindowManager wm = IWindowManager .Stub .asInterface (
735+ ServiceManager .getService (Context .WINDOW_SERVICE ));
736+ try {
737+ if (!wm .hasSystemNavBar ()) {
738+ FrameLayout .LayoutParams lp =
739+ (FrameLayout .LayoutParams ) mTransitionBg .getLayoutParams ();
740+ int statusBarHeight = getResources ().
741+ getDimensionPixelSize (com .android .internal .R .dimen .status_bar_height );
742+ lp .setMargins (0 , statusBarHeight , 0 , 0 );
743+ mTransitionBg .setLayoutParams (lp );
744+ }
745+ } catch (RemoteException e ) {
746+ Log .w (TAG , "Failing checking whether status bar is visible" , e );
747+ }
748+ }
716749
717750 final ImageView placeholderThumbnail = mPlaceholderThumbnail ;
718- mHideWindowAfterPlaceholderThumbnailIsHidden = false ;
751+ mHideRecentsAfterThumbnailScaleUpStarted = false ;
719752 placeholderThumbnail .setVisibility (VISIBLE );
720- Bitmap b2 = bm .copy (bm .getConfig (), true );
721- placeholderThumbnail .setImageBitmap (b2 );
722-
753+ if (!usingDrawingCache ) {
754+ placeholderThumbnail .setImageBitmap (bm );
755+ } else {
756+ Bitmap b2 = bm .copy (bm .getConfig (), true );
757+ placeholderThumbnail .setImageBitmap (b2 );
758+ }
723759 Rect r = new Rect ();
724760 holder .thumbnailViewImage .getGlobalVisibleRect (r );
725761
@@ -728,13 +764,16 @@ public void handleOnClick(View view) {
728764
729765 show (false , true );
730766
767+ mThumbnailScaleUpStarted = false ;
731768 ActivityOptions opts = ActivityOptions .makeDelayedThumbnailScaleUpAnimation (
732769 holder .thumbnailViewImage , bm , 0 , 0 ,
733770 new ActivityOptions .OnAnimationStartedListener () {
734771 @ Override public void onAnimationStarted () {
735- mPlaceholderThumbnail = null ;
736- placeholderThumbnail .setVisibility (INVISIBLE );
737- if (mHideWindowAfterPlaceholderThumbnailIsHidden ) {
772+ mThumbnailScaleUpStarted = true ;
773+ if (!mHighEndGfx ) {
774+ mPlaceholderThumbnail .setVisibility (INVISIBLE );
775+ }
776+ if (mHideRecentsAfterThumbnailScaleUpStarted ) {
738777 hideWindow ();
739778 }
740779 }
@@ -751,15 +790,19 @@ public void handleOnClick(View view) {
751790 if (DEBUG ) Log .v (TAG , "Starting activity " + intent );
752791 context .startActivity (intent , opts .toBundle ());
753792 }
754- holder .thumbnailViewImage .setDrawingCacheEnabled (false );
793+ if (!usingDrawingCache ) {
794+ holder .thumbnailViewImage .setDrawingCacheEnabled (false );
795+ }
755796 }
756797
757798 public void hideWindow () {
758- if (mPlaceholderThumbnail != null ) {
759- mHideWindowAfterPlaceholderThumbnailIsHidden = true ;
799+ if (! mThumbnailScaleUpStarted ) {
800+ mHideRecentsAfterThumbnailScaleUpStarted = true ;
760801 } else {
761802 setVisibility (GONE );
762- mHideWindowAfterPlaceholderThumbnailIsHidden = false ;
803+ mTransitionBg .setVisibility (INVISIBLE );
804+ mPlaceholderThumbnail .setVisibility (INVISIBLE );
805+ mHideRecentsAfterThumbnailScaleUpStarted = false ;
763806 }
764807 }
765808
0 commit comments