<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright 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.
-->

<!-- Car customizations
     - Added title "Enter your PIN" under the entry field
     - Put backspace and enter buttons in row 4
     - Hid the emergency call at the bottom
-->

<com.android.systemui.car.keyguard.CarKeyguardPINView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/keyguard_pin_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_gravity="center_vertical"
    android:paddingHorizontal="@dimen/keyguard_pin_view_padding_horizontal"
    app:layout_maxHeight="@dimen/pin_view_container_maxHeight">

    <FrameLayout
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/pin_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="8dp"
            android:layout_weight="1"
            android:layoutDirection="ltr"
            android:orientation="vertical">

            <androidx.constraintlayout.helper.widget.Flow
                android:id="@+id/flow1"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:orientation="horizontal"
                app:constraint_referenced_ids="key1,key2,key3,key4,key5,key6,key7,key8,key9,delete_button,key0,key_enter"
                app:flow_horizontalGap="@dimen/num_pad_key_margin_end"
                app:flow_horizontalStyle="packed"
                app:flow_maxElementsWrap="3"
                app:flow_verticalStyle="packed"
                app:flow_wrapMode="aligned"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent" />

            <include layout="@layout/num_pad_keys"/>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </FrameLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="vertical">

        <com.android.keyguard.PasswordTextView
            android:id="@+id/pinEntry"
            android:layout_width="@dimen/keyguard_security_width"
            android:layout_height="@dimen/pin_entry_height"
            android:gravity="center"
            android:focusedByDefault="true"
            app:scaledTextSize="@integer/password_text_view_scale"
            android:contentDescription="@string/keyguard_accessibility_pin_area" />

        <View
            android:id="@+id/divider"
            android:layout_width="@dimen/keyguard_security_width"
            android:layout_height="@dimen/divider_height"
            android:background="@android:color/white" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@*android:dimen/car_padding_2"
            android:gravity="center"
            android:textColor="@android:color/white"
            android:textSize="@*android:dimen/car_body1_size"
            android:text="@string/car_keyguard_enter_your_pin" />

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

        <Button
            android:id="@+id/cancel_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            style="@style/KeyguardButton"
            android:text="@string/cancel"/>
    </LinearLayout>

    <!-- CarKeyguardPinView references these resources ids in code so removing them will cause the
         keyguard to crash. Instead put them down here where they are out of the way and set their
         visibility to gone. -->
    <com.android.keyguard.AlphaOptimizedRelativeLayout
        android:id="@+id/row0"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone" />

    <LinearLayout
        android:id="@+id/row1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone" />

    <LinearLayout
        android:id="@+id/row2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone" />

    <LinearLayout
        android:id="@+id/row3"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone" />

    <LinearLayout
        android:id="@+id/row4"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone" />

    <include layout="@layout/keyguard_eca"
        android:id="@+id/keyguard_selector_fade_container"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"/>
</com.android.systemui.car.keyguard.CarKeyguardPINView>
