Loading res/layout/nfc_payment_option.xml +3 −2 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ android:layout_weight="1" android:id="@+id/nfc_payment_pref" android:focusable="true" android:clickable="true" android:clickable="false" android:gravity="center_vertical" android:paddingTop="10dp" android:paddingBottom="10dp" Loading @@ -37,6 +37,7 @@ android:layout_width="wrap_content" android:layout_height="96dp" android:scaleType="centerInside" android:clickable="true" /> </FrameLayout> <RadioButton Loading @@ -46,6 +47,6 @@ android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:duplicateParentState="true" android:clickable="false" android:clickable="true" android:focusable="false" /> </RelativeLayout> res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -4957,6 +4957,9 @@ <string name="nfc_payment_settings_title">Tap & pay</string> <!-- String shown when there are no NFC payment applications installed --> <string name="nfc_payment_no_apps">Pay with just a tap</string> <!-- String shown before a checkbox, allowing the user to indicate that he wants foreground apps to be able to override the configured default app --> <string name="nfc_payment_favor_foreground">Favor foreground app</string> <!-- String shown when there are no NFC payment applications installed, clickable, pointing to a website to learn more--> <string name="nfc_payment_learn_more">Learn more</string> Loading src/com/android/settings/nfc/PaymentBackend.java +15 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.nfc.NfcAdapter; import android.nfc.cardemulation.ApduServiceInfo; import android.nfc.cardemulation.CardEmulation; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import java.util.ArrayList; import java.util.List; Loading Loading @@ -74,6 +75,20 @@ public class PaymentBackend { return appInfos; } boolean isForegroundMode() { try { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.NFC_PAYMENT_FOREGROUND) != 0; } catch (SettingNotFoundException e) { return false; } } void setForegroundMode(boolean foreground) { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.NFC_PAYMENT_FOREGROUND, foreground ? 1 : 0) ; } ComponentName getDefaultPaymentApp() { String componentString = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT); Loading src/com/android/settings/nfc/PaymentDefaultDialog.java +0 −10 Original line number Diff line number Diff line Loading @@ -19,14 +19,7 @@ package com.android.settings.nfc; import android.content.ComponentName; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.nfc.cardemulation.ApduServiceInfo; import android.nfc.cardemulation.CardEmulation; import android.nfc.cardemulation.HostApduService; import android.nfc.cardemulation.OffHostApduService; import android.os.Bundle; import android.util.Log; Loading @@ -35,11 +28,8 @@ import com.android.internal.app.AlertController; import com.android.settings.R; import com.android.settings.nfc.PaymentBackend.PaymentAppInfo; import java.io.IOException; import java.util.List; import org.xmlpull.v1.XmlPullParserException; public final class PaymentDefaultDialog extends AlertActivity implements DialogInterface.OnClickListener { Loading src/com/android/settings/nfc/PaymentSettings.java +25 −4 Original line number Diff line number Diff line Loading @@ -22,7 +22,9 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.provider.Settings; Loading @@ -48,7 +50,7 @@ import com.android.settings.nfc.PaymentBackend.PaymentAppInfo; import java.util.List; public class PaymentSettings extends SettingsPreferenceFragment implements OnClickListener { OnClickListener, OnPreferenceChangeListener { public static final String TAG = "PaymentSettings"; private LayoutInflater mInflater; private PaymentBackend mPaymentBackend; Loading @@ -67,6 +69,7 @@ public class PaymentSettings extends SettingsPreferenceFragment implements public void refresh() { PreferenceManager manager = getPreferenceManager(); PreferenceScreen screen = manager.createPreferenceScreen(getActivity()); // Get all payment services List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos(); if (appInfos != null && appInfos.size() > 0) { Loading @@ -92,6 +95,13 @@ public class PaymentSettings extends SettingsPreferenceFragment implements emptyImage.setVisibility(View.VISIBLE); getListView().setVisibility(View.GONE); } else { CheckBoxPreference foreground = new CheckBoxPreference(getActivity()); boolean foregroundMode = mPaymentBackend.isForegroundMode(); foreground.setPersistent(false); foreground.setTitle(getString(R.string.nfc_payment_favor_foreground)); foreground.setChecked(foregroundMode); foreground.setOnPreferenceChangeListener(this); screen.addPreference(foreground); emptyText.setVisibility(View.GONE); learnMore.setVisibility(View.GONE); emptyImage.setVisibility(View.GONE); Loading Loading @@ -207,14 +217,25 @@ public class PaymentSettings extends SettingsPreferenceFragment implements protected void onBindView(View view) { super.onBindView(view); view.setOnClickListener(listener); view.setTag(appInfo); RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1); radioButton.setChecked(appInfo.isDefault); radioButton.setOnClickListener(listener); radioButton.setTag(appInfo); ImageView banner = (ImageView) view.findViewById(R.id.banner); banner.setImageDrawable(appInfo.banner); banner.setOnClickListener(listener); banner.setTag(appInfo); } } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference instanceof CheckBoxPreference) { mPaymentBackend.setForegroundMode(((Boolean) newValue).booleanValue()); return true; } else { return false; } } } Loading
res/layout/nfc_payment_option.xml +3 −2 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ android:layout_weight="1" android:id="@+id/nfc_payment_pref" android:focusable="true" android:clickable="true" android:clickable="false" android:gravity="center_vertical" android:paddingTop="10dp" android:paddingBottom="10dp" Loading @@ -37,6 +37,7 @@ android:layout_width="wrap_content" android:layout_height="96dp" android:scaleType="centerInside" android:clickable="true" /> </FrameLayout> <RadioButton Loading @@ -46,6 +47,6 @@ android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:duplicateParentState="true" android:clickable="false" android:clickable="true" android:focusable="false" /> </RelativeLayout>
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -4957,6 +4957,9 @@ <string name="nfc_payment_settings_title">Tap & pay</string> <!-- String shown when there are no NFC payment applications installed --> <string name="nfc_payment_no_apps">Pay with just a tap</string> <!-- String shown before a checkbox, allowing the user to indicate that he wants foreground apps to be able to override the configured default app --> <string name="nfc_payment_favor_foreground">Favor foreground app</string> <!-- String shown when there are no NFC payment applications installed, clickable, pointing to a website to learn more--> <string name="nfc_payment_learn_more">Learn more</string> Loading
src/com/android/settings/nfc/PaymentBackend.java +15 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.nfc.NfcAdapter; import android.nfc.cardemulation.ApduServiceInfo; import android.nfc.cardemulation.CardEmulation; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import java.util.ArrayList; import java.util.List; Loading Loading @@ -74,6 +75,20 @@ public class PaymentBackend { return appInfos; } boolean isForegroundMode() { try { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.NFC_PAYMENT_FOREGROUND) != 0; } catch (SettingNotFoundException e) { return false; } } void setForegroundMode(boolean foreground) { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.NFC_PAYMENT_FOREGROUND, foreground ? 1 : 0) ; } ComponentName getDefaultPaymentApp() { String componentString = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT); Loading
src/com/android/settings/nfc/PaymentDefaultDialog.java +0 −10 Original line number Diff line number Diff line Loading @@ -19,14 +19,7 @@ package com.android.settings.nfc; import android.content.ComponentName; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.nfc.cardemulation.ApduServiceInfo; import android.nfc.cardemulation.CardEmulation; import android.nfc.cardemulation.HostApduService; import android.nfc.cardemulation.OffHostApduService; import android.os.Bundle; import android.util.Log; Loading @@ -35,11 +28,8 @@ import com.android.internal.app.AlertController; import com.android.settings.R; import com.android.settings.nfc.PaymentBackend.PaymentAppInfo; import java.io.IOException; import java.util.List; import org.xmlpull.v1.XmlPullParserException; public final class PaymentDefaultDialog extends AlertActivity implements DialogInterface.OnClickListener { Loading
src/com/android/settings/nfc/PaymentSettings.java +25 −4 Original line number Diff line number Diff line Loading @@ -22,7 +22,9 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.provider.Settings; Loading @@ -48,7 +50,7 @@ import com.android.settings.nfc.PaymentBackend.PaymentAppInfo; import java.util.List; public class PaymentSettings extends SettingsPreferenceFragment implements OnClickListener { OnClickListener, OnPreferenceChangeListener { public static final String TAG = "PaymentSettings"; private LayoutInflater mInflater; private PaymentBackend mPaymentBackend; Loading @@ -67,6 +69,7 @@ public class PaymentSettings extends SettingsPreferenceFragment implements public void refresh() { PreferenceManager manager = getPreferenceManager(); PreferenceScreen screen = manager.createPreferenceScreen(getActivity()); // Get all payment services List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos(); if (appInfos != null && appInfos.size() > 0) { Loading @@ -92,6 +95,13 @@ public class PaymentSettings extends SettingsPreferenceFragment implements emptyImage.setVisibility(View.VISIBLE); getListView().setVisibility(View.GONE); } else { CheckBoxPreference foreground = new CheckBoxPreference(getActivity()); boolean foregroundMode = mPaymentBackend.isForegroundMode(); foreground.setPersistent(false); foreground.setTitle(getString(R.string.nfc_payment_favor_foreground)); foreground.setChecked(foregroundMode); foreground.setOnPreferenceChangeListener(this); screen.addPreference(foreground); emptyText.setVisibility(View.GONE); learnMore.setVisibility(View.GONE); emptyImage.setVisibility(View.GONE); Loading Loading @@ -207,14 +217,25 @@ public class PaymentSettings extends SettingsPreferenceFragment implements protected void onBindView(View view) { super.onBindView(view); view.setOnClickListener(listener); view.setTag(appInfo); RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1); radioButton.setChecked(appInfo.isDefault); radioButton.setOnClickListener(listener); radioButton.setTag(appInfo); ImageView banner = (ImageView) view.findViewById(R.id.banner); banner.setImageDrawable(appInfo.banner); banner.setOnClickListener(listener); banner.setTag(appInfo); } } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference instanceof CheckBoxPreference) { mPaymentBackend.setForegroundMode(((Boolean) newValue).booleanValue()); return true; } else { return false; } } }