Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 897bdc09 authored by Norman Bintang's avatar Norman Bintang
Browse files

audio: VolumeDialog: Hide ringer button in single volume mode

While in singleVolume mode, the ringer mode can't be changed [1]. But
the VolumeDialog is still showing it, and it doesn't work.

[1] https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/services/core/java/com/android/server/audio/AudioService.java;l=5687;drc=e7e6ec868a3277517795e77976186fc0dfed9365

Bug: 374870615
Test: press volume keys, see the ringer mode is not shown
Flag: com.android.systemui.hide_ringer_button_in_single_volume_mode

Change-Id: I30508096593084f0e036c2c800c67b6db953a8d1
parent ae2d85e5
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1558,6 +1558,16 @@ flag {
   }
}

flag {
   name: "hide_ringer_button_in_single_volume_mode"
   namespace: "systemui"
   description: "When the device is in single volume mode, hide the ringer button because it doesn't work"
   bug: "374870615"
   metadata {
       purpose: PURPOSE_BUGFIX
   }
}

flag {
    name: "qs_tile_detailed_view"
    namespace: "systemui"
+31 −2
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RotateDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.media.AudioManager;
import android.media.AudioSystem;
import android.os.Debug;
@@ -115,6 +117,7 @@ import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.view.RotationPolicy;
import com.android.settingslib.Utils;
import com.android.systemui.Dumpable;
import com.android.systemui.Flags;
import com.android.systemui.Prefs;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.haptics.slider.HapticSliderViewBinder;
@@ -656,6 +659,11 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            mRingerIcon = mRinger.findViewById(R.id.ringer_icon);
        }

        if (Flags.hideRingerButtonInSingleVolumeMode() && AudioSystem.isSingleVolume(mContext)) {
            mRingerAndDrawerContainer.setVisibility(INVISIBLE);
            mRinger.setVisibility(INVISIBLE);
        }

        mSelectedRingerIcon = mDialog.findViewById(R.id.volume_new_ringer_active_icon);
        mSelectedRingerContainer = mDialog.findViewById(
                R.id.volume_new_ringer_active_icon_container);
@@ -2341,10 +2349,31 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            return;
        }

        LayerDrawable background;
        // mRingerAndDrawerContainer has rounded corner.
        // But when it's not visible, mTopContainer needs to have rounded corner.
        if (Flags.hideRingerButtonInSingleVolumeMode()
                && mRingerAndDrawerContainer.getVisibility() != VISIBLE
        ) {
            float[] radius = new float[] {
                mDialogCornerRadius, mDialogCornerRadius,  // Top-left corner
                mDialogCornerRadius, mDialogCornerRadius,  // Top-right corner
                0, 0,  // Bottom-right corner
                0, 0   // Bottom-left corner
            };

            ShapeDrawable roundedDrawable = new ShapeDrawable(
                    new RoundRectShape(radius, null, null));
            roundedDrawable.getPaint().setColor(Utils.getColorAttrDefaultColor(
                    mContext, com.android.internal.R.attr.colorSurface));

            background = new LayerDrawable(new Drawable[] { roundedDrawable });
        } else {
            final ColorDrawable solidDrawable = new ColorDrawable(
                Utils.getColorAttrDefaultColor(mContext, com.android.internal.R.attr.colorSurface));

        final LayerDrawable background = new LayerDrawable(new Drawable[] { solidDrawable });
            background = new LayerDrawable(new Drawable[] { solidDrawable });
        }

        // Size the solid color to match the primary volume row. In landscape, extend it upwards
        // slightly so that it fills in the bottom corners of the ringer icon, whose background is