diff --git a/app/src/main/java/com/kabouzeid/gramophone/appshortcuts/AppShortcutIconGenerator.java b/app/src/main/java/com/kabouzeid/gramophone/appshortcuts/AppShortcutIconGenerator.java index a01488b2..4798d97e 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/appshortcuts/AppShortcutIconGenerator.java +++ b/app/src/main/java/com/kabouzeid/gramophone/appshortcuts/AppShortcutIconGenerator.java @@ -3,9 +3,14 @@ package com.kabouzeid.gramophone.appshortcuts; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.ScaleDrawable; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.shapes.RectShape; +import android.graphics.drawable.shapes.Shape; import android.os.Build; import android.support.annotation.RequiresApi; import android.util.TypedValue; @@ -53,11 +58,16 @@ public final class AppShortcutIconGenerator { Drawable vectorDrawable = Util.getTintedVectorDrawable(context, iconId, foregroundColor); Drawable backgroundDrawable = Util.getTintedVectorDrawable(context, R.drawable.ic_app_shortcut_background, backgroundColor); - // Squash the two drawables together - LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{backgroundDrawable, vectorDrawable}); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ + AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(backgroundDrawable, vectorDrawable); + return Icon.createWithAdaptiveBitmap(drawableToBitmap(adaptiveIconDrawable)); + } else { + // Squash the two drawables together + LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{backgroundDrawable, vectorDrawable}); - // Return as an Icon - return Icon.createWithBitmap(drawableToBitmap(layerDrawable)); + // Return as an Icon + return Icon.createWithBitmap(drawableToBitmap(layerDrawable)); + } } private static Bitmap drawableToBitmap(Drawable drawable) { diff --git a/app/src/main/res/drawable-v26/ic_app_shortcut_background.xml b/app/src/main/res/drawable-v26/ic_app_shortcut_background.xml new file mode 100644 index 00000000..973bbdba --- /dev/null +++ b/app/src/main/res/drawable-v26/ic_app_shortcut_background.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/main/res/drawable-v26/ic_app_shortcut_last_added.xml b/app/src/main/res/drawable-v26/ic_app_shortcut_last_added.xml new file mode 100644 index 00000000..e65d3cca --- /dev/null +++ b/app/src/main/res/drawable-v26/ic_app_shortcut_last_added.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v26/ic_app_shortcut_shuffle_all.xml b/app/src/main/res/drawable-v26/ic_app_shortcut_shuffle_all.xml new file mode 100644 index 00000000..8ed012ef --- /dev/null +++ b/app/src/main/res/drawable-v26/ic_app_shortcut_shuffle_all.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v26/ic_app_shortcut_top_tracks.xml b/app/src/main/res/drawable-v26/ic_app_shortcut_top_tracks.xml new file mode 100644 index 00000000..7b136c19 --- /dev/null +++ b/app/src/main/res/drawable-v26/ic_app_shortcut_top_tracks.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file