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

Commit 9f879a2d authored by Dake Gu's avatar Dake Gu
Browse files

autofill: render autofill ui in fullscreen for tv

When IME and autofill are both showing on TV, it's confusing which
window has the input focus. This CL changes autofill window to
full screen for TV.

Bug: 72122929
Test: Manual tested on TV with github example. Manually tested on
phone that UI doesn't change.

Change-Id: Id97b6389523b2ee744d02f5bc7847b307b0b29e4
parent e5844ce1
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class AutofillPopupWindow extends PopupWindow {

    private final WindowPresenter mWindowPresenter;
    private WindowManager.LayoutParams mWindowLayoutParams;
    private boolean mFullScreen;

    private final View.OnAttachStateChangeListener mOnAttachStateChangeListener =
            new View.OnAttachStateChangeListener() {
@@ -104,12 +105,17 @@ public class AutofillPopupWindow extends PopupWindow {
     */
    public void update(View anchor, int offsetX, int offsetY, int width, int height,
            Rect virtualBounds) {
        mFullScreen = width == LayoutParams.MATCH_PARENT && height == LayoutParams.MATCH_PARENT;
        // If we are showing the popup for a virtual view we use a fake view which
        // delegates to the anchor but present itself with the same bounds as the
        // virtual view. This ensures that the location logic in popup works
        // symmetrically when the dropdown is below and above the anchor.
        final View actualAnchor;
        if (virtualBounds != null) {
        if (mFullScreen) {
            offsetX = 0;
            offsetY = 0;
            actualAnchor = anchor;
        } else if (virtualBounds != null) {
            final int[] mLocationOnScreen = new int[] {virtualBounds.left, virtualBounds.top};
            actualAnchor = new View(anchor.getContext()) {
                @Override
@@ -208,6 +214,17 @@ public class AutofillPopupWindow extends PopupWindow {
                layoutDirection);
    }

    @Override
    protected boolean findDropDownPosition(View anchor, LayoutParams outParams,
            int xOffset, int yOffset, int width, int height, int gravity, boolean allowScroll) {
        if (mFullScreen) {
            // Do not patch LayoutParams if force full screen
            return false;
        }
        return super.findDropDownPosition(anchor, outParams, xOffset, yOffset,
                width, height, gravity, allowScroll);
    }

    @Override
    public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
        if (sVerbose) {
+1 −1
Original line number Diff line number Diff line
@@ -1583,7 +1583,7 @@ public class PopupWindow {
     *
     * @hide
     */
    protected final boolean findDropDownPosition(View anchor, WindowManager.LayoutParams outParams,
    protected boolean findDropDownPosition(View anchor, WindowManager.LayoutParams outParams,
            int xOffset, int yOffset, int width, int height, int gravity, boolean allowScroll) {
        final int anchorHeight = anchor.getHeight();
        final int anchorWidth = anchor.getWidth();
+48 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 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.
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/autofill_dataset_picker"
    style="@style/AutofillDatasetPicker"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/autofill_window_title"
        android:layout_above="@+id/autofill_dataset_container"
        android:layout_alignStart="@+id/autofill_dataset_container"
        android:textSize="16sp"/>

    <!-- autofill_container is the common parent for inserting authentication item or
         autofill_dataset_list-->
    <FrameLayout
        android:id="@+id/autofill_dataset_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true">
        <ListView
            android:id="@+id/autofill_dataset_list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:divider="@null"
            android:drawSelectorOnTop="true"
            android:visibility="gone"/>
    </FrameLayout>

</RelativeLayout>
+4 −0
Original line number Diff line number Diff line
@@ -20,4 +20,8 @@
     <item type="dimen" format="float" name="ambient_shadow_alpha">0.15</item>
     <item type="dimen" format="float" name="spot_shadow_alpha">0.3</item>

     <!-- Max width/height of the autofill data set picker as a fraction of the screen width/height -->
     <dimen name="autofill_dataset_picker_max_width">60%</dimen>
     <dimen name="autofill_dataset_picker_max_height">70%</dimen>

</resources>
+2 −1
Original line number Diff line number Diff line
@@ -626,7 +626,8 @@
    <dimen name="messaging_avatar_size">@dimen/notification_right_icon_size</dimen>

    <!-- Max width/height of the autofill data set picker as a fraction of the screen width/height -->
    <dimen name="autofill_dataset_picker_max_size">90%</dimen>
    <dimen name="autofill_dataset_picker_max_width">90%</dimen>
    <dimen name="autofill_dataset_picker_max_height">90%</dimen>

    <!-- Max height of the the autofill save custom subtitle as a fraction of the screen width/height -->
    <dimen name="autofill_save_custom_subtitle_max_height">20%</dimen>
Loading