Removing UserManagerCompat wrapper for getting baded label

This removes some crass dependency on Launcher compat implementation
making it easier to move iconCache to a separate library

Change-Id: If5fab0c82d98089cde6f54b6a374fb7bb2db5ae8
This commit is contained in:
Sunny Goyal
2018-11-05 17:19:45 -08:00
parent 06bca75d01
commit d7239fcc52
7 changed files with 13 additions and 28 deletions

View File

@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.graphics.BitmapFactory;
@@ -41,7 +42,6 @@ import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.LauncherIcons;
@@ -64,7 +64,7 @@ public class LoaderCursor extends CursorWrapper {
public final LongSparseArray<UserHandle> allUsers = new LongSparseArray<>();
private final Context mContext;
private final UserManagerCompat mUserManager;
private final PackageManager mPM;
private final IconCache mIconCache;
private final InvariantDeviceProfile mIDP;
@@ -100,7 +100,7 @@ public class LoaderCursor extends CursorWrapper {
mContext = app.getContext();
mIconCache = app.getIconCache();
mIDP = app.getInvariantDeviceProfile();
mUserManager = UserManagerCompat.getInstance(mContext);
mPM = mContext.getPackageManager();
// Init column indices
iconIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);
@@ -228,7 +228,7 @@ public class LoaderCursor extends CursorWrapper {
throw new InvalidParameterException("Invalid restoreType " + restoreFlag);
}
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user);
info.itemType = itemType;
info.status = restoreFlag;
return info;
@@ -284,7 +284,7 @@ public class LoaderCursor extends CursorWrapper {
info.title = componentName.getClassName();
}
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user);
return info;
}