diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-11-18 19:47:42 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2010-11-18 19:57:49 -0800 |
commit | 8e11ef0d949a52fec15359ec35557b2e773b093d (patch) | |
tree | e05b9bc14369925d52a27e8f913e5c5a5533727e | |
parent | 71d4ecb185bbe9e699aa85c65c98427a67a3fb12 (diff) | |
download | frameworks_base-8e11ef0d949a52fec15359ec35557b2e773b093d.zip frameworks_base-8e11ef0d949a52fec15359ec35557b2e773b093d.tar.gz frameworks_base-8e11ef0d949a52fec15359ec35557b2e773b093d.tar.bz2 |
Some work on issue #3201795: Improve transition when keyboard comes up
Now try to slide dialogs if they end up moving due to the IME (or
other system things) showing/hiding. Pretty hackish, but seems to
work.
Change-Id: Icd297e941cf847fa920c9605145c46be63043d52
12 files changed, 76 insertions, 39 deletions
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index a64ee9d..784951f 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -922,7 +922,6 @@ public interface WindowManager extends ViewManager { */ public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; - public LayoutParams() { super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); type = TYPE_APPLICATION; diff --git a/core/res/res/anim/accelerate_cubic_interpolator.xml b/core/res/res/anim/accelerate_cubic_interpolator.xml index c736766..90f62da 100644 --- a/core/res/res/anim/accelerate_cubic_interpolator.xml +++ b/core/res/res/anim/accelerate_cubic_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_in_interpolator.xml -** +/* ** Copyright 2010, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/accelerate_decelerate_interpolator.xml b/core/res/res/anim/accelerate_decelerate_interpolator.xml index 4a0216b..e7f9d9f 100644 --- a/core/res/res/anim/accelerate_decelerate_interpolator.xml +++ b/core/res/res/anim/accelerate_decelerate_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_in_out_interpolator.xml -** +/* ** Copyright 2007, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/accelerate_interpolator.xml b/core/res/res/anim/accelerate_interpolator.xml index 13f87f3..18207f2 100644 --- a/core/res/res/anim/accelerate_interpolator.xml +++ b/core/res/res/anim/accelerate_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_in_interpolator.xml -** +/* ** Copyright 2007, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/accelerate_quint_interpolator.xml b/core/res/res/anim/accelerate_quint_interpolator.xml index 5ab4909..cd3595c 100644 --- a/core/res/res/anim/accelerate_quint_interpolator.xml +++ b/core/res/res/anim/accelerate_quint_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_in_interpolator.xml -** +/* ** Copyright 2010, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/decelerate_cubic_interpolator.xml b/core/res/res/anim/decelerate_cubic_interpolator.xml index 78bdb40..550a591 100644 --- a/core/res/res/anim/decelerate_cubic_interpolator.xml +++ b/core/res/res/anim/decelerate_cubic_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_in_interpolator.xml -** +/* ** Copyright 2010, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/decelerate_interpolator.xml b/core/res/res/anim/decelerate_interpolator.xml index 7b29fb3..48e2308 100644 --- a/core/res/res/anim/decelerate_interpolator.xml +++ b/core/res/res/anim/decelerate_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_out_interpolator.xml -** +/* ** Copyright 2007, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/decelerate_quint_interpolator.xml b/core/res/res/anim/decelerate_quint_interpolator.xml index 0e543e6..7545b17 100644 --- a/core/res/res/anim/decelerate_quint_interpolator.xml +++ b/core/res/res/anim/decelerate_quint_interpolator.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* //device/apps/common/res/anim/ease_in_interpolator.xml -** +/* ** Copyright 2010, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/core/res/res/anim/window_move_from_decor.xml b/core/res/res/anim/window_move_from_decor.xml new file mode 100644 index 0000000..94062db --- /dev/null +++ b/core/res/res/anim/window_move_from_decor.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2009, 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. +*/ +--> + +<!-- Animation when a window is being moved on screen because the decors + around it (such as the IME) have changed. In this case the parent + container size is actually the amount the window has moved. Yes, + a nasty hack. --> +<translate xmlns:android="http://schemas.android.com/apk/res/android" + android:fromYDelta="100%p" android:toYDelta="0" + android:fromXDelta="100%p" android:toXDelta="0" + android:interpolator="@anim/decelerate_quint_interpolator" + android:duration="@android:integer/config_mediumAnimTime" /> diff --git a/core/res/res/drawable/item_background.xml b/core/res/res/drawable/item_background.xml index a1c9ff8..f7fef82 100644 --- a/core/res/res/drawable/item_background.xml +++ b/core/res/res/drawable/item_background.xml @@ -14,7 +14,8 @@ limitations under the License. --> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> +<selector xmlns:android="http://schemas.android.com/apk/res/android" + android:exitFadeDuration="@android:integer/config_mediumAnimTime"> <item android:state_window_focused="false" android:drawable="@color/transparent" /> diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index cc391d5..5287289 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -283,7 +283,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // the same as mCur*, but may be larger if the screen decor has supplied // content insets. int mContentLeft, mContentTop, mContentRight, mContentBottom; - // During layout, the current screen borders along with input method + // During layout, the current screen borders along which input method // windows are placed. int mDockLeft, mDockTop, mDockRight, mDockBottom; // During layout, the layer at which the doc window is placed. @@ -1510,13 +1510,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { return; } - if (false) { - if ("com.google.android.youtube".equals(attrs.packageName) - && attrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { - Log.i(TAG, "GOTCHA!"); - } - } - final int fl = attrs.flags; final int sim = attrs.softInputMode; @@ -1629,16 +1622,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { + " pf=" + pf.toShortString() + " df=" + df.toShortString() + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()); - if (false) { - if ("com.google.android.youtube".equals(attrs.packageName) - && attrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { - if (true || localLOGV) Log.v(TAG, "Computing frame of " + win + - ": sim=#" + Integer.toHexString(sim) - + " pf=" + pf.toShortString() + " df=" + df.toShortString() - + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()); - } - } - win.computeFrameLw(pf, df, cf, vf); // Dock windows carve out the bottom of the screen, so normal windows diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 5038770..ec05437 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -6598,6 +6598,8 @@ public class WindowManagerService extends IWindowManager.Stub final Rect mContentFrame = new Rect(); final Rect mVisibleFrame = new Rect(); + boolean mContentChanged; + float mShownAlpha = 1; float mAlpha = 1; float mLastAlpha = 1; @@ -6800,6 +6802,7 @@ public class WindowManagerService extends IWindowManager.Stub } final Rect content = mContentFrame; + mContentChanged |= !content.equals(cf); content.set(cf); final Rect visible = mVisibleFrame; @@ -9084,7 +9087,7 @@ public class WindowManagerService extends IWindowManager.Stub } } - private final int performLayoutLockedInner() { + private final int performLayoutLockedInner(boolean initial) { if (!mLayoutNeeded) { return 0; } @@ -9142,6 +9145,9 @@ public class WindowManagerService extends IWindowManager.Stub // just don't display"). if (!gone || !win.mHaveFrame) { if (!win.mLayoutAttached) { + if (initial) { + win.mContentChanged = false; + } mPolicy.layoutWindowLw(win, win.mAttrs, null); win.mLayoutSeq = seq; if (DEBUG_LAYOUT) Slog.v(TAG, "-> mFrame=" @@ -9173,6 +9179,9 @@ public class WindowManagerService extends IWindowManager.Stub + " mRelayoutCalled=" + win.mRelayoutCalled); if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame) { + if (initial) { + win.mContentChanged = false; + } mPolicy.layoutWindowLw(win, win.mAttrs, win.mAttachedWindow); win.mLayoutSeq = seq; if (DEBUG_LAYOUT) Slog.v(TAG, "-> mFrame=" @@ -9277,7 +9286,7 @@ public class WindowManagerService extends IWindowManager.Stub // FIRST LOOP: Perform a layout, if needed. if (repeats < 4) { - changes = performLayoutLockedInner(); + changes = performLayoutLockedInner(repeats == 0); if (changes != 0) { continue; } @@ -9327,7 +9336,7 @@ public class WindowManagerService extends IWindowManager.Stub final WindowManager.LayoutParams attrs = w.mAttrs; if (w.mSurface != null) { - // Execute animation. + // Take care of the window being ready to display. if (w.commitFinishDrawingLocked(currentTime)) { if ((w.mAttrs.flags & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) { @@ -9338,7 +9347,31 @@ public class WindowManagerService extends IWindowManager.Stub } final boolean wasAnimating = w.mAnimating; - final boolean nowAnimating = w.stepAnimationLocked(currentTime, dw, dh); + + int animDw = dw; + int animDh = dh; + + // If the window has moved due to its containing + // content frame changing, then we'd like to animate + // it. The checks here are ordered by what is least + //Êlikely to be true first. + if (w.mContentChanged && !wasAnimating && !w.mLastHidden && !mDisplayFrozen + && (w.mFrame.top != w.mLastFrame.top + || w.mFrame.left != w.mLastFrame.left) + && mPolicy.isScreenOn()) { + // Frame has moved, containing content frame + // has also moved, and we're not currently animating... + // let's do something. + Animation a = AnimationUtils.loadAnimation(mContext, + com.android.internal.R.anim.window_move_from_decor); + w.setAnimation(a); + animDw = w.mLastFrame.left - w.mFrame.left; + animDh = w.mLastFrame.top - w.mFrame.top; + } + + // Execute animation. + final boolean nowAnimating = w.stepAnimationLocked(currentTime, + animDw, animDh); // If this window is animating, make a note that we have // an animating window and take care of a request to run @@ -10606,7 +10639,7 @@ public class WindowManagerService extends IWindowManager.Stub mLayoutNeeded = true; } if (mode == UPDATE_FOCUS_PLACING_SURFACES) { - performLayoutLockedInner(); + performLayoutLockedInner(true); } else if (mode == UPDATE_FOCUS_WILL_PLACE_SURFACES) { // Client will do the layout, but we need to assign layers // for handleNewWindowLocked() below. |