Tweak grid item layout. Adjust colors to match spec.
BUG=10960718
BUG=24326989
Change-Id: I74da23fe0b40d713a3f435d1467d26d707e76fca
diff --git a/res/drawable/item_root_background.xml b/res/drawable/item_root_background.xml
deleted file mode 100644
index c403159..0000000
--- a/res/drawable/item_root_background.xml
+++ /dev/null
@@ -1,24 +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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="true" android:state_activated="true">
- <color android:color="@color/material_grey_300" />
- </item>
- <item android:state_focused="false" android:state_activated="true">
- <color android:color="@color/material_grey_300" />
- </item>
-</selector>
diff --git a/res/layout-sw720dp-land/item_doc_list.xml b/res/layout-sw720dp-land/item_doc_list.xml
index 381e1c8..fe06eaf 100644
--- a/res/layout-sw720dp-land/item_doc_list.xml
+++ b/res/layout-sw720dp-land/item_doc_list.xml
@@ -17,7 +17,7 @@
<com.android.documentsui.ListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@drawable/item_doc_list_background"
+ android:background="@color/item_doc_background"
android:orientation="horizontal"
android:focusable="true">
diff --git a/res/layout/drawer_layout.xml b/res/layout/drawer_layout.xml
index 0dac0d5..0146f14 100644
--- a/res/layout/drawer_layout.xml
+++ b/res/layout/drawer_layout.xml
@@ -61,7 +61,7 @@
android:layout_gravity="start"
android:orientation="vertical"
android:elevation="16dp"
- android:background="@*android:color/white">
+ android:background="@color/window_background">
<Toolbar
android:id="@+id/roots_toolbar"
diff --git a/res/layout/fixed_layout.xml b/res/layout/fixed_layout.xml
index 403c667..3135977 100644
--- a/res/layout/fixed_layout.xml
+++ b/res/layout/fixed_layout.xml
@@ -50,9 +50,7 @@
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
- android:baselineAligned="false"
- android:divider="?android:attr/dividerVertical"
- android:showDividers="middle">
+ android:baselineAligned="false">
<FrameLayout
android:id="@+id/container_roots"
@@ -62,8 +60,7 @@
<include layout="@layout/directory_cluster"
android:layout_width="0dp"
android:layout_weight="1"
- android:elevation="8dp"
- android:background="@color/material_grey_50" />
+ android:elevation="8dp" />
</LinearLayout>
diff --git a/res/layout/fragment_directory.xml b/res/layout/fragment_directory.xml
index ada7f49..f9bbccb 100644
--- a/res/layout/fragment_directory.xml
+++ b/res/layout/fragment_directory.xml
@@ -17,7 +17,6 @@
<com.android.documentsui.DirectoryView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/material_grey_50"
android:orientation="vertical"
android:animateLayoutChanges="true">
@@ -78,8 +77,7 @@
android:paddingBottom="0dp"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
- android:drawSelectorOnTop="true"
- android:background="@color/directory_background" />
+ android:drawSelectorOnTop="true" />
</FrameLayout>
diff --git a/res/layout/item_doc_grid.xml b/res/layout/item_doc_grid.xml
index 1dfb34a..dcd5cfd 100644
--- a/res/layout/item_doc_grid.xml
+++ b/res/layout/item_doc_grid.xml
@@ -18,101 +18,101 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/grid_item_margin"
- android:background="@color/item_doc_grid_background"
+ android:background="@color/item_doc_background"
android:focusable="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"
- android:paddingBottom="8dp">
-
+ 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" />
-
- <ImageView
+
+ <com.android.documentsui.GridItemThumbnail
android:id="@+id/icon_mime"
android:layout_width="match_parent"
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" />
- <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" />
-
- <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"
+ <RelativeLayout
+ android:id="@+id/nameplate"
android:layout_width="match_parent"
- android:layout_height="8dp"
- android:layout_below="@id/size" />
+ android:layout_height="wrap_content"
+ android:layout_below="@id/thumbnail"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp"
+ android:paddingLeft="12dp"
+ android:paddingRight="12dp">
+
+ <ImageView
+ android:id="@android:id/icon1"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_marginEnd="8dp"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:scaleType="centerInside"
+ android:contentDescription="@null"/>
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_toEndOf="@android:id/icon1"
+ android:singleLine="true"
+ android:ellipsize="middle"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textColor="@*android:color/primary_text_default_material_light" />
+
+ <TextView
+ android:id="@+id/size"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toEndOf="@android:id/icon1"
+ android:layout_below="@android:id/title"
+ android:layout_marginEnd="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" />
+
+ <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:singleLine="true"
+ android:ellipsize="end"
+ android:textAlignment="viewStart"
+ android:textAppearance="@android:style/TextAppearance.Material.Caption"
+ android:textColor="@*android:color/primary_text_default_material_light" />
+
+ </RelativeLayout>
<!-- 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_alignBottom="@id/nameplate"
android:layout_alignTop="@id/thumbnail"
android:layout_alignLeft="@id/thumbnail"
android:layout_alignRight="@id/thumbnail"
diff --git a/res/layout/item_doc_list.xml b/res/layout/item_doc_list.xml
index c409166..e068423 100644
--- a/res/layout/item_doc_list.xml
+++ b/res/layout/item_doc_list.xml
@@ -17,10 +17,10 @@
<com.android.documentsui.ListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@drawable/item_doc_list_background"
+ android:background="@color/item_doc_background"
android:orientation="horizontal"
android:focusable="true">
-
+
<View
android:id="@+id/focus_indicator"
android:layout_width="4dp"
diff --git a/res/layout/item_root.xml b/res/layout/item_root.xml
index 90b1ff6..ff80d07 100644
--- a/res/layout/item_root.xml
+++ b/res/layout/item_root.xml
@@ -22,8 +22,7 @@
android:paddingEnd="@dimen/list_item_padding"
android:gravity="center_vertical"
android:orientation="horizontal"
- android:baselineAligned="false"
- android:background="@drawable/item_root_background">
+ android:baselineAligned="false">
<FrameLayout
android:layout_width="@dimen/icon_size"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 68c8b65..153c673 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -17,14 +17,20 @@
<resources>
<color name="material_grey_400">#ffbdbdbd</color>
+ <!-- This is the window background, but also the background for anything
+ else that needs to manually declare a background matching the "default"
+ app background (e.g. the drawer overlay). -->
+ <color name="window_background">#fff1f1f1</color>
+
<color name="primary_dark">@*android:color/primary_dark_material_dark</color>
<color name="primary">@*android:color/material_blue_grey_900</color>
<color name="accent">@*android:color/accent_material_light</color>
<color name="action_mode">@color/material_grey_400</color>
-
- <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">@android:color/white</color>
+
<color name="band_select_background">#88ffffff</color>
<color name="band_select_border">#44000000</color>
+
+ <color name="item_doc_background">#fffafafa</color>
+ <color name="item_doc_background_selected">#ffe0f2f1</color>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 15d17cc..6712e2d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -25,6 +25,7 @@
<item name="actionBarTheme">@style/ActionBarTheme</item>
<item name="actionBarPopupTheme">@style/ActionBarPopupTheme</item>
+ <item name="android:windowBackground">@color/window_background</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorAccent">@color/accent</item>
@@ -44,6 +45,7 @@
<item name="actionBarTheme">@style/ActionBarTheme</item>
<item name="actionBarPopupTheme">@style/ActionBarPopupTheme</item>
+ <item name="android:windowBackground">@color/window_background</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorAccent">@color/accent</item>
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index 18dd8c8..8b3893f 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -943,7 +943,6 @@
public void setSelected(boolean selected) {
itemView.setActivated(selected);
- itemView.setBackgroundColor(selected ? mSelectedItemColor : mDefaultItemColor);
}
@Override
@@ -1080,8 +1079,6 @@
holder.setSelected(isSelected(position));
- 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);
@@ -1138,14 +1135,11 @@
getDocumentIcon(mContext, docAuthority, docId, docMimeType, docIcon, state));
}
- boolean hasLine2 = false;
-
- final boolean hideTitle = (state.derivedMode == MODE_GRID) && mHideGridTitles;
- if (!hideTitle) {
+ if ((state.derivedMode == MODE_GRID) && mHideGridTitles) {
+ title.setVisibility(View.GONE);
+ } else {
title.setText(docDisplayName);
title.setVisibility(View.VISIBLE);
- } else {
- title.setVisibility(View.GONE);
}
Drawable iconDrawable = null;
@@ -1161,7 +1155,6 @@
if (alwaysShowSummary) {
summary.setText(root.getDirectoryString());
summary.setVisibility(View.VISIBLE);
- hasLine2 = true;
} else {
if (iconDrawable != null && roots.isIconUniqueBlocking(root)) {
// No summary needed if icon speaks for itself
@@ -1170,7 +1163,6 @@
summary.setText(root.getDirectoryString());
summary.setVisibility(View.VISIBLE);
summary.setTextAlignment(TextView.TEXT_ALIGNMENT_TEXT_END);
- hasLine2 = true;
}
}
}
@@ -1187,48 +1179,37 @@
if (docSummary != null) {
summary.setText(docSummary);
summary.setVisibility(View.VISIBLE);
- hasLine2 = true;
} else {
summary.setVisibility(View.INVISIBLE);
}
}
}
- if (icon1 != null) icon1.setVisibility(View.GONE);
-
if (iconDrawable != null) {
icon1.setVisibility(View.VISIBLE);
icon1.setImageDrawable(iconDrawable);
+ } else {
+ icon1.setVisibility(View.GONE);
}
if (docLastModified == -1) {
date.setText(null);
} else {
date.setText(formatTime(mContext, docLastModified));
- hasLine2 = true;
}
- if (state.showSize) {
- size.setVisibility(View.VISIBLE);
- if (Document.MIME_TYPE_DIR.equals(docMimeType) || docSize == -1) {
- size.setText(null);
- } else {
- size.setText(Formatter.formatFileSize(mContext, docSize));
- hasLine2 = true;
- }
- } else {
+ if (!state.showSize || Document.MIME_TYPE_DIR.equals(docMimeType) || docSize == -1) {
size.setVisibility(View.GONE);
- }
-
- if (line2 != null) {
- line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
+ } else {
+ size.setVisibility(View.VISIBLE);
+ size.setText(Formatter.formatFileSize(mContext, docSize));
}
setEnabledRecursive(itemView, enabled);
iconMime.setAlpha(iconAlpha);
iconThumb.setAlpha(iconAlpha);
- if (icon1 != null) icon1.setAlpha(iconAlpha);
+ icon1.setAlpha(iconAlpha);
if (DEBUG_ENABLE_DND) {
setupDragAndDropOnDocumentView(itemView, cursor);
diff --git a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java
index 0963845..1135c21 100644
--- a/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java
+++ b/src/com/android/documentsui/dirlist/DirectoryItemAnimator.java
@@ -25,6 +25,8 @@
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
+import com.android.documentsui.R;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -43,12 +45,8 @@
private final Integer mSelectedColor;
public DirectoryItemAnimator(Context context) {
- mDefaultColor = context.getResources().getColor(android.R.color.transparent);
- // Get the accent color.
- TypedValue selColor = new TypedValue();
- context.getTheme().resolveAttribute(android.R.attr.colorAccent, selColor, true);
- // Set the opacity to 10%.
- mSelectedColor = (selColor.data & 0x00ffffff) | 0x16000000;
+ mDefaultColor = context.getResources().getColor(R.color.item_doc_background);
+ mSelectedColor = context.getResources().getColor(R.color.item_doc_background_selected);
}
@Override