Merge pull request #2563 from nextcloud/use-comparison-operator-rather-than-equals-for-enums

Use comparison operator rather than equals for enums
This commit is contained in:
Andy Scherzinger 2022-11-14 13:39:53 +01:00 committed by GitHub
commit 796a2683db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 37 deletions

View File

@ -440,7 +440,7 @@ public class CallActivity extends CallBaseActivity {
binding.gridview.setOnItemClickListener((parent, view, position, id) -> animateCallControls(true, 0)); binding.gridview.setOnItemClickListener((parent, view, position, id) -> animateCallControls(true, 0));
binding.callStates.callStateRelativeLayout.setOnClickListener(l -> { binding.callStates.callStateRelativeLayout.setOnClickListener(l -> {
if (currentCallStatus.equals(CallStatus.CALLING_TIMEOUT)) { if (currentCallStatus == CallStatus.CALLING_TIMEOUT) {
setCallState(CallStatus.RECONNECTING); setCallState(CallStatus.RECONNECTING);
hangupNetworkCalls(false); hangupNetworkCalls(false);
} }
@ -747,7 +747,7 @@ public class CallActivity extends CallBaseActivity {
} }
private boolean isConnectionEstablished() { private boolean isConnectionEstablished() {
return (currentCallStatus.equals(CallStatus.JOINED) || currentCallStatus.equals(CallStatus.IN_CONVERSATION)); return (currentCallStatus == CallStatus.JOINED || currentCallStatus == CallStatus.IN_CONVERSATION);
} }
@AfterPermissionGranted(100) @AfterPermissionGranted(100)
@ -838,9 +838,9 @@ public class CallActivity extends CallBaseActivity {
Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", " Log.d(TAG, "onAudioManagerDevicesChanged: " + availableDevices + ", "
+ "currentDevice: " + currentDevice); + "currentDevice: " + currentDevice);
final boolean shouldDisableProximityLock = (currentDevice.equals(WebRtcAudioManager.AudioDevice.WIRED_HEADSET) final boolean shouldDisableProximityLock = (currentDevice == WebRtcAudioManager.AudioDevice.WIRED_HEADSET
|| currentDevice.equals(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE) || currentDevice == WebRtcAudioManager.AudioDevice.SPEAKER_PHONE
|| currentDevice.equals(WebRtcAudioManager.AudioDevice.BLUETOOTH)); || currentDevice == WebRtcAudioManager.AudioDevice.BLUETOOTH);
if (shouldDisableProximityLock) { if (shouldDisableProximityLock) {
powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.WITHOUT_PROXIMITY_SENSOR_LOCK); powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.WITHOUT_PROXIMITY_SENSOR_LOCK);
@ -1230,7 +1230,7 @@ public class CallActivity extends CallBaseActivity {
Log.d(TAG, "localStream is null"); Log.d(TAG, "localStream is null");
} }
if (!currentCallStatus.equals(CallStatus.LEAVING)) { if (currentCallStatus != CallStatus.LEAVING) {
hangup(true); hangup(true);
} }
powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.IDLE); powerManagerUtils.updatePhoneState(PowerManagerUtils.PhoneState.IDLE);
@ -1457,7 +1457,7 @@ public class CallActivity extends CallBaseActivity {
@Override @Override
public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) { public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
if (!currentCallStatus.equals(CallStatus.LEAVING)) { if (currentCallStatus != CallStatus.LEAVING) {
setCallState(CallStatus.JOINED); setCallState(CallStatus.JOINED);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true); ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
@ -1549,7 +1549,7 @@ public class CallActivity extends CallBaseActivity {
conversationUser, externalSignalingServer.getExternalSignalingTicket(), conversationUser, externalSignalingServer.getExternalSignalingTicket(),
TextUtils.isEmpty(credentials)); TextUtils.isEmpty(credentials));
} else { } else {
if (webSocketClient.isConnected() && currentCallStatus.equals(CallStatus.PUBLISHER_FAILED)) { if (webSocketClient.isConnected() && currentCallStatus == CallStatus.PUBLISHER_FAILED) {
webSocketClient.restartWebSocket(); webSocketClient.restartWebSocket();
} }
} }
@ -1567,7 +1567,7 @@ public class CallActivity extends CallBaseActivity {
@Subscribe(threadMode = ThreadMode.BACKGROUND) @Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(WebSocketCommunicationEvent webSocketCommunicationEvent) { public void onMessageEvent(WebSocketCommunicationEvent webSocketCommunicationEvent) {
if (CallStatus.LEAVING.equals(currentCallStatus)) { if (currentCallStatus == CallStatus.LEAVING) {
return; return;
} }
@ -1575,7 +1575,7 @@ public class CallActivity extends CallBaseActivity {
case "hello": case "hello":
Log.d(TAG, "onMessageEvent 'hello'"); Log.d(TAG, "onMessageEvent 'hello'");
if (!webSocketCommunicationEvent.getHashMap().containsKey("oldResumeId")) { if (!webSocketCommunicationEvent.getHashMap().containsKey("oldResumeId")) {
if (currentCallStatus.equals(CallStatus.RECONNECTING)) { if (currentCallStatus == CallStatus.RECONNECTING) {
hangup(false); hangup(false);
} else { } else {
initiateCall(); initiateCall();
@ -1660,7 +1660,7 @@ public class CallActivity extends CallBaseActivity {
private void receivedSignalingMessage(Signaling signaling) throws IOException { private void receivedSignalingMessage(Signaling signaling) throws IOException {
String messageType = signaling.getType(); String messageType = signaling.getType();
if (!isConnectionEstablished() && !currentCallStatus.equals(CallStatus.CONNECTING)) { if (!isConnectionEstablished() && currentCallStatus != CallStatus.CONNECTING) {
return; return;
} }
@ -1889,7 +1889,7 @@ public class CallActivity extends CallBaseActivity {
userIdsBySessionId.put(participant.get("sessionId").toString(), userId); userIdsBySessionId.put(participant.get("sessionId").toString(), userId);
} else { } else {
Log.d(TAG, " inCallFlag of currentSessionId: " + inCallFlag); Log.d(TAG, " inCallFlag of currentSessionId: " + inCallFlag);
if (inCallFlag == 0 && !CallStatus.LEAVING.equals(currentCallStatus) && ApplicationWideCurrentRoomHolder.getInstance().isInCall()) { if (inCallFlag == 0 && currentCallStatus != CallStatus.LEAVING && ApplicationWideCurrentRoomHolder.getInstance().isInCall()) {
Log.d(TAG, "Most probably a moderator ended the call for all."); Log.d(TAG, "Most probably a moderator ended the call for all.");
hangup(true); hangup(true);
} }
@ -1909,7 +1909,7 @@ public class CallActivity extends CallBaseActivity {
// Calculate sessions that join the call // Calculate sessions that join the call
newSessions.removeAll(oldSessions); newSessions.removeAll(oldSessions);
if (!isConnectionEstablished() && !currentCallStatus.equals(CallStatus.CONNECTING)) { if (!isConnectionEstablished() && currentCallStatus != CallStatus.CONNECTING) {
return; return;
} }
@ -1938,7 +1938,7 @@ public class CallActivity extends CallBaseActivity {
}); });
} }
if (newSessions.size() > 0 && !currentCallStatus.equals(CallStatus.IN_CONVERSATION)) { if (newSessions.size() > 0 && currentCallStatus != CallStatus.IN_CONVERSATION) {
setCallState(CallStatus.IN_CONVERSATION); setCallState(CallStatus.IN_CONVERSATION);
} }
@ -2193,7 +2193,7 @@ public class CallActivity extends CallBaseActivity {
boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType() == boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.SENSOR_FAR && videoOn; PeerConnectionEvent.PeerConnectionEventType.SENSOR_FAR && videoOn;
if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA) && if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA) &&
(currentCallStatus.equals(CallStatus.CONNECTING) || isConnectionEstablished()) && videoOn (currentCallStatus == CallStatus.CONNECTING || isConnectionEstablished()) && videoOn
&& enableVideo != localVideoTrack.enabled()) { && enableVideo != localVideoTrack.enabled()) {
toggleMedia(enableVideo, true); toggleMedia(enableVideo, true);
} }
@ -2416,7 +2416,7 @@ public class CallActivity extends CallBaseActivity {
} }
private void setCallState(CallStatus callState) { private void setCallState(CallStatus callState) {
if (currentCallStatus == null || !currentCallStatus.equals(callState)) { if (currentCallStatus == null || currentCallStatus != callState) {
currentCallStatus = callState; currentCallStatus = callState;
if (handler == null) { if (handler == null) {
handler = new Handler(Looper.getMainLooper()); handler = new Handler(Looper.getMainLooper());

View File

@ -145,8 +145,8 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
} }
if (TextUtils.isEmpty(participant.getDisplayName()) && if (TextUtils.isEmpty(participant.getDisplayName()) &&
(participant.getType().equals(Participant.ParticipantType.GUEST) || (participant.getType() == Participant.ParticipantType.GUEST ||
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) { participant.getType() == Participant.ParticipantType.USER_FOLLOWING_LINK)) {
holder.binding.nameText.setText(NextcloudTalkApplication holder.binding.nameText.setText(NextcloudTalkApplication
.Companion .Companion
.getSharedApplication() .getSharedApplication()
@ -167,8 +167,8 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
} else if ( } else if (
participant.getCalculatedActorType() == Participant.ActorType.GUESTS || participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
Participant.ParticipantType.GUEST.equals(participant.getType()) || participant.getType() == Participant.ParticipantType.GUEST ||
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) { participant.getType() == Participant.ParticipantType.GUEST_MODERATOR) {
String displayName; String displayName;

View File

@ -274,7 +274,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
} }
} }
if (Conversation.ConversationType.ROOM_SYSTEM.equals(conversation.getType())) { if (conversation.getType() == Conversation.ConversationType.ROOM_SYSTEM) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Drawable[] layers = new Drawable[2]; Drawable[] layers = new Drawable[2];

View File

@ -140,8 +140,8 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
} }
if (TextUtils.isEmpty(participant.getDisplayName()) && if (TextUtils.isEmpty(participant.getDisplayName()) &&
(participant.getType().equals(Participant.ParticipantType.GUEST) || (participant.getType() == Participant.ParticipantType.GUEST ||
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) { participant.getType() == Participant.ParticipantType.USER_FOLLOWING_LINK)) {
holder.binding.nameText.setText(NextcloudTalkApplication holder.binding.nameText.setText(NextcloudTalkApplication
.Companion .Companion
.getSharedApplication() .getSharedApplication()
@ -170,8 +170,8 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail); holder.binding.avatarDraweeView.setImageResource(R.drawable.ic_circular_mail);
} }
} else if (participant.getCalculatedActorType() == Participant.ActorType.GUESTS || } else if (participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
Participant.ParticipantType.GUEST.equals(participant.getType()) || participant.getType() == Participant.ParticipantType.GUEST ||
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) { participant.getType() == Participant.ParticipantType.GUEST_MODERATOR) {
String displayName = NextcloudTalkApplication.Companion.getSharedApplication() String displayName = NextcloudTalkApplication.Companion.getSharedApplication()
.getResources().getString(R.string.nc_guest); .getResources().getString(R.string.nc_guest);

View File

@ -299,7 +299,7 @@ public class RestModule {
@Override @Override
public void run() { public void run() {
if (Proxy.Type.SOCKS.equals(Proxy.Type.valueOf(appPreferences.getProxyType()))) { if (Proxy.Type.valueOf(appPreferences.getProxyType()) == Proxy.Type.SOCKS) {
proxy = new Proxy(Proxy.Type.valueOf(appPreferences.getProxyType()), proxy = new Proxy(Proxy.Type.valueOf(appPreferences.getProxyType()),
InetSocketAddress.createUnresolved(appPreferences.getProxyHost(), Integer.parseInt( InetSocketAddress.createUnresolved(appPreferences.getProxyHost(), Integer.parseInt(
appPreferences.getProxyPort()))); appPreferences.getProxyPort())));

View File

@ -467,7 +467,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
@Subscribe(threadMode = ThreadMode.BACKGROUND) @Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(NetworkEvent networkEvent) { public void onMessageEvent(NetworkEvent networkEvent) {
if (networkEvent.getNetworkConnectionEvent().equals(NetworkEvent.NetworkConnectionEvent.NETWORK_CONNECTED) && !isConnected()) { if (networkEvent.getNetworkConnectionEvent() == NetworkEvent.NetworkConnectionEvent.NETWORK_CONNECTED && !isConnected()) {
restartWebSocket(); restartWebSocket();
} }
} }

View File

@ -276,7 +276,7 @@ public class PeerConnectionWrapper {
@Override @Override
public void onStateChange() { public void onStateChange() {
if (dataChannel != null && dataChannel.state().equals(DataChannel.State.OPEN) && if (dataChannel != null && dataChannel.state() == DataChannel.State.OPEN &&
dataChannel.label().equals("status")) { dataChannel.label().equals("status")) {
sendInitialMediaStatus(); sendInitialMediaStatus();
} }
@ -343,7 +343,7 @@ public class PeerConnectionWrapper {
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) { public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
Log.d("iceConnectionChangeTo: ", iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId); Log.d("iceConnectionChangeTo: ", iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) { if (iceConnectionState == PeerConnection.IceConnectionState.CONNECTED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED, EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
sessionId, null, null, null)); sessionId, null, null, null));
@ -354,18 +354,18 @@ public class PeerConnectionWrapper {
if (hasInitiated) { if (hasInitiated) {
sendInitialMediaStatus(); sendInitialMediaStatus();
} }
} else if (iceConnectionState.equals(PeerConnection.IceConnectionState.COMPLETED)) { } else if (iceConnectionState == PeerConnection.IceConnectionState.COMPLETED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED, EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
sessionId, null, null, null)); sessionId, null, null, null));
} else if (iceConnectionState.equals(PeerConnection.IceConnectionState.CLOSED)) { } else if (iceConnectionState == PeerConnection.IceConnectionState.CLOSED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
.PEER_CLOSED, sessionId, null, null, videoStreamType)); .PEER_CLOSED, sessionId, null, null, videoStreamType));
} else if (iceConnectionState.equals(PeerConnection.IceConnectionState.DISCONNECTED) || } else if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED ||
iceConnectionState.equals(PeerConnection.IceConnectionState.NEW) || iceConnectionState == PeerConnection.IceConnectionState.NEW ||
iceConnectionState.equals(PeerConnection.IceConnectionState.CHECKING)) { iceConnectionState == PeerConnection.IceConnectionState.CHECKING) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED, EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
sessionId, null, null, null)); sessionId, null, null, null));
} else if (iceConnectionState.equals(PeerConnection.IceConnectionState.FAILED)) { } else if (iceConnectionState == PeerConnection.IceConnectionState.FAILED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED, EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
sessionId, null, null, null)); sessionId, null, null, null));
if (isMCUPublisher) { if (isMCUPublisher) {
@ -469,7 +469,7 @@ public class PeerConnectionWrapper {
if (shouldNotReceiveVideo()) { if (shouldNotReceiveVideo()) {
for (RtpTransceiver t : peerConnection.getTransceivers()) { for (RtpTransceiver t : peerConnection.getTransceivers()) {
if (t.getMediaType().equals(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO)) { if (t.getMediaType() == MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO) {
t.stop(); t.stop();
} }
} }

View File

@ -129,7 +129,7 @@ public class WebRtcAudioManager {
return; return;
} }
if (userSelectedAudioDevice.equals(AudioDevice.SPEAKER_PHONE) if (userSelectedAudioDevice == AudioDevice.SPEAKER_PHONE
&& audioDevices.contains(AudioDevice.EARPIECE) && audioDevices.contains(AudioDevice.EARPIECE)
&& audioDevices.contains(AudioDevice.SPEAKER_PHONE)) { && audioDevices.contains(AudioDevice.SPEAKER_PHONE)) {