Add generic logging to Settings switch bar
Same usage/format as the shared preference logging. Bug: 27043208 Change-Id: I7a7a5c0a9c92ec6cef50df58313016218cf2f2f7
This commit is contained in:
@@ -34,6 +34,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
@@ -64,6 +65,8 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
private boolean mDisabledByAdmin = false;
|
||||
private EnforcedAdmin mEnforcedAdmin = null;
|
||||
|
||||
private String mMetricsTag;
|
||||
|
||||
private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners =
|
||||
new ArrayList<OnSwitchChangeListener>();
|
||||
|
||||
@@ -125,6 +128,10 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void setMetricsTag(String tag) {
|
||||
mMetricsTag = tag;
|
||||
}
|
||||
|
||||
public void setTextViewLabel(boolean isChecked) {
|
||||
mLabel = getResources()
|
||||
.getString(isChecked ? R.string.switch_on_text : R.string.switch_off_text);
|
||||
@@ -217,9 +224,11 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mDisabledByAdmin) {
|
||||
MetricsLogger.histogram(mContext, mMetricsTag + "/switch_bar|restricted", 1);
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mEnforcedAdmin);
|
||||
} else {
|
||||
final boolean isChecked = !mSwitch.isChecked();
|
||||
MetricsLogger.histogram(mContext, mMetricsTag + "/switch_bar|" + isChecked, 1);
|
||||
setChecked(isChecked);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user