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

Commit 2171dd97 authored by Charles Wang's avatar Charles Wang Committed by Christina Tao
Browse files

Implement divider for Autofill bottom sheet save dialog. The divider will only...

Implement divider for Autofill bottom sheet save dialog. The divider will only be visible if there is extra content being hidden below the footer.

Test: manual on phone, table, foldable. also ran atest CtsAutoFillServiceTestCases
Bug: b/301252119
Change-Id: I58533bf8b12deeea8d8483c3667fb7f6a2061c0b
parent 07b38fe4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!-- Copied from //frameworks/base/core/res/res/drawable/list_divider_material.xml. -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:tint="@color/foreground_material_light">
  <solid android:color="#1f000000" />
  <size
      android:height="1dp"
      android:width="1dp"/>
</shape>
 No newline at end of file
+13 −4
Original line number Diff line number Diff line
@@ -31,11 +31,11 @@
        android:gravity="center_horizontal"
        android:orientation="vertical">
        <ScrollView
            android:id="@+id/autofill_sheet_scroll_view"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:fillViewport="true"
            android:layout_weight="1"
            android:layout_marginBottom="8dp">
            android:layout_weight="1">
            <LinearLayout
                android:layout_marginStart="@dimen/autofill_save_outer_margin"
                android:layout_marginEnd="@dimen/autofill_save_outer_margin"
@@ -66,16 +66,25 @@
                    android:layout_height="wrap_content"
                    android:minHeight="0dp"
                    android:visibility="gone"/>

                <View
                    android:id="@+id/autofill_sheet_scroll_view_space"
                    android:layout_width="match_parent"
                    android:layout_height="16dp"/>
            </LinearLayout>
        </ScrollView>

        <View
            android:id="@+id/autofill_sheet_divider"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            style="@style/AutofillHalfSheetDivider" />

        <com.android.internal.widget.ButtonBarLayout
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_gravity="end"
            android:clipToPadding="false"
            android:layout_marginTop="16dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:theme="@style/Theme.DeviceDefault.AutofillHalfScreenDialogButton"
            android:orientation="horizontal"
+5 −0
Original line number Diff line number Diff line
@@ -1515,6 +1515,11 @@ please see styles_device_defaults.xml.
        <item name="background">@drawable/btn_outlined</item>
    </style>

    <!-- @hide Divider for Autofill half screen dialog -->
    <style name="AutofillHalfSheetDivider">
        <item name="android:background">@drawable/autofill_half_sheet_divider</item>
    </style>

    <!-- @hide Autofill background for popup window (not for fullscreen) -->
    <style name="AutofillDatasetPicker">
        <item name="elevation">4dp</item>
+4 −0
Original line number Diff line number Diff line
@@ -3702,6 +3702,10 @@
  <java-symbol type="id" name="autofill_dataset_list"/>
  <java-symbol type="id" name="autofill_dataset_picker"/>
  <java-symbol type="id" name="autofill_dataset_title" />
  <java-symbol type="id" name="autofill_sheet_divider"/>
  <java-symbol type="id" name="autofill_sheet_scroll_view"/>
  <java-symbol type="id" name="autofill_sheet_scroll_view_space"/>

  <java-symbol type="id" name="autofill_save_custom_subtitle" />
  <java-symbol type="id" name="autofill_save_icon" />
  <java-symbol type="id" name="autofill_save_no" />
+16 −0
Original line number Diff line number Diff line
@@ -58,11 +58,13 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.autofill.AutofillManager;
import android.widget.ImageView;
import android.widget.RemoteViews;
import android.widget.ScrollView;
import android.widget.TextView;

import com.android.internal.R;
@@ -370,9 +372,23 @@ final class SaveUi {
        params.windowAnimations = R.style.AutofillSaveAnimation;
        params.setTrustedOverlay();

        ScrollView scrollView = view.findViewById(R.id.autofill_sheet_scroll_view);

        View divider = view.findViewById(R.id.autofill_sheet_divider);

        ViewTreeObserver observer = scrollView.getViewTreeObserver();
        observer.addOnGlobalLayoutListener(() -> adjustDividerVisibility(scrollView, divider));

        scrollView.getViewTreeObserver()
                .addOnScrollChangedListener(() -> adjustDividerVisibility(scrollView, divider));
        show();
    }

    private void adjustDividerVisibility(ScrollView scrollView, View divider) {
        boolean canScrollDown = scrollView.canScrollVertically(1); // 1 to check scrolling down
        divider.setVisibility(canScrollDown ? View.VISIBLE : View.INVISIBLE);
    }

    private boolean applyCustomDescription(@NonNull Context context, @NonNull View saveUiView,
            @NonNull ValueFinder valueFinder, @NonNull SaveInfo info) {
        final CustomDescription customDescription = info.getCustomDescription();