From c016aaaa42f2d7f758bb6d973f035285e3d3dd87 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Tue, 5 Jun 2012 17:22:24 -0700 Subject: Tweak recents out animation a bit more Bug: 6490204 -Fading to black in the recents layer -Tweaking duration and interpolators -Removing some unnecessary debug exceptions (Bug: 6642072) Change-Id: Iba18fade7f874078111fc1d79a81830ee07617d4 --- .../res/layout-land/status_bar_recent_panel.xml | 6 +- .../res/layout-port/status_bar_recent_panel.xml | 6 +- .../res/layout/system_bar_recent_panel.xml | 7 +- .../com/android/systemui/recent/Choreographer.java | 26 ++++++- .../android/systemui/recent/RecentsPanelView.java | 87 ++++++++++++++++------ .../systemui/recent/RecentsVerticalScrollView.java | 6 -- .../android/systemui/statusbar/BaseStatusBar.java | 4 +- .../android/server/wm/WindowManagerService.java | 11 ++- 8 files changed, 115 insertions(+), 38 deletions(-) diff --git a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml index 8a211172ddea..00e3e27ccb8e 100644 --- a/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml +++ b/packages/SystemUI/res/layout-land/status_bar_recent_panel.xml @@ -26,7 +26,11 @@ android:layout_width="match_parent" systemui:recentItemLayout="@layout/status_bar_recent_item" > - + - + - + - mRecentTaskDescriptions; @@ -97,6 +100,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener private boolean mFitThumbnailToXY; private int mRecentItemLayoutId; private boolean mFirstScreenful = true; + private boolean mHighEndGfx; public static interface OnRecentsPanelVisibilityChangedListener { public void onRecentsPanelVisibilityChanged(boolean visible); @@ -248,7 +252,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && !event.isCanceled()) { - show(false, true); + show(false, false); return true; } return super.onKeyUp(keyCode, event); @@ -305,10 +309,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener ArrayList recentTaskDescriptions, boolean firstScreenful) { sendCloseSystemWindows(mContext, BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS); - // For now, disable animations. We may want to re-enable in the future - if (show) { - animate = false; - } if (show) { // Need to update list of recent apps before we set visibility so this view's // content description is updated before it gets focus for TalkBack mode @@ -318,6 +318,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener // quit early boolean noApps = !mFirstScreenful && (mRecentTaskDescriptions.size() == 0); if (mRecentsNoApps != null) { + mRecentsNoApps.setAlpha(1f); mRecentsNoApps.setVisibility(noApps ? View.VISIBLE : View.INVISIBLE); } else { if (noApps) { @@ -339,7 +340,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener mRecentTasksDirty = true; mWaitingToShow = false; mReadyToShow = false; - mRecentsNoApps.setVisibility(View.INVISIBLE); } if (animate) { if (mShowing != show) { @@ -488,7 +488,8 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener if (mRecentsScrim != null) { Display d = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); - if (!ActivityManager.isHighEndGfx(d)) { + mHighEndGfx = ActivityManager.isHighEndGfx(d); + if (!mHighEndGfx) { mRecentsScrim.setBackground(null); } else if (mRecentsScrim.getBackground() instanceof BitmapDrawable) { // In order to save space, we make the background texture repeat in the Y direction @@ -704,22 +705,57 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener setContentDescription(recentAppsAccessibilityDescription); } + + boolean mThumbnailScaleUpStarted; public void handleOnClick(View view) { ViewHolder holder = (ViewHolder)view.getTag(); TaskDescription ad = holder.taskDescription; final Context context = view.getContext(); final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); - holder.thumbnailViewImage.setDrawingCacheEnabled(true); - Bitmap bm = holder.thumbnailViewImage.getDrawingCache(); - mPlaceholderThumbnail = (ImageView) findViewById(R.id.recents_transition_placeholder_icon); + Bitmap bm = holder.thumbnailViewImageBitmap; + boolean usingDrawingCache; + if (bm.getWidth() == holder.thumbnailViewImage.getWidth() && + bm.getHeight() == holder.thumbnailViewImage.getHeight()) { + usingDrawingCache = false; + } else { + holder.thumbnailViewImage.setDrawingCacheEnabled(true); + bm = holder.thumbnailViewImage.getDrawingCache(); + usingDrawingCache = true; + } + + if (mPlaceholderThumbnail == null) { + mPlaceholderThumbnail = + (ImageView) findViewById(R.id.recents_transition_placeholder_icon); + } + if (mTransitionBg == null) { + mTransitionBg = (View) findViewById(R.id.recents_transition_background); + + IWindowManager wm = IWindowManager.Stub.asInterface( + ServiceManager.getService(Context.WINDOW_SERVICE)); + try { + if (!wm.hasSystemNavBar()) { + FrameLayout.LayoutParams lp = + (FrameLayout.LayoutParams) mTransitionBg.getLayoutParams(); + int statusBarHeight = getResources(). + getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + lp.setMargins(0, statusBarHeight, 0, 0); + mTransitionBg.setLayoutParams(lp); + } + } catch (RemoteException e) { + Log.w(TAG, "Failing checking whether status bar is visible", e); + } + } final ImageView placeholderThumbnail = mPlaceholderThumbnail; - mHideWindowAfterPlaceholderThumbnailIsHidden = false; + mHideRecentsAfterThumbnailScaleUpStarted = false; placeholderThumbnail.setVisibility(VISIBLE); - Bitmap b2 = bm.copy(bm.getConfig(), true); - placeholderThumbnail.setImageBitmap(b2); - + if (!usingDrawingCache) { + placeholderThumbnail.setImageBitmap(bm); + } else { + Bitmap b2 = bm.copy(bm.getConfig(), true); + placeholderThumbnail.setImageBitmap(b2); + } Rect r = new Rect(); holder.thumbnailViewImage.getGlobalVisibleRect(r); @@ -728,13 +764,16 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener show(false, true); + mThumbnailScaleUpStarted = false; ActivityOptions opts = ActivityOptions.makeDelayedThumbnailScaleUpAnimation( holder.thumbnailViewImage, bm, 0, 0, new ActivityOptions.OnAnimationStartedListener() { @Override public void onAnimationStarted() { - mPlaceholderThumbnail = null; - placeholderThumbnail.setVisibility(INVISIBLE); - if (mHideWindowAfterPlaceholderThumbnailIsHidden) { + mThumbnailScaleUpStarted = true; + if (!mHighEndGfx) { + mPlaceholderThumbnail.setVisibility(INVISIBLE); + } + if (mHideRecentsAfterThumbnailScaleUpStarted) { hideWindow(); } } @@ -751,15 +790,19 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener if (DEBUG) Log.v(TAG, "Starting activity " + intent); context.startActivity(intent, opts.toBundle()); } - holder.thumbnailViewImage.setDrawingCacheEnabled(false); + if (!usingDrawingCache) { + holder.thumbnailViewImage.setDrawingCacheEnabled(false); + } } public void hideWindow() { - if (mPlaceholderThumbnail != null) { - mHideWindowAfterPlaceholderThumbnailIsHidden = true; + if (!mThumbnailScaleUpStarted) { + mHideRecentsAfterThumbnailScaleUpStarted = true; } else { setVisibility(GONE); - mHideWindowAfterPlaceholderThumbnailIsHidden = false; + mTransitionBg.setVisibility(INVISIBLE); + mPlaceholderThumbnail.setVisibility(INVISIBLE); + mHideRecentsAfterThumbnailScaleUpStarted = false; } } diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java index d387515451e3..e8029852aa06 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java @@ -76,9 +76,6 @@ public class RecentsVerticalScrollView extends ScrollView } private void addToRecycledViews(View v) { - if (mRecycledViews.contains(v)) { - throw new RuntimeException("Child was already recycled"); - } if (mRecycledViews.size() < mNumItemsInOneScreenful) { mRecycledViews.add(v); } @@ -105,9 +102,6 @@ public class RecentsVerticalScrollView extends ScrollView old = recycledViews.next(); recycledViews.remove(); old.setVisibility(VISIBLE); - if (old.getParent() != null) { - throw new RuntimeException("Recycled child has parent (i: " + i + ", recycled i: " + mRecycledViews.size()); - } } final View view = mAdapter.getView(i, old, mLinearLayout); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index cf2690bbcf33..750c6dc0ba1b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -440,13 +440,13 @@ public abstract class BaseStatusBar extends SystemUI implements case MSG_OPEN_RECENTS_PANEL: if (DEBUG) Slog.d(TAG, "opening recents panel"); if (mRecentsPanel != null) { - mRecentsPanel.show(true, true); + mRecentsPanel.show(true, false); } break; case MSG_CLOSE_RECENTS_PANEL: if (DEBUG) Slog.d(TAG, "closing recents panel"); if (mRecentsPanel != null && mRecentsPanel.isShowing()) { - mRecentsPanel.show(false, true); + mRecentsPanel.show(false, false); } break; case MSG_PRELOAD_RECENT_APPS: diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index ba4df96b2bb4..28c8b06bd4cc 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -127,6 +127,7 @@ import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.AnimationUtils; +import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.view.animation.ScaleAnimation; @@ -280,6 +281,8 @@ public class WindowManagerService extends IWindowManager.Stub private static final int ALLOW_DISABLE_UNKNOWN = -1; // check with DevicePolicyManager private int mAllowDisableKeyguard = ALLOW_DISABLE_UNKNOWN; // sync'd by mKeyguardTokenWatcher + private static final float THUMBNAIL_ANIMATION_DECELERATE_FACTOR = 1.5f; + final TokenWatcher mKeyguardTokenWatcher = new TokenWatcher( new Handler(), "WindowManagerService.mKeyguardTokenWatcher") { @Override @@ -3183,7 +3186,7 @@ public class WindowManagerService extends IWindowManager.Stub // it is the standard duration for that. Otherwise we use the longer // task transition duration. int duration; - int delayDuration = delayed ? 200 : 0; + int delayDuration = delayed ? 270 : 0; switch (transit) { case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN: case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE: @@ -3191,7 +3194,7 @@ public class WindowManagerService extends IWindowManager.Stub com.android.internal.R.integer.config_shortAnimTime); break; default: - duration = delayed ? 200 : 300; + duration = delayed ? 250 : 300; break; } if (thumb) { @@ -3206,6 +3209,8 @@ public class WindowManagerService extends IWindowManager.Stub AnimationSet set = new AnimationSet(true); Animation alpha = new AlphaAnimation(1, 0); scale.setDuration(duration); + scale.setInterpolator( + new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR)); set.addAnimation(scale); alpha.setDuration(duration); set.addAnimation(alpha); @@ -3222,6 +3227,8 @@ public class WindowManagerService extends IWindowManager.Stub computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH)); scale.setDuration(duration); + scale.setInterpolator( + new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR)); scale.setFillBefore(true); if (delayDuration > 0) { scale.setStartOffset(delayDuration); -- cgit v1.2.3-59-g8ed1b