only count clicks on zen mode selector

We were counting all changes of mode while the panel was visible, including the
first initialization of the selector.

Bug: 21196323
Change-Id: Icf2165056f03507b0b8c6a21ec1f07830c29173a
This commit is contained in:
Chris Wren
2015-06-29 11:27:18 -04:00
parent 31659c253e
commit 4572cbc917
2 changed files with 11 additions and 9 deletions

View File

@@ -57,7 +57,7 @@ public class SegmentedButtons extends LinearLayout {
return mSelectedValue;
}
public void setSelectedValue(Object value) {
public void setSelectedValue(Object value, boolean fromClick) {
if (Objects.equals(value, mSelectedValue)) return;
mSelectedValue = value;
for (int i = 0; i < getChildCount(); i++) {
@@ -67,7 +67,7 @@ public class SegmentedButtons extends LinearLayout {
c.setSelected(selected);
c.setTypeface(selected ? MEDIUM : REGULAR);
}
fireOnSelected();
fireOnSelected(fromClick);
}
public void addButton(int labelResId, int contentDescriptionResId, Object value) {
@@ -100,9 +100,9 @@ public class SegmentedButtons extends LinearLayout {
}
}
private void fireOnSelected() {
private void fireOnSelected(boolean fromClick) {
if (mCallback != null) {
mCallback.onSelected(mSelectedValue);
mCallback.onSelected(mSelectedValue, fromClick);
}
}
@@ -115,11 +115,11 @@ public class SegmentedButtons extends LinearLayout {
private final View.OnClickListener mClick = new View.OnClickListener() {
@Override
public void onClick(View v) {
setSelectedValue(v.getTag());
setSelectedValue(v.getTag(), true /* fromClick */);
}
};
public interface Callback extends Interaction.Callback {
void onSelected(Object value);
void onSelected(Object value, boolean fromClick);
}
}

View File

@@ -391,7 +391,7 @@ public class ZenModePanel extends LinearLayout {
setExpanded(isShown());
mSessionZen = zen;
}
mZenButtons.setSelectedValue(zen);
mZenButtons.setSelectedValue(zen, false /* fromClick */);
updateWidgets();
handleUpdateConditions();
if (mExpanded) {
@@ -968,10 +968,12 @@ public class ZenModePanel extends LinearLayout {
private final SegmentedButtons.Callback mZenButtonsCallback = new SegmentedButtons.Callback() {
@Override
public void onSelected(final Object value) {
public void onSelected(final Object value, boolean fromClick) {
if (value != null && mZenButtons.isShown() && isAttachedToWindow()) {
final int zen = (Integer) value;
MetricsLogger.action(mContext, MetricsLogger.QS_DND_ZEN_SELECT, zen);
if (fromClick) {
MetricsLogger.action(mContext, MetricsLogger.QS_DND_ZEN_SELECT, zen);
}
if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + zen);
final Uri realConditionId = getRealConditionId(mSessionExitCondition);
AsyncTask.execute(new Runnable() {