summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Stetson <alexstetson@google.com>2023-12-13 21:16:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-12-13 21:16:13 +0000
commit6e3901f05074dda88fd426c49511a1ea0901f440 (patch)
tree606459eacc66cb276e0ff207e15f0d8292edc790
parenta25869d6502b06f66856a94053e26d12f452e93c (diff)
parenteb932b22a0a8be0a8a0830dec891a0013900aa0b (diff)
downloadsystemlibs-6e3901f05074dda88fd426c49511a1ea0901f440.tar.gz
Merge "Add clickable option to QC" into main
-rw-r--r--car-qc-lib/src/com/android/car/qc/QCActionItem.java26
-rw-r--r--car-qc-lib/src/com/android/car/qc/view/QCRowView.java6
2 files changed, 26 insertions, 6 deletions
diff --git a/car-qc-lib/src/com/android/car/qc/QCActionItem.java b/car-qc-lib/src/com/android/car/qc/QCActionItem.java
index b7b9cd1..f4e92d1 100644
--- a/car-qc-lib/src/com/android/car/qc/QCActionItem.java
+++ b/car-qc-lib/src/com/android/car/qc/QCActionItem.java
@@ -31,18 +31,20 @@ import androidx.annotation.StringRes;
public class QCActionItem extends QCItem {
private final boolean mIsChecked;
private final boolean mIsAvailable;
+ private final boolean mIsClickable;
private Icon mIcon;
private PendingIntent mAction;
private PendingIntent mDisabledClickAction;
private String mContentDescription;
public QCActionItem(@NonNull @QCItemType String type, boolean isChecked, boolean isEnabled,
- boolean isAvailable, boolean isClickableWhileDisabled, @Nullable Icon icon,
- @Nullable String contentDescription, @Nullable PendingIntent action,
- @Nullable PendingIntent disabledClickAction) {
+ boolean isAvailable, boolean isClickable, boolean isClickableWhileDisabled,
+ @Nullable Icon icon, @Nullable String contentDescription,
+ @Nullable PendingIntent action, @Nullable PendingIntent disabledClickAction) {
super(type, isEnabled, isClickableWhileDisabled);
mIsChecked = isChecked;
mIsAvailable = isAvailable;
+ mIsClickable = isClickable;
mIcon = icon;
mContentDescription = contentDescription;
mAction = action;
@@ -53,6 +55,7 @@ public class QCActionItem extends QCItem {
super(in);
mIsChecked = in.readBoolean();
mIsAvailable = in.readBoolean();
+ mIsClickable = in.readBoolean();
boolean hasIcon = in.readBoolean();
if (hasIcon) {
mIcon = Icon.CREATOR.createFromParcel(in);
@@ -76,6 +79,7 @@ public class QCActionItem extends QCItem {
super.writeToParcel(dest, flags);
dest.writeBoolean(mIsChecked);
dest.writeBoolean(mIsAvailable);
+ dest.writeBoolean(mIsClickable);
boolean includeIcon = getType().equals(QC_TYPE_ACTION_TOGGLE) && mIcon != null;
dest.writeBoolean(includeIcon);
if (includeIcon) {
@@ -116,6 +120,10 @@ public class QCActionItem extends QCItem {
return mIsAvailable;
}
+ public boolean isClickable() {
+ return mIsClickable;
+ }
+
@Nullable
public Icon getIcon() {
return mIcon;
@@ -146,6 +154,7 @@ public class QCActionItem extends QCItem {
private boolean mIsChecked;
private boolean mIsEnabled = true;
private boolean mIsAvailable = true;
+ private boolean mIsClickable = true;
private boolean mIsClickableWhileDisabled = false;
private Icon mIcon;
private PendingIntent mAction;
@@ -184,6 +193,15 @@ public class QCActionItem extends QCItem {
}
/**
+ * Sets whether the action is clickable. This differs from available in that the style will
+ * remain as if it's enabled/available but click actions will not be processed.
+ */
+ public Builder setClickable(boolean clickable) {
+ mIsClickable = clickable;
+ return this;
+ }
+
+ /**
* Sets whether or not an action item should be clickable while disabled.
*/
public Builder setClickableWhileDisabled(boolean clickable) {
@@ -236,7 +254,7 @@ public class QCActionItem extends QCItem {
* Builds the final {@link QCActionItem}.
*/
public QCActionItem build() {
- return new QCActionItem(mType, mIsChecked, mIsEnabled, mIsAvailable,
+ return new QCActionItem(mType, mIsChecked, mIsEnabled, mIsAvailable, mIsClickable,
mIsClickableWhileDisabled, mIcon, mContentDescription, mAction,
mDisabledClickAction);
}
diff --git a/car-qc-lib/src/com/android/car/qc/view/QCRowView.java b/car-qc-lib/src/com/android/car/qc/view/QCRowView.java
index 06a5fe2..2045fd2 100644
--- a/car-qc-lib/src/com/android/car/qc/view/QCRowView.java
+++ b/car-qc-lib/src/com/android/car/qc/view/QCRowView.java
@@ -308,7 +308,8 @@ public class QCRowView extends FrameLayout {
CarUiUtils.makeAllViewsEnabled(switchView, action.isEnabled());
boolean shouldEnableView =
- (action.isEnabled() || action.isClickableWhileDisabled()) && action.isAvailable();
+ (action.isEnabled() || action.isClickableWhileDisabled()) && action.isAvailable()
+ && action.isClickable();
switchView.setOnCheckedChangeListener(null);
switchView.setEnabled(shouldEnableView);
switchView.setChecked(action.isChecked());
@@ -339,7 +340,8 @@ public class QCRowView extends FrameLayout {
}
DrawableStateToggleButton toggleButton = tmpToggleButton; // must be effectively final
boolean shouldEnableView =
- (action.isEnabled() || action.isClickableWhileDisabled()) && action.isAvailable();
+ (action.isEnabled() || action.isClickableWhileDisabled()) && action.isAvailable()
+ && action.isClickable();
toggleButton.setText(null);
toggleButton.setTextOn(null);
toggleButton.setTextOff(null);