mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Rework MainActivity navigation to properly suppor empty state.
This commit is contained in:
committed by
Greyson Parrelli
parent
58d2fbc94e
commit
638f718d7c
@@ -103,7 +103,7 @@ public abstract class AudioManagerCompat {
|
||||
Log.w(TAG, "isSpeakerphoneOn: Failed to find communication device.");
|
||||
return false;
|
||||
} else {
|
||||
return audioDeviceInfo.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER;
|
||||
return AudioDeviceMapping.fromPlatformType(audioDeviceInfo.getType()) == SignalAudioManager.AudioDevice.SPEAKER_PHONE;
|
||||
}
|
||||
} else {
|
||||
return audioManager.isSpeakerphoneOn();
|
||||
@@ -112,16 +112,16 @@ public abstract class AudioManagerCompat {
|
||||
|
||||
public void setSpeakerphoneOn(boolean on) {
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
int desiredType = on ? AudioDeviceInfo.TYPE_BUILTIN_SPEAKER : AudioDeviceInfo.TYPE_BUILTIN_EARPIECE;
|
||||
AudioDeviceInfo candidate = getAvailableCommunicationDevices().stream()
|
||||
.filter(audioDeviceInfo -> audioDeviceInfo.getType() == desiredType)
|
||||
SignalAudioManager.AudioDevice audioDevice = on ? SignalAudioManager.AudioDevice.SPEAKER_PHONE : SignalAudioManager.AudioDevice.EARPIECE;
|
||||
AudioDeviceInfo candidate = getAvailableCommunicationDevices().stream()
|
||||
.filter(it -> AudioDeviceMapping.fromPlatformType(it.getType()) == audioDevice)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (candidate != null) {
|
||||
setCommunicationDevice(candidate);
|
||||
} else {
|
||||
Log.w(TAG, "setSpeakerphoneOn: Failed to find candidate for device type {" + desiredType + "}. Falling back on deprecated method.");
|
||||
Log.w(TAG, "setSpeakerphoneOn: Failed to find candidate for SignalAudioDevice {" + audioDevice + "}. Falling back on deprecated method.");
|
||||
audioManager.setSpeakerphoneOn(on);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user