packages/apps/AndroidTerm
Revision | 9ca6313151f1ea2a2cd417386341ec245ff663c1 (tree) |
---|---|
Zeit | 2012-01-26 06:29:43 |
Autor | Steven Luo <steven+android@stev...> |
Commiter | Jack Palevich |
Update LayoutParams and redo layout on EmulatorView resize
At the moment, when we resize an EmulatorView, we're only resizing the
contents and the area on which we're drawing, not the view itself. This
is fine in most cases (any blank space is being covered by the soft
keyboard), but on ICS, when the status bar is disabled and the action
bar is always showing, rotating from portrait to landscape with the soft
keyboard showing appears to result in an EmulatorView large enough to
push the action bar off screen.
Work around this by resizing the EmulatorView itself through adjustment
of its LayoutParams, not just the contents.
Signed-off-by: Jack Palevich <jackpal@google.com>
@@ -38,6 +38,7 @@ import android.view.GestureDetector; | ||
38 | 38 | import android.view.KeyEvent; |
39 | 39 | import android.view.MotionEvent; |
40 | 40 | import android.view.View; |
41 | +import android.view.ViewGroup.LayoutParams; | |
41 | 42 | import android.view.inputmethod.CompletionInfo; |
42 | 43 | import android.view.inputmethod.CorrectionInfo; |
43 | 44 | import android.view.inputmethod.EditorInfo; |
@@ -212,6 +213,8 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe | ||
212 | 213 | } |
213 | 214 | }; |
214 | 215 | |
216 | + private boolean mRedoLayout = false; | |
217 | + | |
215 | 218 | private GestureDetector mGestureDetector; |
216 | 219 | private GestureDetector.OnGestureListener mExtGestureListener; |
217 | 220 | private float mScrollRemainder; |
@@ -985,11 +988,10 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe | ||
985 | 988 | public void updateSize(boolean force) { |
986 | 989 | if (mKnownSize) { |
987 | 990 | getWindowVisibleDisplayFrame(mVisibleRect); |
988 | - // Work around bug in getWindowVisibleDisplayFrame | |
989 | - if (AndroidCompat.SDK < 10) { | |
990 | - if (!mSettings.showStatusBar()) { | |
991 | - mVisibleRect.top = 0; | |
992 | - } | |
991 | + /* Work around bug in getWindowVisibleDisplayFrame, and avoid | |
992 | + distracting visual glitch otherwise */ | |
993 | + if (!mSettings.showStatusBar()) { | |
994 | + mVisibleRect.top = 0; | |
993 | 995 | } |
994 | 996 | if (mSizeCallback != null) { |
995 | 997 | // Let activity adjust our size |
@@ -1001,6 +1003,13 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe | ||
1001 | 1003 | if (force || w != mVisibleWidth || h != mVisibleHeight) { |
1002 | 1004 | mVisibleWidth = w; |
1003 | 1005 | mVisibleHeight = h; |
1006 | + | |
1007 | + LayoutParams params = getLayoutParams(); | |
1008 | + params.width = w; | |
1009 | + params.height = h; | |
1010 | + setLayoutParams(params); | |
1011 | + mRedoLayout = true; | |
1012 | + | |
1004 | 1013 | updateSize(mVisibleWidth, mVisibleHeight); |
1005 | 1014 | } |
1006 | 1015 | } |
@@ -1021,6 +1030,10 @@ public class EmulatorView extends View implements GestureDetector.OnGestureListe | ||
1021 | 1030 | @Override |
1022 | 1031 | protected void onDraw(Canvas canvas) { |
1023 | 1032 | updateSize(false); |
1033 | + if (mRedoLayout) { | |
1034 | + requestLayout(); | |
1035 | + mRedoLayout = false; | |
1036 | + } | |
1024 | 1037 | int w = getWidth(); |
1025 | 1038 | int h = getHeight(); |
1026 | 1039 |