<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- FYI: This layout has an extra top level container view that was previously used
     to allow for the insertion of debug info. The debug info is now gone, but the
     container remains because there is a high likelihood of UI regression relating
     to focus and selection states, some of which are specific to keyboard
     when touch mode is not enable. So, if you, heroic engineer of the future,
     decide to rip these out, please be sure to check out focus and keyboards. -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_margin="4dp"
    android:background="@drawable/grid_item_background"
    android:elevation="@dimen/grid_item_elevation"
    android:focusable="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:duplicateParentState="true">

        <!-- Main item thumbnail. Comprised of two overlapping images, the
             visibility of which is controlled by code in
             DirectoryFragment.java. -->

        <FrameLayout
            android:id="@+id/thumbnail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.android.documentsui.GridItemThumbnail
                android:id="@+id/icon_thumb"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scaleType="centerCrop"
                android:contentDescription="@null"
                android:tint="?attr/gridItemTint"
                android:tintMode="src_over"/>

            <com.android.documentsui.GridItemThumbnail
                android:id="@+id/icon_mime_lg"
                android:layout_width="@dimen/icon_size"
                android:layout_height="@dimen/icon_size"
                android:layout_gravity="center"
                android:scaleType="fitCenter"
                android:contentDescription="@null"/>

        </FrameLayout>

        <FrameLayout
            android:layout_width="@dimen/button_touch_size"
            android:layout_height="@dimen/button_touch_size"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:pointerIcon="hand">

            <ImageView
                android:id="@+id/icon_check"
                android:src="@drawable/ic_check_circle"
                android:alpha="0"
                android:layout_width="@dimen/check_icon_size"
                android:layout_height="@dimen/check_icon_size"
                android:layout_gravity="center"
                android:scaleType="fitCenter"
                android:contentDescription="@null"/>

        </FrameLayout>

        <FrameLayout
            android:id="@+id/preview_icon"
            android:layout_width="@dimen/button_touch_size"
            android:layout_height="@dimen/button_touch_size"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:pointerIcon="hand"
            android:focusable="true"
            android:clickable="true">

            <ImageView
                android:layout_width="@dimen/zoom_icon_size"
                android:layout_height="@dimen/zoom_icon_size"
                android:padding="2dp"
                android:layout_gravity="center"
                android:background="@drawable/circle_button_background"
                android:scaleType="fitCenter"
                android:src="@drawable/ic_zoom_out"/>

        </FrameLayout>

        <!-- An overlay that draws the item border when it is focused. -->
        <View
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@id/thumbnail"
            android:layout_alignTop="@id/thumbnail"
            android:layout_alignLeft="@id/thumbnail"
            android:layout_alignRight="@id/thumbnail"
            android:contentDescription="@null"
            android:background="@drawable/item_doc_grid_border"
            android:duplicateParentState="true"/>

    </RelativeLayout>

</LinearLayout>