diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 05010775e7f..d436ba70cce 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -83,7 +83,7 @@ + + + + diff --git a/res/drawable/ic_shortcut_battery.xml b/res/drawable/ic_shortcut_battery.xml index 97fdd11e34a..a61b1a3dc95 100644 --- a/res/drawable/ic_shortcut_battery.xml +++ b/res/drawable/ic_shortcut_battery.xml @@ -14,17 +14,20 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - - - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable/ic_shortcut_data_usage.xml b/res/drawable/ic_shortcut_data_usage.xml index dddd4930141..cc0c6bc8a83 100644 --- a/res/drawable/ic_shortcut_data_usage.xml +++ b/res/drawable/ic_shortcut_data_usage.xml @@ -14,18 +14,21 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - - - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable/ic_shortcut_wireless.xml b/res/drawable/ic_shortcut_wireless.xml index d5607e5abd4..a5fc43a604f 100644 --- a/res/drawable/ic_shortcut_wireless.xml +++ b/res/drawable/ic_shortcut_wireless.xml @@ -14,16 +14,19 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> - - - - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/shortcut_badge_maskable.xml b/res/layout/shortcut_badge_maskable.xml new file mode 100644 index 00000000000..e1d555a8c3a --- /dev/null +++ b/res/layout/shortcut_badge_maskable.xml @@ -0,0 +1,36 @@ + + + + + + + + \ No newline at end of file diff --git a/res/mipmap-hdpi/ic_launcher_settings.png b/res/mipmap-hdpi/ic_launcher_settings.png index 252e6b41c6c..ddce98e04e4 100644 Binary files a/res/mipmap-hdpi/ic_launcher_settings.png and b/res/mipmap-hdpi/ic_launcher_settings.png differ diff --git a/res/mipmap-mdpi/ic_launcher_settings.png b/res/mipmap-mdpi/ic_launcher_settings.png index d2ecee98c83..86f3be86ab5 100644 Binary files a/res/mipmap-mdpi/ic_launcher_settings.png and b/res/mipmap-mdpi/ic_launcher_settings.png differ diff --git a/res/mipmap-xhdpi/ic_launcher_settings.png b/res/mipmap-xhdpi/ic_launcher_settings.png index fa8c8135754..360aa696792 100644 Binary files a/res/mipmap-xhdpi/ic_launcher_settings.png and b/res/mipmap-xhdpi/ic_launcher_settings.png differ diff --git a/res/mipmap-xxhdpi/ic_launcher_settings.png b/res/mipmap-xxhdpi/ic_launcher_settings.png index 3fa69e9d6d2..7cb67a92b24 100644 Binary files a/res/mipmap-xxhdpi/ic_launcher_settings.png and b/res/mipmap-xxhdpi/ic_launcher_settings.png differ diff --git a/res/mipmap-xxxhdpi/ic_launcher_settings.png b/res/mipmap-xxxhdpi/ic_launcher_settings.png index 72946b7dc26..3fec9c491bf 100644 Binary files a/res/mipmap-xxxhdpi/ic_launcher_settings.png and b/res/mipmap-xxxhdpi/ic_launcher_settings.png differ diff --git a/res/values/colors.xml b/res/values/colors.xml index 300d73a2385..fdb1265b5fc 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -114,4 +114,7 @@ #ffd7d7d7 + + #fff5f5f5 + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 2bc83c1e960..0ddc634024e 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -245,7 +245,9 @@ 16dp 56dp + 120dp 40dp + 16dp 10dp diff --git a/src/com/android/settings/CreateShortcut.java b/src/com/android/settings/CreateShortcut.java index 56ab34a8b3b..bd7137772a9 100644 --- a/src/com/android/settings/CreateShortcut.java +++ b/src/com/android/settings/CreateShortcut.java @@ -29,6 +29,7 @@ import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.drawable.Icon; +import android.graphics.drawable.MaskableIconDrawable; import android.net.ConnectivityManager; import android.os.AsyncTask; import android.support.annotation.VisibleForTesting; @@ -68,19 +69,22 @@ public class CreateShortcut extends LauncherActivity { protected Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo, CharSequence label) { shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - + ShortcutManager sm = getSystemService(ShortcutManager.class); ActivityInfo activityInfo = resolveInfo.activityInfo; - Bitmap icon = activityInfo.icon != 0 ? createIcon(activityInfo.icon) : null; + Icon maskableIcon = activityInfo.icon != 0 ? Icon.createWithMaskableBitmap( + createIcon(activityInfo.icon, + R.layout.shortcut_badge_maskable, + getResources().getDimensionPixelSize(R.dimen.shortcut_size_maskable))) : + Icon.createWithResource(this, R.drawable.ic_launcher_settings); String shortcutId = SHORTCUT_ID_PREFIX + shortcutIntent.getComponent().flattenToShortString(); ShortcutInfo info = new ShortcutInfo.Builder(this, shortcutId) .setShortLabel(label) .setIntent(shortcutIntent) - .setIcon(icon != null ? Icon.createWithBitmap(icon) : - Icon.createWithResource(this, R.mipmap.ic_launcher_settings)) + .setIcon(maskableIcon) .build(); - Intent intent = getSystemService(ShortcutManager.class).createShortcutResultIntent(info); + Intent intent = sm.createShortcutResultIntent(info); if (intent == null) { intent = new Intent(); } @@ -88,7 +92,12 @@ public class CreateShortcut extends LauncherActivity { Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_settings)); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label); - intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); + + if (activityInfo.icon != 0) { + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(activityInfo.icon, + R.layout.shortcut_badge, + getResources().getDimensionPixelSize(R.dimen.shortcut_size))); + } return intent; } @@ -101,12 +110,12 @@ public class CreateShortcut extends LauncherActivity { info.activityInfo.name); } - private Bitmap createIcon(int resource) { + private Bitmap createIcon(int resource, int layoutRes, int size) { Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material); - View view = LayoutInflater.from(context).inflate(R.layout.shortcut_badge, null); + View view = LayoutInflater.from(context).inflate(layoutRes, null); ((ImageView) view.findViewById(android.R.id.icon)).setImageResource(resource); - int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + int spec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); view.measure(spec, spec); Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Config.ARGB_8888);