<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2015, Nordic Semiconductor
  ~ All rights reserved.
  ~
  ~ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  ~
  ~ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  ~
  ~ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
  ~ documentation and/or other materials provided with the distribution.
  ~
  ~ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
  ~ software without specific prior written permission.
  ~
  ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  ~ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  ~ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  ~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  ~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  ~ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:orientation="vertical"
	tools:context=".dfu.DfuActivity">

	<include
		android:id="@+id/toolbar_actionbar"
		layout="@layout/toolbar"/>

	<no.nordicsemi.android.nrftoolbox.widget.ForegroundRelativeLayout
		style="@style/HeaderShadow"
		android:layout_width="match_parent"
		android:layout_height="match_parent">

		<!-- The size of text below must be fixed, therefore dp are used instead of sp -->

		<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerVertical="true"
			android:layout_marginLeft="@dimen/dfu_feature_title_long_margin"
			android:rotation="270"
			android:text="@string/dfu_feature_title_long"
			android:textColor="@color/darkGray"
			android:textSize="32dp"
			android:textStyle="bold"/>

		<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
			android:id="@+id/device_name"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerHorizontal="true"
			android:layout_marginTop="@dimen/feature_device_name_margin_top"
			android:ellipsize="end"
			android:freezesText="true"
			android:maxLines="1"
			android:text="@string/dfu_default_name"
			android:textAllCaps="true"
			android:textAppearance="?android:attr/textAppearanceLarge"/>

		<Button
			android:id="@+id/action_connect"
			style="@style/Widget.Connect"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentBottom="true"
			android:layout_centerHorizontal="true"
			android:layout_marginBottom="@dimen/activity_vertical_margin_bottom"
			android:onClick="onConnectClicked"
			android:text="@string/action_select"/>

		<ImageView
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentBottom="true"
			android:layout_centerHorizontal="true"
			android:layout_marginBottom="6dp"
			android:src="@drawable/background_title"/>

		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:gravity="center_horizontal"
			android:orientation="vertical"
			android:layout_alignParentTop="true"
			android:layout_alignParentStart="true">

			<!-- Application section -->

			<LinearLayout
				style="@style/Widget.List"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_marginLeft="@dimen/feature_horizontal_margin"
				android:layout_marginRight="@dimen/feature_horizontal_margin"
				android:layout_marginTop="@dimen/feature_vertical_margin_top"
				android:orientation="vertical">

				<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
					style="@style/Widget.ListTitle"
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:text="@string/dfu_section_application_header"/>

				<TableLayout
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:padding="@dimen/feature_section_padding">

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

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:text="@string/dfu_file_name_label"/>

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
							android:id="@+id/file_name"
							android:layout_width="0dp"
							android:layout_height="wrap_content"
							android:layout_marginLeft="5dp"
							android:layout_weight="1"
							android:ellipsize="middle"
							android:freezesText="true"
							android:singleLine="true"/>
					</TableRow>

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

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:text="@string/dfu_file_type_label"/>

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
							android:id="@+id/file_type"
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:layout_marginLeft="5dp"
							android:freezesText="true"/>
					</TableRow>

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

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:text="@string/dfu_file_scope_label"/>

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
							android:id="@+id/file_scope"
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:layout_marginLeft="5dp"
							android:freezesText="true"/>
					</TableRow>

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

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:text="@string/dfu_file_size_label"/>

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
							android:id="@+id/file_size"
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:layout_marginLeft="5dp"
							android:freezesText="true"/>
					</TableRow>

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

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:text="@string/dfu_file_status_label"/>

						<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
							android:id="@+id/file_status"
							android:layout_width="wrap_content"
							android:layout_height="wrap_content"
							android:layout_marginLeft="5dp"
							android:freezesText="true"
							android:text="@string/dfu_file_status_no_file"/>
					</TableRow>
				</TableLayout>

				<LinearLayout
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginBottom="@dimen/feature_section_padding"
					android:layout_marginTop="4dp"
					android:gravity="center_vertical"
					android:orientation="horizontal"
					android:paddingLeft="42dp">

					<Button
						android:id="@+id/action_select_file"
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:onClick="onSelectFileClicked"
						android:text="@string/dfu_action_select_file"/>

					<ImageView
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_marginLeft="10dp"
						android:onClick="onSelectFileHelpClicked"
						android:src="@drawable/ic_help"/>
				</LinearLayout>
			</LinearLayout>

			<!-- DFU section -->

			<LinearLayout
				android:id="@+id/dfu_pane"
				style="@style/Widget.List"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_marginBottom="8dp"
				android:layout_marginLeft="@dimen/feature_horizontal_margin"
				android:layout_marginRight="@dimen/feature_horizontal_margin"
				android:layout_marginTop="15dp"
				android:orientation="vertical">

				<no.nordicsemi.android.nrftoolbox.widget.TrebuchetBoldTextView
					style="@style/Widget.ListTitle"
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:text="@string/dfu_section_dfu_header"/>

				<Button
					android:id="@+id/action_upload"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_margin="@dimen/feature_section_padding"
					android:enabled="false"
					android:onClick="onUploadClicked"
					android:text="@string/dfu_action_upload"/>

				<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
					android:id="@+id/textviewUploading"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_margin="@dimen/feature_section_padding"
					android:freezesText="true"
					android:text="@string/dfu_status_uploading"
					android:visibility="invisible"/>

				<ProgressBar
					android:id="@+id/progressbar_file"
					style="@android:style/Widget.Holo.ProgressBar.Horizontal"
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:max="100"
					android:visibility="invisible"/>

				<no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
					android:id="@+id/textviewProgress"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_margin="@dimen/feature_section_padding"
					android:freezesText="true"
					android:text="@string/dfu_uploading_percentage_label"
					android:visibility="invisible"/>
			</LinearLayout>

			<TextView
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_marginRight="@dimen/feature_horizontal_margin"
				android:layout_gravity="right"
				android:text="@string/dfu_lib_version"
				android:textSize="12sp"/>
		</LinearLayout>


	</no.nordicsemi.android.nrftoolbox.widget.ForegroundRelativeLayout>
</LinearLayout>