Merge "Removing UserManagerCompat wrapper for getting baded label" into ub-launcher3-master
This commit is contained in:
commit
ea14a7ac3a
|
@ -59,7 +59,6 @@ public class TaskUtils {
|
|||
*/
|
||||
public static CharSequence getTitle(Context context, Task task) {
|
||||
LauncherAppsCompat launcherAppsCompat = LauncherAppsCompat.getInstance(context);
|
||||
UserManagerCompat userManagerCompat = UserManagerCompat.getInstance(context);
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
UserHandle user = UserHandle.of(task.key.userId);
|
||||
ApplicationInfo applicationInfo = launcherAppsCompat.getApplicationInfo(
|
||||
|
@ -68,7 +67,7 @@ public class TaskUtils {
|
|||
Log.e(TAG, "Failed to get title for task " + task);
|
||||
return "";
|
||||
}
|
||||
return userManagerCompat.getBadgedLabelForUser(
|
||||
return packageManager.getUserBadgedLabel(
|
||||
applicationInfo.loadLabel(packageManager), user);
|
||||
}
|
||||
|
||||
|
|
|
@ -659,8 +659,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
|||
info.applyFrom(iconInfo);
|
||||
|
||||
info.title = Utilities.trim(name);
|
||||
info.contentDescription = UserManagerCompat.getInstance(app.getContext())
|
||||
.getBadgedLabelForUser(info.title, info.user);
|
||||
info.contentDescription = app.getContext().getPackageManager()
|
||||
.getUserBadgedLabel(info.title, info.user);
|
||||
info.intent = intent;
|
||||
return info;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import android.os.Build;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.compat.UserManagerCompat;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
||||
import com.android.launcher3.util.ContentWriter;
|
||||
|
@ -172,8 +171,7 @@ public class ShortcutInfo extends ItemInfoWithIcon {
|
|||
if (TextUtils.isEmpty(label)) {
|
||||
label = shortcutInfo.getShortLabel();
|
||||
}
|
||||
contentDescription = UserManagerCompat.getInstance(context)
|
||||
.getBadgedLabelForUser(label, user);
|
||||
contentDescription = context.getPackageManager().getUserBadgedLabel(label, user);
|
||||
if (shortcutInfo.isEnabled()) {
|
||||
runtimeStatusFlags &= ~FLAG_DISABLED_BY_PUBLISHER;
|
||||
} else {
|
||||
|
|
|
@ -57,7 +57,6 @@ public abstract class UserManagerCompat {
|
|||
public abstract List<UserHandle> getUserProfiles();
|
||||
public abstract long getSerialNumberForUser(UserHandle user);
|
||||
public abstract UserHandle getUserForSerialNumber(long serialNumber);
|
||||
public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user);
|
||||
public abstract boolean isQuietModeEnabled(UserHandle user);
|
||||
public abstract boolean isUserUnlocked(UserHandle user);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package com.android.launcher3.compat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.ArrayMap;
|
||||
|
@ -30,7 +29,6 @@ import java.util.List;
|
|||
public class UserManagerCompatVL extends UserManagerCompat {
|
||||
|
||||
protected final UserManager mUserManager;
|
||||
private final PackageManager mPm;
|
||||
|
||||
protected LongSparseArray<UserHandle> mUsers;
|
||||
// Create a separate reverse map as LongSparseArray.indexOfValue checks if objects are same
|
||||
|
@ -39,7 +37,6 @@ public class UserManagerCompatVL extends UserManagerCompat {
|
|||
|
||||
UserManagerCompatVL(Context context) {
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mPm = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,13 +122,5 @@ public class UserManagerCompatVL extends UserManagerCompat {
|
|||
}
|
||||
return getUserProfiles().size() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) {
|
||||
if (user == null) {
|
||||
return label;
|
||||
}
|
||||
return mPm.getUserBadgedLabel(label, user);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ public class BaseIconCache {
|
|||
cachingLogic.loadIcon(mContext, object, entry);
|
||||
}
|
||||
entry.title = cachingLogic.getLabel(object);
|
||||
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
|
||||
entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user);
|
||||
mCache.put(key, entry);
|
||||
|
||||
ContentValues values = newContentValues(entry, entry.title.toString(),
|
||||
|
@ -320,7 +320,7 @@ public class BaseIconCache {
|
|||
}
|
||||
if (object != null) {
|
||||
entry.title = cachingLogic.getLabel(object);
|
||||
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
|
||||
entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ public class BaseIconCache {
|
|||
li.recycle();
|
||||
|
||||
entry.title = appInfo.loadLabel(mPackageManager);
|
||||
entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
|
||||
entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user);
|
||||
entry.icon = useLowResIcon ? LOW_RES_ICON : iconInfo.icon;
|
||||
entry.color = iconInfo.color;
|
||||
|
||||
|
@ -441,7 +441,7 @@ public class BaseIconCache {
|
|||
entry.title = "";
|
||||
entry.contentDescription = "";
|
||||
} else {
|
||||
entry.contentDescription = mUserManager.getBadgedLabelForUser(
|
||||
entry.contentDescription = mPackageManager.getUserBadgedLabel(
|
||||
entry.title, cacheKey.user);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue