am 1af8d591: am 57d0790a: Merge "Final pass at Material DocumentsUI." into lmp-dev
* commit '1af8d591a20d2c68e218fc6c878e9e312cb9da19': Final pass at Material DocumentsUI.
This commit is contained in:
21
packages/DocumentsUI/res/color/item_root_icon.xml
Normal file
21
packages/DocumentsUI/res/color/item_root_icon.xml
Normal file
@@ -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>
|
||||
22
packages/DocumentsUI/res/color/item_root_primary_text.xml
Normal file
22
packages/DocumentsUI/res/color/item_root_primary_text.xml
Normal file
@@ -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>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 996 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
22
packages/DocumentsUI/res/drawable/item_doc_grid_overlay.xml
Normal file
22
packages/DocumentsUI/res/drawable/item_doc_grid_overlay.xml
Normal file
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user