<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2015 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.
-->
<com.android.messaging.ui.conversation.ComposeMessageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/message_compose_view_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <!-- Note it may seem off to have the layout_weight="1" on the compose bar and attachment view
     when it's the media picker that expands, but this is correct because weight also works when
     there's not enough space.  Any views with positive weights will be shrunk to make space.
     When the media picker goes full screen, it fills the parent, leaving no room for the compose
     bar -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:orientation="vertical">

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

        <include layout="@layout/attachment_preview"
            android:id="@+id/attachment_draft_view"
            style="@style/ComposeMessageViewDraftViewStyle"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginBottom="4dp"
            android:layout_weight="1"
            android:visibility="gone" />

        <RelativeLayout
            android:id="@+id/subject_view"
            style="@style/SubjectViewStyle"
            android:paddingTop="@dimen/compose_message_subject_top_padding"
            android:paddingBottom="@dimen/compose_message_subject_bottom_padding"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:orientation="horizontal">

            <com.android.messaging.ui.PlainTextEditText
                android:background="@drawable/subject_editor_bubble"
                android:id="@+id/compose_subject_text"
                style="@style/ConversationComposeSubjectText"
                android:hint="@string/compose_message_view_subject_hint_text"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:imeOptions="flagNoExtractUi" />

            <ImageButton
                android:id="@+id/delete_subject_button"
                style="@style/AttachmentPreviewCloseButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@null"
                android:src="@drawable/ic_remove_light"
                android:translationY="@dimen/compose_message_subject_cancel_top_offset"
                android:contentDescription="@string/delete_subject_content_description" />

        </RelativeLayout>

        <!-- Holds all views that create the actual compose box -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <!-- Contains compose message bubble and character counter for SMS which should be left
            aligned -->
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <!-- Contains media button and compose message bubble whose centers should be
                vertically aligned -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <ImageButton
                        android:id="@+id/attach_media_button"
                        style="@style/ComposeMessageViewAttachMediaButtonStyle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:src="@drawable/ic_attachment_dark"
                        android:paddingTop="@dimen/compose_message_attachment_padding_topBottom"
                        android:paddingBottom="@dimen/compose_message_attachment_padding_topBottom"
                        android:contentDescription="@string/attachMediaButtonContentDescription" />

                    <com.android.messaging.ui.PlainTextEditText
                        android:id="@+id/compose_message_text"
                        style="@style/ConversationComposeSendText"
                        android:layout_height="wrap_content"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_gravity="center"
                        android:background="@drawable/msg_bubble_input"
                        android:hint="@string/compose_message_view_hint_text"
                        android:imeOptions="actionSend|flagNoEnterAction|flagNoExtractUi" />

                </LinearLayout>

                <TextView
                    android:id="@+id/char_counter"
                    style="@style/ComposeMessageViewTextCounterStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:maxLines="1"
                    android:visibility="invisible" />
            </LinearLayout>

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    style="@style/ComposeMessageViewFrameLayoutStyle"
                    android:layout_gravity="top" >
                    <com.android.messaging.ui.conversation.SimIconView
                        android:id="@+id/self_send_icon"
                        android:layout_width="@dimen/conversation_message_contact_icon_size"
                        android:layout_height="@dimen/conversation_message_contact_icon_size"
                        android:importantForAccessibility="no"
                        app:iconSize="normal"
                        app:reveal="true"
                        android:clickable="true" />
                    <ImageButton
                        android:id="@+id/send_message_button"
                        android:layout_width="@dimen/conversation_message_contact_icon_size"
                        android:layout_height="@dimen/conversation_message_contact_icon_size"
                        android:src="@drawable/ic_send_light"
                        android:background="@drawable/send_arrow_background"
                        android:contentDescription="@string/sendButtonContentDescription"
                        android:visibility="gone" />
                </FrameLayout>

                <TextView
                    android:id="@+id/mms_indicator"
                    style="@style/MmsIndicatorStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:maxLines="1"
                    android:visibility="invisible"
                    android:text="@string/mms_text" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <FrameLayout
        android:id="@+id/mediapicker_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0" />

</com.android.messaging.ui.conversation.ComposeMessageView>
