summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/notification/SoundSettings.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/notification/SoundSettings.java')
-rw-r--r--src/com/android/settings/notification/SoundSettings.java47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 7fffb765f1..1005d20f52 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -26,16 +26,22 @@ import android.os.UserHandle;
import android.preference.SeekBarVolumizer;
import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.RingtonePreference;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.sound.HandsFreeProfileOutputPreferenceController;
+import com.android.settings.sound.MediaOutputPreferenceController;
import com.android.settings.widget.PreferenceCategoryController;
+import com.android.settings.widget.UpdatableListPreferenceDialogFragment;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.ArrayList;
@@ -68,6 +74,9 @@ public class SoundSettings extends DashboardFragment {
};
private RingtonePreference mRequestPreference;
+ private UpdatableListPreferenceDialogFragment mDialogFragment;
+ private String mMediaOutputControllerKey;
+ private String mHfpOutputControllerKey;
@Override
public int getMetricsCategory() {
@@ -82,6 +91,11 @@ public class SoundSettings extends DashboardFragment {
if (!TextUtils.isEmpty(selectedPreference)) {
mRequestPreference = (RingtonePreference) findPreference(selectedPreference);
}
+
+ UpdatableListPreferenceDialogFragment dialogFragment =
+ (UpdatableListPreferenceDialogFragment) getFragmentManager()
+ .findFragmentByTag(TAG);
+ mDialogFragment = dialogFragment;
}
}
@@ -112,6 +126,23 @@ public class SoundSettings extends DashboardFragment {
}
@Override
+ public void onDisplayPreferenceDialog(Preference preference) {
+ final int metricsCategory;
+ if (mHfpOutputControllerKey.equals(preference.getKey())) {
+ metricsCategory = MetricsProto.MetricsEvent.DIALOG_SWITCH_HFP_DEVICES;
+ } else if (mMediaOutputControllerKey.equals(preference.getKey())) {
+ metricsCategory = MetricsProto.MetricsEvent.DIALOG_SWITCH_A2DP_DEVICES;
+ } else {
+ metricsCategory = Instrumentable.METRICS_CATEGORY_UNKNOWN;
+ }
+
+ mDialogFragment = UpdatableListPreferenceDialogFragment.
+ newInstance(preference.getKey(), metricsCategory);
+ mDialogFragment.setTargetFragment(this, 0);
+ mDialogFragment.show(getFragmentManager(), TAG);
+ }
+
+ @Override
protected String getLogTag() {
return TAG;
}
@@ -152,6 +183,14 @@ public class SoundSettings extends DashboardFragment {
volumeControllers.add(use(NotificationVolumePreferenceController.class));
volumeControllers.add(use(CallVolumePreferenceController.class));
+ use(MediaOutputPreferenceController.class).setCallback(listPreference ->
+ onPreferenceDataChanged(listPreference));
+ mMediaOutputControllerKey = use(MediaOutputPreferenceController.class).getPreferenceKey();
+ use(HandsFreeProfileOutputPreferenceController.class).setCallback(listPreference ->
+ onPreferenceDataChanged(listPreference));
+ mHfpOutputControllerKey =
+ use(HandsFreeProfileOutputPreferenceController.class).getPreferenceKey();
+
for (VolumeSeekBarPreferenceController controller : volumeControllers) {
controller.setCallback(mVolumeCallback);
getLifecycle().addObserver(controller);
@@ -287,4 +326,10 @@ public class SoundSettings extends DashboardFragment {
workSoundController.enableWorkSync();
}
}
-}
+
+ private void onPreferenceDataChanged(ListPreference preference) {
+ if (mDialogFragment != null) {
+ mDialogFragment.onListPreferenceUpdated(preference);
+ }
+ }
+} \ No newline at end of file