1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings.notification;
18
19import android.content.Context;
20import android.media.AudioManager;
21
22import com.android.internal.annotations.VisibleForTesting;
23import com.android.settings.Utils;
24import com.android.settings.core.lifecycle.Lifecycle;
25import com.android.settings.notification.VolumeSeekBarPreference.Callback;
26
27public class NotificationVolumePreferenceController extends
28    RingVolumePreferenceController {
29
30    private static final String KEY_NOTIFICATION_VOLUME = "notification_volume";
31    private AudioHelper mHelper;
32
33    public NotificationVolumePreferenceController(Context context, Callback callback,
34        Lifecycle lifecycle) {
35        this(context, callback, lifecycle, new AudioHelper(context));
36    }
37
38    @VisibleForTesting
39    NotificationVolumePreferenceController(Context context,
40        Callback callback, Lifecycle lifecycle, AudioHelper helper) {
41        super(context, callback, lifecycle);
42        mHelper = helper;
43    }
44
45
46    @Override
47    public boolean isAvailable() {
48        return !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume();
49    }
50
51    @Override
52    public String getPreferenceKey() {
53        return KEY_NOTIFICATION_VOLUME;
54    }
55
56    @Override
57    public int getAudioStream() {
58        return AudioManager.STREAM_NOTIFICATION;
59    }
60
61    @Override
62    public int getMuteIcon() {
63        return com.android.internal.R.drawable.ic_audio_ring_notif_mute;
64    }
65
66}
67