diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
index cc80de7..9ce9975 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -200,7 +200,7 @@
 
     /**
      * Creates bitmap using the source drawable and various parameters.
-     * The bitmap is visually normalized with other icons.
+     * The bitmap is visually normalized with other icons and has enough spacing to add shadow.
      *
      * @param icon                      source of the icon
      * @param user                      info can be used for a badge
@@ -211,36 +211,15 @@
      */
     public BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon, UserHandle user,
             boolean shrinkNonAdaptiveIcons, boolean isInstantApp, float[] scale) {
-        return createBadgedIconBitmap(icon, user, shrinkNonAdaptiveIcons, isInstantApp, scale,
-                false /* addShadow */);
-    }
-
-    /**
-     * Creates bitmap using the source drawable and various parameters.
-     * The bitmap is visually normalized with other icons and has enough spacing to add shadow.
-     *
-     * @param icon                      source of the icon
-     * @param user                      info can be used for a badge
-     * @param shrinkNonAdaptiveIcons    {@code true} if non adaptive icons should be treated
-     * @param isInstantApp              info can be used for a badge
-     * @param scale                     returns the scale result from normalization
-     * @param addShadow                 If true, adds a shadow under the icon.
-     * @return a bitmap suitable for disaplaying as an icon at various system UIs.
-     */
-    private BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon, UserHandle user,
-            boolean shrinkNonAdaptiveIcons, boolean isInstantApp, float[] scale,
-            boolean addShadow) {
         if (scale == null) {
             scale = new float[1];
         }
         icon = normalizeAndWrapToAdaptiveIcon(icon, shrinkNonAdaptiveIcons, null, scale);
         Bitmap bitmap = createIconBitmap(icon, scale[0]);
         if (ATLEAST_OREO && icon instanceof AdaptiveIconDrawable) {
-            if (addShadow) {
-                mCanvas.setBitmap(bitmap);
-                getShadowGenerator().recreateIcon(Bitmap.createBitmap(bitmap), mCanvas);
-                mCanvas.setBitmap(null);
-            }
+            mCanvas.setBitmap(bitmap);
+            getShadowGenerator().recreateIcon(Bitmap.createBitmap(bitmap), mCanvas);
+            mCanvas.setBitmap(null);
         }
 
         if (isInstantApp) {
diff --git a/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java b/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java
index 7702727..ccaebe7 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/ShadowGenerator.java
@@ -32,6 +32,9 @@
  * Utility class to add shadows to bitmaps.
  */
 public class ShadowGenerator {
+
+    public static final boolean ENABLE_SHADOWS = false;
+
     public static final float BLUR_FACTOR = 0.5f/48;
 
     // Percent of actual icon size
@@ -60,17 +63,20 @@
 
     public synchronized void recreateIcon(Bitmap icon, BlurMaskFilter blurMaskFilter,
             int ambientAlpha, int keyAlpha, Canvas out) {
-        int[] offset = new int[2];
-        mBlurPaint.setMaskFilter(blurMaskFilter);
-        Bitmap shadow = icon.extractAlpha(mBlurPaint, offset);
+        if (ENABLE_SHADOWS) {
+            int[] offset = new int[2];
+            mBlurPaint.setMaskFilter(blurMaskFilter);
+            Bitmap shadow = icon.extractAlpha(mBlurPaint, offset);
 
-        // Draw ambient shadow
-        mDrawPaint.setAlpha(ambientAlpha);
-        out.drawBitmap(shadow, offset[0], offset[1], mDrawPaint);
+            // Draw ambient shadow
+            mDrawPaint.setAlpha(ambientAlpha);
+            out.drawBitmap(shadow, offset[0], offset[1], mDrawPaint);
 
-        // Draw key shadow
-        mDrawPaint.setAlpha(keyAlpha);
-        out.drawBitmap(shadow, offset[0], offset[1] + KEY_SHADOW_DISTANCE * mIconSize, mDrawPaint);
+            // Draw key shadow
+            mDrawPaint.setAlpha(keyAlpha);
+            out.drawBitmap(shadow, offset[0], offset[1] + KEY_SHADOW_DISTANCE * mIconSize,
+                    mDrawPaint);
+        }
 
         // Draw the icon
         mDrawPaint.setAlpha(255);
@@ -84,15 +90,18 @@
     public static float getScaleForBounds(RectF bounds) {
         float scale = 1;
 
-        // For top, left & right, we need same space.
-        float minSide = Math.min(Math.min(bounds.left, bounds.right), bounds.top);
-        if (minSide < BLUR_FACTOR) {
-            scale = (HALF_DISTANCE - BLUR_FACTOR) / (HALF_DISTANCE - minSide);
-        }
+        if (ENABLE_SHADOWS) {
+            // For top, left & right, we need same space.
+            float minSide = Math.min(Math.min(bounds.left, bounds.right), bounds.top);
+            if (minSide < BLUR_FACTOR) {
+                scale = (HALF_DISTANCE - BLUR_FACTOR) / (HALF_DISTANCE - minSide);
+            }
 
-        float bottomSpace = BLUR_FACTOR + KEY_SHADOW_DISTANCE;
-        if (bounds.bottom < bottomSpace) {
-            scale = Math.min(scale, (HALF_DISTANCE - bottomSpace) / (HALF_DISTANCE - bounds.bottom));
+            float bottomSpace = BLUR_FACTOR + KEY_SHADOW_DISTANCE;
+            if (bounds.bottom < bottomSpace) {
+                scale = Math.min(scale,
+                        (HALF_DISTANCE - bottomSpace) / (HALF_DISTANCE - bounds.bottom));
+            }
         }
         return scale;
     }
@@ -115,8 +124,13 @@
         }
 
         public Builder setupBlurForSize(int height) {
-            shadowBlur = height * 1f / 24;
-            keyShadowDistance = height * 1f / 16;
+            if (ENABLE_SHADOWS) {
+                shadowBlur = height * 1f / 24;
+                keyShadowDistance = height * 1f / 16;
+            } else {
+                shadowBlur = 0;
+                keyShadowDistance = 0;
+            }
             return this;
         }
 
@@ -141,15 +155,17 @@
             Paint p = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
             p.setColor(color);
 
-            // Key shadow
-            p.setShadowLayer(shadowBlur, 0, keyShadowDistance,
-                    setColorAlphaBound(Color.BLACK, keyShadowAlpha));
-            c.drawRoundRect(bounds, radius, radius, p);
+            if (ENABLE_SHADOWS) {
+                // Key shadow
+                p.setShadowLayer(shadowBlur, 0, keyShadowDistance,
+                        setColorAlphaBound(Color.BLACK, keyShadowAlpha));
+                c.drawRoundRect(bounds, radius, radius, p);
 
-            // Ambient shadow
-            p.setShadowLayer(shadowBlur, 0, 0,
-                    setColorAlphaBound(Color.BLACK, ambientShadowAlpha));
-            c.drawRoundRect(bounds, radius, radius, p);
+                // Ambient shadow
+                p.setShadowLayer(shadowBlur, 0, 0,
+                        setColorAlphaBound(Color.BLACK, ambientShadowAlpha));
+                c.drawRoundRect(bounds, radius, radius, p);
+            }
 
             if (Color.alpha(color) < 255) {
                 // Clear any content inside the pill-rect for translucent fill.
diff --git a/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java b/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java
index 89dfa18..c948eba 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java
@@ -510,7 +510,7 @@
      * Cache class to store the actual entries on disk
      */
     public static final class IconDB extends SQLiteCacheHelper {
-        private static final int RELEASE_VERSION = 28;
+        private static final int RELEASE_VERSION = 29;
 
         public static final String TABLE_NAME = "icons";
         public static final String COLUMN_ROWID = "rowid";
