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

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

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

        <variable
            name="someOptionsDisabledDueToChildAuthentication"
            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">

        <EditText
            android:id="@+id/search"
            android:inputType="textFilter"
            android:hint="@string/category_apps_add_activity_dialog_search_hint"
            android:padding="8dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="0dp">

            <TextView
                android:padding="16dp"
                android:textAppearance="?android:textAppearanceMedium"
                android:text="@{emptyViewText}"
                android:visibility="@{TextUtils.isEmpty(emptyViewText) ? View.GONE : View.VISIBLE}"
                tools:text="@string/category_apps_add_activity_empty_unfiltered"
                android:gravity="center"
                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" />

        </FrameLayout>

        <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/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_activity_btn_positive"
                android:id="@+id/add_activities_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </LinearLayout>
</layout>
