diff options
author | 2015-11-06 11:07:22 -0800 | |
---|---|---|
committer | 2015-11-10 20:32:17 -0800 | |
commit | 3e4db1a2f28358bf05563499ea0655931846478e (patch) | |
tree | 5b89ad1b512d2ba5ba32c67a1ba8851fa901c39c | |
parent | f32af0a5546ec1d7bb694653222a3194ff01c0ba (diff) |
Adjust grid item layouts to match mocks.
BUG=24326989
Change-Id: I8a4133890036a2ef9173f20828f062a7e991525d
-rw-r--r-- | res/color/item_doc_grid_overlay.xml | 28 | ||||
-rw-r--r-- | res/drawable-hdpi/ic_grid_selection_check.png | bin | 1575 -> 0 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_grid_selection_check.png | bin | 996 -> 0 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_grid_selection_check.png | bin | 2062 -> 0 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/ic_grid_selection_check.png | bin | 3976 -> 0 bytes | |||
-rw-r--r-- | res/drawable-xxxhdpi/ic_grid_selection_check.png | bin | 4126 -> 0 bytes | |||
-rw-r--r-- | res/drawable/item_doc_grid_overlay.xml | 20 | ||||
-rw-r--r-- | res/drawable/item_doc_grid_overlay_icon.xml | 21 | ||||
-rw-r--r-- | res/layout/item_doc_grid.xml | 200 | ||||
-rw-r--r-- | res/values/colors.xml | 2 | ||||
-rw-r--r-- | src/com/android/documentsui/GridItemThumbnail.java (renamed from src/com/android/documentsui/GridItem.java) | 13 | ||||
-rw-r--r-- | src/com/android/documentsui/dirlist/DirectoryFragment.java | 27 | ||||
-rw-r--r-- | src/com/android/documentsui/model/RootInfo.java | 9 |
13 files changed, 102 insertions, 218 deletions
diff --git a/res/color/item_doc_grid_overlay.xml b/res/color/item_doc_grid_overlay.xml deleted file mode 100644 index bf19d4e11..000000000 --- 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 Binary files differdeleted file mode 100644 index f3007c288..000000000 --- a/res/drawable-hdpi/ic_grid_selection_check.png +++ /dev/null diff --git a/res/drawable-mdpi/ic_grid_selection_check.png b/res/drawable-mdpi/ic_grid_selection_check.png Binary files differdeleted file mode 100644 index 16f2ab9a5..000000000 --- a/res/drawable-mdpi/ic_grid_selection_check.png +++ /dev/null diff --git a/res/drawable-xhdpi/ic_grid_selection_check.png b/res/drawable-xhdpi/ic_grid_selection_check.png Binary files differdeleted file mode 100644 index 08853207e..000000000 --- a/res/drawable-xhdpi/ic_grid_selection_check.png +++ /dev/null diff --git a/res/drawable-xxhdpi/ic_grid_selection_check.png b/res/drawable-xxhdpi/ic_grid_selection_check.png Binary files differdeleted file mode 100644 index 083bbcc37..000000000 --- a/res/drawable-xxhdpi/ic_grid_selection_check.png +++ /dev/null diff --git a/res/drawable-xxxhdpi/ic_grid_selection_check.png b/res/drawable-xxxhdpi/ic_grid_selection_check.png Binary files differdeleted file mode 100644 index 74b1ca517..000000000 --- a/res/drawable-xxxhdpi/ic_grid_selection_check.png +++ /dev/null diff --git a/res/drawable/item_doc_grid_overlay.xml b/res/drawable/item_doc_grid_overlay.xml deleted file mode 100644 index 3f50fb9f1..000000000 --- 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 d40de1e15..000000000 --- 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 15b12ce52..1dfb34a9b 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" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scaleType="centerCrop" - android:contentDescription="@null" /> - - <LinearLayout + <!-- 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: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" /> - - <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"> - - <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> - + + </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:layout_width="match_parent" - android:layout_height="match_parent" - android:src="@drawable/item_doc_grid_overlay" + 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:background="@drawable/item_doc_grid_border" - android:duplicateParentState="true" /> + android:paddingStart="12dp" + android:paddingEnd="8dp"/> - <ImageView + <!-- 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_icon" - android:scaleType="center" + 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" /> -</com.android.documentsui.GridItem> +</RelativeLayout> diff --git a/res/values/colors.xml b/res/values/colors.xml index a376418e0..68c8b65c4 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 index 990dca70f..38d6d725c 100644 --- a/src/com/android/documentsui/GridItem.java +++ b/src/com/android/documentsui/GridItemThumbnail.java @@ -18,22 +18,21 @@ package com.android.documentsui; 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 e448a1955..6f15d6842 100644 --- a/src/com/android/documentsui/dirlist/DirectoryFragment.java +++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java @@ -1091,14 +1091,12 @@ public class DirectoryFragment extends Fragment { 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); @@ -1151,13 +1149,14 @@ public class DirectoryFragment extends Fragment { 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; @@ -1165,11 +1164,7 @@ public class DirectoryFragment extends Fragment { // 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() @@ -1211,16 +1206,10 @@ public class DirectoryFragment extends Fragment { } 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) { @@ -1242,9 +1231,6 @@ public class DirectoryFragment extends Fragment { size.setVisibility(View.GONE); } - if (line1 != null) { - line1.setVisibility(hasLine1 ? View.VISIBLE : View.GONE); - } if (line2 != null) { line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE); } @@ -1254,7 +1240,6 @@ public class DirectoryFragment extends Fragment { 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 501392ca9..723700ded 100644 --- a/src/com/android/documentsui/model/RootInfo.java +++ b/src/com/android/documentsui/model/RootInfo.java @@ -249,15 +249,6 @@ public class RootInfo implements Durable, Parcelable { } } - 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, |