<!--
  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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="io.timelimit.android.ui.manage.category.apps.add.AddCategoryAppsFragment">

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

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

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

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

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

        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp">

            <com.google.android.material.appbar.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <LinearLayout
                    android:background="?android:windowBackground"
                    app:layout_scrollFlags="scroll|enterAlways|snap"
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <include android:id="@+id/filter"
                        layout="@layout/app_filter_view" />

                    <CheckBox
                        android:checked="true"
                        android:id="@+id/show_other_categories_apps"
                        android:text="@string/category_apps_add_dialog_show_assigned_to_other_category"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <CheckBox
                        android:checked="false"
                        android:id="@+id/show_apps_from_unassigned_devices"
                        android:text="@string/category_apps_add_dialog_show_from_other_devices"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                    <CheckBox
                        android:checked="false"
                        android:id="@+id/assign_to_this_device_only"
                        android:text="@string/category_apps_add_dialog_assign_current_device_only"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />

                </LinearLayout>
            </com.google.android.material.appbar.AppBarLayout>

            <!-- this gets a custom behavior for the correct align -->
            <TextView
                android:id="@+id/empty_view"
                android:textAppearance="?android:textAppearanceMedium"
                android:padding="16dp"
                android:gravity="center"
                tools:text="Es gab einen schlimmen Fehler, daher ist diese Liste jetzt leer"
                android:text="@{emptyText}"
                android:visibility="@{TextUtils.isEmpty(emptyText) ? View.GONE : View.VISIBLE}"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.recyclerview.widget.RecyclerView
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:id="@+id/recycler"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </androidx.coordinatorlayout.widget.CoordinatorLayout>

        <TextView
            android:padding="8dp"
            android:textAppearance="?android:textAppearanceMedium"
            tools:text="2 entries are hidden"
            android:visibility="@{TextUtils.isEmpty(hiddenEntries) ? View.GONE : View.VISIBLE}"
            android:text="@{hiddenEntries}"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:visibility="@{someOptionsDisabledDueToChildAuthentication ? View.VISIBLE : View.GONE}"
            android:drawablePadding="8dp"
            android:textAppearance="?android:textAppearanceSmall"
            android:padding="8dp"
            android:text="@string/child_self_limit_add_caused_missing_options_hint"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:drawableStartCompat="@drawable/ic_vpn_key_black_24dp" />

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

            <Button
                style="?borderlessButtonStyle"
                android:layout_weight="1"
                android:text="@string/category_apps_add_dialog_select_all"
                android:id="@+id/select_all_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <Button
                style="?borderlessButtonStyle"
                android:layout_weight="1"
                android:text="@string/generic_cancel"
                android:id="@+id/cancel_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <Button
                style="?borderlessButtonStyle"
                android:layout_weight="1"
                android:text="@string/category_apps_add_dialog_btn_positive"
                android:id="@+id/add_apps_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </LinearLayout>
</layout>
