<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:app="http://schemas.android.com/apk/res-auto"
	android:id="@+id/compose_root"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:orientation="vertical">

	<!-- http://stackoverflow.com/questions/21201569/android-resize-only-parts-of-view-with-soft-keyboard-on-screen -->
	<ScrollView
		android:id="@+id/wallpaper_scroll"
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:background="@android:color/transparent"
		android:importantForAccessibility="no"
		android:fillViewport="true"
		android:scrollbars="none">

		<ImageView
			android:id="@+id/wallpaper_view"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:scaleType="centerCrop"
			android:visibility="gone"
			android:importantForAccessibility="no"/>

	</ScrollView>

	<androidx.coordinatorlayout.widget.CoordinatorLayout
		android:id="@+id/coordinator"
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:gravity="bottom">

		<LinearLayout
			android:id="@+id/conversation_parent"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:orientation="vertical"
			app:layout_behavior="ch.threema.app.ui.LinearLayoutBehavior">

			<ch.threema.app.ui.OpenBallotNoticeView
				android:id="@+id/open_ballots_layout"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:animateLayoutChanges="true"
				android:background="?attr/background_openNotice"
				android:elevation="4dp"
				android:visibility="gone" />

			<ch.threema.app.grouplinks.OpenGroupRequestNoticeView
				android:id="@+id/open_group_requests_layout"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:animateLayoutChanges="true"
				android:background="?attr/background_openNotice"
				android:elevation="4dp"
				android:visibility="gone" />

			<RelativeLayout
				android:layout_width="match_parent"
				android:layout_height="0dp"
				android:layout_weight="1.0">

				<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
					android:id="@+id/ptr_layout"
					android:layout_width="match_parent"
					android:layout_height="match_parent"
					android:layout_alignWithParentIfMissing="true"
					android:layout_above="@+id/quote_panel">

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

						<ch.threema.app.ui.ConversationListView
							android:id="@+id/history"
							android:layout_width="match_parent"
							android:layout_height="match_parent"
							android:cacheColorHint="@android:color/white"
							android:choiceMode="singleChoice"
							android:fadeScrollbars="true"
							android:fadingEdge="none"
							android:listSelector="@android:color/transparent"
							android:paddingTop="5dp"
							android:scrollbarAlwaysDrawVerticalTrack="false"
							android:scrollbarSize="@dimen/scrollbar_size"
							android:scrollbarStyle="insideOverlay"
							android:smoothScrollbar="true"
							android:stackFromBottom="true"
							android:transcriptMode="normal"
							android:visibility="visible" />

						<FrameLayout
							android:id="@+id/date_separator_container"
							android:layout_width="match_parent"
							android:layout_height="wrap_content"
							android:gravity="top|center_horizontal"
							android:paddingTop="5dp"
							android:paddingBottom="3dp"
							android:paddingLeft="3dp"
							android:paddingRight="3dp"
							android:clipToPadding="false"
							android:visibility="gone">

							<include layout="@layout/date_separator" />
						</FrameLayout>

						<ImageView
							android:id="@+id/quickscroll_top"
							android:layout_width="48dp"
							android:layout_height="48dp"
							android:layout_gravity="right|top"
							android:layout_marginTop="8dp"
							android:layout_marginRight="8dp"
							android:background="@drawable/background_quickscroll"
							android:clickable="true"
							android:scaleType="center"
							android:visibility="gone"
							app:srcCompat="@drawable/ic_arrow_upward"
							app:tint="?attr/colorAccent" />

						<ImageView
							android:id="@+id/quickscroll_bottom"
							android:layout_width="48dp"
							android:layout_height="48dp"
							android:layout_gravity="right|bottom"
							android:layout_marginRight="8dp"
							android:layout_marginBottom="8dp"
							android:background="@drawable/background_quickscroll"
							android:clickable="true"
							android:scaleType="center"
							android:visibility="gone"
							app:srcCompat="@drawable/ic_arrow_downward"
							app:tint="?attr/colorAccent" />

					</FrameLayout>

				</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

				<ScrollView
					android:id="@+id/quote_panel"
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:layout_alignParentBottom="true"
					android:visibility="gone">

					<FrameLayout
						android:layout_width="match_parent"
						android:layout_height="wrap_content">

						<LinearLayout
							android:id="@+id/quote_inner_panel"
							android:layout_width="match_parent"
							android:layout_height="wrap_content"
							android:layout_gravity="top"
							android:background="?background_secondary"
							android:orientation="horizontal"
							android:paddingTop="8dp"
							android:paddingBottom="8dp">

							<View
								android:id="@+id/quote_bar"
								android:layout_width="4dp"
								android:layout_height="match_parent"
								android:layout_marginLeft="8dp"
								android:layout_marginRight="8dp"
								android:background="?colorAccent" />

							<LinearLayout
								android:layout_width="0dp"
								android:layout_height="wrap_content"
								android:layout_gravity="center_vertical"
								android:layout_weight="2"
								android:orientation="vertical">

								<TextView
									android:id="@+id/quote_id_view"
									android:layout_width="wrap_content"
									android:layout_height="wrap_content"
									android:textColor="?attr/textColorTertiary"
									android:textSize="?attr/font_medium"
									android:textStyle="bold" />

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

									<ImageView
										android:id="@+id/quote_type_image"
										android:layout_width="14dp"
										android:layout_height="14dp"
										android:layout_gravity="left|top"
										android:layout_marginLeft="-2dp"
										android:layout_marginTop="3dp"
										android:layout_marginRight="4dp"
										android:visibility="gone"
										app:tint="?attr/textColorSecondary" />

									<ch.threema.app.emojis.EmojiTextView
										android:id="@+id/quote_text_view"
										android:layout_width="wrap_content"
										android:layout_height="wrap_content"
										android:ellipsize="end"
										android:linksClickable="false"
										android:maxLines="3"
										android:text=""
										android:textColor="?attr/textColorSecondary"
										android:textSize="?attr/font_status" />

								</LinearLayout>

							</LinearLayout>

							<ImageView
								android:id="@+id/quote_thumbnail"
								android:layout_width="@dimen/avatar_size_small"
								android:layout_height="@dimen/avatar_size_small"
								android:layout_gravity="right|center_vertical"
								android:layout_marginLeft="8dp"
								android:layout_marginRight="8dp"
								android:importantForAccessibility="no"
								android:scaleType="centerCrop"
								android:visibility="gone" />

							<ImageView
								android:id="@+id/quote_panel_close_button"
								android:layout_width="wrap_content"
								android:layout_height="wrap_content"
								android:layout_gravity="right|center_vertical"
								android:layout_marginLeft="8dp"
								android:layout_marginRight="8dp"
								android:background="?android:selectableItemBackground"
								android:contentDescription="@string/close"
								app:srcCompat="@drawable/ic_close"
								app:tint="?attr/textColorSecondary" />

						</LinearLayout>

						<View
							android:layout_width="match_parent"
							android:layout_height="@dimen/list_divider_height"
							android:layout_gravity="bottom"
							android:background="?attr/divider_color" />

					</FrameLayout>

				</ScrollView>

			</RelativeLayout>

			<FrameLayout
				android:id="@+id/bottom_panel"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:background="?compose_container"
				android:paddingLeft="8dp"
				android:paddingTop="4dp"
				android:paddingRight="8dp"
				android:paddingBottom="4dp">

				<ch.threema.app.ui.ContentCommitComposeEditText
					android:id="@+id/embedded_text_editor"
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:layout_gravity="bottom"
					android:layout_marginRight="56dp"
					android:background="?compose_edittext_bubble"
					android:ellipsize="end"
					android:hint="@string/compose_message_and_enter"
					android:maxLength="99000"
					android:maxLines="@integer/message_edittext_max_lines"
					android:minHeight="@dimen/input_text_height"
					android:nextFocusLeft="@+id/emoji_button"
					android:nextFocusRight="@+id/camera_button"
					android:paddingLeft="@dimen/emoji_button_width"
					android:paddingTop="3dp"
					android:paddingRight="@dimen/emoji_and_photo_button_width"
					android:paddingBottom="4dp"
					android:scrollbars="vertical"
					android:scrollHorizontally="false"
					android:textColor="?android:textColorPrimary"
					android:textSize="?attr/font_textentry">

					<requestFocus />
				</ch.threema.app.ui.ContentCommitComposeEditText>

				<ch.threema.app.emojis.EmojiButton
					android:id="@+id/emoji_button"
					style="?android:attr/borderlessButtonStyle"
					android:layout_width="@dimen/emoji_button_width"
					android:layout_height="@dimen/emoji_button_width"
					android:layout_gravity="left|bottom"
					android:layout_marginLeft="2dp"
					android:layout_marginBottom="5dp"
					android:background="@drawable/selector_compose_button"
					android:contentDescription="@string/select_emoji"
					android:drawablePadding="0dip"
					android:nextFocusRight="@+id/embedded_text_editor"
					android:padding="8dp"
					android:tint="?attr/textColorSecondary" />

				<FrameLayout
					android:layout_width="@dimen/emoji_button_width"
					android:layout_height="@dimen/emoji_button_width"
					android:layout_gravity="bottom|right"
					android:layout_marginRight="94dp"
					android:layout_marginBottom="5dp">

					<ImageButton
						android:id="@+id/camera_button"
						style="?android:attr/borderlessButtonStyle"
						android:layout_width="@dimen/emoji_button_width"
						android:layout_height="@dimen/emoji_button_width"
						android:background="@drawable/selector_compose_button"
						android:contentDescription="@string/take_photo"
						android:drawablePadding="0dip"
						android:focusable="true"
						android:nextFocusLeft="@+id/embedded_text_editor"
						android:nextFocusRight="@+id/attach_button"
						app:srcCompat="@drawable/ic_camera_outline"
						app:tint="?attr/textColorSecondary" />

				</FrameLayout>

				<ImageButton
					android:id="@+id/attach_button"
					style="?android:attr/borderlessButtonStyle"
					android:layout_width="@dimen/emoji_button_width"
					android:layout_height="@dimen/emoji_button_width"
					android:layout_gravity="bottom|right"
					android:layout_marginRight="58dp"
					android:layout_marginBottom="5dp"
					android:background="@drawable/selector_compose_button"
					android:contentDescription="@string/add_attachment"
					android:drawablePadding="0dip"
					android:focusable="true"
					android:nextFocusLeft="@+id/embedded_text_editor"
					android:nextFocusRight="@+id/send_button"
					android:padding="8dp"
					app:srcCompat="@drawable/ic_attachment"
					app:tint="?attr/textColorSecondary" />

				<ch.threema.app.ui.SendButton
					android:id="@+id/send_button"
					android:layout_width="@dimen/input_text_height"
					android:layout_height="@dimen/input_text_height"
					android:layout_gravity="bottom|right"
					android:clickable="true"
					android:focusable="true"
					android:foreground="@drawable/selector_avatar"
					android:nextFocusLeft="@+id/attach_button" />

			</FrameLayout>

		</LinearLayout>

	</androidx.coordinatorlayout.widget.CoordinatorLayout>

</FrameLayout>
