From 57beb3b5b3b1a1a2fb8387ae1fab0c18c7cf200d Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Thu, 10 Oct 2013 10:27:44 -0400 Subject: [PATCH] IME navigation guard implemented as a View. Instead of a custom onDraw in order to stay 100% in sync with abrupt layout changes. Also use the unrestricted layout bottom to avoid unnecessary fitSystemWindows churn. Bug:11162351 Change-Id: If9bb9a52d503e348d642bf1238f75c4a418ad805 --- .../internal/inputmethod/InputMethodRoot.java | 32 ++++++++----------- core/res/res/layout/input_method.xml | 5 +++ core/res/res/values/symbols.xml | 1 + .../policy/impl/PhoneWindowManager.java | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/java/com/android/internal/inputmethod/InputMethodRoot.java b/core/java/com/android/internal/inputmethod/InputMethodRoot.java index f070a58d467b7..40a424bcdd92f 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodRoot.java +++ b/core/java/com/android/internal/inputmethod/InputMethodRoot.java @@ -17,15 +17,15 @@ package com.android.internal.inputmethod; import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; import android.widget.LinearLayout; public class InputMethodRoot extends LinearLayout { - private final Rect mGuardRect = new Rect(); - private final Paint mGuardPaint = new Paint(); + + private View mNavigationGuard; public InputMethodRoot(Context context) { this(context, null); @@ -37,25 +37,19 @@ public class InputMethodRoot extends LinearLayout { public InputMethodRoot(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); - setWillNotDraw(false); - mGuardPaint.setColor(context.getResources() - .getColor(com.android.internal.R.color.input_method_navigation_guard)); } @Override protected boolean fitSystemWindows(Rect insets) { - setPadding(0, 0, 0, insets.bottom); + if (mNavigationGuard == null) { + mNavigationGuard = findViewById(com.android.internal.R.id.navigationGuard); + } + if (mNavigationGuard == null) { + return super.fitSystemWindows(insets); + } + ViewGroup.LayoutParams lp = mNavigationGuard.getLayoutParams(); + lp.height = insets.bottom; + mNavigationGuard.setLayoutParams(lp); return true; } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - // draw navigation bar guard - final int w = getMeasuredWidth(); - final int h = getMeasuredHeight(); - mGuardRect.set(0, h - getPaddingBottom(), w, h); - canvas.drawRect(mGuardRect, mGuardPaint); - } } diff --git a/core/res/res/layout/input_method.xml b/core/res/res/layout/input_method.xml index 23d71893fd992..00a3990ba4302 100644 --- a/core/res/res/layout/input_method.xml +++ b/core/res/res/layout/input_method.xml @@ -52,4 +52,9 @@ android:layout_height="wrap_content" android:visibility="gone"> + + diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index edfdcc2e2fde7..adcb3fb2db3bf 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -105,6 +105,7 @@ + diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index e9e3b27e7f84e..225bb94ea2033 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -2992,7 +2992,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pf.top = df.top = of.top = cf.top = vf.top = mDockTop; pf.right = df.right = of.right = cf.right = vf.right = mDockRight; // IM dock windows layout below the nav bar... - pf.bottom = df.bottom = of.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; + pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; // ...with content insets above the nav bar cf.bottom = vf.bottom = mStableBottom; // IM dock windows always go to the bottom of the screen.