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

View File

@ -145,8 +145,8 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
}
if (TextUtils.isEmpty(participant.getDisplayName()) &&
(participant.getType().equals(Participant.ParticipantType.GUEST) ||
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
(participant.getType() == Participant.ParticipantType.GUEST ||
participant.getType() == Participant.ParticipantType.USER_FOLLOWING_LINK)) {
holder.binding.nameText.setText(NextcloudTalkApplication
.Companion
.getSharedApplication()
@ -167,8 +167,8 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
} else if (
participant.getCalculatedActorType() == Participant.ActorType.GUESTS ||
Participant.ParticipantType.GUEST.equals(participant.getType()) ||
Participant.ParticipantType.GUEST_MODERATOR.equals(participant.getType())) {
participant.getType() == Participant.ParticipantType.GUEST ||
participant.getType() == Participant.ParticipantType.GUEST_MODERATOR) {
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) {
Drawable[] layers = new Drawable[2];

View File

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

View File

@ -299,7 +299,7 @@ public class RestModule {
@Override
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()),
InetSocketAddress.createUnresolved(appPreferences.getProxyHost(), Integer.parseInt(
appPreferences.getProxyPort())));

View File

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

View File

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

View File

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