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

Commit eb1ec3af authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Show volume number in volume control ui

The volume can be controlled in 25 steps. Respectively, the ui shown
goes from 0 to 25.

An alternative would have been to display a percentage, but that would
mean that one volume button press would jump 4% up, which doesn't look
great.

Bug: 162302410
Test: flash system ui && click +/- volume controls
      Result: https://hsv.googleplex.com/5706562045739008
Change-Id: I295cf055937fae067f8ccc34eff656f42f85f072
parent 23ef82f4
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -33,8 +33,8 @@
        <com.android.keyguard.AlphaOptimizedImageButton
        <com.android.keyguard.AlphaOptimizedImageButton
            android:id="@+id/volume_row_icon"
            android:id="@+id/volume_row_icon"
            style="@style/VolumeButtons"
            style="@style/VolumeButtons"
            android:layout_width="@dimen/volume_dialog_tap_target_size"
            android:layout_width="@dimen/tv_volume_dialog_bubble_size"
            android:layout_height="@dimen/volume_dialog_tap_target_size"
            android:layout_height="@dimen/tv_volume_dialog_bubble_size"
            android:background="@drawable/ripple_drawable_20dp"
            android:background="@drawable/ripple_drawable_20dp"
            android:tint="@color/accent_tint_color_selector"
            android:tint="@color/accent_tint_color_selector"
            android:soundEffectsEnabled="false" />
            android:soundEffectsEnabled="false" />
@@ -62,6 +62,13 @@
                android:layout_gravity="center"
                android:layout_gravity="center"
                android:rotation="0" />
                android:rotation="0" />
        </FrameLayout>
        </FrameLayout>
        <TextView
            android:id="@+id/volume_number"
            android:layout_width="@dimen/tv_volume_dialog_bubble_size"
            android:layout_height="@dimen/tv_volume_dialog_bubble_size"
            android:maxLength="2"
            android:gravity="center"
            android:textColor="@color/accent_tint_color_selector"/>
    </LinearLayout>
    </LinearLayout>


    <include layout="@layout/volume_dnd_icon"/>
    <include layout="@layout/volume_dnd_icon"/>
+1 −1
Original line number Original line Diff line number Diff line
@@ -17,5 +17,5 @@
<resources>
<resources>
  <!-- Width of volume bar -->
  <!-- Width of volume bar -->
  <dimen name="volume_dialog_row_width">252dp</dimen>
  <dimen name="volume_dialog_row_width">252dp</dimen>
  <dimen name="volume_dialog_tap_target_size">36dp</dimen>
  <dimen name="tv_volume_dialog_bubble_size">36dp</dimen>
</resources>
</resources>
+7 −0
Original line number Original line Diff line number Diff line
@@ -421,6 +421,7 @@ public class VolumeDialogImpl implements VolumeDialog,
        row.dndIcon = row.view.findViewById(R.id.dnd_icon);
        row.dndIcon = row.view.findViewById(R.id.dnd_icon);
        row.slider = row.view.findViewById(R.id.volume_row_slider);
        row.slider = row.view.findViewById(R.id.volume_row_slider);
        row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
        row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
        row.number = row.view.findViewById(R.id.volume_number);


        row.anim = null;
        row.anim = null;


@@ -1090,6 +1091,7 @@ public class VolumeDialogImpl implements VolumeDialog,
        final int vlevel = row.ss.muted && (!isRingStream && !zenMuted) ? 0
        final int vlevel = row.ss.muted && (!isRingStream && !zenMuted) ? 0
                : row.ss.level;
                : row.ss.level;
        updateVolumeRowSliderH(row, enableSlider, vlevel);
        updateVolumeRowSliderH(row, enableSlider, vlevel);
        if (row.number != null) row.number.setText(Integer.toString(vlevel));
    }
    }


    private boolean isStreamMuted(final StreamState streamState) {
    private boolean isStreamMuted(final StreamState streamState) {
@@ -1115,6 +1117,10 @@ public class VolumeDialogImpl implements VolumeDialog,
        row.icon.setImageTintList(tint);
        row.icon.setImageTintList(tint);
        row.icon.setImageAlpha(alpha);
        row.icon.setImageAlpha(alpha);
        row.cachedTint = tint;
        row.cachedTint = tint;
        if (row.number != null) {
            row.number.setTextColor(tint);
            row.number.setAlpha(alpha);
        }
    }
    }


    private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) {
    private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) {
@@ -1458,6 +1464,7 @@ public class VolumeDialogImpl implements VolumeDialog,
        private TextView header;
        private TextView header;
        private ImageButton icon;
        private ImageButton icon;
        private SeekBar slider;
        private SeekBar slider;
        private TextView number;
        private int stream;
        private int stream;
        private StreamState ss;
        private StreamState ss;
        private long userAttempt;  // last user-driven slider change
        private long userAttempt;  // last user-driven slider change