<?xml version="1.0" encoding="utf-8"?>
<!--
    TimeLimit Copyright <C> 2019 - 2022 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:tools="http://schemas.android.com/tools">

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

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

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

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

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="io.timelimit.android.ui.manipulation.AnnoyActivity">

        <TextView
            android:gravity="center_horizontal"
            android:layout_margin="16dp"
            android:textAppearance="?android:textAppearanceLarge"
            android:text="@string/annoy_info"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <RelativeLayout
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp">
            <LinearLayout
                android:layout_margin="8dp"
                android:orientation="vertical"
                android:layout_centerVertical="true"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_margin="4dp"
                    android:textAppearance="?android:textAppearanceMedium"
                    android:gravity="center"
                    android:id="@+id/annoy_reason"
                    tools:text="@string/annoy_reason"
                    android:text="@{reasonText}"
                    android:visibility="@{TextUtils.isEmpty(reasonText) ? View.GONE : View.VISIBLE}"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

                <LinearLayout
                    android:layout_gravity="center_horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <Button
                        android:enabled="@{canRequestUnlock}"
                        android:id="@+id/unlock_temporarily_button"
                        android:layout_gravity="center_horizontal"
                        android:text="@string/annoy_unlock_temp_button"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <Button
                        style="?materialButtonOutlinedStyle"
                        android:id="@+id/parent_unlock_button"
                        android:layout_gravity="center_horizontal"
                        android:text="@string/annoy_unlock_parent_button"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                </LinearLayout>

                <TextView
                    android:layout_margin="4dp"
                    android:textAppearance="?android:textAppearanceSmall"
                    android:gravity="center"
                    android:id="@+id/annoy_timer"
                    tools:text="@string/annoy_timer"
                    android:text="@{countdownText}"
                    android:visibility="@{canRequestUnlock ? View.INVISIBLE : View.VISIBLE}"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

            </LinearLayout>
        </RelativeLayout>

        <Button
            style="?materialButtonOutlinedStyle"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_gravity="center_horizontal"
            android:id="@+id/use_backdoor_button"
            android:text="@string/backdoor_start_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>
</layout>