<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:foreground="?android:attr/selectableItemBackground"
        card_view:cardCornerRadius="4dp"
        card_view:cardElevation="4dp"
        card_view:contentPadding="8dp">

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

            <RelativeLayout
                android:id="@+id/device_item_infos_box"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_marginBottom="8dp"
                android:focusable="false"
                android:visibility="gone">

                <ListView
                    android:id="@+id/device_item_infos"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_alignParentStart="true"
                    android:layout_toStartOf="@+id/device_action_remove"
                    android:focusable="false"
                    android:scrollbars="none" />

                <ImageView
                    android:id="@+id/device_action_remove"
                    android:layout_width="36dp"
                    android:layout_height="36dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentTop="true"
                    android:layout_marginTop="8dp"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_delete_device"
                    android:tint="?attr/textColorTertiary"
                    card_view:srcCompat="@drawable/ic_remove_device" />
            </RelativeLayout>

            <ImageView
                android:id="@+id/device_image"
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_alignParentStart="true"
                android:layout_below="@id/device_item_infos_box"
                android:contentDescription="@string/candidate_item_device_image"
                android:clickable="true"
                android:longClickable="true"
                android:background="?android:attr/selectableItemBackground"
                android:src="@drawable/ic_device_pebble"
                android:layout_marginTop="8dp" />

            <TextView
                android:id="@+id/device_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toEndOf="@id/device_image"
                android:layout_alignParentEnd="true"
                android:layout_marginEnd="48dp"
                android:layout_below="@id/device_item_infos_box"
                android:gravity="center"
                android:maxLines="1"
                android:textAppearance="@style/TextAppearance.AppCompat.Large"
                tools:text="My Pebble Watch" />

            <TextView
                android:id="@+id/device_status"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/device_name"
                android:layout_toEndOf="@id/device_image"
                android:layout_alignParentEnd="true"
                android:layout_marginEnd="48dp"
                android:gravity="center"
                android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
                tools:text="@string/connecting" />

            <ImageView
                android:id="@+id/device_info_image"
                android:layout_width="36dp"
                android:layout_height="36dp"
                android:layout_alignParentEnd="true"
                android:layout_below="@id/device_item_infos_box"
                android:layout_marginBottom="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="0dp"
                android:layout_marginTop="8dp"
                android:clickable="true"
                android:contentDescription="@string/candidate_item_device_image"
                android:tint="@color/secondarytext"
                android:background="?android:attr/selectableItemBackground"
                card_view:srcCompat="@drawable/ic_more_vert" />

            <LinearLayout
                android:id="@+id/device_battery_status_box"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/device_image"
                android:layout_alignParentStart="true"
                android:layout_margin="4dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/device_battery_status"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:padding="4dp"
                    android:scaleType="fitXY"
                    android:tint="@color/secondarytext"
                    card_view:srcCompat="@drawable/level_list_battery" />

                <TextView
                    android:id="@+id/battery_status"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_horizontal"
                    android:minWidth="36dp"
                    android:textColor="@color/secondarytext"
                    android:textStyle="bold"
                    tools:text="100%" />

            </LinearLayout>

            <LinearLayout
                android:id="@+id/device_action_fetch_activity_box"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/device_image"
                android:layout_margin="4dp"
                android:layout_toEndOf="@id/device_battery_status_box"
                android:gravity="center_vertical"
                android:minWidth="36dp"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/device_action_fetch_activity"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:padding="4dp"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_fetch_activity_data"
                    android:scaleType="fitXY"
                    android:tint="@color/secondarytext"
                    card_view:srcCompat="@drawable/ic_action_fetch_activity_data" />

                <ProgressBar
                    android:id="@+id/device_busy_indicator"
                    style="@android:style/Widget.ProgressBar.Horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="4dp"
                    android:indeterminate="true"
                    android:visibility="visible"
                    tools:visibility="visible" />

            </LinearLayout>

            <ImageView
                android:id="@+id/device_action_take_screenshot"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_below="@id/device_image"
                android:layout_margin="4dp"
                android:layout_toEndOf="@id/device_action_fetch_activity_box"
                android:background="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:contentDescription="@string/controlcenter_take_screenshot"
                android:padding="4dp"
                android:scaleType="fitXY"
                android:tint="@color/secondarytext"
                card_view:srcCompat="@drawable/ic_screenshot" />

            <ImageView
                android:id="@+id/device_action_manage_apps"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_below="@id/device_image"
                android:layout_margin="4dp"
                android:layout_toEndOf="@id/device_action_take_screenshot"
                android:background="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:contentDescription="@string/title_activity_appmanager"
                android:padding="4dp"
                android:scaleType="fitXY"
                android:tint="@color/secondarytext"
                card_view:srcCompat="@drawable/ic_action_manage_apps" />

            <ImageView
                android:id="@+id/device_action_set_alarms"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_below="@id/device_image"
                android:layout_margin="4dp"
                android:layout_toEndOf="@id/device_action_manage_apps"
                android:background="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:contentDescription="@string/controlcenter_start_configure_alarms"
                android:padding="4dp"
                android:scaleType="fitXY"
                android:tint="@color/secondarytext"
                card_view:srcCompat="@drawable/ic_device_set_alarms" />

            <ImageView
                android:id="@+id/device_action_show_activity_graphs"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_below="@id/device_image"
                android:layout_margin="4dp"
                android:layout_toEndOf="@id/device_action_set_alarms"
                android:background="?android:attr/selectableItemBackground"
                android:clickable="true"
                android:contentDescription="@string/controlcenter_start_activitymonitor"
                android:padding="4dp"
                android:scaleType="fitXY"
                android:tint="@color/secondarytext"
                card_view:srcCompat="@drawable/ic_activity_graphs" />

            <ImageView
                android:id="@+id/device_action_find"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_below="@id/device_image"
                android:layout_margin="4dp"
                android:layout_toEndOf="@id/device_action_show_activity_graphs"
                android:clickable="true"
                android:contentDescription="@string/controlcenter_find_device"
                android:padding="4dp"
                android:scaleType="fitXY"
                android:tint="@color/secondarytext"
                card_view:srcCompat="@drawable/ic_action_find_lost_device" />

        </RelativeLayout>

    </android.support.v7.widget.CardView>


</android.support.design.widget.CoordinatorLayout>
