fix: output devices

This commit is contained in:
Next Alone 2022-07-14 23:03:15 +08:00 committed by luvletter2333
parent 6ccb87a96e
commit bcec381654
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
1 changed files with 17 additions and 14 deletions

View File

@ -139,7 +139,9 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import kotlin.Unit;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.ui.BottomBuilder;
@SuppressLint("NewApi")
public class VoIPService extends Service implements SensorEventListener, AudioManager.OnAudioFocusChangeListener, VoIPController.ConnectionStateListener, NotificationCenter.NotificationCenterDelegate {
@ -2662,20 +2664,21 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa
public void toggleSpeakerphoneOrShowRouteSheet(Context context, boolean fromOverlayWindow) {
if (isBluetoothHeadsetConnected() && hasEarpiece()) {
BottomSheet.Builder builder = new BottomSheet.Builder(context)
.setTitle(LocaleController.getString("VoipOutputDevices", R.string.VoipOutputDevices), true)
.setItems(new CharSequence[]{
LocaleController.getString("VoipAudioRoutingSpeaker", R.string.VoipAudioRoutingSpeaker),
isHeadsetPlugged ? LocaleController.getString("VoipAudioRoutingHeadset", R.string.VoipAudioRoutingHeadset) : LocaleController.getString("VoipAudioRoutingEarpiece", R.string.VoipAudioRoutingEarpiece),
currentBluetoothDeviceName != null ? currentBluetoothDeviceName : LocaleController.getString("VoipAudioRoutingBluetooth", R.string.VoipAudioRoutingBluetooth)},
new int[]{R.drawable.calls_menu_speaker,
isHeadsetPlugged ? R.drawable.calls_menu_headset : R.drawable.calls_menu_phone,
R.drawable.calls_menu_bluetooth}, (dialog, which) -> {
if (getSharedInstance() == null) {
return;
}
setAudioOutput(which);
});
BottomBuilder builder = new BottomBuilder(context);
builder.addTitle(LocaleController.getString("VoipOutputDevices", R.string.VoipOutputDevices), true);
builder.addItems(new String[]{
LocaleController.getString("VoipAudioRoutingSpeaker", R.string.VoipAudioRoutingSpeaker),
isHeadsetPlugged ? LocaleController.getString("VoipAudioRoutingHeadset", R.string.VoipAudioRoutingHeadset) : LocaleController.getString("VoipAudioRoutingEarpiece", R.string.VoipAudioRoutingEarpiece),
currentBluetoothDeviceName != null ? currentBluetoothDeviceName : LocaleController.getString("VoipAudioRoutingBluetooth", R.string.VoipAudioRoutingBluetooth)},
new int[]{R.drawable.calls_menu_speaker,
isHeadsetPlugged ? R.drawable.calls_menu_headset : R.drawable.calls_menu_phone,
R.drawable.calls_menu_bluetooth}, (which, dialog, __) -> {
if (getSharedInstance() == null) {
return Unit.INSTANCE;
}
setAudioOutput(which);
return Unit.INSTANCE;
});
BottomSheet bottomSheet = builder.create();
if (fromOverlayWindow) {