summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Simon Wingrove <simonjw@google.com> 2022-07-08 15:52:04 +0100
committer Simon Wingrove <simonjw@google.com> 2022-07-08 19:49:22 +0100
commitf6ad27e961ed0ce98bf623752fd4ac7f2686a1a2 (patch)
treea29e764a2971da86cd204e3f29b0b3872be3aaf6
parent91f0bea4303750fa71aeb1efb98a049ca2b7d3a3 (diff)
Read isInFlight for action buttons
Disable/enable button as appropriate. Bug: 237367469 Test: manual Change-Id: Id310db133093ca8afa628936ab355945097906e0
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java
index 1134b9a34..2d0d77dc6 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java
@@ -197,8 +197,18 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
Button button =
isFirstButton ? createFirstButton(context) : createSubsequentButton(context);
button.setText(action.getLabel());
- button.setOnClickListener(
- view -> mSafetyCenterViewModel.executeIssueAction(mIssue, action));
+ button.setEnabled(!action.isInFlight());
+ button.setOnClickListener((view) -> {
+ if (action.willResolve()) {
+ // Disable the button to prevent double-taps.
+ // We ideally want to do this on any button press, however out of an abundance of
+ // caution we only do it with actions that indicate they will resolve (and therefore
+ // we can rely on a model update to redraw state). We expect the model to update
+ // with either isInFlight() or simply removing/updating the issue.
+ button.setEnabled(false);
+ }
+ mSafetyCenterViewModel.executeIssueAction(mIssue, action);
+ });
return button;
}