<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="item"
            type="com.topjohnwu.magisk.model.entity.recycler.LogItemEntryRvItem" />

        <variable
            name="viewModel"
            type="com.topjohnwu.magisk.ui.log.LogViewModel" />

    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        android:background="?attr/selectableItemBackground"
        android:onClick="@{() -> item.toggle()}"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingLeft="@dimen/margin_generic"
            android:paddingTop="@dimen/margin_generic_half"
            android:paddingRight="@dimen/margin_generic"
            android:paddingBottom="@dimen/margin_generic_half">

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@{item.item.appName}"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="?android:attr/textColorPrimary"
                android:textIsSelectable="false"
                tools:text="@tools:sample/lorem" />

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center_horizontal"
                android:text="@{item.item.action ? @string/grant : @string/deny}"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="?android:attr/textColorSecondary"
                tools:text="@string/grant" />

            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/time"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center_horizontal"
                android:text="@{item.item.timeString}"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="?android:attr/textColorSecondary"
                tools:text="@tools:sample/date/hhmm" />

        </LinearLayout>

        <LinearLayout
            gone="@{!item.isExpanded}"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:gravity="center"
            android:orientation="horizontal"
            android:paddingStart="@dimen/margin_generic"
            android:paddingTop="@dimen/margin_generic_half"
            android:paddingEnd="@dimen/margin_generic"
            android:paddingBottom="@dimen/margin_generic_half">

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@{@string/pid(item.item.fromPid)}"
                android:textColor="?android:attr/textColorSecondary"
                android:textSize="12sp"
                tools:text="@string/pid" />

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@{@string/target_uid(item.item.toUid)}"
                android:textColor="?android:attr/textColorSecondary"
                android:textSize="12sp"
                tools:text="@string/target_uid" />

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="@{@string/command(item.item.command)}"
                android:textColor="?android:attr/textColorSecondary"
                android:textSize="12sp"
                tools:text="@string/command" />

        </LinearLayout>

    </LinearLayout>

</layout>