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:
Jason Monk
2016-02-21 09:37:41 -05:00
parent 18d9865388
commit e4ebcd12be
2 changed files with 24 additions and 8 deletions

View File

@@ -460,18 +460,22 @@ public class SettingsActivity extends SettingsDrawerActivity
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
if (name.equals(getPackageName() + "_preferences")) {
String tag = getClass().getName();
if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
}
if (tag.startsWith("com.android.settings.")) {
tag = tag.replace("com.android.settings.", "");
}
return new SharedPreferencesLogger(this, tag);
return new SharedPreferencesLogger(this, getMetricsTag());
}
return super.getSharedPreferences(name, mode);
}
private String getMetricsTag() {
String tag = getClass().getName();
if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
}
if (tag.startsWith("com.android.settings.")) {
tag = tag.replace("com.android.settings.", "");
}
return tag;
}
private static boolean isShortCutIntent(final Intent intent) {
Set<String> categories = intent.getCategories();
return (categories != null) && categories.contains("com.android.settings.SHORTCUT");
@@ -610,6 +614,9 @@ public class SettingsActivity extends SettingsDrawerActivity
mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
}
mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar);
if (mSwitchBar != null) {
mSwitchBar.setMetricsTag(getMetricsTag());
}
// see if we should show Back/Next buttons
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {