Rename 'WebRtcAudioManger' to 'WebRtcAudioManager'

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-06-23 15:20:32 +02:00
parent c13d23bda2
commit 10a4521af9
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E
4 changed files with 33 additions and 34 deletions

View File

@ -95,7 +95,7 @@ import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.power.PowerManagerUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences;
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
import com.nextcloud.talk.webrtc.WebRtcAudioManger;
import com.nextcloud.talk.webrtc.WebRtcAudioManager;
import com.nextcloud.talk.webrtc.MagicWebRTCUtils;
import com.nextcloud.talk.webrtc.MagicWebSocketInstance;
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
@ -162,7 +162,6 @@ import me.zhanghai.android.effortlesspermissions.OpenAppDetailsDialogFragment;
import okhttp3.Cache;
import pub.devrel.easypermissions.AfterPermissionGranted;
import static android.app.PendingIntent.FLAG_MUTABLE;
import static android.app.PendingIntent.FLAG_MUTABLE;
import static com.nextcloud.talk.webrtc.Globals.JOB_ID;
import static com.nextcloud.talk.webrtc.Globals.PARTICIPANTS_UPDATE;
@ -189,7 +188,7 @@ public class CallActivity extends CallBaseActivity {
public static final String TAG = "CallActivity";
public WebRtcAudioManger audioManager;
public WebRtcAudioManager audioManager;
private static final String[] PERMISSIONS_CALL = {
Manifest.permission.CAMERA,
@ -452,16 +451,16 @@ public class CallActivity extends CallBaseActivity {
// Create and audio manager that will take care of audio routing,
// audio modes, audio device enumeration etc.
audioManager = WebRtcAudioManger.create(getApplicationContext(), isVoiceOnlyCall);
audioManager = WebRtcAudioManager.create(getApplicationContext(), isVoiceOnlyCall);
// Store existing audio settings and change audio mode to
// MODE_IN_COMMUNICATION for best possible VoIP performance.
Log.d(TAG, "Starting the audio manager...");
audioManager.start(this::onAudioManagerDevicesChanged);
if (isVoiceOnlyCall) {
setAudioOutputChannel(WebRtcAudioManger.AudioDevice.EARPIECE);
setAudioOutputChannel(WebRtcAudioManager.AudioDevice.EARPIECE);
} else {
setAudioOutputChannel(WebRtcAudioManger.AudioDevice.SPEAKER_PHONE);
setAudioOutputChannel(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE);
}
iceServers = new ArrayList<>();
@ -495,14 +494,14 @@ public class CallActivity extends CallBaseActivity {
microphoneInitialization();
}
public void setAudioOutputChannel(WebRtcAudioManger.AudioDevice selectedAudioDevice) {
public void setAudioOutputChannel(WebRtcAudioManager.AudioDevice selectedAudioDevice) {
if (audioManager != null) {
audioManager.selectAudioDevice(selectedAudioDevice);
updateAudioOutputButton(audioManager.getCurrentAudioDevice());
}
}
private void updateAudioOutputButton(WebRtcAudioManger.AudioDevice activeAudioDevice) {
private void updateAudioOutputButton(WebRtcAudioManager.AudioDevice activeAudioDevice) {
switch (activeAudioDevice) {
case BLUETOOTH:
binding.audioOutputButton.getHierarchy().setPlaceholderImage(
@ -796,14 +795,14 @@ public class CallActivity extends CallBaseActivity {
}
private void onAudioManagerDevicesChanged(
final WebRtcAudioManger.AudioDevice currentDevice,
final Set<WebRtcAudioManger.AudioDevice> availableDevices) {
final WebRtcAudioManager.AudioDevice currentDevice,
final Set<WebRtcAudioManager.AudioDevice> availableDevices) {
Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", "
+ "currentDevice: " + currentDevice);
final boolean shouldDisableProximityLock = (currentDevice.equals(WebRtcAudioManger.AudioDevice.WIRED_HEADSET)
|| currentDevice.equals(WebRtcAudioManger.AudioDevice.SPEAKER_PHONE)
|| currentDevice.equals(WebRtcAudioManger.AudioDevice.BLUETOOTH));
final boolean shouldDisableProximityLock = (currentDevice.equals(WebRtcAudioManager.AudioDevice.WIRED_HEADSET)
|| currentDevice.equals(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE)
|| currentDevice.equals(WebRtcAudioManager.AudioDevice.BLUETOOTH));
if (shouldDisableProximityLock) {
powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.WITHOUT_PROXIMITY_SENSOR_LOCK);

View File

@ -30,7 +30,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import com.nextcloud.talk.R
import com.nextcloud.talk.activities.CallActivity
import com.nextcloud.talk.databinding.DialogAudioOutputBinding
import com.nextcloud.talk.webrtc.WebRtcAudioManger
import com.nextcloud.talk.webrtc.WebRtcAudioManager
class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(callActivity) {
@ -47,26 +47,26 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
}
fun updateOutputDeviceList() {
if (callActivity.audioManager?.audioDevices?.contains(WebRtcAudioManger.AudioDevice.BLUETOOTH) == false) {
if (callActivity.audioManager?.audioDevices?.contains(WebRtcAudioManager.AudioDevice.BLUETOOTH) == false) {
dialogAudioOutputBinding.audioOutputBluetooth.visibility = View.GONE
} else {
dialogAudioOutputBinding.audioOutputBluetooth.visibility = View.VISIBLE
}
if (callActivity.audioManager?.audioDevices?.contains(WebRtcAudioManger.AudioDevice.EARPIECE) == false) {
if (callActivity.audioManager?.audioDevices?.contains(WebRtcAudioManager.AudioDevice.EARPIECE) == false) {
dialogAudioOutputBinding.audioOutputEarspeaker.visibility = View.GONE
} else {
dialogAudioOutputBinding.audioOutputEarspeaker.visibility = View.VISIBLE
}
if (callActivity.audioManager?.audioDevices?.contains(WebRtcAudioManger.AudioDevice.SPEAKER_PHONE) == false) {
if (callActivity.audioManager?.audioDevices?.contains(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE) == false) {
dialogAudioOutputBinding.audioOutputSpeaker.visibility = View.GONE
} else {
dialogAudioOutputBinding.audioOutputSpeaker.visibility = View.VISIBLE
}
if (callActivity.audioManager?.currentAudioDevice?.equals(
WebRtcAudioManger.AudioDevice.WIRED_HEADSET
WebRtcAudioManager.AudioDevice.WIRED_HEADSET
) == true
) {
dialogAudioOutputBinding.audioOutputEarspeaker.visibility = View.GONE
@ -81,7 +81,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
private fun highlightActiveOutputChannel() {
when (callActivity.audioManager?.currentAudioDevice) {
WebRtcAudioManger.AudioDevice.BLUETOOTH -> {
WebRtcAudioManager.AudioDevice.BLUETOOTH -> {
dialogAudioOutputBinding.audioOutputBluetoothIcon.setColorFilter(
ContextCompat.getColor(
context,
@ -94,7 +94,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
)
}
WebRtcAudioManger.AudioDevice.SPEAKER_PHONE -> {
WebRtcAudioManager.AudioDevice.SPEAKER_PHONE -> {
dialogAudioOutputBinding.audioOutputSpeakerIcon.setColorFilter(
ContextCompat.getColor(
context,
@ -107,7 +107,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
)
}
WebRtcAudioManger.AudioDevice.EARPIECE -> {
WebRtcAudioManager.AudioDevice.EARPIECE -> {
dialogAudioOutputBinding.audioOutputEarspeakerIcon.setColorFilter(
ContextCompat.getColor(
context,
@ -120,7 +120,7 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
)
}
WebRtcAudioManger.AudioDevice.WIRED_HEADSET -> {
WebRtcAudioManager.AudioDevice.WIRED_HEADSET -> {
dialogAudioOutputBinding.audioOutputWiredHeadsetIcon.setColorFilter(
ContextCompat.getColor(
context,
@ -139,17 +139,17 @@ class AudioOutputDialog(val callActivity: CallActivity) : BottomSheetDialog(call
private fun initClickListeners() {
dialogAudioOutputBinding.audioOutputBluetooth.setOnClickListener {
callActivity.setAudioOutputChannel(WebRtcAudioManger.AudioDevice.BLUETOOTH)
callActivity.setAudioOutputChannel(WebRtcAudioManager.AudioDevice.BLUETOOTH)
dismiss()
}
dialogAudioOutputBinding.audioOutputSpeaker.setOnClickListener {
callActivity.setAudioOutputChannel(WebRtcAudioManger.AudioDevice.SPEAKER_PHONE)
callActivity.setAudioOutputChannel(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE)
dismiss()
}
dialogAudioOutputBinding.audioOutputEarspeaker.setOnClickListener {
callActivity.setAudioOutputChannel(WebRtcAudioManger.AudioDevice.EARPIECE)
callActivity.setAudioOutputChannel(WebRtcAudioManager.AudioDevice.EARPIECE)
dismiss()
}
}

View File

@ -54,8 +54,8 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class WebRtcAudioManger {
private static final String TAG = WebRtcAudioManger.class.getCanonicalName();
public class WebRtcAudioManager {
private static final String TAG = WebRtcAudioManager.class.getSimpleName();
private final Context magicContext;
private final WebRtcBluetoothManager bluetoothManager;
private final boolean useProximitySensor;
@ -79,7 +79,7 @@ public class WebRtcAudioManger {
private final PowerManagerUtils powerManagerUtils;
private WebRtcAudioManger(Context context, boolean useProximitySensor) {
private WebRtcAudioManager(Context context, boolean useProximitySensor) {
Log.d(TAG, "ctor");
ThreadUtils.checkIsOnMainThread();
magicContext = context;
@ -110,8 +110,8 @@ public class WebRtcAudioManger {
/**
* Construction.
*/
public static WebRtcAudioManger create(Context context, boolean useProximitySensor) {
return new WebRtcAudioManger(context, useProximitySensor);
public static WebRtcAudioManager create(Context context, boolean useProximitySensor) {
return new WebRtcAudioManager(context, useProximitySensor);
}
public void startBluetoothManager() {
@ -141,7 +141,7 @@ public class WebRtcAudioManger {
.SENSOR_NEAR, null, null, null, null));
} else {
setAudioDeviceInternal(WebRtcAudioManger.AudioDevice.SPEAKER_PHONE);
setAudioDeviceInternal(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE);
Log.d(TAG, "switched to SPEAKER_PHONE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=far");
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType

View File

@ -66,7 +66,7 @@ public class WebRtcBluetoothManager {
// Maximum number of SCO connection attempts.
private static final int MAX_SCO_CONNECTION_ATTEMPTS = 2;
private final Context apprtcContext;
private final WebRtcAudioManger webRtcAudioManager;
private final WebRtcAudioManager webRtcAudioManager;
private final AudioManager audioManager;
private final Handler handler;
private final BluetoothProfile.ServiceListener bluetoothServiceListener;
@ -82,7 +82,7 @@ public class WebRtcBluetoothManager {
private final Runnable bluetoothTimeoutRunnable = this::bluetoothTimeout;
private boolean started = false;
protected WebRtcBluetoothManager(Context context, WebRtcAudioManger audioManager) {
protected WebRtcBluetoothManager(Context context, WebRtcAudioManager audioManager) {
Log.d(TAG, "ctor");
ThreadUtils.checkIsOnMainThread();
apprtcContext = context;
@ -97,7 +97,7 @@ public class WebRtcBluetoothManager {
/**
* Construction.
*/
static WebRtcBluetoothManager create(Context context, WebRtcAudioManger audioManager) {
static WebRtcBluetoothManager create(Context context, WebRtcAudioManager audioManager) {
return new WebRtcBluetoothManager(context, audioManager);
}