<?xml version="1.0" encoding="utf-8"?>
<!--
  TimeLimit Copyright <C> 2019 - 2020 Jonas Lochmann
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>
        <variable
            name="title"
            type="String" />

        <variable
            name="usedTimeToday"
            type="String" />

        <variable
            name="remainingTimeToday"
            type="String" />

        <variable
            name="usedForAppsWithoutCategory"
            type="boolean" />

        <variable
            name="isTemporarilyBlocked"
            type="boolean" />

        <variable
            name="temporarilyBlockedUntil"
            type="String" />

        <variable
            name="limitsDisabledUntil"
            type="String" />

        <import type="android.text.TextUtils" />
        <import type="android.view.View" />
    </data>

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

        <View
            android:id="@+id/left_space"
            android:layout_width="0dp"
            android:layout_height="wrap_content" />

        <androidx.cardview.widget.CardView
            android:foreground="?selectableItemBackground"
            android:id="@+id/card"
            android:paddingStart="8dp"
            android:paddingEnd="8dp"
            app:cardUseCompatPadding="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:padding="8dp"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_weight="1"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <TextView
                        android:textAppearance="?android:textAppearanceLarge"
                        android:text="@{title}"
                        tools:text="Erlaubte Apps"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:textAppearance="?android:textAppearanceMedium"
                        android:visibility="@{usedForAppsWithoutCategory ? View.VISIBLE : View.GONE}"
                        android:text="@string/manage_child_category_for_unassigned_apps"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:visibility="@{TextUtils.isEmpty(usedTimeToday) ? View.GONE : View.VISIBLE}"
                        android:text="@{usedTimeToday}"
                        tools:text="2 Minuten benutzt"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:visibility="@{TextUtils.isEmpty(remainingTimeToday) ? View.GONE : View.VISIBLE}"
                        android:text="@{remainingTimeToday}"
                        tools:text="5 Minuten verbleibend"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <TextView
                        android:visibility="@{TextUtils.isEmpty(remainingTimeToday) ? View.VISIBLE : View.GONE}"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="@string/manage_child_category_no_time_limits"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <TextView
                        tools:ignore="UnusedAttribute"
                        android:drawableTint="?colorOnSurface"
                        android:drawablePadding="8dp"
                        android:drawableStart="@drawable/ic_lock_outline_black_24dp"
                        android:visibility="@{isTemporarilyBlocked ? View.VISIBLE : View.GONE}"
                        android:textAppearance="?android:textAppearanceMedium"
                        tools:text="@string/overview_user_item_temporarily_blocked"
                        android:text="@{TextUtils.isEmpty(temporarilyBlockedUntil) ? @string/overview_user_item_temporarily_blocked : @string/overview_user_item_temporarily_blocked_until(temporarilyBlockedUntil)}"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <TextView
                        tools:ignore="UnusedAttribute"
                        android:drawableTint="?colorOnSurface"
                        android:drawablePadding="8dp"
                        android:drawableStart="@drawable/ic_alarm_off_black_24dp"
                        android:visibility="@{TextUtils.isEmpty(limitsDisabledUntil) ? View.GONE : View.VISIBLE}"
                        android:textAppearance="?android:textAppearanceMedium"
                        tools:text="@string/overview_user_item_temporarily_disabled_until"
                        android:text="@{@string/overview_user_item_temporarily_disabled_until(limitsDisabledUntil)}"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                </LinearLayout>

                <androidx.appcompat.widget.SwitchCompat
                    android:id="@+id/category_switch"
                    android:layout_gravity="center_vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

            </LinearLayout>
        </androidx.cardview.widget.CardView>
    </LinearLayout>
</layout>
