NFC: don't use dynamic resources.
Also fixed talk-back for the default payment app selection. Bug: 21343778 Bug: 21588534 Change-Id: I2886b73edae507c7861351bac4610dbf3bebe027
This commit is contained in:
@@ -174,11 +174,13 @@ public class NfcPaymentPreference extends DialogPreference implements
|
|||||||
}
|
}
|
||||||
holder.imageView.setImageDrawable(appInfo.banner);
|
holder.imageView.setImageDrawable(appInfo.banner);
|
||||||
holder.imageView.setTag(appInfo);
|
holder.imageView.setTag(appInfo);
|
||||||
|
holder.imageView.setContentDescription(appInfo.label);
|
||||||
holder.imageView.setOnClickListener(this);
|
holder.imageView.setOnClickListener(this);
|
||||||
|
|
||||||
// Prevent checked callback getting called on recycled views
|
// Prevent checked callback getting called on recycled views
|
||||||
holder.radioButton.setOnCheckedChangeListener(null);
|
holder.radioButton.setOnCheckedChangeListener(null);
|
||||||
holder.radioButton.setChecked(appInfo.isDefault);
|
holder.radioButton.setChecked(appInfo.isDefault);
|
||||||
|
holder.radioButton.setContentDescription(appInfo.label);
|
||||||
holder.radioButton.setOnCheckedChangeListener(this);
|
holder.radioButton.setOnCheckedChangeListener(this);
|
||||||
holder.radioButton.setTag(appInfo);
|
holder.radioButton.setTag(appInfo);
|
||||||
return convertView;
|
return convertView;
|
||||||
|
@@ -17,7 +17,8 @@
|
|||||||
package com.android.settings.nfc;
|
package com.android.settings.nfc;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.*;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -71,14 +72,10 @@ public class PaymentBackend {
|
|||||||
|
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
mSettingsPackageMonitor.unregister();
|
mSettingsPackageMonitor.unregister();
|
||||||
mContext.unregisterReceiver(mReceiver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
mSettingsPackageMonitor.register(mContext, mContext.getMainLooper(), false);
|
mSettingsPackageMonitor.register(mContext, mContext.getMainLooper(), false);
|
||||||
// Register broadcast receiver for dynamic resource updates
|
|
||||||
IntentFilter filter = new IntentFilter(CardEmulation.ACTION_REQUEST_SERVICE_RESOURCES);
|
|
||||||
mContext.registerReceiver(mReceiver, filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
@@ -112,14 +109,8 @@ public class PaymentBackend {
|
|||||||
} else {
|
} else {
|
||||||
appInfo.settingsComponent = null;
|
appInfo.settingsComponent = null;
|
||||||
}
|
}
|
||||||
if (service.hasDynamicResources()) {
|
appInfo.description = service.getDescription();
|
||||||
appInfo.description = "";
|
appInfo.banner = service.loadBanner(pm);
|
||||||
appInfo.banner = null;
|
|
||||||
sendBroadcastForResources(appInfo);
|
|
||||||
} else {
|
|
||||||
appInfo.description = service.getDescription();
|
|
||||||
appInfo.banner = service.loadBanner(pm);
|
|
||||||
}
|
|
||||||
appInfos.add(appInfo);
|
appInfos.add(appInfo);
|
||||||
}
|
}
|
||||||
mAppInfos = appInfos;
|
mAppInfos = appInfos;
|
||||||
@@ -162,14 +153,6 @@ public class PaymentBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendBroadcastForResources(PaymentAppInfo appInfo) {
|
|
||||||
Intent broadcastIntent = new Intent(CardEmulation.ACTION_REQUEST_SERVICE_RESOURCES);
|
|
||||||
broadcastIntent.setPackage(appInfo.componentName.getPackageName());
|
|
||||||
broadcastIntent.putExtra(CardEmulation.EXTRA_SERVICE_COMPONENT, appInfo.componentName);
|
|
||||||
mContext.sendOrderedBroadcastAsUser(broadcastIntent, UserHandle.CURRENT,
|
|
||||||
null, mReceiver, null, Activity.RESULT_OK, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isForegroundMode() {
|
boolean isForegroundMode() {
|
||||||
try {
|
try {
|
||||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
@@ -201,37 +184,6 @@ public class PaymentBackend {
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
Bundle results = getResultExtras(false);
|
|
||||||
if (results != null) {
|
|
||||||
String desc = results.getString(CardEmulation.EXTRA_DESCRIPTION);
|
|
||||||
int resId = results.getInt(CardEmulation.EXTRA_BANNER_RES_ID, -1);
|
|
||||||
// Find corresponding component
|
|
||||||
PaymentAppInfo matchingAppInfo = null;
|
|
||||||
for (PaymentAppInfo appInfo : mAppInfos) {
|
|
||||||
if (appInfo.componentName.equals(
|
|
||||||
intent.getParcelableExtra(CardEmulation.EXTRA_SERVICE_COMPONENT))) {
|
|
||||||
matchingAppInfo = appInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (matchingAppInfo != null && (desc != null || resId != -1)) {
|
|
||||||
if (desc != null) {
|
|
||||||
matchingAppInfo.description = desc;
|
|
||||||
}
|
|
||||||
if (resId != -1) {
|
|
||||||
matchingAppInfo.banner = loadDrawableForPackage(
|
|
||||||
matchingAppInfo.componentName.getPackageName(), resId);
|
|
||||||
}
|
|
||||||
makeCallbacks();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Didn't find results extra.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private final Handler mHandler = new Handler() {
|
private final Handler mHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void dispatchMessage(Message msg) {
|
public void dispatchMessage(Message msg) {
|
||||||
@@ -260,4 +212,4 @@ public class PaymentBackend {
|
|||||||
mHandler.obtainMessage().sendToTarget();
|
mHandler.obtainMessage().sendToTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user