/* * Copyright (C) 2024 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. */ package com.android.settingslib.bluetooth; import static com.android.settingslib.bluetooth.HearingAidInfo.DeviceSide.SIDE_LEFT; import static com.android.settingslib.bluetooth.HearingAidInfo.DeviceSide.SIDE_RIGHT; import android.bluetooth.BluetoothDevice; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.List; import java.util.Map; /** Interface for the ambient volume UI. */ public interface AmbientVolumeUi { /** Interface definition for a callback to be invoked when event happens in AmbientVolumeUi. */ interface AmbientVolumeUiListener { /** Called when the expand icon is clicked. */ void onExpandIconClick(); /** Called when the ambient volume icon is clicked. */ void onAmbientVolumeIconClick(); /** Called when the slider of the specified side is changed. */ void onSliderValueChange(int side, int value); }; /** The rotation degree of the expand icon when the UI is in collapsed mode. */ float ROTATION_COLLAPSED = 0f; /** The rotation degree of the expand icon when the UI is in expanded mode. */ float ROTATION_EXPANDED = 180f; /** * The default ambient volume level for hearing device ambient volume icon * *
This icon visually represents the current ambient volume. It displays separate * levels for the left and right sides, each with 5 levels ranging from 0 to 4. * *
To represent the combined left/right levels with a single value, the following * calculation is used: * finalLevel = (leftLevel * 5) + rightLevel * For example: *
If the UI is not expandable, it implies the UI will always stay in collapsed mode */ void setExpandable(boolean expandable); /** @return if the UI is expandable. */ boolean isExpandable(); /** Sets if the UI is in expanded mode. */ void setExpanded(boolean expanded); /** @return if the UI is in expanded mode. */ boolean isExpanded(); /** * Sets if the UI is capable to mute the ambient of the remote device. * *
If the value is {@code false}, it implies the remote device ambient will always be * unmute and can not be mute from the UI */ void setMutable(boolean mutable); /** @return if the UI is capable to mute the ambient of remote device. */ boolean isMutable(); /** Sets if the UI shows mute state. */ void setMuted(boolean muted); /** @return if the UI shows mute state */ boolean isMuted(); /** * Sets listener on the UI. * * @see AmbientVolumeUiListener */ void setListener(@Nullable AmbientVolumeUiListener listener); /** * Sets up sliders in the UI. * *
For each side of device, the UI should hava a corresponding slider to control it's * ambient volume. *
For all devices in the same set, the UI should have a slider to control all devices'
* ambient volume at once.
* @param sideToDeviceMap the side and device mapping of all devices in the same set
*/
void setupSliders(@NonNull Map