diff options
Diffstat (limited to 'packages/DocumentsUI/src/com/android/documentsui')
5 files changed, 49 insertions, 39 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index 001cac4..0a7eedc 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -70,7 +70,6 @@ import android.widget.AbsListView.RecyclerListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; -import android.widget.FrameLayout; import android.widget.GridView; import android.widget.ImageView; import android.widget.ListView; @@ -705,11 +704,11 @@ public class DirectoryFragment extends Fragment { if (extras != null) { final String info = extras.getString(DocumentsContract.EXTRA_INFO); if (info != null) { - mFooters.add(new MessageFooter(2, R.drawable.ic_dialog_info_dark, info)); + mFooters.add(new MessageFooter(2, R.drawable.ic_dialog_info, info)); } final String error = extras.getString(DocumentsContract.EXTRA_ERROR); if (error != null) { - mFooters.add(new MessageFooter(3, R.drawable.ic_dialog_alert_dark, error)); + mFooters.add(new MessageFooter(3, R.drawable.ic_dialog_alert, error)); } if (extras.getBoolean(DocumentsContract.EXTRA_LOADING, false)) { mFooters.add(new LoadingFooter()); @@ -718,7 +717,7 @@ public class DirectoryFragment extends Fragment { if (result != null && result.exception != null) { mFooters.add(new MessageFooter( - 3, R.drawable.ic_dialog_alert_dark, getString(R.string.query_error))); + 3, R.drawable.ic_dialog_alert, getString(R.string.query_error))); } if (isEmpty()) { @@ -854,7 +853,7 @@ public class DirectoryFragment extends Fragment { // be shown, so this will never block. final RootInfo root = roots.getRootBlocking(docAuthority, docRootId); if (state.derivedMode == MODE_GRID) { - iconDrawable = root.loadLightIcon(context); + iconDrawable = root.loadGridIcon(context); } else { iconDrawable = root.loadIcon(context); } @@ -883,8 +882,8 @@ 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 = context.getResources().getDrawable( - R.drawable.ic_root_folder_light); + iconDrawable = IconUtils.applyTint(context, R.drawable.ic_doc_folder, + android.R.attr.textColorPrimaryInverse); } if (summary != null) { diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index a2e8432..29f8b9d 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -425,7 +425,8 @@ public class DocumentsActivity extends Activity { final RootInfo root = getCurrentRoot(); final boolean showRootIcon = mShowAsDialog || (mState.action == ACTION_MANAGE); if (showRootIcon) { - mToolbar.setNavigationIcon(root != null ? root.loadLightIcon(this) : null); + mToolbar.setNavigationIcon( + root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null); mToolbar.setNavigationOnClickListener(null); } else { mToolbar.setNavigationIcon(R.drawable.ic_hamburger); diff --git a/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java b/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java index eaa74eb..b7e1294 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java +++ b/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java @@ -22,6 +22,7 @@ import android.content.pm.ProviderInfo; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.provider.DocumentsContract.Document; +import android.util.TypedValue; import com.google.android.collect.Maps; @@ -45,7 +46,7 @@ public class IconUtils { add("application/vnd.android.package-archive", icon); // Audio - icon = R.drawable.ic_doc_audio_dark; + icon = R.drawable.ic_doc_audio; add("application/ogg", icon); add("application/x-flac", icon); @@ -132,7 +133,7 @@ public class IconUtils { add("application/x-font-ttf", icon); // Image - icon = R.drawable.ic_doc_image_dark; + icon = R.drawable.ic_doc_image; add("application/vnd.oasis.opendocument.graphics", icon); add("application/vnd.oasis.opendocument.graphics-template", icon); add("application/vnd.oasis.opendocument.image", icon); @@ -186,7 +187,7 @@ public class IconUtils { add("application/x-kword", icon); // Video - icon = R.drawable.ic_doc_video_dark; + icon = R.drawable.ic_doc_video; add("application/x-quicktimeplayer", icon); add("application/x-shockwave-flash", icon); } @@ -220,7 +221,7 @@ public class IconUtils { if (mode == DocumentsActivity.State.MODE_GRID) { return res.getDrawable(R.drawable.ic_grid_folder); } else { - return res.getDrawable(R.drawable.ic_root_folder_dark); + return res.getDrawable(R.drawable.ic_doc_folder); } } @@ -231,8 +232,7 @@ public class IconUtils { final Resources res = context.getResources(); if (Document.MIME_TYPE_DIR.equals(mimeType)) { - // TODO: return a mipmap, since this is used for grid - return res.getDrawable(R.drawable.ic_root_folder_dark); + return res.getDrawable(R.drawable.ic_doc_folder); } // Look for exact match first @@ -249,15 +249,27 @@ public class IconUtils { // Otherwise look for partial match final String typeOnly = mimeType.split("/")[0]; if ("audio".equals(typeOnly)) { - return res.getDrawable(R.drawable.ic_doc_audio_dark); + return res.getDrawable(R.drawable.ic_doc_audio); } else if ("image".equals(typeOnly)) { - return res.getDrawable(R.drawable.ic_doc_image_dark); + return res.getDrawable(R.drawable.ic_doc_image); } else if ("text".equals(typeOnly)) { return res.getDrawable(R.drawable.ic_doc_text); } else if ("video".equals(typeOnly)) { - return res.getDrawable(R.drawable.ic_doc_video_dark); + return res.getDrawable(R.drawable.ic_doc_video); } else { return res.getDrawable(R.drawable.ic_doc_generic); } } + + 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); + + final Drawable icon = res.getDrawable(drawableId); + icon.mutate(); + icon.setTintList(res.getColorStateList(outValue.resourceId)); + return icon; + } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java index 1235c9b..a465ecd 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java @@ -103,8 +103,7 @@ public class RootsCache { // Special root for recents mRecentsRoot.authority = null; mRecentsRoot.rootId = null; - mRecentsRoot.icon = R.drawable.ic_root_recent_dark; - mRecentsRoot.lightIcon = R.drawable.ic_root_recent_light; + mRecentsRoot.derivedIcon = R.drawable.ic_root_recent; mRecentsRoot.flags = Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_IS_CHILD; mRecentsRoot.title = mContext.getString(R.string.root_recent); diff --git a/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java b/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java index 79cbf26..a358798 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java +++ b/packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java @@ -48,7 +48,6 @@ public class RootInfo implements Durable, Parcelable { public String rootId; public int flags; public int icon; - public int lightIcon; public String title; public String summary; public String documentId; @@ -59,7 +58,6 @@ public class RootInfo implements Durable, Parcelable { public String derivedPackageName; public String[] derivedMimeTypes; public int derivedIcon; - public int derivedLightIcon; public RootInfo() { reset(); @@ -71,7 +69,6 @@ public class RootInfo implements Durable, Parcelable { rootId = null; flags = 0; icon = 0; - lightIcon = 0; title = null; summary = null; documentId = null; @@ -81,7 +78,6 @@ public class RootInfo implements Durable, Parcelable { derivedPackageName = null; derivedMimeTypes = null; derivedIcon = 0; - derivedLightIcon = 0; } @Override @@ -163,20 +159,15 @@ public class RootInfo implements Durable, Parcelable { // TODO: remove these special case icons if (isExternalStorage()) { - derivedIcon = R.drawable.ic_root_sdcard_dark; - derivedLightIcon = R.drawable.ic_root_sdcard_light; + derivedIcon = R.drawable.ic_root_sdcard; } else if (isDownloads()) { - derivedIcon = R.drawable.ic_root_download_dark; - derivedLightIcon = R.drawable.ic_root_download_light; + derivedIcon = R.drawable.ic_root_download; } else if (isImages()) { - derivedIcon = R.drawable.ic_doc_image_dark; - derivedLightIcon = R.drawable.ic_doc_image_light; + derivedIcon = R.drawable.ic_doc_image; } else if (isVideos()) { - derivedIcon = R.drawable.ic_doc_video_dark; - derivedLightIcon = R.drawable.ic_doc_video_light; + derivedIcon = R.drawable.ic_doc_video; } else if (isAudio()) { - derivedIcon = R.drawable.ic_doc_audio_dark; - derivedLightIcon = R.drawable.ic_doc_audio_light; + derivedIcon = R.drawable.ic_doc_audio; } } @@ -220,13 +211,21 @@ public class RootInfo implements Durable, Parcelable { } } - public Drawable loadLightIcon(Context context) { - if (derivedLightIcon != 0) { - return context.getResources().getDrawable(derivedLightIcon); - } else if (lightIcon != 0) { - return IconUtils.loadPackageIcon(context, authority, lightIcon); + public Drawable loadGridIcon(Context context) { + if (derivedIcon != 0) { + return IconUtils.applyTint(context, derivedIcon, + android.R.attr.textColorPrimaryInverse); + } else { + return IconUtils.loadPackageIcon(context, authority, icon); + } + } + + public Drawable loadToolbarIcon(Context context) { + if (derivedIcon != 0) { + return IconUtils.applyTint(context, derivedIcon, + android.R.attr.colorControlNormal); } else { - return loadIcon(context); + return IconUtils.loadPackageIcon(context, authority, icon); } } |
