Merge "Adjust grid item layouts to match mocks."

This commit is contained in:
Ben Kwa
2015-11-11 05:09:59 +00:00
committed by Android (Google) Code Review
13 changed files with 101 additions and 217 deletions

View File

@@ -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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -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>

View File

@@ -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>

View File

@@ -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">
<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/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"
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>

View File

@@ -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>

View File

@@ -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);
}

View File

@@ -1080,14 +1080,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);
@@ -1140,13 +1138,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;
@@ -1154,11 +1153,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()
@@ -1200,16 +1195,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) {
@@ -1231,9 +1220,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);
}
@@ -1243,7 +1229,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);

View File

@@ -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,