Fixing icon shape not properly clipped

> Using ShapeDelegate for icon clipping
> Creating ShapeDelegate based on the current icon shape
> Defining different shape delegates for icon and folder
> Updating preview rendering to use dagger graph
> Adding tests for all icon shapes

Bug: 392145015
Test: atest IconShapesProviderTest
Flag: com.android.launcher3.enable_launcher_icon_shapes

Change-Id: Ic9f287e2a6fef2aad18ba224404de58a64da0bb3
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index d8bb84e..484cef4 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -58,11 +58,11 @@
             else encryptedContext.getSharedPreferences(sharedPrefFile, MODE_PRIVATE)
 
     /** Returns the value with type [T] for [item]. */
-    fun <T> get(item: ContextualItem<T>): T =
+    open fun <T> get(item: ContextualItem<T>): T =
         getInner(item, item.defaultValueFromContext(encryptedContext))
 
     /** Returns the value with type [T] for [item]. */
-    fun <T> get(item: ConstantItem<T>): T = getInner(item, item.defaultValue)
+    open fun <T> get(item: ConstantItem<T>): T = getInner(item, item.defaultValue)
 
     /**
      * Retrieves the value for an [Item] from [SharedPreferences]. It handles method typing via the
@@ -406,3 +406,20 @@
     ENCRYPTED,
     DEVICE_PROTECTED,
 }
+
+/**
+ * LauncherPrefs which delegates all lookup to [prefs] but uses the real prefs for initial values
+ */
+class ProxyPrefs(context: Context, private val prefs: SharedPreferences) : LauncherPrefs(context) {
+
+    private val realPrefs = LauncherPrefs(context)
+
+    override val Item.sharedPrefs: SharedPreferences
+        get() = prefs
+
+    override fun <T> get(item: ConstantItem<T>) =
+        super.get(backedUpItem(item.sharedPrefKey, realPrefs.get(item)))
+
+    override fun <T> get(item: ContextualItem<T>) =
+        super.get(backedUpItem(item.sharedPrefKey, realPrefs.get(item)))
+}