From 793b9a5efbdf48396e6e80b20cda1557eaaa4536 Mon Sep 17 00:00:00 2001 From: Puneet Mishra Date: Thu, 27 Aug 2015 18:11:26 +0100 Subject: Settings: Tap and Pay UI needs to be long clickable NFC payment applications in the Tap and Pay UI need to react to a long click to open the settings menu of the application with a predefined intent. Added longClickListener to NfcPaymentAdapter. Change-Id: If352cf0ae7f819ed3286d5a7c7bb2b7dfc1b0ef7 --- .../android/settings/nfc/NfcPaymentPreference.java | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/nfc/NfcPaymentPreference.java b/src/com/android/settings/nfc/NfcPaymentPreference.java index e8dcf0b..0eef242 100644 --- a/src/com/android/settings/nfc/NfcPaymentPreference.java +++ b/src/com/android/settings/nfc/NfcPaymentPreference.java @@ -29,6 +29,7 @@ import android.widget.BaseAdapter; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.RadioButton; +import android.content.pm.PackageManager; import com.android.settings.R; import com.android.settings.nfc.PaymentBackend.PaymentAppInfo; @@ -129,7 +130,7 @@ public class NfcPaymentPreference extends DialogPreference implements } class NfcPaymentAdapter extends BaseAdapter implements CompoundButton.OnCheckedChangeListener, - View.OnClickListener { + View.OnClickListener, View.OnLongClickListener { // Only modified on UI thread private PaymentAppInfo[] appInfos; @@ -175,6 +176,7 @@ public class NfcPaymentPreference extends DialogPreference implements holder.imageView.setTag(appInfo); holder.imageView.setContentDescription(appInfo.label); holder.imageView.setOnClickListener(this); + holder.imageView.setOnLongClickListener(this); // Prevent checked callback getting called on recycled views holder.radioButton.setOnCheckedChangeListener(null); @@ -202,6 +204,28 @@ public class NfcPaymentPreference extends DialogPreference implements makeDefault(appInfo); } + @Override + public boolean onLongClick(View view){ + PaymentAppInfo appInfo = (PaymentAppInfo) view.getTag(); + if (appInfo.componentName != null) { + Log.d(TAG, "LongClick: " + appInfo.componentName.toString()); + PackageManager pm = mContext.getPackageManager(); + Intent gsmaIntent = + pm.getLaunchIntentForPackage(appInfo.componentName.getPackageName()); + if (gsmaIntent != null) { + gsmaIntent.setAction("com.gsma.services.nfc.SELECT_DEFAULT_SERVICE"); + gsmaIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); + gsmaIntent.setPackage(gsmaIntent.getPackage()); + try { + mContext.startActivity(gsmaIntent); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "Settings activity for " + appInfo.componentName.toString() + " not found."); + } + } + } + return true; + } + void makeDefault(PaymentAppInfo appInfo) { if (!appInfo.isDefault) { mPaymentBackend.setDefaultPaymentApp(appInfo.componentName); -- cgit v1.1