diff options
| author | Mitsuru Oshima <oshima@google.com> | 2009-06-09 21:16:08 -0700 |
|---|---|---|
| committer | Mitsuru Oshima <oshima@google.com> | 2009-06-10 15:22:17 -0700 |
| commit | e5fb328825995aa33b5b7ecf8b5bee2b17f81715 (patch) | |
| tree | 4b6ca87aaf21dd587e1d033f5ba3318c4329698f /core/java/android/view | |
| parent | ca436e24dec0fa258a8a756c3e7d07bcb096c5b3 (diff) | |
| download | frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.zip frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.tar.gz frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.tar.bz2 | |
resolution support fix/improvement
* adding compatibility menu
* backup gravity
* set expanable=true if the screen size is hvga * density.
* added "supports any density" mode. I'll add sdk check later.
* disallow to catch orientation change event if the app is not expandable. This
was causing layout problem under non-expandable mode. I discussed this with Mike C
and we agreed to do this approach for now. We'll revisit if this causes problem to
a lot of applications.
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/ViewRoot.java | 31 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 63 |
2 files changed, 57 insertions, 37 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index d8bab56..ee8229d 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -129,7 +129,6 @@ public final class ViewRoot extends Handler implements ViewParent, boolean mIsAnimating; private CompatibilityInfo mCompatibilityInfo; - private int[] mWindowLayoutParamsBackup = null; final View.AttachInfo mAttachInfo; @@ -388,10 +387,11 @@ public final class ViewRoot extends Handler implements ViewParent, if (mView == null) { mView = view; mWindowAttributes.copyFrom(attrs); - mCompatibilityInfo = - mView.getContext().getResources().getCompatibilityInfo(); - if (mCompatibilityInfo.mScalingRequired) { - mWindowLayoutParamsBackup = new int[4]; + mCompatibilityInfo = mView.getContext().getResources().getCompatibilityInfo(); + boolean restore = false; + if (mCompatibilityInfo.mScalingRequired || !mCompatibilityInfo.mExpandable) { + restore = true; + mWindowAttributes.backup(); } if (!mCompatibilityInfo.mExpandable) { adjustWindowAttributesForCompatibleMode(mWindowAttributes); @@ -420,6 +420,11 @@ public final class ViewRoot extends Handler implements ViewParent, unscheduleTraversals(); throw new RuntimeException("Adding window failed", e); } + + if (restore) { + mWindowAttributes.restore(); + } + if (mCompatibilityInfo.mScalingRequired) { mAttachInfo.mContentInsets.scale( mCompatibilityInfo.mApplicationInvertedScale); @@ -1921,9 +1926,6 @@ public final class ViewRoot extends Handler implements ViewParent, } else { didFinish = false; } - if (event != null && mCompatibilityInfo.mScalingRequired) { - event.scale(mCompatibilityInfo.mApplicationInvertedScale); - } if (DEBUG_TRACKBALL) Log.v(TAG, "Motion event:" + event); @@ -2355,13 +2357,15 @@ public final class ViewRoot extends Handler implements ViewParent, boolean restore = false; float appScale = mCompatibilityInfo.mApplicationScale; boolean scalingRequired = mCompatibilityInfo.mScalingRequired; - if (params != null && !mCompatibilityInfo.mExpandable) { + restore = true; + params.backup(); adjustWindowAttributesForCompatibleMode(params); } if (params != null && scalingRequired) { + if (!restore) params.backup(); restore = true; - params.scale(appScale, mWindowLayoutParamsBackup); + params.scale(appScale); } int relayoutResult = sWindowSession.relayout( mWindow, params, @@ -2370,7 +2374,7 @@ public final class ViewRoot extends Handler implements ViewParent, viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mSurface); if (restore) { - params.restore(mWindowLayoutParamsBackup); + params.restore(); } if (scalingRequired) { float invertedScale = mCompatibilityInfo.mApplicationInvertedScale; @@ -2396,12 +2400,15 @@ public final class ViewRoot extends Handler implements ViewParent, if (attrs.width == ViewGroup.LayoutParams.FILL_PARENT) { attrs.width = metrics.widthPixels; attrs.gravity |= Gravity.CENTER_HORIZONTAL; + mWindowAttributesChanged = attrs == mWindowAttributes; } if (attrs.height == ViewGroup.LayoutParams.FILL_PARENT) { attrs.height = metrics.heightPixels; + attrs.gravity |= Gravity.TOP; + mWindowAttributesChanged = attrs == mWindowAttributes; } if (DEBUG_LAYOUT) { - Log.d(TAG, "Attributes fixed for compatibility : " + attrs); + Log.d(TAG, "Adjusted Attributes for compatibility : " + attrs); } } } diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index ec2069c..e1c4687 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -818,6 +818,9 @@ public interface WindowManager extends ViewManager { public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; + // internal buffer to backup/restore parameters under compatibility mode. + private int[] mCompatibilityParamsBackup = null; + public final int copyFrom(LayoutParams o) { int changes = 0; @@ -975,37 +978,47 @@ public interface WindowManager extends ViewManager { /** * Scale the layout params' coordinates and size. - * Returns the original info as a backup so that the caller can - * restore the layout params; - */ - void scale(float scale, int[] backup) { - if (scale != 1.0f) { - backup[0] = x; - backup[1] = y; - x *= scale; - y *= scale; - if (width > 0) { - backup[2] = width; - width *= scale; - } - if (height > 0) { - backup[3] = height; - height *= scale; - } + */ + void scale(float scale) { + x *= scale; + y *= scale; + if (width > 0) { + width *= scale; + } + if (height > 0) { + height *= scale; } } /** - * Restore the layout params' coordinates and size. - */ - void restore(int[] backup) { - x = backup[0]; - y = backup[1]; - if (width > 0) { - width = backup[2]; + * Backup the layout parameters used in compatibility mode. + * @see LayoutParams#restore() + */ + void backup() { + int[] backup = mCompatibilityParamsBackup; + if (backup == null) { + // we backup 5 elements, x, y, width, height and gravity. + backup = mCompatibilityParamsBackup = new int[5]; } - if (height > 0) { + backup[0] = x; + backup[1] = y; + backup[2] = width; + backup[3] = height; + backup[4] = gravity; + } + + /** + * Restore the layout params' coordinates, size and gravity + * @see LayoutParams#backup() + */ + void restore() { + int[] backup = mCompatibilityParamsBackup; + if (backup != null) { + x = backup[0]; + y = backup[1]; + width = backup[2]; height = backup[3]; + gravity = backup[4]; } } |
