Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5217f09 authored by John Spurlock's avatar John Spurlock Committed by Android Git Automerger
Browse files

am 1eeb5ff2: am d4595bd1: Merge "Move the IME navigation guard view up to decor." into klp-dev

* commit '1eeb5ff2':
  Move the IME navigation guard view up to decor.
parents 51e4f391 1eeb5ff2
Loading
Loading
Loading
Loading
+0 −61
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2013 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.
 */

package com.android.internal.inputmethod;

import android.content.Context;
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 View mNavigationGuard;

    public InputMethodRoot(Context context) {
        this(context, null);
    }

    public InputMethodRoot(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public InputMethodRoot(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        requestFitSystemWindows();
    }

    @Override
    protected boolean fitSystemWindows(Rect insets) {
        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;
    }
}
+2 −7
Original line number Original line Diff line number Diff line
@@ -18,12 +18,11 @@
*/
*/
-->
-->


<com.android.internal.inputmethod.InputMethodRoot xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parentPanel"
    android:id="@+id/parentPanel"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:orientation="vertical"
    android:gravity="start|bottom"
    >
    >


    <LinearLayout
    <LinearLayout
@@ -54,8 +53,4 @@
        android:visibility="gone">
        android:visibility="gone">
    </FrameLayout>
    </FrameLayout>


    <View android:id="@+id/navigationGuard"
</LinearLayout>
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@+color/input_method_navigation_guard"/>
</com.android.internal.inputmethod.InputMethodRoot>
+0 −1
Original line number Original line Diff line number Diff line
@@ -105,7 +105,6 @@
  <java-symbol type="id" name="month" />
  <java-symbol type="id" name="month" />
  <java-symbol type="id" name="month_name" />
  <java-symbol type="id" name="month_name" />
  <java-symbol type="id" name="name" />
  <java-symbol type="id" name="name" />
  <java-symbol type="id" name="navigationGuard" />
  <java-symbol type="id" name="next" />
  <java-symbol type="id" name="next" />
  <java-symbol type="id" name="next_button" />
  <java-symbol type="id" name="next_button" />
  <java-symbol type="id" name="new_app_action" />
  <java-symbol type="id" name="new_app_action" />
+32 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,8 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManager.LayoutParams.*;


import android.view.ViewConfiguration;
import android.view.ViewConfiguration;

import com.android.internal.R;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.RootViewSurfaceTaker;
import com.android.internal.view.StandaloneActionMode;
import com.android.internal.view.StandaloneActionMode;
import com.android.internal.view.menu.ContextMenuBuilder;
import com.android.internal.view.menu.ContextMenuBuilder;
@@ -1920,6 +1922,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        private PopupWindow mActionModePopup;
        private PopupWindow mActionModePopup;
        private Runnable mShowActionModePopup;
        private Runnable mShowActionModePopup;


        // View added at runtime to IME windows to cover the navigation bar
        private View mNavigationGuard;

        public DecorView(Context context, int featureId) {
        public DecorView(Context context, int featureId) {
            super(context);
            super(context);
            mFeatureId = featureId;
            mFeatureId = featureId;
@@ -2479,6 +2484,33 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        @Override
        @Override
        protected boolean fitSystemWindows(Rect insets) {
        protected boolean fitSystemWindows(Rect insets) {
            mFrameOffsets.set(insets);
            mFrameOffsets.set(insets);

            // IMEs lay out below the nav bar, but the content view must not (for back compat)
            if (getAttributes().type == WindowManager.LayoutParams.TYPE_INPUT_METHOD) {
                // prevent the content view from including the nav bar height
                if (mContentParent != null) {
                    if (mContentParent.getLayoutParams() instanceof MarginLayoutParams) {
                        MarginLayoutParams mlp =
                                (MarginLayoutParams) mContentParent.getLayoutParams();
                        mlp.bottomMargin = insets.bottom;
                        mContentParent.setLayoutParams(mlp);
                    }
                }
                // position the navigation guard view, creating it if necessary
                if (mNavigationGuard == null) {
                    mNavigationGuard = new View(mContext);
                    mNavigationGuard.setBackgroundColor(mContext.getResources()
                            .getColor(R.color.input_method_navigation_guard));
                    addView(mNavigationGuard, new LayoutParams(
                            LayoutParams.MATCH_PARENT, insets.bottom,
                            Gravity.START | Gravity.BOTTOM));
                } else {
                    LayoutParams lp = (LayoutParams) mNavigationGuard.getLayoutParams();
                    lp.height = insets.bottom;
                    mNavigationGuard.setLayoutParams(lp);
                }
            }

            if (getForeground() != null) {
            if (getForeground() != null) {
                drawableChanged();
                drawableChanged();
            }
            }