Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad320aa8 authored by Martijn Coenen's avatar Martijn Coenen Committed by Android (Google) Code Review
Browse files

Merge "Update NFC payments to match new framework APIs." into klp-dev

parents 1f2779f2 573a21ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4659,7 +4659,7 @@
    <string name="global_font_change_title">Change font size</string>

    <!-- 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
         a payment terminal is tapped -->
    <string name="nfc_payment_ask">Ask every time</string>
+0 −13
Original line number Diff line number Diff line
@@ -86,17 +86,4 @@ public class PaymentBackend {
                Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
                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);
    }
}
 No newline at end of file
+1 −3
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ public final class PaymentDefaultDialog extends AlertActivity implements
        switch (which) {
            case BUTTON_POSITIVE:
                mBackend.setDefaultPaymentApp(mNewDefault);
                mBackend.setAutoPaymentMode(true);
                setResult(RESULT_OK);
                break;
            case BUTTON_NEGATIVE:
@@ -98,7 +97,6 @@ public final class PaymentDefaultDialog extends AlertActivity implements
        }

        // Get current mode and default component
        boolean isAuto = mBackend.isAutoPaymentMode();
        ComponentName defaultComponent = mBackend.getDefaultPaymentApp();
        if (defaultComponent != null && defaultComponent.equals(component)) {
            Log.e(TAG, "Component " + component + " is already default.");
@@ -128,7 +126,7 @@ public final class PaymentDefaultDialog extends AlertActivity implements
        // Compose dialog; get
        final AlertController.AlertParams p = mAlertParams;
        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?";
        } else {
            p.mMessage = "Always use " + newAppInfo.loadLabel(pm) + " instead of " +
+1 −6
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
        PreferenceManager manager = getPreferenceManager();
        PreferenceScreen screen = manager.createPreferenceScreen(getActivity());

        boolean isAuto = mPaymentBackend.isAutoPaymentMode();

        // Get all payment services
        List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
        if (appInfos != null && appInfos.size() > 0) {
@@ -58,7 +56,6 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
                PaymentAppPreference preference =
                        new PaymentAppPreference(getActivity(), appInfo, this);
                // If for some reason isAuto gets out of sync, clear out app default
                appInfo.isDefault &= isAuto;
                preference.setIcon(appInfo.icon);
                preference.setTitle(appInfo.caption);
                screen.addPreference(preference);
@@ -67,7 +64,7 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
                PaymentAppInfo appInfo = new PaymentAppInfo();
                appInfo.icon = null;
                appInfo.componentName = null;
                appInfo.isDefault = !isAuto;
                appInfo.isDefault = !(mPaymentBackend.getDefaultPaymentApp() != null);
                // Add "Ask every time" option
                PaymentAppPreference preference =
                        new PaymentAppPreference(getActivity(), appInfo, this);
@@ -85,10 +82,8 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
            PaymentAppInfo appInfo = (PaymentAppInfo) v.getTag();
            if (appInfo.componentName != null) {
                mPaymentBackend.setDefaultPaymentApp(appInfo.componentName);
                mPaymentBackend.setAutoPaymentMode(true);
            } else {
                mPaymentBackend.setDefaultPaymentApp(null);
                mPaymentBackend.setAutoPaymentMode(false);
            }
            refresh();
        }