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

Commit da0fe825 authored by Beverly's avatar Beverly
Browse files

Added DND icon on muted streams on volume dialog

Now users cannot toggle off dnd from the volume dialog
since the ringer (volume footer) will be disabled if it's muted by dnd

Test: manual
Change-Id: I7d4dd552e0f791ee52135272d8d0837899abe152
Fixes: 72711020
parent d591904d
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"
          android:color="?android:attr/colorButtonNormal"/>

    <item android:color="?android:attr/colorAccent"/>
</selector>
 No newline at end of file
+43 −38
Original line number Diff line number Diff line
@@ -38,24 +38,27 @@
            android:layout_height="wrap_content"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:background="@drawable/rounded_bg_full"
            android:translationZ="@dimen/volume_panel_elevation"
            android:orientation="horizontal" >
                <!-- volume rows added and removed here! :-) -->
        </LinearLayout>

        <LinearLayout
        <FrameLayout
            android:id="@+id/footer"
            android:layout_width="@dimen/volume_dialog_panel_width"
            android:layout_height="@dimen/volume_dialog_panel_width"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:layout_marginTop="6dp"
            android:layout_marginBottom="6dp"
            android:layout_below="@id/volume_dialog_rows"
            android:background="@drawable/rounded_bg_full"
            android:background="@drawable/rounded_bg_full">

            <LinearLayout
                android:id="@+id/footer_linear_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipChildren="false"
                android:clipToPadding="false"
                android:gravity="center"
                android:layout_gravity="end"
                android:translationZ="@dimen/volume_panel_elevation"
@@ -79,7 +82,7 @@
                    android:background="?android:selectableItemBackgroundBorderless"
                    android:layout_width="@dimen/volume_dialog_panel_width"
                    android:layout_height="@dimen/volume_button_size"
                android:tint="?android:attr/colorAccent"
                    android:tint="@color/accent_tint_color_selector"
                    android:soundEffectsEnabled="false" />

                <TextView
@@ -90,7 +93,9 @@
                    android:maxLines="1"
                    android:textColor="?android:attr/colorControlNormal"
                    android:textAppearance="@style/TextAppearance.Volume.Header.Secondary" />

            </LinearLayout>

            <include layout="@layout/volume_dnd_icon"/>
        </FrameLayout>
    </LinearLayout>
</com.android.systemui.volume.VolumeUiLayout>
 No newline at end of file
+70 −61
Original line number Diff line number Diff line
@@ -13,14 +13,20 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:tag="row"
    android:layout_height="wrap_content"
    android:layout_width="@dimen/volume_dialog_panel_width"
    android:clipChildren="true"
    android:clipToPadding="true"
    android:theme="@style/qs_theme"
    android:theme="@style/qs_theme">

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:gravity="center"
        android:orientation="vertical" >

@@ -97,5 +103,8 @@
            android:layout_height="@dimen/volume_button_size"
            android:background="?android:selectableItemBackgroundBorderless"
            android:soundEffectsEnabled="false" />

    </LinearLayout>

    <include layout="@layout/volume_dnd_icon"/>

</FrameLayout>
+30 −0
Original line number Diff line number Diff line
<!--
     Copyright (C) 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="14dp"
    android:layout_height="14dp"
    android:layout_marginTop="6dp"
    android:layout_marginRight="6dp"
    android:layout_gravity="right|top">

    <ImageView
        android:id="@+id/dnd_icon"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_dnd"
        android:tint="?android:attr/textColorTertiary"/>
</FrameLayout>
+32 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
@@ -109,7 +110,9 @@ public class VolumeDialogImpl implements VolumeDialog {
    private ViewGroup mDialogRowsView;
    private ViewGroup mFooter;
    private ImageButton mRingerIcon;
    private ImageView mZenIcon;
    private TextView mRingerStatus;
    private TextView mRingerTitle;
    private final List<VolumeRow> mRows = new ArrayList<>();
    private ConfigurableTexts mConfigurableTexts;
    private final SparseBooleanArray mDynamic = new SparseBooleanArray();
@@ -216,6 +219,8 @@ public class VolumeDialogImpl implements VolumeDialog {
        mFooter = mDialog.findViewById(R.id.footer);
        mRingerIcon = mFooter.findViewById(R.id.ringer_icon);
        mRingerStatus = mFooter.findViewById(R.id.ringer_status);
        mRingerTitle = mFooter.findViewById(R.id.ringer_title);
        mZenIcon = mFooter.findViewById(R.id.dnd_icon);

        if (mRows.isEmpty()) {
            addRow(AudioManager.STREAM_MUSIC,
@@ -349,6 +354,7 @@ public class VolumeDialogImpl implements VolumeDialog {
        if (stream == STREAM_ACCESSIBILITY) {
            row.header.setFilters(new InputFilter[] {new InputFilter.LengthFilter(13)});
        }
        row.dndIcon = row.view.findViewById(R.id.dnd_icon);
        row.slider =  row.view.findViewById(R.id.volume_row_slider);
        row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row));
        row.anim = null;
@@ -559,6 +565,8 @@ public class VolumeDialogImpl implements VolumeDialog {
            if (ss == null) {
                return;
            }

            enableRingerViewsH(mState.zenMode == Global.ZEN_MODE_OFF || !mState.disallowRinger);
            switch (mState.ringerModeInternal) {
                case AudioManager.RINGER_MODE_VIBRATE:
                    mRingerStatus.setText(R.string.volume_ringer_status_vibrate);
@@ -603,6 +611,28 @@ public class VolumeDialogImpl implements VolumeDialog {
        }
    }

    /**
     * Toggles enable state of views in a VolumeRow (not including seekbar, outputChooser or icon)
     * Hides/shows zen icon
     * @param enable whether to enable volume row views and hide dnd icon
     */
    private void enableVolumeRowViewsH(VolumeRow row, boolean enable) {
        row.header.setEnabled(enable);
        row.dndIcon.setVisibility(enable ? View.GONE : View.VISIBLE);
    }

    /**
     * Toggles enable state of footer/ringer views
     * Hides/shows zen icon
     * @param enable whether to enable ringer views and hide dnd icon
     */
    private void enableRingerViewsH(boolean enable) {
        mRingerTitle.setEnabled(enable);
        mRingerStatus.setEnabled(enable);
        mRingerIcon.setEnabled(enable);
        mZenIcon.setVisibility(enable ? View.GONE : View.VISIBLE);
    }

    private void trimObsoleteH() {
        if (D.BUG) Log.d(TAG, "trimObsoleteH");
        for (int i = mRows.size() - 1; i >= 0; i--) {
@@ -748,6 +778,7 @@ public class VolumeDialogImpl implements VolumeDialog {
        if (zenMuted) {
            row.tracking = false;
        }
        enableVolumeRowViewsH(row, !zenMuted);

        // update slider
        final boolean enableSlider = !zenMuted;
@@ -1178,5 +1209,6 @@ public class VolumeDialogImpl implements VolumeDialog {
        private int lastAudibleLevel = 1;
        private View outputChooser;
        private TextView connectedDevice;
        private ImageView dndIcon;
    }
}