Merge "Update NFC payments to match new framework APIs." into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ad320aa8d3
@@ -4659,7 +4659,7 @@
|
|||||||
<string name="global_font_change_title">Change font size</string>
|
<string name="global_font_change_title">Change font size</string>
|
||||||
|
|
||||||
<!-- NFC payment settings --><skip/>
|
<!-- NFC payment settings --><skip/>
|
||||||
<string name="nfc_payment_settings_title">Tap and Pay</string>
|
<string name="nfc_payment_settings_title">Payments</string>
|
||||||
<!-- Option to tell Android to ask the user which payment app to use every time
|
<!-- Option to tell Android to ask the user which payment app to use every time
|
||||||
a payment terminal is tapped -->
|
a payment terminal is tapped -->
|
||||||
<string name="nfc_payment_ask">Ask every time</string>
|
<string name="nfc_payment_ask">Ask every time</string>
|
||||||
|
@@ -86,17 +86,4 @@ public class PaymentBackend {
|
|||||||
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
|
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
|
||||||
app != null ? app.flattenToString() : null);
|
app != null ? app.flattenToString() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutoPaymentMode() {
|
|
||||||
String mode = Settings.Secure.getString(mContext.getContentResolver(),
|
|
||||||
Settings.Secure.NFC_PAYMENT_MODE);
|
|
||||||
return (!CardEmulationManager.PAYMENT_MODE_MANUAL.equals(mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAutoPaymentMode(boolean enable) {
|
|
||||||
Settings.Secure.putString(mContext.getContentResolver(),
|
|
||||||
Settings.Secure.NFC_PAYMENT_MODE,
|
|
||||||
enable ? CardEmulationManager.PAYMENT_MODE_AUTO
|
|
||||||
: CardEmulationManager.PAYMENT_MODE_MANUAL);
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -62,7 +62,6 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
|||||||
switch (which) {
|
switch (which) {
|
||||||
case BUTTON_POSITIVE:
|
case BUTTON_POSITIVE:
|
||||||
mBackend.setDefaultPaymentApp(mNewDefault);
|
mBackend.setDefaultPaymentApp(mNewDefault);
|
||||||
mBackend.setAutoPaymentMode(true);
|
|
||||||
setResult(RESULT_OK);
|
setResult(RESULT_OK);
|
||||||
break;
|
break;
|
||||||
case BUTTON_NEGATIVE:
|
case BUTTON_NEGATIVE:
|
||||||
@@ -98,7 +97,6 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get current mode and default component
|
// Get current mode and default component
|
||||||
boolean isAuto = mBackend.isAutoPaymentMode();
|
|
||||||
ComponentName defaultComponent = mBackend.getDefaultPaymentApp();
|
ComponentName defaultComponent = mBackend.getDefaultPaymentApp();
|
||||||
if (defaultComponent != null && defaultComponent.equals(component)) {
|
if (defaultComponent != null && defaultComponent.equals(component)) {
|
||||||
Log.e(TAG, "Component " + component + " is already default.");
|
Log.e(TAG, "Component " + component + " is already default.");
|
||||||
@@ -128,7 +126,7 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
|||||||
// Compose dialog; get
|
// Compose dialog; get
|
||||||
final AlertController.AlertParams p = mAlertParams;
|
final AlertController.AlertParams p = mAlertParams;
|
||||||
p.mTitle = getString(R.string.nfc_payment_set_default);
|
p.mTitle = getString(R.string.nfc_payment_set_default);
|
||||||
if (defaultAppInfo == null || !isAuto) {
|
if (defaultAppInfo == null) {
|
||||||
p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " when you tap and pay?";
|
p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " when you tap and pay?";
|
||||||
} else {
|
} else {
|
||||||
p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " instead of " +
|
p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " instead of " +
|
||||||
|
@@ -48,8 +48,6 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
PreferenceManager manager = getPreferenceManager();
|
PreferenceManager manager = getPreferenceManager();
|
||||||
PreferenceScreen screen = manager.createPreferenceScreen(getActivity());
|
PreferenceScreen screen = manager.createPreferenceScreen(getActivity());
|
||||||
|
|
||||||
boolean isAuto = mPaymentBackend.isAutoPaymentMode();
|
|
||||||
|
|
||||||
// Get all payment services
|
// Get all payment services
|
||||||
List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
|
List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
|
||||||
if (appInfos != null && appInfos.size() > 0) {
|
if (appInfos != null && appInfos.size() > 0) {
|
||||||
@@ -58,7 +56,6 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
PaymentAppPreference preference =
|
PaymentAppPreference preference =
|
||||||
new PaymentAppPreference(getActivity(), appInfo, this);
|
new PaymentAppPreference(getActivity(), appInfo, this);
|
||||||
// If for some reason isAuto gets out of sync, clear out app default
|
// If for some reason isAuto gets out of sync, clear out app default
|
||||||
appInfo.isDefault &= isAuto;
|
|
||||||
preference.setIcon(appInfo.icon);
|
preference.setIcon(appInfo.icon);
|
||||||
preference.setTitle(appInfo.caption);
|
preference.setTitle(appInfo.caption);
|
||||||
screen.addPreference(preference);
|
screen.addPreference(preference);
|
||||||
@@ -67,7 +64,7 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
PaymentAppInfo appInfo = new PaymentAppInfo();
|
PaymentAppInfo appInfo = new PaymentAppInfo();
|
||||||
appInfo.icon = null;
|
appInfo.icon = null;
|
||||||
appInfo.componentName = null;
|
appInfo.componentName = null;
|
||||||
appInfo.isDefault = !isAuto;
|
appInfo.isDefault = !(mPaymentBackend.getDefaultPaymentApp() != null);
|
||||||
// Add "Ask every time" option
|
// Add "Ask every time" option
|
||||||
PaymentAppPreference preference =
|
PaymentAppPreference preference =
|
||||||
new PaymentAppPreference(getActivity(), appInfo, this);
|
new PaymentAppPreference(getActivity(), appInfo, this);
|
||||||
@@ -85,10 +82,8 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
PaymentAppInfo appInfo = (PaymentAppInfo) v.getTag();
|
PaymentAppInfo appInfo = (PaymentAppInfo) v.getTag();
|
||||||
if (appInfo.componentName != null) {
|
if (appInfo.componentName != null) {
|
||||||
mPaymentBackend.setDefaultPaymentApp(appInfo.componentName);
|
mPaymentBackend.setDefaultPaymentApp(appInfo.componentName);
|
||||||
mPaymentBackend.setAutoPaymentMode(true);
|
|
||||||
} else {
|
} else {
|
||||||
mPaymentBackend.setDefaultPaymentApp(null);
|
mPaymentBackend.setDefaultPaymentApp(null);
|
||||||
mPaymentBackend.setAutoPaymentMode(false);
|
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user