diff options
author | Hyunyoung Song <hyunyoungs@google.com> | 2017-07-21 12:43:50 -0700 |
---|---|---|
committer | Hyunyoung Song <hyunyoungs@google.com> | 2017-07-25 15:27:31 -0700 |
commit | a62e5047cb708a47c8b23aeb2be0951540a1d6e6 (patch) | |
tree | cfa17a6f0b10ed1150e75c9d91e925904d7a3a03 | |
parent | 6daebf55a1da09af50aa808ab2a79d967b25a442 (diff) | |
download | platform_packages_apps_DocumentsUI-a62e5047cb708a47c8b23aeb2be0951540a1d6e6.tar.gz platform_packages_apps_DocumentsUI-a62e5047cb708a47c8b23aeb2be0951540a1d6e6.tar.bz2 platform_packages_apps_DocumentsUI-a62e5047cb708a47c8b23aeb2be0951540a1d6e6.zip |
Upgrade launcher icon and shortcuts to adaptive icon
Bug: 62023774
Test: build, and runs, manual testing on marlin device
Details:
1. Inverted shortcut color and set background to be Grey 100 material color
following the shortcut design guidelines
2. Fixed wrong typecasting in FilesActivity
etc, etc...
Change-Id: I96d245c190ad234aac22fb2e1d58c6e299fb7fcf
26 files changed, 87 insertions, 42 deletions
diff --git a/res/drawable/ic_images_shortcut.xml b/res/drawable/ic_images_shortcut.xml index a60f27cd4..5e84369ea 100644 --- a/res/drawable/ic_images_shortcut.xml +++ b/res/drawable/ic_images_shortcut.xml @@ -15,16 +15,19 @@ ~ limitations under the License. --> -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> - <item> - <shape android:shape="oval"> - <solid android:color="@color/shortcut_background" /> - </shape> - </item> - <item - android:drawable="@drawable/ic_images_white" - android:top="16dp" - android:right="16dp" - android:bottom="16dp" - android:left="16dp" /> -</layer-list>
\ No newline at end of file +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/shortcut_background" /> + <foreground> + <inset android:inset="33%"> + <vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportHeight="24" + android:viewportWidth="24"> + <path + android:fillColor="@color/shortcut_foreground" + android:pathData="M21 19V5c0,-1.1,-.9,-2,-2,-2H5c-1.1 0,-2 .9,-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2,-.9 2,-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5,-4.5z" /> + </vector> + </inset> + </foreground> +</adaptive-icon> diff --git a/res/drawable/ic_images_white.xml b/res/drawable/ic_images_white.xml deleted file mode 100644 index 35d0e3aaa..000000000 --- a/res/drawable/ic_images_white.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2017 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. - --> - -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" - android:height="24dp" - android:viewportHeight="24" - android:viewportWidth="24"> - <path - android:fillColor="#FFFFFFFF" - android:pathData="M21 19V5c0,-1.1,-.9,-2,-2,-2H5c-1.1 0,-2 .9,-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2,-.9 2,-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5,-4.5z" /> -</vector> diff --git a/res/mipmap-anydpi/ic_app_icon.xml b/res/mipmap-anydpi/ic_app_icon.xml new file mode 100644 index 000000000..cd4fa58a8 --- /dev/null +++ b/res/mipmap-anydpi/ic_app_icon.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/app_icon_background"/> + <foreground android:drawable="@mipmap/ic_launcher_icon_foreground"/> +</adaptive-icon> diff --git a/res/mipmap-anydpi/ic_launcher_downloads.xml b/res/mipmap-anydpi/ic_launcher_downloads.xml new file mode 100644 index 000000000..296c9d79a --- /dev/null +++ b/res/mipmap-anydpi/ic_launcher_downloads.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@color/downloads_icon_background"/> + <foreground android:drawable="@mipmap/ic_launcher_downloads_foreground"/> +</adaptive-icon> diff --git a/res/mipmap-hdpi/ic_app_icon.png b/res/mipmap-hdpi/ic_app_icon.png Binary files differdeleted file mode 100644 index 7b0d04f92..000000000 --- a/res/mipmap-hdpi/ic_app_icon.png +++ /dev/null diff --git a/res/mipmap-hdpi/ic_launcher_downloads.png b/res/mipmap-hdpi/ic_launcher_downloads.png Binary files differdeleted file mode 100644 index f958bbd3c..000000000 --- a/res/mipmap-hdpi/ic_launcher_downloads.png +++ /dev/null diff --git a/res/mipmap-hdpi/ic_launcher_downloads_foreground.png b/res/mipmap-hdpi/ic_launcher_downloads_foreground.png Binary files differnew file mode 100644 index 000000000..d27d5266e --- /dev/null +++ b/res/mipmap-hdpi/ic_launcher_downloads_foreground.png diff --git a/res/mipmap-hdpi/ic_launcher_icon_foreground.png b/res/mipmap-hdpi/ic_launcher_icon_foreground.png Binary files differnew file mode 100644 index 000000000..992c44e2d --- /dev/null +++ b/res/mipmap-hdpi/ic_launcher_icon_foreground.png diff --git a/res/mipmap-mdpi/ic_app_icon.png b/res/mipmap-mdpi/ic_app_icon.png Binary files differdeleted file mode 100644 index 1747fb27a..000000000 --- a/res/mipmap-mdpi/ic_app_icon.png +++ /dev/null diff --git a/res/mipmap-mdpi/ic_launcher_downloads.png b/res/mipmap-mdpi/ic_launcher_downloads.png Binary files differdeleted file mode 100644 index f2e937663..000000000 --- a/res/mipmap-mdpi/ic_launcher_downloads.png +++ /dev/null diff --git a/res/mipmap-mdpi/ic_launcher_downloads_foreground.png b/res/mipmap-mdpi/ic_launcher_downloads_foreground.png Binary files differnew file mode 100644 index 000000000..a462402e4 --- /dev/null +++ b/res/mipmap-mdpi/ic_launcher_downloads_foreground.png diff --git a/res/mipmap-mdpi/ic_launcher_icon_foreground.png b/res/mipmap-mdpi/ic_launcher_icon_foreground.png Binary files differnew file mode 100644 index 000000000..4639ff014 --- /dev/null +++ b/res/mipmap-mdpi/ic_launcher_icon_foreground.png diff --git a/res/mipmap-xhdpi/ic_app_icon.png b/res/mipmap-xhdpi/ic_app_icon.png Binary files differdeleted file mode 100644 index 8a461fcc6..000000000 --- a/res/mipmap-xhdpi/ic_app_icon.png +++ /dev/null diff --git a/res/mipmap-xhdpi/ic_launcher_downloads.png b/res/mipmap-xhdpi/ic_launcher_downloads.png Binary files differdeleted file mode 100644 index 4dc533638..000000000 --- a/res/mipmap-xhdpi/ic_launcher_downloads.png +++ /dev/null diff --git a/res/mipmap-xhdpi/ic_launcher_downloads_foreground.png b/res/mipmap-xhdpi/ic_launcher_downloads_foreground.png Binary files differnew file mode 100644 index 000000000..c637eb492 --- /dev/null +++ b/res/mipmap-xhdpi/ic_launcher_downloads_foreground.png diff --git a/res/mipmap-xhdpi/ic_launcher_icon_foreground.png b/res/mipmap-xhdpi/ic_launcher_icon_foreground.png Binary files differnew file mode 100644 index 000000000..b99294403 --- /dev/null +++ b/res/mipmap-xhdpi/ic_launcher_icon_foreground.png diff --git a/res/mipmap-xxhdpi/ic_app_icon.png b/res/mipmap-xxhdpi/ic_app_icon.png Binary files differdeleted file mode 100644 index c8eff03f3..000000000 --- a/res/mipmap-xxhdpi/ic_app_icon.png +++ /dev/null diff --git a/res/mipmap-xxhdpi/ic_launcher_downloads.png b/res/mipmap-xxhdpi/ic_launcher_downloads.png Binary files differdeleted file mode 100644 index 871629096..000000000 --- a/res/mipmap-xxhdpi/ic_launcher_downloads.png +++ /dev/null diff --git a/res/mipmap-xxhdpi/ic_launcher_downloads_foreground.png b/res/mipmap-xxhdpi/ic_launcher_downloads_foreground.png Binary files differnew file mode 100644 index 000000000..6f31eeff0 --- /dev/null +++ b/res/mipmap-xxhdpi/ic_launcher_downloads_foreground.png diff --git a/res/mipmap-xxhdpi/ic_launcher_icon_foreground.png b/res/mipmap-xxhdpi/ic_launcher_icon_foreground.png Binary files differnew file mode 100644 index 000000000..ae44b2f68 --- /dev/null +++ b/res/mipmap-xxhdpi/ic_launcher_icon_foreground.png diff --git a/res/mipmap-xxxhdpi/ic_app_icon.png b/res/mipmap-xxxhdpi/ic_app_icon.png Binary files differdeleted file mode 100644 index 2961a6417..000000000 --- a/res/mipmap-xxxhdpi/ic_app_icon.png +++ /dev/null diff --git a/res/mipmap-xxxhdpi/ic_launcher_downloads.png b/res/mipmap-xxxhdpi/ic_launcher_downloads.png Binary files differdeleted file mode 100644 index f5be21991..000000000 --- a/res/mipmap-xxxhdpi/ic_launcher_downloads.png +++ /dev/null diff --git a/res/mipmap-xxxhdpi/ic_launcher_downloads_foreground.png b/res/mipmap-xxxhdpi/ic_launcher_downloads_foreground.png Binary files differnew file mode 100644 index 000000000..4b033db0a --- /dev/null +++ b/res/mipmap-xxxhdpi/ic_launcher_downloads_foreground.png diff --git a/res/mipmap-xxxhdpi/ic_launcher_icon_foreground.png b/res/mipmap-xxxhdpi/ic_launcher_icon_foreground.png Binary files differnew file mode 100644 index 000000000..85150eb3b --- /dev/null +++ b/res/mipmap-xxxhdpi/ic_launcher_icon_foreground.png diff --git a/res/values/colors.xml b/res/values/colors.xml index 1e47825cd..8c3ff642b 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -64,7 +64,10 @@ <color name="item_drag_shadow_background">@*android:color/white</color> <color name="item_drag_shadow_container_background">@*android:color/transparent</color> - <color name="shortcut_background">@*android:color/Blue_700</color> + <color name="downloads_icon_background">#ff4688f2</color> + <color name="app_icon_background">#ff4688f2</color> + <color name="shortcut_foreground">#ff3367d6</color> + <color name="shortcut_background">#fff5f5f5</color> <color name="dialog_title">@*android:color/primary_text_default_material_light</color> diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java index 9085dfbe3..a29bc58fe 100644 --- a/src/com/android/documentsui/files/FilesActivity.java +++ b/src/com/android/documentsui/files/FilesActivity.java @@ -21,7 +21,14 @@ import static com.android.documentsui.OperationDialogFragment.DIALOG_TYPE_UNKNOW import android.app.ActivityManager.TaskDescription; import android.app.FragmentManager; import android.content.Intent; +import android.content.Context; +import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; import android.net.Uri; import android.os.Bundle; import android.support.annotation.CallSuper; @@ -183,12 +190,60 @@ public class FilesActivity extends BaseActivity implements ActionHandler.Addons int iconRes = intent.getIntExtra(LauncherActivity.TASK_ICON_RES, -1); assert(iconRes > -1); - BitmapDrawable drawable = (BitmapDrawable) getResources().getDrawable( + Drawable drawable = getResources().getDrawable( iconRes, null // we don't care about theme, since the supplier should have handled that. ); - setTaskDescription(new TaskDescription(label, drawable.getBitmap())); + setTaskDescription(new TaskDescription(label, flattenDrawableToBitmap(drawable))); + } + + // AdaptiveIconDrawable assumes that the consumer of the icon applies the shadow and + // recents assume that the provider of the task description handles these. Hence, + // we apply the shadow treatment same as Launcher3 implementation. + private Bitmap flattenDrawableToBitmap(Drawable d) { + // Percent of actual icon size + float ICON_SIZE_BLUR_FACTOR = 0.5f/48; + // Percent of actual icon size + float ICON_SIZE_KEY_SHADOW_DELTA_FACTOR = 1f/48; + int KEY_SHADOW_ALPHA = 61; + int AMBIENT_SHADOW_ALPHA = 30; + if (d instanceof BitmapDrawable) { + return ((BitmapDrawable) d).getBitmap(); + } else if (d instanceof AdaptiveIconDrawable) { + AdaptiveIconDrawable aid = (AdaptiveIconDrawable) d; + int iconSize = getResources().getDimensionPixelSize(android.R.dimen.app_icon_size); + int shadowSize = Math.max(iconSize, aid.getIntrinsicHeight()); + aid.setBounds(0, 0, shadowSize, shadowSize); + + float blur = ICON_SIZE_BLUR_FACTOR * shadowSize; + float keyShadowDistance = ICON_SIZE_KEY_SHADOW_DELTA_FACTOR * shadowSize; + + int bitmapSize = (int) (shadowSize + 2 * blur + keyShadowDistance); + Bitmap shadow = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888); + + Canvas canvas = new Canvas(shadow); + canvas.translate(blur + keyShadowDistance / 2, blur); + + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + paint.setColor(Color.TRANSPARENT); + + // Draw ambient shadow + paint.setShadowLayer(blur, 0, 0, AMBIENT_SHADOW_ALPHA << 24); + canvas.drawPath(aid.getIconMask(), paint); + + // Draw key shadow + canvas.translate(0, keyShadowDistance); + paint.setShadowLayer(blur, 0, 0, KEY_SHADOW_ALPHA << 24); + canvas.drawPath(aid.getIconMask(), paint); + + // Draw original drawable + aid.draw(canvas); + + canvas.setBitmap(null); + return shadow; + } + return null; } private void presentFileErrors(Bundle icicle, final Intent intent) { |