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

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:foreground="?android:attr/selectableItemBackground"
        app:cardBackgroundColor="?attr/cardview_background_color"
        card_view:cardElevation="3dp"
        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:focusable="false"
                    android:scrollbars="none">
                </ListView>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:id="@+id/device_name_layout"
                android:layout_below="@id/device_item_infos_box"
                android:layout_height="wrap_content">

                <ImageView
                    android:id="@+id/device_image"
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:layout_alignParentStart="true"
                    android:layout_marginTop="2dp"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/candidate_item_device_image"
                    android:tooltipText="@string/candidate_item_device_image"
                    android:focusable="true"
                    android:longClickable="true"
                    card_view:srcCompat="@drawable/ic_device_pebble" />

                <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: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_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:tooltipText="@string/candidate_item_device_image"
                    android:background="?android:attr/selectableItemBackground"
                    card_view:srcCompat="@drawable/ic_more_vert"
                    android:focusable="true"
                    card_view:tint="@color/secondarytext" />
            </RelativeLayout>

            <com.google.android.flexbox.FlexboxLayout
                android:id="@+id/device_info_icons"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/device_name_layout"
                card_view:flexWrap="wrap">

                <LinearLayout
                    android:id="@+id/device_battery_status_box"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/battery_detail_activity_title"
                    android:tooltipText="@string/battery_detail_activity_title"
                    android:layout_alignParentStart="true"
                    android:layout_margin="3dp"
                    android:orientation="vertical">

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

                    <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_battery_status_box1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:layout_alignParentStart="true"
                    android:layout_margin="3dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/device_battery_status1"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/level_list_battery"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/battery_status1"
                        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_battery_status_box2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:layout_alignParentStart="true"
                    android:layout_margin="3dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/device_battery_status2"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/level_list_battery"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/battery_status2"
                        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>


                <ImageView
                    android:id="@+id/device_specific_settings"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_below="@id/device_image"
                    android:layout_marginStart="3dp"
                    android:layout_marginTop="3dp"
                    android:layout_marginEnd="3dp"
                    android:layout_marginBottom="3dp"
                    android:layout_toEndOf="@id/device_battery_status_box"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:focusable="true"
                    android:padding="3dp"
                    android:contentDescription="@string/title_activity_device_specific_settings"
                    android:tooltipText="@string/title_activity_device_specific_settings"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_settings"
                    card_view:tint="@color/secondarytext" />


                <LinearLayout
                    android:id="@+id/device_fm_frequency_box"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/device_image"
                    android:contentDescription="@string/controlcenter_change_fm_frequency"
                    android:tooltipText="@string/controlcenter_change_fm_frequency"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_specific_settings"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/device_fm_frequency"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/ic_radio"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/fm_frequency"
                        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="107.8" />

                </LinearLayout>

                <ImageView
                    android:id="@+id/device_led_color"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_fm_frequency_box"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_change_led_color"
                    android:tooltipText="@string/controlcenter_change_led_color"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_led_color" />

                <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="3dp"
                    android:layout_toEndOf="@id/device_led_color"
                    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:background="?android:attr/selectableItemBackground"
                        android:clickable="true"
                        android:contentDescription="@string/controlcenter_fetch_activity_data"
                        android:tooltipText="@string/controlcenter_fetch_activity_data"
                        android:focusable="true"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/ic_refresh"
                        card_view:tint="@color/secondarytext" />

                    <ProgressBar
                        android:id="@+id/device_busy_indicator"
                        style="@android:style/Widget.ProgressBar.Horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="3dp"
                        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="3dp"
                    android:layout_toEndOf="@id/device_action_fetch_activity_box"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_take_screenshot"
                    android:tooltipText="@string/controlcenter_take_screenshot"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_screenshot"
                    card_view:tint="@color/secondarytext" />

                <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="3dp"
                    android:layout_toEndOf="@id/device_action_take_screenshot"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/title_activity_appmanager"
                    android:tooltipText="@string/title_activity_appmanager"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_action_manage_apps"
                    card_view:tint="@color/secondarytext" />

                <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="3dp"
                    android:layout_toEndOf="@id/device_action_manage_apps"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_start_configure_alarms"
                    android:tooltipText="@string/controlcenter_start_configure_alarms"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_access_alarms"
                    card_view:tint="@color/secondarytext" />

                <ImageView
                    android:id="@+id/device_action_set_reminders"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_action_set_alarms"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_start_configure_reminders"
                    android:tooltipText="@string/controlcenter_start_configure_reminders"
                    android:focusable="true"
                    android:padding="4dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_device_set_reminders"
                    app:tint="@color/secondarytext" />

                <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="3dp"
                    android:layout_toEndOf="@id/device_action_set_reminders"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_start_activitymonitor"
                    android:tooltipText="@string/controlcenter_start_activitymonitor"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_activity_graphs"
                    card_view:tint="@color/secondarytext" />

                <ImageView
                    android:id="@+id/device_action_show_activity_tracks"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_action_show_activity_graphs"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_start_activity_tracks"
                    android:tooltipText="@string/controlcenter_start_activity_tracks"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_activity_tracks"
                    card_view:tint="@color/secondarytext" />

                <ImageView
                    android:id="@+id/device_action_find"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_action_show_activity_tracks"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_find_device"
                    android:tooltipText="@string/controlcenter_find_device"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_action_find_lost_device"
                    card_view:tint="@color/secondarytext" />

                <ImageView
                    android:id="@+id/device_action_calibrate"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_action_find"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_calibrate_device"
                    android:tooltipText="@string/controlcenter_calibrate_device"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_activity_unknown"
                    card_view:tint="@color/secondarytext" />

                <LinearLayout
                    android:id="@+id/device_heart_rate_status_box"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/controlcenter_get_heartrate_measurement"
                    android:tooltipText="@string/controlcenter_get_heartrate_measurement"
                    android:layout_alignParentStart="true"
                    android:layout_margin="3dp"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/device_heart_rate_status"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/ic_heart"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/heart_rate_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>

                <ImageView
                    android:id="@+id/device_action_power_off"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_heart_rate_status_box"
                    android:background="?android:attr/selectableItemBackground"
                    android:clickable="true"
                    android:contentDescription="@string/controlcenter_power_off"
                    android:tooltipText="@string/controlcenter_power_off"
                    android:focusable="true"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    card_view:srcCompat="@drawable/ic_power_settings_new"
                    card_view:tint="@color/secondarytext" />

                <LinearLayout
                    android:id="@+id/device_custom_action_0_box"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_action_power_off"
                    android:contentDescription=""
                    android:orientation="vertical"
                    android:tooltipText="">

                    <ImageView
                        android:id="@+id/device_custom_action_0_image"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/ic_device_unknown"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/device_custom_action_0_label"
                        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="" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/device_custom_action_1_box"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_custom_action_0_box"
                    android:contentDescription=""
                    android:orientation="vertical"
                    android:tooltipText="">

                    <ImageView
                        android:id="@+id/device_custom_action_1_image"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/ic_device_unknown"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/device_custom_action_1_label"
                        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="" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/device_custom_action_2_box"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/device_image"
                    android:layout_margin="3dp"
                    android:layout_toEndOf="@id/device_custom_action_1_box"
                    android:contentDescription=""
                    android:orientation="vertical"
                    android:tooltipText="">

                    <ImageView
                        android:id="@+id/device_custom_action_2_image"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:background="?android:attr/selectableItemBackground"
                        android:padding="3dp"
                        android:scaleType="fitXY"
                        card_view:srcCompat="@drawable/ic_device_unknown"
                        card_view:tint="@color/secondarytext" />

                    <TextView
                        android:id="@+id/device_custom_action_2_label"
                        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="" />
                </LinearLayout>
            </com.google.android.flexbox.FlexboxLayout>

            <LinearLayout
                android:id="@+id/card_view_activity_card_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/device_info_icons"
                android:layout_marginBottom="10dp"
                android:orientation="vertical">

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

                    <com.github.mikephil.charting.charts.PieChart
                        android:id="@+id/activity_dashboard_piechart1"
                        android:layout_width="110dp"
                        android:layout_height="110dp"
                        android:layout_gravity="bottom|center"
                        android:layout_marginBottom="0dp"
                        android:contentDescription="@string/live_activity_total_steps"
                        android:tooltipText="@string/live_activity_total_steps"
                        android:layout_weight="1" />

                    <com.github.mikephil.charting.charts.PieChart
                        android:id="@+id/activity_dashboard_piechart2"
                        android:layout_width="110dp"
                        android:layout_height="110dp"
                        android:layout_gravity="bottom|center"
                        android:contentDescription="@string/activity_list_summary_distance"
                        android:tooltipText="@string/activity_list_summary_distance"
                        android:layout_marginBottom="0dp"
                        android:layout_weight="1" />

                    <com.github.mikephil.charting.charts.PieChart
                        android:id="@+id/activity_dashboard_piechart3"
                        android:layout_width="110dp"
                        android:layout_height="110dp"
                        android:layout_gravity="bottom|center"
                        android:contentDescription="@string/sleepchart_your_sleep"
                        android:tooltipText="@string/sleepchart_your_sleep"
                        android:layout_marginBottom="0dp"
                        android:layout_weight="1" />
                </LinearLayout>
            </LinearLayout>
        </RelativeLayout>

    </com.google.android.material.card.MaterialCardView>


</androidx.coordinatorlayout.widget.CoordinatorLayout>
