use of com.android.settings.nfc.PaymentBackend.PaymentAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PaymentDefaultDialog method buildDialog.
private boolean buildDialog(ComponentName component, String category) {
if (component == null || category == null) {
Log.e(TAG, "Component or category are null");
return false;
}
if (!CardEmulation.CATEGORY_PAYMENT.equals(category)) {
Log.e(TAG, "Don't support defaults for category " + category);
return false;
}
// Check if passed in service exists
PaymentAppInfo requestedPaymentApp = null;
PaymentAppInfo defaultPaymentApp = null;
List<PaymentAppInfo> services = mBackend.getPaymentAppInfos();
for (PaymentAppInfo service : services) {
if (component.equals(service.componentName)) {
requestedPaymentApp = service;
}
if (service.isDefault) {
defaultPaymentApp = service;
}
}
if (requestedPaymentApp == null) {
Log.e(TAG, "Component " + component + " is not a registered payment service.");
return false;
}
// Get current mode and default component
ComponentName defaultComponent = mBackend.getDefaultPaymentApp();
if (defaultComponent != null && defaultComponent.equals(component)) {
Log.e(TAG, "Component " + component + " is already default.");
return false;
}
mNewDefault = component;
// Compose dialog; get
final AlertController.AlertParams p = mAlertParams;
p.mTitle = getString(R.string.nfc_payment_set_default_label);
if (defaultPaymentApp == null) {
String formatString = getString(R.string.nfc_payment_set_default);
String msg = String.format(formatString, sanitizePaymentAppCaption(requestedPaymentApp.label.toString()));
p.mMessage = msg;
} else {
String formatString = getString(R.string.nfc_payment_set_default_instead_of);
String msg = String.format(formatString, sanitizePaymentAppCaption(requestedPaymentApp.label.toString()), sanitizePaymentAppCaption(defaultPaymentApp.label.toString()));
p.mMessage = msg;
}
p.mPositiveButtonText = getString(R.string.yes);
p.mNegativeButtonText = getString(R.string.no);
p.mPositiveButtonListener = this;
p.mNegativeButtonListener = this;
setupAlert();
return true;
}
use of com.android.settings.nfc.PaymentBackend.PaymentAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NfcPaymentPreference method onClick.
@Override
public void onClick(View view) {
PaymentAppInfo defaultAppInfo = mPaymentBackend.getDefaultApp();
if (defaultAppInfo != null && defaultAppInfo.settingsComponent != null) {
Intent settingsIntent = new Intent(Intent.ACTION_MAIN);
settingsIntent.setComponent(defaultAppInfo.settingsComponent);
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
mContext.startActivity(settingsIntent);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Settings activity not found.");
}
}
}
use of com.android.settings.nfc.PaymentBackend.PaymentAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NfcPaymentPreference method refresh.
/**
* MUST be called on UI thread.
*/
public void refresh() {
List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
PaymentAppInfo defaultApp = mPaymentBackend.getDefaultApp();
if (appInfos != null) {
PaymentAppInfo[] apps = appInfos.toArray(new PaymentAppInfo[appInfos.size()]);
mAdapter.updateApps(apps, defaultApp);
}
setTitle(R.string.nfc_payment_default);
if (defaultApp != null) {
setSummary(defaultApp.label);
} else {
setSummary(mContext.getString(R.string.nfc_payment_default_not_set));
}
updateSettingsVisibility();
}
Aggregations