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

Commit 6eab2a5f authored by Christina Tao's avatar Christina Tao Committed by Android (Google) Code Review
Browse files

Merge "Ensure Autofill save dialog buttons are always visible when text is...

Merge "Ensure Autofill save dialog buttons are always visible when text is long + display/font size is large" into main
parents 048eb573 03866991
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -79,16 +79,16 @@
            android:layout_height="1dp"
            style="@style/AutofillHalfSheetDivider" />

        <com.android.internal.widget.ButtonBarLayout
      <com.android.server.autofill.ui.BottomSheetButtonBarLayout
          android:id="@+id/autofill_save_button_bar"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:clipToPadding="false"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:theme="@style/Theme.DeviceDefault.AutofillHalfScreenDialogButton"
            android:orientation="horizontal"
            android:gravity="center_vertical"
            android:layout_marginStart="@dimen/autofill_save_outer_margin"
            android:layout_marginEnd="@dimen/autofill_save_outer_margin"
            >
@@ -100,12 +100,15 @@
                android:paddingEnd="12dp"
                android:paddingTop="0dp"
                android:paddingBottom="0dp"
                android:layout_marginTop="4dp"
                android:layout_marginBottom="4dp"
                android:minWidth="0dp"
                style="?android:attr/borderlessButtonStyle"
                android:text="@string/autofill_save_no">
            </Button>

            <Space
                android:id="@+id/autofill_button_bar_spacer"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="1"
@@ -116,12 +119,14 @@
                android:id="@+id/autofill_save_yes"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginTop="4dp"
                android:layout_marginBottom="4dp"
                android:minWidth="0dp"
                style="@style/AutofillHalfSheetTonalButton"
                android:text="@string/autofill_save_yes">
            </Button>

        </com.android.internal.widget.ButtonBarLayout>
        </com.android.server.autofill.ui.BottomSheetButtonBarLayout>

    </com.android.server.autofill.ui.BottomSheetLayout>
</LinearLayout>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -887,6 +887,8 @@
    <dimen name="autofill_save_scroll_view_top_margin">16dp</dimen>
    <dimen name="autofill_save_button_bar_padding">16dp</dimen>
    <dimen name="autofill_dialog_corner_radius">24dp</dimen>
    <dimen name="autofill_button_bar_spacer_width">12dp</dimen>
    <dimen name="autofill_button_bar_spacer_height">4dp</dimen>

    <!-- How much extra space should be left around the autofill dialog -->
    <dimen name="autofill_dialog_offset">72dp</dimen>
+3 −0
Original line number Diff line number Diff line
@@ -3728,6 +3728,7 @@
  <java-symbol type="id" name="autofill_save_no" />
  <java-symbol type="id" name="autofill_save_title" />
  <java-symbol type="id" name="autofill_save_yes" />
  <java-symbol type="id" name="autofill_button_bar_spacer" />
  <java-symbol type="id" name="autofill_service_icon" />
  <java-symbol type="id" name="autofill_dialog_picker"/>
  <java-symbol type="id" name="autofill_dialog_header"/>
@@ -3774,6 +3775,8 @@
  <java-symbol type="dimen" name="autofill_dialog_max_width" />
  <java-symbol type="dimen" name="autofill_dialog_offset"/>
  <java-symbol type="dimen" name="autofill_save_outer_margin"/>
  <java-symbol type="dimen" name="autofill_button_bar_spacer_width"/>
  <java-symbol type="dimen" name="autofill_button_bar_spacer_height"/>

  <java-symbol type="bool" name="autofill_dialog_horizontal_space_included"/>

+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.server.autofill.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;

import com.android.internal.R;
import com.android.internal.widget.ButtonBarLayout;

/** An extension of {@link ButtonBarLayout} for use in Autofill bottom sheets. */
public class BottomSheetButtonBarLayout extends ButtonBarLayout {

    public BottomSheetButtonBarLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        final View spacer = findViewById(R.id.autofill_button_bar_spacer);
        if (spacer == null) {
            return;
        }
        if (isStacked()) {
            spacer.getLayoutParams().width = 0;
            spacer.getLayoutParams().height =
                    getResources().getDimensionPixelSize(R.dimen.autofill_button_bar_spacer_height);
            setGravity(Gravity.CENTER_VERTICAL | Gravity.END);
        } else {
            spacer.getLayoutParams().width =
                    getResources().getDimensionPixelSize(R.dimen.autofill_button_bar_spacer_width);
            spacer.getLayoutParams().height = 0;
            setGravity(Gravity.CENTER_VERTICAL);
        }
    }

    private boolean isStacked() {
        return getOrientation() == LinearLayout.VERTICAL;
    }
}