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

Commit 20586a28 authored by Bruno Martins's avatar Bruno Martins Committed by Michael Bestas
Browse files

Settings: Add switch for linked ring and media notification volumes

Change-Id: I900af398f566a5415c44fe883cc214985f4e9cd4
parent 9b65f813
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -77,4 +77,7 @@
    <string name="increasing_ring_volume_option_title">Increasing ring volume</string>
    <string name="increasing_ring_volume_option_title">Increasing ring volume</string>
    <string name="increasing_ring_min_volume_title">Start volume</string>
    <string name="increasing_ring_min_volume_title">Start volume</string>
    <string name="increasing_ring_ramp_up_time_title">Ramp-up time</string>
    <string name="increasing_ring_ramp_up_time_title">Ramp-up time</string>

    <!-- Volume link notification -->
    <string name="volume_link_notification_title">Link ring &amp; notification volumes</string>
</resources>
</resources>
+6 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,12 @@
                android:icon="@*android:drawable/ic_audio_ring_notif"
                android:icon="@*android:drawable/ic_audio_ring_notif"
                android:title="@string/notification_volume_option_title" />
                android:title="@string/notification_volume_option_title" />


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

        <!-- Increasing ring -->
        <!-- Increasing ring -->
        <lineageos.preference.LineageSystemSettingSwitchPreference
        <lineageos.preference.LineageSystemSettingSwitchPreference
                android:key="increasing_ring"
                android:key="increasing_ring"
+43 −0
Original line number Original line 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.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;

public class LinkedVolumesPreferenceController extends AbstractPreferenceController
        implements PreferenceControllerMixin {

    private static final String KEY_VOLUME_LINK_NOTIFICATION = "volume_link_notification";

    public LinkedVolumesPreferenceController(Context context) {
        super(context);
    }

    @Override
    public String getPreferenceKey() {
        return KEY_VOLUME_LINK_NOTIFICATION;
    }

    @Override
    public boolean isAvailable() {
        return Utils.isVoiceCapable(mContext);
    }
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ public class NotificationVolumePreferenceController extends


    @Override
    @Override
    public boolean isAvailable() {
    public boolean isAvailable() {
        return !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume();
        return !mHelper.isSingleVolume();
    }
    }


    @Override
    @Override
+3 −0
Original line number Original line Diff line number Diff line
@@ -225,6 +225,7 @@ public class SoundSettings extends DashboardFragment {
        controllers.add(
        controllers.add(
                new NotificationVolumePreferenceController(context, callback, lifecycle));
                new NotificationVolumePreferenceController(context, callback, lifecycle));
        controllers.add(new RingVolumePreferenceController(context, callback, lifecycle));
        controllers.add(new RingVolumePreferenceController(context, callback, lifecycle));
        controllers.add(new LinkedVolumesPreferenceController(context));
        controllers.add(new IncreasingRingPreferenceController(context));
        controllers.add(new IncreasingRingPreferenceController(context));
        controllers.add(new IncreasingRingVolumePreferenceController(
        controllers.add(new IncreasingRingVolumePreferenceController(
                    context, incCallback, lifecycle));
                    context, incCallback, lifecycle));
@@ -273,6 +274,8 @@ public class SoundSettings extends DashboardFragment {
                public List<String> getNonIndexableKeys(Context context) {
                public List<String> getNonIndexableKeys(Context context) {
                    List<String> keys = super.getNonIndexableKeys(context);
                    List<String> keys = super.getNonIndexableKeys(context);
                    if (!Utils.isVoiceCapable(context)) {
                    if (!Utils.isVoiceCapable(context)) {
                        keys.add((new LinkedVolumesPreferenceController(
                                context)).getPreferenceKey());
                        keys.add((new IncreasingRingPreferenceController(
                        keys.add((new IncreasingRingPreferenceController(
                                context)).getPreferenceKey());
                                context)).getPreferenceKey());
                    }
                    }