summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorMichael Kwan <mkwan@google.com>2016-10-12 18:40:49 -0700
committerMichael Kwan <mkwan@google.com>2016-10-12 18:47:58 -0700
commit931d2d25caace670b16fb83bac6721993f466489 (patch)
treebfdde84ecd554176c7e158906ba7a8b2ac461054 /src/android
parent9999019f0801cf45ba296c5e4f39dc2338fe9cd0 (diff)
downloadandroid_packages_apps_PackageInstaller-931d2d25caace670b16fb83bac6721993f466489.tar.gz
android_packages_apps_PackageInstaller-931d2d25caace670b16fb83bac6721993f466489.tar.bz2
android_packages_apps_PackageInstaller-931d2d25caace670b16fb83bac6721993f466489.zip
Fix issue where dialog buttons were not functional if the ID changed.
Bug: 31779188 Change-Id: Ifb42b6505fcd8a1928d31c6a20620b24450e420f
Diffstat (limited to 'src/android')
-rw-r--r--src/android/support/wearable/view/AcceptDenyDialog.java34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/android/support/wearable/view/AcceptDenyDialog.java b/src/android/support/wearable/view/AcceptDenyDialog.java
index 8ccccd5d..8961ee71 100644
--- a/src/android/support/wearable/view/AcceptDenyDialog.java
+++ b/src/android/support/wearable/view/AcceptDenyDialog.java
@@ -37,7 +37,7 @@ import com.android.packageinstaller.R;
* no click listener attached by default, the buttons are hidden be default.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
-public class AcceptDenyDialog extends Dialog implements View.OnClickListener {
+public class AcceptDenyDialog extends Dialog {
/** Icon at the top of the dialog. */
protected ImageView mIcon;
/** Title at the top of the dialog. */
@@ -63,6 +63,16 @@ public class AcceptDenyDialog extends Dialog implements View.OnClickListener {
/** Spacer between the positive and negative button. Hidden if one button is hidden. */
protected View mSpacer;
+ private final View.OnClickListener mButtonHandler = (v) -> {
+ if (v == mPositiveButton && mPositiveButtonListener != null) {
+ mPositiveButtonListener.onClick(this, DialogInterface.BUTTON_POSITIVE);
+ dismiss();
+ } else if (v == mNegativeButton && mNegativeButtonListener != null) {
+ mNegativeButtonListener.onClick(this, DialogInterface.BUTTON_NEGATIVE);
+ dismiss();
+ }
+ };
+
public AcceptDenyDialog(Context context) {
this(context, 0 /* use default context theme */);
}
@@ -76,31 +86,13 @@ public class AcceptDenyDialog extends Dialog implements View.OnClickListener {
mMessage = (TextView) findViewById(android.R.id.message);
mIcon = (ImageView) findViewById(android.R.id.icon);
mPositiveButton = (ImageButton) findViewById(android.R.id.button1);
- mPositiveButton.setOnClickListener(this);
+ mPositiveButton.setOnClickListener(mButtonHandler);
mNegativeButton = (ImageButton) findViewById(android.R.id.button2);
- mNegativeButton.setOnClickListener(this);
+ mNegativeButton.setOnClickListener(mButtonHandler);
mSpacer = (Space) findViewById(R.id.spacer);
mButtonPanel = findViewById(R.id.buttonPanel);
}
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case android.R.id.button1:
- if (mPositiveButtonListener != null) {
- mPositiveButtonListener.onClick(this, DialogInterface.BUTTON_POSITIVE);
- }
- dismiss();
- break;
- case android.R.id.button2:
- if (mNegativeButtonListener != null) {
- mNegativeButtonListener.onClick(this, DialogInterface.BUTTON_NEGATIVE);
- }
- dismiss();
- break;
- }
- }
-
public ImageButton getButton(int whichButton) {
switch (whichButton) {
case DialogInterface.BUTTON_POSITIVE: