Merge "Make sure tuner has metrics coverage for new stuff" into nyc-dev
This commit is contained in:
@@ -91,6 +91,7 @@
|
|||||||
|
|
||||||
<declare-styleable name="TunerSwitch">
|
<declare-styleable name="TunerSwitch">
|
||||||
<attr name="defValue" format="boolean" />
|
<attr name="defValue" format="boolean" />
|
||||||
|
<attr name="metricsAction" format="integer" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|||||||
@@ -109,14 +109,20 @@
|
|||||||
android:key="volume_and_do_not_disturb"
|
android:key="volume_and_do_not_disturb"
|
||||||
android:title="@string/volume_and_do_not_disturb">
|
android:title="@string/volume_and_do_not_disturb">
|
||||||
|
|
||||||
|
<!-- Action for this is
|
||||||
|
MetricsConstants.ACTION_TUNER_DO_NOT_DISTURB_VOLUME_PANEL -->
|
||||||
<com.android.systemui.tuner.TunerSwitch
|
<com.android.systemui.tuner.TunerSwitch
|
||||||
android:key="sysui_show_full_zen"
|
android:key="sysui_show_full_zen"
|
||||||
android:title="@string/tuner_full_zen_title" />
|
android:title="@string/tuner_full_zen_title"
|
||||||
|
sysui:metricsAction="314" />
|
||||||
|
|
||||||
|
<!-- Action for this is
|
||||||
|
MetricsConstants.ACTION_TUNER_DO_NOT_DISTURB_VOLUME_SHORTCUT -->
|
||||||
<com.android.systemui.tuner.TunerSwitch
|
<com.android.systemui.tuner.TunerSwitch
|
||||||
android:key="sysui_volume_down_silent,sysui_volume_up_silent"
|
android:key="sysui_volume_down_silent,sysui_volume_up_silent"
|
||||||
android:title="@string/volume_dnd_silent"
|
android:title="@string/volume_dnd_silent"
|
||||||
sysui:defValue="true" />
|
sysui:defValue="true"
|
||||||
|
sysui:metricsAction="315" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.statusbar.policy.NightModeController;
|
import com.android.systemui.statusbar.policy.NightModeController;
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ public class ColorAndAppearanceFragment extends PreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
MetricsLogger.visibility(getContext(), MetricsEvent.TUNER_COLOR_AND_APPEARANCE, true);
|
||||||
// TODO: Figure out better title model for Tuner, to avoid any more of this.
|
// TODO: Figure out better title model for Tuner, to avoid any more of this.
|
||||||
getActivity().setTitle(R.string.color_and_appearance);
|
getActivity().setTitle(R.string.color_and_appearance);
|
||||||
|
|
||||||
@@ -62,6 +65,12 @@ public class ColorAndAppearanceFragment extends PreferenceFragment {
|
|||||||
? R.string.night_mode_on : R.string.night_mode_off);
|
? R.string.night_mode_on : R.string.night_mode_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
MetricsLogger.visibility(getContext(), MetricsEvent.TUNER_COLOR_AND_APPEARANCE, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisplayPreferenceDialog(Preference preference) {
|
public void onDisplayPreferenceDialog(Preference preference) {
|
||||||
if (preference instanceof CalibratePreference) {
|
if (preference instanceof CalibratePreference) {
|
||||||
@@ -76,6 +85,7 @@ public class ColorAndAppearanceFragment extends PreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onApply() {
|
private void onApply() {
|
||||||
|
MetricsLogger.action(getContext(), MetricsEvent.ACTION_TUNER_CALIBRATE_DISPLAY_CHANGED);
|
||||||
mNightModeController.setCustomValues(Settings.Secure.getString(
|
mNightModeController.setCustomValues(Settings.Secure.getString(
|
||||||
getContext().getContentResolver(), Secure.ACCESSIBILITY_DISPLAY_COLOR_MATRIX));
|
getContext().getContentResolver(), Secure.ACCESSIBILITY_DISPLAY_COLOR_MATRIX));
|
||||||
getView().removeCallbacks(mResetColorMatrix);
|
getView().removeCallbacks(mResetColorMatrix);
|
||||||
@@ -125,6 +135,7 @@ public class ColorAndAppearanceFragment extends PreferenceFragment {
|
|||||||
bindView(v.findViewById(R.id.r_group), 0);
|
bindView(v.findViewById(R.id.r_group), 0);
|
||||||
bindView(v.findViewById(R.id.g_group), 5);
|
bindView(v.findViewById(R.id.g_group), 5);
|
||||||
bindView(v.findViewById(R.id.b_group), 10);
|
bindView(v.findViewById(R.id.b_group), 10);
|
||||||
|
MetricsLogger.visible(getContext(), MetricsEvent.TUNER_CALIBRATE_DISPLAY);
|
||||||
return new AlertDialog.Builder(getContext())
|
return new AlertDialog.Builder(getContext())
|
||||||
.setTitle(R.string.calibrate_display)
|
.setTitle(R.string.calibrate_display)
|
||||||
.setView(v)
|
.setView(v)
|
||||||
@@ -133,6 +144,12 @@ public class ColorAndAppearanceFragment extends PreferenceFragment {
|
|||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
super.onDismiss(dialog);
|
||||||
|
MetricsLogger.hidden(getContext(), MetricsEvent.TUNER_CALIBRATE_DISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
private void bindView(View view, final int index) {
|
private void bindView(View view, final int index) {
|
||||||
SeekBar seekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
|
SeekBar seekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
|
||||||
seekBar.setMax(1000);
|
seekBar.setMax(1000);
|
||||||
|
|||||||
@@ -17,23 +17,20 @@ package com.android.systemui.tuner;
|
|||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.UiModeManager;
|
import android.app.UiModeManager;
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.support.v14.preference.PreferenceFragment;
|
import android.support.v14.preference.PreferenceFragment;
|
||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.support.v7.preference.DropDownPreference;
|
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.statusbar.phone.QSTileHost;
|
|
||||||
import com.android.systemui.statusbar.policy.NightModeController;
|
import com.android.systemui.statusbar.policy.NightModeController;
|
||||||
import com.android.systemui.statusbar.policy.NightModeController.Listener;
|
import com.android.systemui.statusbar.policy.NightModeController.Listener;
|
||||||
import com.android.systemui.tuner.TunerService.Tunable;
|
import com.android.systemui.tuner.TunerService.Tunable;
|
||||||
@@ -100,6 +97,7 @@ public class NightModeFragment extends PreferenceFragment implements Tunable,
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean newState = !mNightModeController.isEnabled();
|
boolean newState = !mNightModeController.isEnabled();
|
||||||
|
MetricsLogger.action(getContext(), MetricsEvent.ACTION_TUNER_NIGHT_MODE, newState);
|
||||||
mNightModeController.setNightMode(newState);
|
mNightModeController.setNightMode(newState);
|
||||||
mSwitch.setChecked(newState);
|
mSwitch.setChecked(newState);
|
||||||
}
|
}
|
||||||
@@ -109,6 +107,7 @@ public class NightModeFragment extends PreferenceFragment implements Tunable,
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
MetricsLogger.visibility(getContext(), MetricsEvent.TUNER_NIGHT_MODE, true);
|
||||||
mNightModeController.addListener(this);
|
mNightModeController.addListener(this);
|
||||||
TunerService.get(getContext()).addTunable(this, Secure.BRIGHTNESS_USE_TWILIGHT,
|
TunerService.get(getContext()).addTunable(this, Secure.BRIGHTNESS_USE_TWILIGHT,
|
||||||
NightModeController.NIGHT_MODE_ADJUST_TINT);
|
NightModeController.NIGHT_MODE_ADJUST_TINT);
|
||||||
@@ -119,24 +118,33 @@ public class NightModeFragment extends PreferenceFragment implements Tunable,
|
|||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
MetricsLogger.visibility(getContext(), MetricsEvent.TUNER_NIGHT_MODE, false);
|
||||||
mNightModeController.removeListener(this);
|
mNightModeController.removeListener(this);
|
||||||
TunerService.get(getContext()).removeTunable(this);
|
TunerService.get(getContext()).removeTunable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
final Boolean value = (Boolean) newValue;
|
||||||
if (mAutoSwitch == preference) {
|
if (mAutoSwitch == preference) {
|
||||||
mNightModeController.setAuto((Boolean) newValue);
|
MetricsLogger.action(getContext(), MetricsEvent.ACTION_TUNER_NIGHT_MODE_AUTO, value);
|
||||||
|
mNightModeController.setAuto(value);
|
||||||
} else if (mDarkTheme == preference) {
|
} else if (mDarkTheme == preference) {
|
||||||
mUiModeManager.setNightMode(((Boolean) newValue) ? UiModeManager.MODE_NIGHT_AUTO
|
MetricsLogger.action(getContext(),
|
||||||
|
MetricsEvent.ACTION_TUNER_NIGHT_MODE_ADJUST_DARK_THEME, value);
|
||||||
|
mUiModeManager.setNightMode(value ? UiModeManager.MODE_NIGHT_AUTO
|
||||||
: UiModeManager.MODE_NIGHT_NO);
|
: UiModeManager.MODE_NIGHT_NO);
|
||||||
postCalculateDisabled();
|
postCalculateDisabled();
|
||||||
} else if (mAdjustTint == preference) {
|
} else if (mAdjustTint == preference) {
|
||||||
mNightModeController.setAdjustTint((Boolean) newValue);
|
MetricsLogger.action(getContext(),
|
||||||
|
MetricsEvent.ACTION_TUNER_NIGHT_MODE_ADJUST_TINT, value);
|
||||||
|
mNightModeController.setAdjustTint(value);
|
||||||
postCalculateDisabled();
|
postCalculateDisabled();
|
||||||
} else if (mAdjustBrightness == preference) {
|
} else if (mAdjustBrightness == preference) {
|
||||||
|
MetricsLogger.action(getContext(),
|
||||||
|
MetricsEvent.ACTION_TUNER_NIGHT_MODE_ADJUST_BRIGHTNESS, value);
|
||||||
TunerService.get(getContext()).setValue(Secure.BRIGHTNESS_USE_TWILIGHT,
|
TunerService.get(getContext()).setValue(Secure.BRIGHTNESS_USE_TWILIGHT,
|
||||||
((Boolean) newValue) ? 1 : 0);
|
value ? 1 : 0);
|
||||||
postCalculateDisabled();
|
postCalculateDisabled();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ public class TunerActivity extends SettingsDrawerActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (!getFragmentManager().popBackStackImmediate()) {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
|
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,18 +6,21 @@ import android.provider.Settings;
|
|||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.tuner.TunerService.Tunable;
|
import com.android.systemui.tuner.TunerService.Tunable;
|
||||||
|
|
||||||
public class TunerSwitch extends SwitchPreference implements Tunable {
|
public class TunerSwitch extends SwitchPreference implements Tunable {
|
||||||
|
|
||||||
private final boolean mDefault;
|
private final boolean mDefault;
|
||||||
|
private final int mAction;
|
||||||
|
|
||||||
public TunerSwitch(Context context, AttributeSet attrs) {
|
public TunerSwitch(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TunerSwitch);
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TunerSwitch);
|
||||||
mDefault = a.getBoolean(R.styleable.TunerSwitch_defValue, false);
|
mDefault = a.getBoolean(R.styleable.TunerSwitch_defValue, false);
|
||||||
|
mAction = a.getInt(R.styleable.TunerSwitch_metricsAction, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,6 +40,14 @@ public class TunerSwitch extends SwitchPreference implements Tunable {
|
|||||||
setChecked(newValue != null ? Integer.parseInt(newValue) != 0 : mDefault);
|
setChecked(newValue != null ? Integer.parseInt(newValue) != 0 : mDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
super.onClick();
|
||||||
|
if (mAction != -1) {
|
||||||
|
MetricsLogger.action(getContext(), mAction, isChecked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean persistBoolean(boolean value) {
|
protected boolean persistBoolean(boolean value) {
|
||||||
for (String key : getKey().split(",")) {
|
for (String key : getKey().split(",")) {
|
||||||
|
|||||||
@@ -408,5 +408,38 @@ message MetricsEvent {
|
|||||||
|
|
||||||
// Changes made on bug report details screen were canceled by user.
|
// Changes made on bug report details screen were canceled by user.
|
||||||
ACTION_BUGREPORT_DETAILS_CANCELED = 304;
|
ACTION_BUGREPORT_DETAILS_CANCELED = 304;
|
||||||
|
|
||||||
|
// Tuner: Open/close calibrate dialog.
|
||||||
|
TUNER_CALIBRATE_DISPLAY = 305;
|
||||||
|
|
||||||
|
// Tuner: Open/close color and appearance.
|
||||||
|
TUNER_COLOR_AND_APPEARANCE = 306;
|
||||||
|
|
||||||
|
// Tuner: Apply calibrate dialog.
|
||||||
|
ACTION_TUNER_CALIBRATE_DISPLAY_CHANGED = 307;
|
||||||
|
|
||||||
|
// Tuner: Open/close night mode.
|
||||||
|
TUNER_NIGHT_MODE = 308;
|
||||||
|
|
||||||
|
// Tuner: Change night mode.
|
||||||
|
ACTION_TUNER_NIGHT_MODE = 309;
|
||||||
|
|
||||||
|
// Tuner: Change night mode auto.
|
||||||
|
ACTION_TUNER_NIGHT_MODE_AUTO = 310;
|
||||||
|
|
||||||
|
// Tuner: Change night mode adjust dark theme.
|
||||||
|
ACTION_TUNER_NIGHT_MODE_ADJUST_DARK_THEME = 311;
|
||||||
|
|
||||||
|
// Tuner: Change night mode adjust tint.
|
||||||
|
ACTION_TUNER_NIGHT_MODE_ADJUST_TINT = 312;
|
||||||
|
|
||||||
|
// Tuner: Change night mode adjust brightness.
|
||||||
|
ACTION_TUNER_NIGHT_MODE_ADJUST_BRIGHTNESS = 313;
|
||||||
|
|
||||||
|
// Tuner: Change do not disturb in volume panel.
|
||||||
|
ACTION_TUNER_DO_NOT_DISTURB_VOLUME_PANEL = 314;
|
||||||
|
|
||||||
|
// Tuner: Change do not disturb volume buttons shortcut.
|
||||||
|
ACTION_TUNER_DO_NOT_DISTURB_VOLUME_SHORTCUT = 315;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user