|
23 | 23 | import static android.view.WindowManager.LayoutParams.*;
|
24 | 24 |
|
25 | 25 | import android.view.ViewConfiguration;
|
| 26 | + |
| 27 | +import com.android.internal.R; |
26 | 28 | import com.android.internal.view.RootViewSurfaceTaker;
|
27 | 29 | import com.android.internal.view.StandaloneActionMode;
|
28 | 30 | import com.android.internal.view.menu.ContextMenuBuilder;
|
@@ -1920,6 +1922,9 @@ private final class DecorView extends FrameLayout implements RootViewSurfaceTake
|
1920 | 1922 | private PopupWindow mActionModePopup;
|
1921 | 1923 | private Runnable mShowActionModePopup;
|
1922 | 1924 |
|
| 1925 | + // View added at runtime to IME windows to cover the navigation bar |
| 1926 | + private View mNavigationGuard; |
| 1927 | + |
1923 | 1928 | public DecorView(Context context, int featureId) {
|
1924 | 1929 | super(context);
|
1925 | 1930 | mFeatureId = featureId;
|
@@ -2479,6 +2484,33 @@ public void setWindowFrame(Drawable drawable) {
|
2479 | 2484 | @Override
|
2480 | 2485 | protected boolean fitSystemWindows(Rect insets) {
|
2481 | 2486 | mFrameOffsets.set(insets);
|
| 2487 | + |
| 2488 | + // IMEs lay out below the nav bar, but the content view must not (for back compat) |
| 2489 | + if (getAttributes().type == WindowManager.LayoutParams.TYPE_INPUT_METHOD) { |
| 2490 | + // prevent the content view from including the nav bar height |
| 2491 | + if (mContentParent != null) { |
| 2492 | + if (mContentParent.getLayoutParams() instanceof MarginLayoutParams) { |
| 2493 | + MarginLayoutParams mlp = |
| 2494 | + (MarginLayoutParams) mContentParent.getLayoutParams(); |
| 2495 | + mlp.bottomMargin = insets.bottom; |
| 2496 | + mContentParent.setLayoutParams(mlp); |
| 2497 | + } |
| 2498 | + } |
| 2499 | + // position the navigation guard view, creating it if necessary |
| 2500 | + if (mNavigationGuard == null) { |
| 2501 | + mNavigationGuard = new View(mContext); |
| 2502 | + mNavigationGuard.setBackgroundColor(mContext.getResources() |
| 2503 | + .getColor(R.color.input_method_navigation_guard)); |
| 2504 | + addView(mNavigationGuard, new LayoutParams( |
| 2505 | + LayoutParams.MATCH_PARENT, insets.bottom, |
| 2506 | + Gravity.START | Gravity.BOTTOM)); |
| 2507 | + } else { |
| 2508 | + LayoutParams lp = (LayoutParams) mNavigationGuard.getLayoutParams(); |
| 2509 | + lp.height = insets.bottom; |
| 2510 | + mNavigationGuard.setLayoutParams(lp); |
| 2511 | + } |
| 2512 | + } |
| 2513 | + |
2482 | 2514 | if (getForeground() != null) {
|
2483 | 2515 | drawableChanged();
|
2484 | 2516 | }
|
|
0 commit comments