Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8aa00dae authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Cleaning up temporary interfaces which were created for refactoring

Bug: 366237794
Test: Presubmit
Flag: EXEMPT refactor
Change-Id: Ibd14560241922aebb23d09876fde4e157193a02f
parent 447099dc
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.launcher3.icons.cache;

import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;

@@ -29,10 +28,8 @@ import com.android.launcher3.icons.IconProvider;

/**
 * A simple interface to represent an object which can be added to icon cache
 *
 * @param <T> Any subclass of the icon cache with which this object is associated
 */
public interface CachedObject<T extends BaseIconCache> {
public interface CachedObject {

    /**
     * Returns the component name for the underlying object
@@ -47,13 +44,13 @@ public interface CachedObject<T extends BaseIconCache> {
    /**
     * Loads the user visible label for the provided object
     */
    @Nullable CharSequence getLabel(PackageManager pm);
    @Nullable CharSequence getLabel();

    /**
     * Loads the user visible icon for the provided object
     */
    @Nullable
    default Drawable getFullResIcon(@NonNull T cache) {
    default Drawable getFullResIcon(@NonNull BaseIconCache cache) {
        return null;
    }

@@ -63,7 +60,6 @@ public interface CachedObject<T extends BaseIconCache> {
    @Nullable
    ApplicationInfo getApplicationInfo();


    /**
     * Returns a persistable string that can be used to indicate indicate the correctness of the
     * cache for the provided item
+8 −15
Original line number Diff line number Diff line
@@ -24,30 +24,23 @@ import com.android.launcher3.icons.BitmapInfo
import com.android.launcher3.icons.IconProvider

/** Caching logic for ComponentWithLabelAndIcon */
class CachedObjectCachingLogic<T : BaseIconCache>(context: Context) :
    CachingLogic<CachedObject<T>> {
object CachedObjectCachingLogic : CachingLogic<CachedObject> {

    private val pm = context.packageManager
    override fun getComponent(info: CachedObject): ComponentName = info.component

    override fun getComponent(info: CachedObject<T>): ComponentName = info.component
    override fun getUser(info: CachedObject): UserHandle = info.user

    override fun getUser(info: CachedObject<T>): UserHandle = info.user
    override fun getLabel(info: CachedObject): CharSequence? = info.label

    override fun getLabel(info: CachedObject<T>): CharSequence? = info.getLabel(pm)

    override fun loadIcon(
        context: Context,
        cache: BaseIconCache,
        info: CachedObject<T>,
    ): BitmapInfo {
        val d = info.getFullResIcon(cache as T) ?: return BitmapInfo.LOW_RES_INFO
    override fun loadIcon(context: Context, cache: BaseIconCache, info: CachedObject): BitmapInfo {
        val d = info.getFullResIcon(cache) ?: return BitmapInfo.LOW_RES_INFO
        cache.iconFactory.use { li ->
            return li.createBadgedIconBitmap(d, IconOptions().setUser(info.user))
        }
    }

    override fun getApplicationInfo(info: CachedObject<T>) = info.applicationInfo
    override fun getApplicationInfo(info: CachedObject) = info.applicationInfo

    override fun getFreshnessIdentifier(item: CachedObject<T>, provider: IconProvider): String? =
    override fun getFreshnessIdentifier(item: CachedObject, provider: IconProvider): String? =
        item.getFreshnessIdentifier(provider)
}