<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<merge
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <!-- Scan card -->
    <com.google.android.material.button.MaterialButton
        android:id="@+id/scan_card_button"
        style="@style/Widget.Material3Expressive.Button.TonalButton"
        android:layout_width="match_parent"
        android:layout_height="@dimen/local_card_scanner_height"
        android:text="@string/autofill_scan_credit_card_button"
        android:textAppearance="@style/TextAppearance.TextMediumThick.Primary"
        app:shapeAppearance="@style/ShapeAppearance.Material3.Corner.Large"
        app:icon="@drawable/ic_photo_camera"
        app:iconSize="@dimen/text_size_medium"
        app:iconGravity="textStart"
        android:visibility="gone"/>

    <!-- Required fields indicator -->
    <TextView
        android:id="@+id/required_fields_indicator_label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/pref_autofill_field_large_top_margin"
        android:layout_marginBottom="@dimen/pref_autofill_field_bottom_margin"
        android:textAppearance="@style/TextAppearance.TextSmall.Secondary"
        android:text="@string/payments_required_field_message"/>

    <!-- Credit card number -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/credit_card_number_label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/pref_autofill_field_top_margin"
        android:layout_marginBottom="@dimen/pref_autofill_field_bottom_margin"
        app:errorTextAppearance="@style/TextAppearance.ErrorCaption"
        android:hint="@string/autofill_credit_card_editor_number">

        <!-- TODO(crbug.com/40600572): Fix and remove lint ignore -->
        <org.chromium.chrome.browser.autofill.editors.common.EditTextNoAutofillView
            tools:ignore="Autofill"
            android:id="@+id/credit_card_number_edit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/min_touch_target_size"
            android:imeOptions="flagNoExtractUi"
            android:inputType="phone"
            android:digits="0123456789- " />

    </com.google.android.material.textfield.TextInputLayout>

    <!--- Expiration date & CVC -->
    <LinearLayout
        android:id="@+id/credit_card_expiration_and_cvc_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_weight="1">

            <TextView
                android:id="@+id/credit_card_expiration_month_and_year_label"
                android:labelFor="@+id/expiration_month_and_year"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/pref_autofill_field_top_margin"
                android:textAppearance="@style/TextAppearance.TextSmall.Secondary"
                android:text="@string/autofill_credit_card_editor_expiration_date" />

            <org.chromium.chrome.browser.autofill.editors.common.EditTextNoAutofillView
                android:id="@+id/expiration_month_and_year"
                android:width="@dimen/local_card_expiration_date_editor_width"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:digits="0123456789/"
                android:gravity="start"
                android:hint="@string/autofill_credit_card_editor_expiration_date_hint"
                android:imeOptions="actionNext"
                android:inputType="number"
                android:maxLength="5"
                android:minHeight="@dimen/min_touch_target_size"
                android:textAppearance="@style/TextAppearance.TextLarge.Primary"
                tools:ignore="Autofill,LabelFor" />
        </LinearLayout>

<!--        TODO(crbug.com/439911511): Legacy CVV container.-->
        <FrameLayout
            android:id="@+id/cvc_legacy_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1">

            <!-- While a 3-deep nested layout is typically not recommended, it
                 is used here because of the tight constraints shown below.

                 Small display/font size:

                 |Expiration date                  Security code *Icon*|
                 |_______________                  _____________ *    *|

                 Large display/font size:

                 |Expiration Security *Icon*|
                 |date       code     *    *|
                 |__________ ________ *    *| -->
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_gravity="end"
                tools:ignore="UselessParent">

                <TextView
                    android:id="@+id/credit_card_security_code_label"
                    android:labelFor="@+id/cvc"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/pref_autofill_field_top_margin"
                    android:textAppearance="@style/TextAppearance.TextSmall.Secondary"
                    android:text="@string/autofill_credit_card_editor_security_code" />

                <org.chromium.chrome.browser.autofill.editors.common.EditTextNoAutofillView
                    android:id="@+id/cvc"
                    android:width="@dimen/local_card_cvc_editor_width"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:hint="@string/autofill_optional_tag"
                    android:imeOptions="actionNext"
                    android:inputType="number"
                    android:minHeight="@dimen/min_touch_target_size"
                    android:textAppearance="@style/TextAppearance.TextLarge.Primary"
                    tools:ignore="Autofill,LabelFor" />
            </LinearLayout>
        </FrameLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/credit_card_security_code_label_material"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="end"
            android:hint="@string/autofill_optional_tag"
            android:visibility="gone">

            <org.chromium.chrome.browser.autofill.editors.common.EditTextNoAutofillView
                android:id="@+id/cvc_material"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:imeOptions="actionNext"
                android:inputType="number"
                tools:ignore="Autofill,LabelFor" />
        </com.google.android.material.textfield.TextInputLayout>

        <ImageView
            android:id="@+id/cvc_hint_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/local_card_cvc_image_horizontal_margin"
            android:layout_marginEnd="@dimen/local_card_cvc_image_large_horizontal_margin"
            android:layout_gravity="center_vertical"
            android:src="@drawable/cvc_icon"
            tools:ignore="ContentDescription" />

    </LinearLayout>

    <!-- Name -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/credit_card_name_label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/pref_autofill_field_top_margin"
        android:layout_marginBottom="@dimen/pref_autofill_field_bottom_margin"
        android:hint="@string/autofill_credit_card_editor_name">

        <!-- TODO(crbug.com/40600572): Fix and remove lint ignore -->
        <org.chromium.chrome.browser.autofill.editors.common.EditTextNoAutofillView
            tools:ignore="Autofill"
            android:id="@+id/credit_card_name_edit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/min_touch_target_size"
            android:imeOptions="flagNoExtractUi"
            android:inputType="textCapWords" />

    </com.google.android.material.textfield.TextInputLayout>

    <include layout="@layout/autofill_billing_address_dropdown" />

    <!-- Nickname -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/credit_card_nickname_label"
        app:counterMaxLength="25"
        app:errorEnabled="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/pref_autofill_field_extra_large_top_margin"
        android:layout_marginBottom="@dimen/pref_autofill_field_bottom_margin"
        android:hint="@string/autofill_credit_card_editor_nickname">

        <org.chromium.chrome.browser.autofill.editors.common.EditTextNoAutofillView
            tools:ignore="Autofill"
            android:id="@+id/credit_card_nickname_edit"
            android:maxLength="25"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/min_touch_target_size"
            android:imeOptions="flagNoExtractUi"
            android:inputType="textCapWords" />

    </com.google.android.material.textfield.TextInputLayout>
</merge>
