diff options
author | Jeff Sharkey <jsharkey@android.com> | 2014-09-02 07:11:17 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-02 07:11:17 +0000 |
commit | 08a3d71789a86b6a1929d2af5e582bef80fcbd77 (patch) | |
tree | 4d5f4eb5f75a91ea6927049a6b04741f9ced99dc /packages/DocumentsUI | |
parent | 984e0eeedbc96573e28da0e8a707ff40b8743f2e (diff) | |
parent | 3989b187d71fa2ec2ea7e8046d11fd9a125a9dac (diff) | |
download | frameworks_base-08a3d71789a86b6a1929d2af5e582bef80fcbd77.zip frameworks_base-08a3d71789a86b6a1929d2af5e582bef80fcbd77.tar.gz frameworks_base-08a3d71789a86b6a1929d2af5e582bef80fcbd77.tar.bz2 |
am f085228b: am 1af8d591: am 57d0790a: Merge "Final pass at Material DocumentsUI." into lmp-dev
* commit 'f085228b60b4773344ce0ac5717691851568119a':
Final pass at Material DocumentsUI.
Diffstat (limited to 'packages/DocumentsUI')
22 files changed, 149 insertions, 62 deletions
diff --git a/packages/DocumentsUI/res/color/item_root_icon.xml b/packages/DocumentsUI/res/color/item_root_icon.xml new file mode 100644 index 0000000..1374e61 --- /dev/null +++ b/packages/DocumentsUI/res/color/item_root_icon.xml @@ -0,0 +1,21 @@ +<?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"> + <item android:state_focused="true" android:state_activated="true" android:color="@*android:color/primary_text_default_material_dark" /> + <item android:state_focused="false" android:state_activated="true" android:color="@*android:color/primary_text_default_material_dark" /> + <item android:color="@*android:color/secondary_text_material_light" /> +</selector> diff --git a/packages/DocumentsUI/res/color/item_root_primary_text.xml b/packages/DocumentsUI/res/color/item_root_primary_text.xml new file mode 100644 index 0000000..4ac6916 --- /dev/null +++ b/packages/DocumentsUI/res/color/item_root_primary_text.xml @@ -0,0 +1,22 @@ +<?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"> + <item android:state_focused="true" android:state_activated="true" android:color="@*android:color/primary_text_default_material_dark" /> + <item android:state_focused="false" android:state_activated="true" android:color="@*android:color/primary_text_default_material_dark" /> + <item android:state_enabled="false" android:alpha="@*android:dimen/disabled_alpha_material" android:color="@*android:color/primary_text_default_material_light" /> + <item android:color="@*android:color/primary_text_default_material_light" /> +</selector> diff --git a/packages/DocumentsUI/res/drawable-hdpi/ic_grid_selection_check.png b/packages/DocumentsUI/res/drawable-hdpi/ic_grid_selection_check.png Binary files differnew file mode 100644 index 0000000..f3007c2 --- /dev/null +++ b/packages/DocumentsUI/res/drawable-hdpi/ic_grid_selection_check.png diff --git a/packages/DocumentsUI/res/drawable-mdpi/ic_grid_selection_check.png b/packages/DocumentsUI/res/drawable-mdpi/ic_grid_selection_check.png Binary files differnew file mode 100644 index 0000000..16f2ab9 --- /dev/null +++ b/packages/DocumentsUI/res/drawable-mdpi/ic_grid_selection_check.png diff --git a/packages/DocumentsUI/res/drawable-xhdpi/ic_grid_selection_check.png b/packages/DocumentsUI/res/drawable-xhdpi/ic_grid_selection_check.png Binary files differnew file mode 100644 index 0000000..0885320 --- /dev/null +++ b/packages/DocumentsUI/res/drawable-xhdpi/ic_grid_selection_check.png diff --git a/packages/DocumentsUI/res/drawable-xxhdpi/ic_grid_selection_check.png b/packages/DocumentsUI/res/drawable-xxhdpi/ic_grid_selection_check.png Binary files differnew file mode 100644 index 0000000..083bbcc --- /dev/null +++ b/packages/DocumentsUI/res/drawable-xxhdpi/ic_grid_selection_check.png diff --git a/packages/DocumentsUI/res/drawable-xxxhdpi/ic_grid_selection_check.png b/packages/DocumentsUI/res/drawable-xxxhdpi/ic_grid_selection_check.png Binary files differnew file mode 100644 index 0000000..74b1ca5 --- /dev/null +++ b/packages/DocumentsUI/res/drawable-xxxhdpi/ic_grid_selection_check.png diff --git a/packages/DocumentsUI/res/drawable/item_doc_grid_overlay.xml b/packages/DocumentsUI/res/drawable/item_doc_grid_overlay.xml new file mode 100644 index 0000000..3fbd25e --- /dev/null +++ b/packages/DocumentsUI/res/drawable/item_doc_grid_overlay.xml @@ -0,0 +1,22 @@ +<?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" android:drawable="@color/item_doc_grid_overlay_activated" /> + <item android:state_focused="false" android:state_activated="true" android:drawable="@color/item_doc_grid_overlay_activated" /> + <item android:state_enabled="false" android:drawable="@color/item_doc_grid_overlay_disabled" /> + <item android:drawable="@android:color/transparent" /> +</selector> diff --git a/packages/DocumentsUI/res/drawable/grid_protect_background.xml b/packages/DocumentsUI/res/drawable/item_doc_grid_overlay_icon.xml index 2e7aadd..d40de1e 100644 --- a/packages/DocumentsUI/res/drawable/grid_protect_background.xml +++ b/packages/DocumentsUI/res/drawable/item_doc_grid_overlay_icon.xml @@ -14,11 +14,8 @@ limitations under the License. --> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_enabled="false"> - <color android:color="#88000000" /> - </item> - <item> - <color android:color="#88252525" /> - </item> +<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/packages/DocumentsUI/res/drawable/item_activated_overlay.xml b/packages/DocumentsUI/res/drawable/item_doc_list_background.xml index 83e4d7e..b879542 100644 --- a/packages/DocumentsUI/res/drawable/item_activated_overlay.xml +++ b/packages/DocumentsUI/res/drawable/item_doc_list_background.xml @@ -15,11 +15,7 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_focused="true" android:state_activated="true"> - <color android:color="@color/accent_color_overlay" /> - </item> - <item android:state_focused="false" android:state_activated="true"> - <color android:color="@color/accent_color_overlay" /> - </item> + <item android:state_focused="true" android:state_activated="true" android:drawable="@color/item_doc_list_background_activated" /> + <item android:state_focused="false" android:state_activated="true" android:drawable="@color/item_doc_list_background_activated" /> <item android:drawable="@android:color/transparent" /> </selector> diff --git a/packages/DocumentsUI/res/drawable/item_activated.xml b/packages/DocumentsUI/res/drawable/item_root_background.xml index 1b3f44a..1b3f44a 100644 --- a/packages/DocumentsUI/res/drawable/item_activated.xml +++ b/packages/DocumentsUI/res/drawable/item_root_background.xml diff --git a/packages/DocumentsUI/res/layout-sw720dp-land/item_doc_list.xml b/packages/DocumentsUI/res/layout-sw720dp-land/item_doc_list.xml index 95af7e9..d124320 100644 --- a/packages/DocumentsUI/res/layout-sw720dp-land/item_doc_list.xml +++ b/packages/DocumentsUI/res/layout-sw720dp-land/item_doc_list.xml @@ -17,7 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/item_activated"> + android:background="@drawable/item_doc_list_background"> <LinearLayout android:layout_width="match_parent" diff --git a/packages/DocumentsUI/res/layout/item_doc_grid.xml b/packages/DocumentsUI/res/layout/item_doc_grid.xml index bdb3184..d62d050 100644 --- a/packages/DocumentsUI/res/layout/item_doc_grid.xml +++ b/packages/DocumentsUI/res/layout/item_doc_grid.xml @@ -17,9 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="@dimen/grid_item_height" - android:orientation="vertical" - android:background="@color/grid_item_background" - android:foreground="@drawable/item_activated_overlay"> + android:background="@color/item_doc_grid_background"> <ImageView android:id="@+id/icon_thumb" @@ -44,7 +42,7 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/grid_protect_background" + android:background="@color/item_doc_grid_protect_background" android:orientation="vertical" android:paddingStart="16dp" android:paddingEnd="12dp" @@ -68,7 +66,7 @@ android:ellipsize="middle" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Subhead" - android:textColor="?android:attr/textColorPrimaryInverse" /> + android:textColor="@*android:color/primary_text_default_material_dark" /> <ImageView android:id="@android:id/icon1" @@ -97,7 +95,7 @@ android:ellipsize="end" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Caption" - android:textColor="?android:attr/textColorPrimaryInverse" /> + android:textColor="@*android:color/primary_text_default_material_dark" /> <TextView android:id="@+id/size" @@ -109,7 +107,7 @@ android:ellipsize="end" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Caption" - android:textColor="?android:attr/textColorPrimaryInverse" /> + android:textColor="@*android:color/primary_text_default_material_dark" /> <ImageView android:id="@android:id/icon2" @@ -126,4 +124,19 @@ </LinearLayout> + <ImageView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:src="@drawable/item_doc_grid_overlay" + android:contentDescription="@null" + 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" /> + </FrameLayout> diff --git a/packages/DocumentsUI/res/layout/item_doc_list.xml b/packages/DocumentsUI/res/layout/item_doc_list.xml index c5f1842..c576669 100644 --- a/packages/DocumentsUI/res/layout/item_doc_list.xml +++ b/packages/DocumentsUI/res/layout/item_doc_list.xml @@ -17,7 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/item_activated"> + android:background="@drawable/item_doc_list_background"> <LinearLayout android:layout_width="match_parent" diff --git a/packages/DocumentsUI/res/layout/item_root.xml b/packages/DocumentsUI/res/layout/item_root.xml index 266b9b0..bd83923 100644 --- a/packages/DocumentsUI/res/layout/item_root.xml +++ b/packages/DocumentsUI/res/layout/item_root.xml @@ -23,19 +23,21 @@ android:gravity="center_vertical" android:orientation="horizontal" android:baselineAligned="false" - android:background="@drawable/item_activated"> + android:background="@drawable/item_root_background"> <FrameLayout android:layout_width="@dimen/icon_size" android:layout_height="@dimen/icon_size" - android:layout_marginEnd="16dp"> + android:layout_marginEnd="16dp" + android:duplicateParentState="true"> <ImageView android:id="@android:id/icon" android:layout_width="@dimen/root_icon_size" android:layout_height="match_parent" android:scaleType="centerInside" - android:contentDescription="@null" /> + android:contentDescription="@null" + android:duplicateParentState="true" /> </FrameLayout> @@ -54,7 +56,7 @@ android:ellipsize="end" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Body1" - android:textColor="?android:attr/textColorPrimary" /> + android:textColor="@color/item_root_primary_text" /> <TextView android:id="@android:id/summary" @@ -64,7 +66,7 @@ android:ellipsize="end" android:textAlignment="viewStart" android:textAppearance="@android:style/TextAppearance.Material.Body1" - android:textColor="?android:attr/textColorSecondary" /> + android:textColor="@color/item_root_primary_text" /> </LinearLayout> diff --git a/packages/DocumentsUI/res/values/colors.xml b/packages/DocumentsUI/res/values/colors.xml index 7442b09..2ceb968 100644 --- a/packages/DocumentsUI/res/values/colors.xml +++ b/packages/DocumentsUI/res/values/colors.xml @@ -18,8 +18,16 @@ <color name="material_grey_50">#fffafafa</color> <color name="material_grey_300">#ffeeeeee</color> - <!-- Half-alpha of material_teal_500 --> - <color name="accent_color_overlay">#8800bcd4</color> + <color name="item_doc_grid_background">@color/material_grey_300</color> + + <color name="item_doc_grid_protect_background">#88000000</color> + + <color name="item_doc_grid_overlay_activated">#88000000</color> + <color name="item_doc_grid_overlay_disabled">#88ffffff</color> + + <color name="item_doc_list_overlay_disabled">#88ffffff</color> + + <!-- 10% alpha of material_deep_teal_500 --> + <color name="item_doc_list_background_activated">#1a009688</color> - <color name="grid_item_background">@color/material_grey_300</color> </resources> diff --git a/packages/DocumentsUI/res/values/styles.xml b/packages/DocumentsUI/res/values/styles.xml index 5cfe046..7693da3 100644 --- a/packages/DocumentsUI/res/values/styles.xml +++ b/packages/DocumentsUI/res/values/styles.xml @@ -28,6 +28,7 @@ <item name="android:colorAccent">@*android:color/material_deep_teal_500</item> <item name="android:windowActionBar">false</item> + <item name="android:windowActionModeOverlay">true</item> <item name="android:windowNoTitle">true</item> <item name="*android:windowFixedWidthMajor">@null</item> diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index caa07ab..39c2252 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -807,6 +807,9 @@ public class DirectoryFragment extends Fragment { || MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, docMimeType); final boolean showThumbnail = supportsThumbnail && allowThumbnail && !mSvelteRecents; + final boolean enabled = isDocumentEnabled(docMimeType, docFlags); + final float iconAlpha = (state.derivedMode == MODE_LIST && !enabled) ? 0.5f : 1f; + boolean cacheHit = false; if (showThumbnail) { final Uri uri = DocumentsContract.buildDocumentUri(docAuthority, docId); @@ -817,7 +820,7 @@ public class DirectoryFragment extends Fragment { } else { iconThumb.setImageDrawable(null); final ThumbnailAsyncTask task = new ThumbnailAsyncTask( - uri, iconMime, iconThumb, mThumbSize); + uri, iconMime, iconThumb, mThumbSize, iconAlpha); iconThumb.setTag(task); ProviderExecutor.forAuthority(docAuthority).execute(task); } @@ -886,7 +889,7 @@ public class DirectoryFragment extends Fragment { // hint to remind user they're a directory. if (Document.MIME_TYPE_DIR.equals(docMimeType) && state.derivedMode == MODE_GRID && showThumbnail) { - iconDrawable = IconUtils.applyTint(context, R.drawable.ic_doc_folder, + iconDrawable = IconUtils.applyTintAttr(context, R.drawable.ic_doc_folder, android.R.attr.textColorPrimaryInverse); } @@ -940,20 +943,12 @@ public class DirectoryFragment extends Fragment { line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE); } - final boolean enabled = isDocumentEnabled(docMimeType, docFlags); - if (enabled) { - setEnabledRecursive(convertView, true); - iconMime.setAlpha(1f); - iconThumb.setAlpha(1f); - if (icon1 != null) icon1.setAlpha(1f); - if (icon2 != null) icon2.setAlpha(1f); - } else { - setEnabledRecursive(convertView, false); - iconMime.setAlpha(0.5f); - iconThumb.setAlpha(0.5f); - if (icon1 != null) icon1.setAlpha(0.5f); - if (icon2 != null) icon2.setAlpha(0.5f); - } + setEnabledRecursive(convertView, enabled); + + iconMime.setAlpha(iconAlpha); + iconThumb.setAlpha(iconAlpha); + if (icon1 != null) icon1.setAlpha(iconAlpha); + if (icon2 != null) icon2.setAlpha(iconAlpha); return convertView; } @@ -1000,14 +995,16 @@ public class DirectoryFragment extends Fragment { private final ImageView mIconMime; private final ImageView mIconThumb; private final Point mThumbSize; + private final float mTargetAlpha; private final CancellationSignal mSignal; - public ThumbnailAsyncTask( - Uri uri, ImageView iconMime, ImageView iconThumb, Point thumbSize) { + public ThumbnailAsyncTask(Uri uri, ImageView iconMime, ImageView iconThumb, Point thumbSize, + float targetAlpha) { mUri = uri; mIconMime = iconMime; mIconThumb = iconThumb; mThumbSize = thumbSize; + mTargetAlpha = targetAlpha; mSignal = new CancellationSignal(); } @@ -1051,11 +1048,10 @@ public class DirectoryFragment extends Fragment { mIconThumb.setTag(null); mIconThumb.setImageBitmap(result); - final float targetAlpha = mIconMime.isEnabled() ? 1f : 0.5f; - mIconMime.setAlpha(targetAlpha); + mIconMime.setAlpha(mTargetAlpha); mIconMime.animate().alpha(0f).start(); mIconThumb.setAlpha(0f); - mIconThumb.animate().alpha(targetAlpha).start(); + mIconThumb.animate().alpha(mTargetAlpha).start(); } } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java b/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java index b2e38fc..416aeb0 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java +++ b/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java @@ -266,15 +266,16 @@ public class IconUtils { } } - public static Drawable applyTint(Context context, int drawableId, int tintAttrId) { - final Resources res = context.getResources(); - - final TypedValue outValue = new TypedValue(); - context.getTheme().resolveAttribute(tintAttrId, outValue, true); - + public static Drawable applyTintColor(Context context, int drawableId, int tintColorId) { final Drawable icon = context.getDrawable(drawableId); icon.mutate(); - icon.setTintList(res.getColorStateList(outValue.resourceId)); + icon.setTintList(context.getResources().getColorStateList(tintColorId)); return icon; } + + public static Drawable applyTintAttr(Context context, int drawableId, int tintAttrId) { + final TypedValue outValue = new TypedValue(); + context.getTheme().resolveAttribute(tintAttrId, outValue, true); + return applyTintColor(context, drawableId, outValue.resourceId); + } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java index a465ecd..f81690a 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java @@ -58,7 +58,7 @@ import java.util.concurrent.TimeUnit; * Cache of known storage backends and their roots. */ public class RootsCache { - private static final boolean LOGD = true; + private static final boolean LOGD = false; public static final Uri sNotificationUri = Uri.parse( "content://com.android.documentsui.roots/"); diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java index b19e028..884cf31 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java @@ -235,7 +235,7 @@ public class RootsFragment extends Fragment { final TextView summary = (TextView) convertView.findViewById(android.R.id.summary); final Context context = convertView.getContext(); - icon.setImageDrawable(root.loadIcon(context)); + icon.setImageDrawable(root.loadDrawerIcon(context)); title.setText(root.title); // Show available space if no summary diff --git a/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java b/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java index fcfe518..97d8ed0 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java +++ b/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java @@ -211,9 +211,17 @@ public class RootInfo implements Durable, Parcelable { } } + public Drawable loadDrawerIcon(Context context) { + if (derivedIcon != 0) { + return IconUtils.applyTintColor(context, derivedIcon, R.color.item_root_icon); + } else { + return IconUtils.loadPackageIcon(context, authority, icon); + } + } + public Drawable loadGridIcon(Context context) { if (derivedIcon != 0) { - return IconUtils.applyTint(context, derivedIcon, + return IconUtils.applyTintAttr(context, derivedIcon, android.R.attr.textColorPrimaryInverse); } else { return IconUtils.loadPackageIcon(context, authority, icon); @@ -222,7 +230,7 @@ public class RootInfo implements Durable, Parcelable { public Drawable loadToolbarIcon(Context context) { if (derivedIcon != 0) { - return IconUtils.applyTint(context, derivedIcon, + return IconUtils.applyTintAttr(context, derivedIcon, android.R.attr.colorControlNormal); } else { return IconUtils.loadPackageIcon(context, authority, icon); |