<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<!-- There seems to be a bug in layout inflation where it can't use a resource to inflate a view
     group that sets layout_marginTop with a dimension. Work around by putting in a shell layout.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- This CardView is clickable so that clicks do not fall through to the fragment that
         is underneath the dialer_fragment. -->
    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="@dimen/lens_header_height"
        android:clickable="true"
        card_view:cardBackgroundColor="@color/car_card"
        card_view:cardElevation="@dimen/dialer_card_elevation">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/number"
                android:layout_width="match_parent"
                android:layout_height="@dimen/dialer_number_view_height"
                android:paddingTop="@dimen/dialer_number_view_padding"
                android:paddingBottom="@dimen/dialer_number_view_padding"
                android:gravity="center"
                android:focusable="true"
                android:text="@string/dial_a_number"
                android:layout_alignParentTop="true"
                style="@style/CarBody1" />

            <View
                android:id="@+id/line_divider"
                android:background="@color/car_list_divider"
                android:layout_width="match_parent"
                android:layout_height="@dimen/line_divider_height"
                android:layout_marginLeft="@dimen/stream_content_keyline_1"
                android:layout_marginRight="@dimen/stream_content_keyline_1"
                android:layout_below="@id/number" />

            <LinearLayout
                android:orientation="horizontal"
                android:layout_marginTop="@dimen/dial_container_vertical_margin"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/line_divider" >

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

                    <ImageButton
                        android:id="@+id/call"
                        android:scaleType="center"
                        android:src="@drawable/ic_phone"
                        style="@style/DialpadCall"
                        android:elevation="@dimen/call_fab_elevation"
                        android:layout_gravity="center" />
                </FrameLayout>

                <include
                    android:layout_gravity="center"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    layout="@layout/dialpad" />

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

                    <ImageButton
                        android:id="@+id/delete"
                        android:layout_width="@dimen/bksp_button_width"
                        android:layout_height="@dimen/bksp_button_width"
                        android:scaleType="centerInside"
                        android:src="@drawable/ic_backspace"
                        android:tint="@color/car_tint"
                        android:background="@drawable/dialpad_delete_button_background"
                        android:layout_gravity="center" />
                </FrameLayout>
            </LinearLayout>
        </RelativeLayout>

        <!-- This FrameLayout ensures that the back button is centered within the
             exit_dialer_button despite the button's touch target
             being smaller. -->
        <FrameLayout
            android:layout_gravity="start|top"
            android:layout_width="@dimen/stream_content_keyline_1"
            android:layout_height="@dimen/stream_content_keyline_1">

            <ImageView
                android:id="@+id/exit_dialer_button"
                android:background="@drawable/dialpad_button_background"
                android:layout_gravity="center"
                android:layout_width="@dimen/stream_button_size"
                android:layout_height="@dimen/stream_button_size"
                android:scaleType="center"
                android:tint="@color/car_tint"
                android:src="@drawable/ic_down_outlined" />
        </FrameLayout>
    </android.support.v7.widget.CardView>
</FrameLayout>