Merge "Adjust grid item layouts to match mocks."
diff --git a/res/color/item_doc_grid_overlay.xml b/res/color/item_doc_grid_overlay.xml
deleted file mode 100644
index bf19d4e..0000000
--- a/res/color/item_doc_grid_overlay.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:state_activated="true"
- android:color="?android:attr/colorAccent"
- android:alpha="0.1" />
- <item
- android:state_enabled="false"
- android:color="?android:attr/colorBackground"
- android:alpha="0.5" />
- <item
- android:color="@android:color/transparent" />
-</selector>
diff --git a/res/drawable-hdpi/ic_grid_selection_check.png b/res/drawable-hdpi/ic_grid_selection_check.png
deleted file mode 100644
index f3007c2..0000000
--- a/res/drawable-hdpi/ic_grid_selection_check.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_grid_selection_check.png b/res/drawable-mdpi/ic_grid_selection_check.png
deleted file mode 100644
index 16f2ab9..0000000
--- a/res/drawable-mdpi/ic_grid_selection_check.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_grid_selection_check.png b/res/drawable-xhdpi/ic_grid_selection_check.png
deleted file mode 100644
index 0885320..0000000
--- a/res/drawable-xhdpi/ic_grid_selection_check.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_grid_selection_check.png b/res/drawable-xxhdpi/ic_grid_selection_check.png
deleted file mode 100644
index 083bbcc..0000000
--- a/res/drawable-xxhdpi/ic_grid_selection_check.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_grid_selection_check.png b/res/drawable-xxxhdpi/ic_grid_selection_check.png
deleted file mode 100644
index 74b1ca5..0000000
--- a/res/drawable-xxxhdpi/ic_grid_selection_check.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/item_doc_grid_overlay.xml b/res/drawable/item_doc_grid_overlay.xml
deleted file mode 100644
index 3f50fb9..0000000
--- a/res/drawable/item_doc_grid_overlay.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <solid android:color="@color/item_doc_grid_overlay" />
-</shape>
diff --git a/res/drawable/item_doc_grid_overlay_icon.xml b/res/drawable/item_doc_grid_overlay_icon.xml
deleted file mode 100644
index d40de1e..0000000
--- a/res/drawable/item_doc_grid_overlay_icon.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true">
- <item android:state_focused="true" android:state_activated="true" android:drawable="@drawable/ic_grid_selection_check" />
- <item android:state_focused="false" android:state_activated="true" android:drawable="@drawable/ic_grid_selection_check" />
- <item android:drawable="@android:color/transparent" />
-</selector>
diff --git a/res/layout/item_doc_grid.xml b/res/layout/item_doc_grid.xml
index 15b12ce..1dfb34a 100644
--- a/res/layout/item_doc_grid.xml
+++ b/res/layout/item_doc_grid.xml
@@ -14,132 +14,110 @@
limitations under the License.
-->
-<com.android.documentsui.GridItem xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="@dimen/grid_item_height"
+ android:layout_height="wrap_content"
android:layout_margin="@dimen/grid_item_margin"
android:background="@color/item_doc_grid_background"
android:focusable="true">
- <ImageView
- android:id="@+id/icon_thumb"
+ <!-- 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="match_parent"
- android:scaleType="centerCrop"
- android:contentDescription="@null" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
+ android:layout_height="wrap_content"
+ android:paddingBottom="8dp">
+
+ <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" />
+
<ImageView
android:id="@+id/icon_mime"
android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
+ android:layout_height="wrap_content"
android:scaleType="centerInside"
android:contentDescription="@null" />
+
+ </FrameLayout>
+
+ <!-- Item nameplate. Has a mime-type icon and some text fields (title,
+ size, mod-time, etc). -->
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/thumbnail"
+ android:layout_toEndOf="@android:id/icon1"
+ android:singleLine="true"
+ android:ellipsize="middle"
+ android:textAlignment="viewStart"
+ android:paddingEnd="12dp"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textColor="@*android:color/primary_text_default_material_light" />
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/item_doc_grid_protect_background"
- android:orientation="vertical"
- android:paddingStart="16dp"
- android:paddingEnd="12dp"
- android:paddingTop="8dp"
- android:paddingBottom="8dp">
+ <TextView
+ android:id="@+id/size"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_toEndOf="@android:id/icon1"
+ android:paddingEnd="4dp"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Caption"
+ android:textColor="@*android:color/primary_text_default_material_light" />
- <LinearLayout
- android:id="@+id/line1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:baselineAligned="false">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:singleLine="true"
- android:ellipsize="middle"
- android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
- android:textColor="@*android:color/primary_text_default_material_dark" />
-
- <ImageView
- android:id="@android:id/icon1"
- android:layout_width="@dimen/root_icon_size"
- android:layout_height="@dimen/root_icon_size"
- android:layout_marginStart="8dp"
- android:scaleType="centerInside"
- android:contentDescription="@null" />
-
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/line2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:baselineAligned="false">
-
- <TextView
- android:id="@+id/date"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="0.5"
- android:singleLine="true"
- android:ellipsize="end"
- android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Caption"
- android:textColor="@*android:color/primary_text_default_material_dark" />
-
- <TextView
- android:id="@+id/size"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="0.5"
- android:layout_marginStart="8dp"
- android:singleLine="true"
- android:ellipsize="end"
- android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Caption"
- android:textColor="@*android:color/primary_text_default_material_dark" />
-
- <ImageView
- android:id="@android:id/icon2"
- android:layout_width="@dimen/root_icon_size"
- android:layout_height="@dimen/root_icon_size"
- android:layout_marginStart="8dp"
- android:scaleType="centerInside"
- android:contentDescription="@null"
- android:visibility="gone" />
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
+ <TextView
+ android:id="@+id/date"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_toEndOf="@id/size"
+ android:paddingEnd="12dp"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Caption"
+ android:textColor="@*android:color/primary_text_default_material_light" />
+
<ImageView
+ android:id="@android:id/icon1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_below="@id/thumbnail"
+ android:layout_alignParentLeft="true"
+ android:layout_alignBottom="@id/size"
+ android:layout_alignTop="@android:id/title"
+ android:scaleType="centerInside"
+ android:contentDescription="@null"
+ android:paddingStart="12dp"
+ android:paddingEnd="8dp"/>
+
+ <!-- Use an explicit spacer so we can align things to it. -->
+ <Space
+ android:id="@+id/bottomPadding"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/item_doc_grid_overlay"
+ android:layout_height="8dp"
+ android:layout_below="@id/size" />
+
+ <!-- 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/bottomPadding"
+ 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" />
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/item_doc_grid_overlay_icon"
- android:scaleType="center"
- android:contentDescription="@null"
- android:duplicateParentState="true" />
-
-</com.android.documentsui.GridItem>
+</RelativeLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index a376418..68c8b65 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -24,7 +24,7 @@
<color name="directory_background">@*android:color/material_grey_300</color>
<color name="item_doc_grid_background">@android:color/white</color>
- <color name="item_doc_grid_protect_background">#88000000</color>
+ <color name="item_doc_grid_protect_background">@android:color/white</color>
<color name="band_select_background">#88ffffff</color>
<color name="band_select_border">#44000000</color>
</resources>
diff --git a/src/com/android/documentsui/GridItem.java b/src/com/android/documentsui/GridItemThumbnail.java
similarity index 80%
rename from src/com/android/documentsui/GridItem.java
rename to src/com/android/documentsui/GridItemThumbnail.java
index 990dca7..38d6d72 100644
--- a/src/com/android/documentsui/GridItem.java
+++ b/src/com/android/documentsui/GridItemThumbnail.java
@@ -18,22 +18,21 @@
import android.content.Context;
import android.util.AttributeSet;
-import android.widget.FrameLayout;
+import android.widget.ImageView;
/**
- * A FrameLayout subclass used by DirectoryFragment. Ensures that the resulting grid item is always
- * square.
+ * Ensures that grid thumbnails are always square.
*/
-public class GridItem extends FrameLayout {
- public GridItem(Context context) {
+public class GridItemThumbnail extends ImageView {
+ public GridItemThumbnail(Context context) {
super(context);
}
- public GridItem(Context context, AttributeSet attrs) {
+ public GridItemThumbnail(Context context, AttributeSet attrs) {
super(context, attrs);
}
- public GridItem(Context context, AttributeSet attrs, int defStyle) {
+ public GridItemThumbnail(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index b95c001..21420c8 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -1080,14 +1080,12 @@
holder.setSelected(isSelected(position));
- final View line1 = itemView.findViewById(R.id.line1);
final View line2 = itemView.findViewById(R.id.line2);
final ImageView iconMime = (ImageView) itemView.findViewById(R.id.icon_mime);
final ImageView iconThumb = (ImageView) itemView.findViewById(R.id.icon_thumb);
final TextView title = (TextView) itemView.findViewById(android.R.id.title);
final ImageView icon1 = (ImageView) itemView.findViewById(android.R.id.icon1);
- final ImageView icon2 = (ImageView) itemView.findViewById(android.R.id.icon2);
final TextView summary = (TextView) itemView.findViewById(android.R.id.summary);
final TextView date = (TextView) itemView.findViewById(R.id.date);
final TextView size = (TextView) itemView.findViewById(R.id.size);
@@ -1140,13 +1138,14 @@
getDocumentIcon(mContext, docAuthority, docId, docMimeType, docIcon, state));
}
- boolean hasLine1 = false;
boolean hasLine2 = false;
final boolean hideTitle = (state.derivedMode == MODE_GRID) && mHideGridTitles;
if (!hideTitle) {
title.setText(docDisplayName);
- hasLine1 = true;
+ title.setVisibility(View.VISIBLE);
+ } else {
+ title.setVisibility(View.GONE);
}
Drawable iconDrawable = null;
@@ -1154,11 +1153,7 @@
// We've already had to enumerate roots before any results can
// be shown, so this will never block.
final RootInfo root = roots.getRootBlocking(docAuthority, docRootId);
- if (state.derivedMode == MODE_GRID) {
- iconDrawable = root.loadGridIcon(mContext);
- } else {
- iconDrawable = root.loadIcon(mContext);
- }
+ iconDrawable = root.loadIcon(mContext);
if (summary != null) {
final boolean alwaysShowSummary = getResources()
@@ -1200,16 +1195,10 @@
}
if (icon1 != null) icon1.setVisibility(View.GONE);
- if (icon2 != null) icon2.setVisibility(View.GONE);
if (iconDrawable != null) {
- if (hasLine1) {
- icon1.setVisibility(View.VISIBLE);
- icon1.setImageDrawable(iconDrawable);
- } else {
- icon2.setVisibility(View.VISIBLE);
- icon2.setImageDrawable(iconDrawable);
- }
+ icon1.setVisibility(View.VISIBLE);
+ icon1.setImageDrawable(iconDrawable);
}
if (docLastModified == -1) {
@@ -1231,9 +1220,6 @@
size.setVisibility(View.GONE);
}
- if (line1 != null) {
- line1.setVisibility(hasLine1 ? View.VISIBLE : View.GONE);
- }
if (line2 != null) {
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
}
@@ -1243,7 +1229,6 @@
iconMime.setAlpha(iconAlpha);
iconThumb.setAlpha(iconAlpha);
if (icon1 != null) icon1.setAlpha(iconAlpha);
- if (icon2 != null) icon2.setAlpha(iconAlpha);
if (DEBUG_ENABLE_DND) {
setupDragAndDropOnDocumentView(itemView, cursor);
diff --git a/src/com/android/documentsui/model/RootInfo.java b/src/com/android/documentsui/model/RootInfo.java
index 501392c..723700d 100644
--- a/src/com/android/documentsui/model/RootInfo.java
+++ b/src/com/android/documentsui/model/RootInfo.java
@@ -249,15 +249,6 @@
}
}
- public Drawable loadGridIcon(Context context) {
- if (derivedIcon != 0) {
- return IconUtils.applyTintAttr(context, derivedIcon,
- android.R.attr.textColorPrimaryInverse);
- } else {
- return IconUtils.loadPackageIcon(context, authority, icon);
- }
- }
-
public Drawable loadToolbarIcon(Context context) {
if (derivedIcon != 0) {
return IconUtils.applyTintAttr(context, derivedIcon,