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..d4ea4a34 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/appshortcuts/AppShortcutIconGenerator.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/appshortcuts/AppShortcutIconGenerator.java
@@ -3,11 +3,13 @@ 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.os.Build;
import android.support.annotation.RequiresApi;
+import android.support.v4.graphics.drawable.IconCompat;
import android.util.TypedValue;
import com.kabouzeid.appthemehelper.ThemeStore;
@@ -21,14 +23,14 @@ import com.kabouzeid.gramophone.util.Util;
@RequiresApi(Build.VERSION_CODES.N_MR1)
public final class AppShortcutIconGenerator {
public static Icon generateThemedIcon(Context context, int iconId) {
- if (PreferenceUtil.getInstance(context).coloredAppShortcuts()){
- return generateUserThemedIcon(context, iconId);
+ if (PreferenceUtil.getInstance(context).coloredAppShortcuts()) {
+ return generateUserThemedIcon(context, iconId).toIcon();
} else {
- return generateDefaultThemedIcon(context, iconId);
+ return generateDefaultThemedIcon(context, iconId).toIcon();
}
}
- private static Icon generateDefaultThemedIcon(Context context, int iconId) {
+ private static IconCompat generateDefaultThemedIcon(Context context, int iconId) {
// Return an Icon of iconId with default colors
return generateThemedIcon(context, iconId,
context.getColor(R.color.app_shortcut_default_foreground),
@@ -36,7 +38,7 @@ public final class AppShortcutIconGenerator {
);
}
- private static Icon generateUserThemedIcon(Context context, int iconId) {
+ private static IconCompat generateUserThemedIcon(Context context, int iconId) {
// Get background color from context's theme
final TypedValue typedColorBackground = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.colorBackground, typedColorBackground, true);
@@ -48,16 +50,21 @@ public final class AppShortcutIconGenerator {
);
}
- private static Icon generateThemedIcon(Context context, int iconId, int foregroundColor, int backgroundColor) {
+ private static IconCompat generateThemedIcon(Context context, int iconId, int foregroundColor, int backgroundColor) {
// Get and tint foreground and background drawables
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 IconCompat.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 IconCompat.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