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

Commit c7f22ff5 authored by Bruno Martins's avatar Bruno Martins Committed by Sevenrock
Browse files

Settings: Add switch for linked ring and media notification volumes

Author: Dan Pasanen <dan.pasanen@gmail.com>
Date:   Wed Oct 30 09:22:30 2019 -0500

    VolumePanel: fix showing notification volume slider when unlinked

    * volume_link_notification lives in Settings.Secure not LineageSettings.Secure
    * Set max panel slices to 6. We could have up to 5 volumes to control and
      MEDIA_OUTPUT_INDICATOR_SLICE_URI counts as one slice as well.

    Change-Id: I0a4c7db1c92e778fba669931259cd52164b1df65

Change-Id: I900af398f566a5415c44fe883cc214985f4e9cd4
parent b3889bc5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@
    <string name="touchscreen_gesture_settings_title">Touchscreen gestures</string>
    <string name="touchscreen_gesture_settings_summary">Perform various touchscreen gestures for quick actions</string>

    <!-- Volume link notification -->
    <string name="volume_link_notification_title">Link ring &amp; notification volumes</string>

    <!-- Wake on plug -->
    <string name="wake_when_plugged_or_unplugged_title">Wake on plug</string>
    <string name="wake_when_plugged_or_unplugged_summary">Turn the screen on when connecting or disconnecting a power source</string>
+8 −0
Original line number Diff line number Diff line
@@ -90,6 +90,14 @@
        android:order="-140"
        settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>

    <!-- Link ringtone and notification volumes -->
    <lineageos.preference.SecureSettingSwitchPreference
        android:key="volume_link_notification"
        android:title="@string/volume_link_notification_title"
        android:defaultValue="true"
        android:order="-138"
        settings:controller="com.android.settings.notification.LinkedVolumesPreferenceController"/>

    <!-- Also vibrate for calls -->
    <Preference
        android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The LineageOS 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.
 */

package com.android.settings.notification;

import android.content.Context;

import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;

public class LinkedVolumesPreferenceController extends BasePreferenceController {
    public LinkedVolumesPreferenceController(Context context, String key) {
        super(context, key);
    }

    @Override
    public int getAvailabilityStatus() {
        return Utils.isVoiceCapable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -35,8 +35,7 @@ public class NotificationVolumePreferenceController extends
    @Override
    public int getAvailabilityStatus() {
        return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
                && !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume()
                ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
                && !mHelper.isSingleVolume() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.settings.slices.CustomSliceRegistry.REMOTE_MEDIA_SLICE
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_ALARM_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_CALL_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_NOTIFICATION_URI;
import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI;

import android.app.settings.SettingsEnums;
@@ -30,6 +31,7 @@ import android.net.Uri;
import android.provider.Settings;

import com.android.settings.R;
import com.android.settings.Utils;

import java.util.ArrayList;
import java.util.List;
@@ -60,6 +62,10 @@ public class VolumePanel implements PanelContent {
        uris.add(MEDIA_OUTPUT_INDICATOR_SLICE_URI);
        uris.add(VOLUME_CALL_URI);
        uris.add(VOLUME_RINGER_URI);
        if (Utils.isVoiceCapable(mContext) && Settings.Secure.getInt(
                mContext.getContentResolver(), Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 0) {
            uris.add(VOLUME_NOTIFICATION_URI);
        }
        uris.add(VOLUME_ALARM_URI);
        return uris;
    }
Loading