Skip to content

Commit

Permalink
Revert "Settings: Allow separating ringer & notification sound streams"
Browse files Browse the repository at this point in the history
This reverts commit ef734a8.
  • Loading branch information
basamaryan committed Aug 10, 2023
1 parent 29c6af6 commit 475ff23
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 123 deletions.
3 changes: 0 additions & 3 deletions res/values/custom_strings.xml
Expand Up @@ -342,7 +342,4 @@
<string name="smart_5g_title">Smart 5G</string>
<string name="smart_5g_summary">Automatically switch between 5G and 4G to reduce battery consumption</string>

<!-- Separate ring & notification toggle -->
<string name="volume_separate_notification_title">Separated Ring and Notification</string>
<string name="volume_separate_notification_summary">Allow controlling each stream individually</string>
</resources>
7 changes: 0 additions & 7 deletions res/xml/sound_settings.xml
Expand Up @@ -97,13 +97,6 @@
android:order="-140"
settings:controller="com.android.settings.notification.AlarmVolumePreferenceController"/>

<!-- Separate ring & notification toggle -->
<SwitchPreference
android:key="volume_separate_notification"
android:title="@string/volume_separate_notification_title"
android:summary="@string/volume_separate_notification_summary"
android:order="-137"/>

<!-- Per-app volume -->
<com.android.settings.custom.preference.SystemSettingSwitchPreference
android:key="show_app_volume"
Expand Down
Expand Up @@ -61,12 +61,10 @@ public NotificationVolumePreferenceController(Context context, String key) {
mNormalIconId = R.drawable.ic_notifications;
mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
mSilentIconId = R.drawable.ic_notifications_off_24dp;
mSeparateNotification = isSeparateNotificationConfigEnabled();

if (updateRingerMode()) {
updateEnabledState();
}
updateVisibility();
}

/**
Expand All @@ -84,7 +82,6 @@ public void displayPreference(PreferenceScreen screen) {
updateEffectsSuppressor();
selectPreferenceIconState();
updateEnabledState();
updateVisibility();
}

/**
Expand All @@ -98,21 +95,18 @@ private void onDeviceConfigChange(DeviceConfig.Properties properties) {
if (newVal != mSeparateNotification) {
mSeparateNotification = newVal;
// Update UI if config change happens when Sound Settings page is on the foreground
updateVisibility();
if (mPreference != null) {
int status = getAvailabilityStatus();
mPreference.setVisible(status == AVAILABLE
|| status == DISABLED_DEPENDENT_SETTING);
if (status == DISABLED_DEPENDENT_SETTING) {
mPreference.setEnabled(false);
}
}
}
}
}

private void updateVisibility() {
if (mPreference == null) return;
int status = getAvailabilityStatus();
mPreference.setVisible(status == AVAILABLE
|| status == DISABLED_DEPENDENT_SETTING);
if (status == DISABLED_DEPENDENT_SETTING) {
mPreference.setEnabled(false);
}
}

@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@Override
public void onResume() {
Expand All @@ -139,7 +133,7 @@ public int getAvailabilityStatus() {
&& !mHelper.isSingleVolume() && separateNotification
? (mRingerMode == AudioManager.RINGER_MODE_NORMAL
? AVAILABLE : DISABLED_DEPENDENT_SETTING)
: CONDITIONALLY_UNAVAILABLE;
: UNSUPPORTED_ON_DEVICE;
}

@Override
Expand Down
Expand Up @@ -63,9 +63,6 @@ public RingVolumePreferenceController(Context context, String key) {

mSeparateNotification = isSeparateNotificationConfigEnabled();
updateRingerMode();
if (mPreference != null) {
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
}
}

/**
Expand All @@ -78,9 +75,6 @@ private void onDeviceConfigChange(DeviceConfig.Properties properties) {
if (valueUpdated) {
updateEffectsSuppressor();
selectPreferenceIconState();
if (mPreference != null) {
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
}
}
}
}
Expand Down Expand Up @@ -120,7 +114,7 @@ public String getPreferenceKey() {
public int getAvailabilityStatus() {
boolean separateNotification = isSeparateNotificationConfigEnabled();
return !separateNotification && !mHelper.isSingleVolume()
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}

@Override
Expand Down
Expand Up @@ -62,9 +62,6 @@ public SeparateRingVolumePreferenceController(Context context, String key) {

mSeparateNotification = isSeparateNotificationConfigEnabled();
updateRingerMode();
if (mPreference != null) {
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
}
}

/**
Expand All @@ -77,9 +74,6 @@ private void onDeviceConfigChange(DeviceConfig.Properties properties) {
if (valueUpdated) {
updateEffectsSuppressor();
selectPreferenceIconState();
if (mPreference != null) {
mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
}
}
}
}
Expand Down Expand Up @@ -117,7 +111,7 @@ public String getPreferenceKey() {
public int getAvailabilityStatus() {
boolean separateNotification = isSeparateNotificationConfigEnabled();
return separateNotification && !mHelper.isSingleVolume()
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}

@Override
Expand Down
6 changes: 0 additions & 6 deletions src/com/android/settings/notification/SoundSettings.java
Expand Up @@ -42,7 +42,6 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.sound.HandsFreeProfileOutputPreferenceController;
import com.android.settings.sound.SeparateNotificationPreferenceController;
import com.android.settings.widget.PreferenceCategoryController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.Instrumentable;
Expand Down Expand Up @@ -277,11 +276,6 @@ private static List<AbstractPreferenceController> buildPreferenceControllers(Con
controllers.add(new AlarmRingtonePreferenceController(context));
controllers.add(new NotificationRingtonePreferenceController(context));

final SeparateNotificationPreferenceController separateNotificationPreferenceController =
new SeparateNotificationPreferenceController(context);

controllers.add(separateNotificationPreferenceController);

return controllers;
}

Expand Down
Expand Up @@ -54,7 +54,9 @@ public void setCallback(Callback callback) {
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
setupVolPreference(screen);
if (isAvailable()) {
setupVolPreference(screen);
}
}

protected void setupVolPreference(PreferenceScreen screen) {
Expand Down

This file was deleted.

0 comments on commit 475ff23

Please sign in to comment.