Log switch toggle action whenever its status changes. am: 6d2a0c80df

am: 181f21393c

Change-Id: I16a34ea7636bf6ca015996e16ca554bc6f72c5aa
This commit is contained in:
Fan Zhang
2016-08-01 19:22:07 +00:00
committed by android-build-merger

View File

@@ -45,7 +45,7 @@ import java.util.ArrayList;
public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedChangeListener, public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedChangeListener,
View.OnClickListener { View.OnClickListener {
public static interface OnSwitchChangeListener { public interface OnSwitchChangeListener {
/** /**
* Called when the checked state of the Switch has changed. * Called when the checked state of the Switch has changed.
* *
@@ -63,7 +63,8 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
private String mLabel; private String mLabel;
private String mSummary; private String mSummary;
private boolean mDisabledByAdmin = false; private boolean mLoggingIntialized;
private boolean mDisabledByAdmin;
private EnforcedAdmin mEnforcedAdmin = null; private EnforcedAdmin mEnforcedAdmin = null;
private String mMetricsTag; private String mMetricsTag;
@@ -233,7 +234,6 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mEnforcedAdmin); RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mEnforcedAdmin);
} else { } else {
final boolean isChecked = !mSwitch.isChecked(); final boolean isChecked = !mSwitch.isChecked();
MetricsLogger.count(mContext, mMetricsTag + "/switch_bar|" + isChecked, 1);
setChecked(isChecked); setChecked(isChecked);
} }
} }
@@ -247,6 +247,10 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mLoggingIntialized) {
MetricsLogger.count(mContext, mMetricsTag + "/switch_bar|" + isChecked, 1);
}
mLoggingIntialized = true;
propagateChecked(isChecked); propagateChecked(isChecked);
} }