Skip to content

Commit d4ccd5d

Browse files
JertlokArianK16a
authored andcommitted
VolumeDialog: Hide the music row if there is an ally stream
- Introduce the concept of tracking ally streams, useful when you are still on a call, for instance, but you also want to change the media volume for a future use. When you tap on the media row the calling row will disappear because of AOSP logic. With this patch, we hide the music row if there is a "special" row, like the voice call volume row, and show it on the expanded panel like our other custom rows. After collapsing the expanded panel we set active stream back to this "special" row. Change-Id: I23792369cf1fd8e0b4d6913c67d02bd4c09f1ac7 Co-authored-by: Arian <arian.kulmer@web.de> Signed-off-by: Jesse Chan <jc@lineageos.org>
1 parent 702680e commit d4ccd5d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ public class VolumeDialogImpl implements VolumeDialog,
173173
private boolean mShowA11yStream;
174174

175175
private int mActiveStream;
176+
private int mAllyStream;
176177
private int mPrevActiveStream;
177178
private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE;
179+
private boolean mMusicHidden;
178180
private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE;
179181
private State mState;
180182
private SafetyWarningDialog mSafetyWarning;
@@ -351,6 +353,9 @@ private void initDialog() {
351353
initRingerH();
352354
initSettingsH();
353355
initODICaptionsH();
356+
357+
mAllyStream = -1;
358+
mMusicHidden = false;
354359
}
355360

356361
private final OnComputeInternalInsetsListener mInsetsListener = internalInsetsInfo -> {
@@ -583,6 +588,10 @@ public void initSettingsH() {
583588
});
584589
}
585590

591+
if (mAllyStream == -1) {
592+
mAllyStream = mActiveStream;
593+
}
594+
586595
if (mExpandRowsView != null) {
587596
mExpandRowsView.setVisibility(
588597
mDeviceProvisionedController.isCurrentUserSetup() &&
@@ -592,14 +601,18 @@ public void initSettingsH() {
592601
if (mExpandRows != null) {
593602
mExpandRows.setOnClickListener(v -> {
594603
rescheduleTimeoutH();
604+
if (mMusicHidden) {
605+
Util.setVisOrGone(findRow(AudioManager.STREAM_MUSIC).view,
606+
!mExpanded);
607+
}
595608
Util.setVisOrGone(findRow(AudioManager.STREAM_RING).view, !mExpanded);
596609
Util.setVisOrGone(findRow(STREAM_ALARM).view, !mExpanded);
597610
if (!isNotificationVolumeLinked()) {
598611
Util.setVisOrGone(
599612
findRow(AudioManager.STREAM_NOTIFICATION).view, !mExpanded);
600613
}
601614

602-
if (mExpanded) mController.setActiveStream(AudioManager.STREAM_MUSIC);
615+
if (mExpanded) mController.setActiveStream(mAllyStream);
603616
mExpandRows.setExpanded(!mExpanded);
604617
mExpanded = !mExpanded;
605618
});
@@ -917,6 +930,8 @@ protected void dismissH(int reason) {
917930
}
918931
mExpanded = false;
919932
mExpandRows.setExpanded(mExpanded);
933+
mAllyStream = -1;
934+
mMusicHidden = false;
920935
tryToRemoveCaptionsTooltip();
921936
mController.notifyVisible(false);
922937
}, 50));
@@ -939,6 +954,12 @@ private boolean showActiveStreamOnly() {
939954
private boolean shouldBeVisibleH(VolumeRow row, VolumeRow activeRow) {
940955
boolean isActive = row.stream == activeRow.stream;
941956

957+
if (row.stream == AudioSystem.STREAM_MUSIC &&
958+
activeRow.stream != AudioSystem.STREAM_MUSIC && !mExpanded) {
959+
mMusicHidden = true;
960+
return false;
961+
}
962+
942963
if (isActive) {
943964
return true;
944965
}

0 commit comments

Comments
 (0)