<!--
  ~ 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">

    <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/cgms_feature_title_long_margin"
            android:rotation="270"
            android:text="@string/cgms_feature_title_long"
            android:textColor="@color/darkGray"
            android:textSize="32dp"
            android:textStyle="bold"/>

        <TextView
            android:id="@+id/battery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="@dimen/feature_horizontal_margin"
            android:layout_marginTop="@dimen/feature_device_name_margin_top"
            android:background="@drawable/battery"
            android:freezesText="true"
            android:gravity="center"
            android:text="@string/not_available"
            android:textColor="#FFFFFF"
            android:textSize="12sp"/>

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/action_connect"
            android:gravity="center_horizontal"
            android:orientation="vertical">

            <!-- Application section -->

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

                <RelativeLayout
                    style="@style/Widget.ListTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

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

                    <no.nordicsemi.android.nrftoolbox.widget.TrebuchetTextView
                        android:id="@+id/unit"
                        style="@style/Widget.ListTitle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/cgms_value_unit"
                        android:layout_alignParentRight="true"
                        android:layout_marginRight="4dp"/>
                </RelativeLayout>

                <ListView
                    android:id="@+id/list"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scrollbarStyle="outsideOverlay"
                    tools:listitem="@layout/activity_feature_gls_item"/>

                <TextView
                    android:id="@+id/empty"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="@string/gls_no_data"/>
            </LinearLayout>

            <!-- Timestamp section -->

            <LinearLayout
                style="@style/Widget.List"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/activity_vertical_margin_bottom"
                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/gls_section_actions"/>

                <LinearLayout
                    android:id="@+id/cgms_control_std"
                    style="?android:attr/buttonBarStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <Button
                        android:id="@+id/action_all"
                        style="?android:attr/buttonBarButtonStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:minWidth="0dp"
                        android:text="@string/gls_action_all"/>

                    <Button
                        android:id="@+id/action_last"
                        style="?android:attr/buttonBarButtonStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:minWidth="0dp"
                        android:text="@string/gls_action_last"/>

                    <Button
                        android:id="@+id/action_more"
                        style="?android:attr/buttonBarButtonStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:minWidth="0dp"
                        android:text="@string/gls_action_more"/>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/cgms_control_abort"
                    style="?android:attr/buttonBarStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:visibility="gone">

                    <Button
                        android:id="@+id/action_abort"
                        style="?android:attr/buttonBarButtonStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:minWidth="0dp"
                        android:text="@string/gls_action_abort"/>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <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_connect"/>

        <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"/>

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