Merge "Add a tile service meta-data for QuickAccessWalletServiceInfo that fetches a drawable for wallet tile." into sc-dev am: 516cd210f6 am: a74c519459
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15045436 Change-Id: If5a76aa12a67a9547d36f93b95d20845cbeeb64c
This commit is contained in:
@@ -177,6 +177,14 @@ public interface QuickAccessWalletClient extends Closeable {
|
||||
@Nullable
|
||||
Drawable getLogo();
|
||||
|
||||
/**
|
||||
* Returns the tile icon associated with the {@link QuickAccessWalletService}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Nullable
|
||||
Drawable getTileIcon();
|
||||
|
||||
/**
|
||||
* Returns the service label specified by {@code android:label} in the service manifest entry.
|
||||
*
|
||||
|
||||
@@ -307,6 +307,12 @@ public class QuickAccessWalletClientImpl implements QuickAccessWalletClient, Ser
|
||||
return mServiceInfo == null ? null : mServiceInfo.getWalletLogo(mContext);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Drawable getTileIcon() {
|
||||
return mServiceInfo == null ? null : mServiceInfo.getTileIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CharSequence getServiceLabel() {
|
||||
|
||||
@@ -195,6 +195,13 @@ public abstract class QuickAccessWalletService extends Service {
|
||||
*/
|
||||
public static final String SERVICE_META_DATA = "android.quickaccesswallet";
|
||||
|
||||
/**
|
||||
* Name of the QuickAccessWallet tile service meta-data.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final String TILE_SERVICE_META_DATA = "android.quickaccesswallet.tile";
|
||||
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,12 +56,15 @@ class QuickAccessWalletServiceInfo {
|
||||
|
||||
private final ServiceInfo mServiceInfo;
|
||||
private final ServiceMetadata mServiceMetadata;
|
||||
private final TileServiceMetadata mTileServiceMetadata;
|
||||
|
||||
private QuickAccessWalletServiceInfo(
|
||||
@NonNull ServiceInfo serviceInfo,
|
||||
@NonNull ServiceMetadata metadata) {
|
||||
@NonNull ServiceMetadata metadata,
|
||||
@NonNull TileServiceMetadata tileServiceMetadata) {
|
||||
mServiceInfo = serviceInfo;
|
||||
mServiceMetadata = metadata;
|
||||
mTileServiceMetadata = tileServiceMetadata;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -84,7 +87,9 @@ class QuickAccessWalletServiceInfo {
|
||||
}
|
||||
|
||||
ServiceMetadata metadata = parseServiceMetadata(context, serviceInfo);
|
||||
return new QuickAccessWalletServiceInfo(serviceInfo, metadata);
|
||||
TileServiceMetadata tileServiceMetadata =
|
||||
new TileServiceMetadata(parseTileServiceMetadata(context, serviceInfo));
|
||||
return new QuickAccessWalletServiceInfo(serviceInfo, metadata, tileServiceMetadata);
|
||||
}
|
||||
|
||||
private static ComponentName getDefaultPaymentApp(Context context) {
|
||||
@@ -105,6 +110,31 @@ class QuickAccessWalletServiceInfo {
|
||||
return resolveInfos.isEmpty() ? null : resolveInfos.get(0).serviceInfo;
|
||||
}
|
||||
|
||||
private static class TileServiceMetadata {
|
||||
@Nullable
|
||||
private final Drawable mTileIcon;
|
||||
|
||||
private TileServiceMetadata(@Nullable Drawable tileIcon) {
|
||||
mTileIcon = tileIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Drawable parseTileServiceMetadata(Context context, ServiceInfo serviceInfo) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
int tileIconDrawableId =
|
||||
serviceInfo.metaData.getInt(QuickAccessWalletService.TILE_SERVICE_META_DATA);
|
||||
if (tileIconDrawableId != 0) {
|
||||
try {
|
||||
Resources resources = pm.getResourcesForApplication(serviceInfo.applicationInfo);
|
||||
return resources.getDrawable(tileIconDrawableId, null);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Error parsing quickaccesswallet tile service meta-data", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class ServiceMetadata {
|
||||
@Nullable
|
||||
private final String mSettingsActivity;
|
||||
@@ -216,6 +246,11 @@ class QuickAccessWalletServiceInfo {
|
||||
return mServiceInfo.loadIcon(context.getPackageManager());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Drawable getTileIcon() {
|
||||
return mTileServiceMetadata.mTileIcon;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
CharSequence getShortcutShortLabel(Context context) {
|
||||
if (!TextUtils.isEmpty(mServiceMetadata.mShortcutShortLabel)) {
|
||||
|
||||
Reference in New Issue
Block a user