diff options
author | Puneet Mishra <puneetm@codeaurora.org> | 2015-08-27 18:11:26 +0100 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:12 -0600 |
commit | 793b9a5efbdf48396e6e80b20cda1557eaaa4536 (patch) | |
tree | 324426812c1b85a1c1e6ff5f364a26806d357024 | |
parent | cc37a3c5394d3dec94cabaabaf0874f4ffde65f3 (diff) | |
download | packages_apps_Settings-793b9a5efbdf48396e6e80b20cda1557eaaa4536.zip packages_apps_Settings-793b9a5efbdf48396e6e80b20cda1557eaaa4536.tar.gz packages_apps_Settings-793b9a5efbdf48396e6e80b20cda1557eaaa4536.tar.bz2 |
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
-rw-r--r-- | src/com/android/settings/nfc/NfcPaymentPreference.java | 26 |
1 files changed, 25 insertions, 1 deletions
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); |