Răsfoiți Sursa

Spotbugs: literal string comparison

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 ani în urmă
părinte
comite
ff3dffd051

+ 1 - 1
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -367,7 +367,7 @@ public class CallActivity extends CallBaseActivity {
 
         powerManagerUtils = new PowerManagerUtils();
 
-        if (extras.getString("state", "").equalsIgnoreCase("resume")) {
+        if ("resume".equalsIgnoreCase(extras.getString("state", ""))) {
             setCallState(CallStatus.IN_CONVERSATION);
         } else {
             setCallState(CallStatus.CONNECTING);

+ 10 - 4
app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.java

@@ -154,8 +154,11 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
             participant.getType() == Participant.ParticipantType.GUEST ||
             participant.getType() == Participant.ParticipantType.GUEST_MODERATOR) {
 
-            String displayName = NextcloudTalkApplication.Companion.getSharedApplication()
-                .getResources().getString(R.string.nc_guest);
+            String displayName = NextcloudTalkApplication
+                .Companion
+                .getSharedApplication()
+                .getResources()
+                .getString(R.string.nc_guest);
 
             if (!TextUtils.isEmpty(participant.getDisplayName())) {
                 displayName = participant.getDisplayName();
@@ -164,8 +167,11 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
             ImageViewExtensionsKt.loadGuestAvatar(holder.binding.avatarView, user, displayName, false);
 
         } else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
-            participant.getSource().equals("users")) {
-            ImageViewExtensionsKt.loadAvatar(holder.binding.avatarView, user, participant.getCalculatedActorId(), true);
+            "users".equals(participant.getSource())) {
+            ImageViewExtensionsKt.loadAvatar(holder.binding.avatarView,
+                                             user,
+                                             participant.getCalculatedActorId(),
+                                             true);
         }
 
         Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();

+ 3 - 6
app/src/main/java/com/nextcloud/talk/utils/AuthenticatorService.java

@@ -62,8 +62,7 @@ public class AuthenticatorService extends Service {
         }
 
         @Override
-        public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
-                throws NetworkErrorException {
+        public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
             return null;
         }
 
@@ -73,8 +72,7 @@ public class AuthenticatorService extends Service {
         }
 
         @Override
-        public Bundle hasFeatures(AccountAuthenticatorResponse response,
-                                  Account account, String[] features) {
+        public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) {
             return null;
         }
 
@@ -82,7 +80,6 @@ public class AuthenticatorService extends Service {
         public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) {
             return null;
         }
-
     }
 
     protected Authenticator getAuthenticator() {
@@ -95,7 +92,7 @@ public class AuthenticatorService extends Service {
 
     @Override
     public IBinder onBind(Intent intent) {
-        if (intent.getAction().equals(AccountManager.ACTION_AUTHENTICATOR_INTENT)) {
+        if (AccountManager.ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) {
             return getAuthenticator().getIBinder();
         } else {
             return null;

+ 8 - 5
app/src/main/java/com/nextcloud/talk/utils/DeviceUtils.java

@@ -35,14 +35,17 @@ public class DeviceUtils {
     private static final String TAG = "DeviceUtils";
 
     public static void ignoreSpecialBatteryFeatures() {
-        if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi") || Build.MANUFACTURER.equalsIgnoreCase("meizu")) {
+        if ("xiaomi".equalsIgnoreCase(Build.MANUFACTURER) || "meizu".equalsIgnoreCase(Build.MANUFACTURER)) {
             try {
                 @SuppressLint("PrivateApi") Class<?> appOpsUtilsClass = Class.forName("android.miui.AppOpsUtils");
                 if (appOpsUtilsClass != null) {
                     Method setApplicationAutoStartMethod = appOpsUtilsClass.getMethod("setApplicationAutoStart", Context
                             .class, String.class, Boolean.TYPE);
                     if (setApplicationAutoStartMethod != null) {
-                        Context applicationContext = NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext();
+                        Context applicationContext = NextcloudTalkApplication
+                            .Companion
+                            .getSharedApplication()
+                            .getApplicationContext();
                         setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext
                                 .getPackageName(), Boolean.TRUE);
                     }
@@ -56,10 +59,10 @@ public class DeviceUtils {
             } catch (InvocationTargetException e) {
                 Log.e(TAG, "InvocationTargetException");
             }
-        } else if (Build.MANUFACTURER.equalsIgnoreCase("huawei")) {
+        } else if ("huawei".equalsIgnoreCase(Build.MANUFACTURER)) {
             try {
-                @SuppressLint("PrivateApi") Class<?> protectAppControlClass = Class.forName("com.huawei.systemmanager.optimize.process" +
-                        ".ProtectAppControl");
+                @SuppressLint("PrivateApi") Class<?> protectAppControlClass = Class.forName(
+                    "com.huawei.systemmanager.optimize.process.ProtectAppControl");
                 if (protectAppControlClass != null) {
                     Context applicationContext = NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext();
 

+ 7 - 7
app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java

@@ -78,7 +78,7 @@ public class DatabaseStorageModule implements StorageModule {
 
     @Override
     public void saveBoolean(String key, boolean value) {
-        if (key.equals("call_notifications")) {
+        if ("call_notifications".equals(key)) {
             int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4});
             ncApi.notificationCalls(ApiUtils.getCredentials(conversationUser.getUsername(),
                                                             conversationUser.getToken()),
@@ -112,7 +112,7 @@ public class DatabaseStorageModule implements StorageModule {
                           );
         }
 
-        if (!key.equals("conversation_lobby")) {
+        if (!"conversation_lobby".equals(key)) {
             arbitraryStorageManager.storeStorageSetting(accountIdentifier,
                                                         key,
                                                         Boolean.toString(value),
@@ -124,7 +124,7 @@ public class DatabaseStorageModule implements StorageModule {
 
     @Override
     public void saveString(String key, String value) {
-        if (key.equals("message_expire_key")) {
+        if ("message_expire_key".equals(key)) {
             int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4});
 
             String trimmedValue = value.replace("expire_", "");
@@ -163,7 +163,7 @@ public class DatabaseStorageModule implements StorageModule {
                     }
                 });
 
-        } else if (key.equals("message_notification_level")) {
+        } else if ("message_notification_level".equals(key)) {
             if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "notification-levels")) {
                 if (!TextUtils.isEmpty(messageNotificationLevel) && !messageNotificationLevel.equals(value)) {
                     int intValue;
@@ -232,7 +232,7 @@ public class DatabaseStorageModule implements StorageModule {
 
     @Override
     public boolean getBoolean(String key, boolean defaultVal) {
-        if (key.equals("conversation_lobby")) {
+        if ("conversation_lobby".equals(key)) {
             return lobbyValue;
         } else {
             return arbitraryStorageManager
@@ -244,7 +244,7 @@ public class DatabaseStorageModule implements StorageModule {
 
     @Override
     public String getString(String key, String defaultVal) {
-        if (key.equals("message_expire_key")) {
+        if ("message_expire_key".equals(key)) {
             switch (messageExpiration) {
                 case 2419200:
                     return "expire_2419200";
@@ -259,7 +259,7 @@ public class DatabaseStorageModule implements StorageModule {
                 default:
                     return "expire_0";
             }
-        } else if (key.equals("message_notification_level")) {
+        } else if ("message_notification_level".equals(key)) {
             return messageNotificationLevel;
         } else {
             return arbitraryStorageManager

+ 5 - 4
app/src/main/java/com/nextcloud/talk/webrtc/PeerConnectionWrapper.java

@@ -171,7 +171,7 @@ public class PeerConnectionWrapper {
                 dataChannel.registerObserver(new MagicDataChannelObserver());
                 if (isMCUPublisher) {
                     peerConnection.createOffer(magicSdpObserver, mediaConstraints);
-                } else if (hasMCU && this.videoStreamType.equals("video")) {
+                } else if (hasMCU && "video".equals(this.videoStreamType)) {
                     // If the connection type is "screen" the client sharing the screen will send an
                     // offer; offers should be requested only for videos.
                     // "to" property is not actually needed in the "requestoffer" signaling message, but it is used to
@@ -360,8 +360,9 @@ public class PeerConnectionWrapper {
 
         @Override
         public void onStateChange() {
-            if (dataChannel != null && dataChannel.state() == DataChannel.State.OPEN &&
-                    dataChannel.label().equals("status")) {
+            if (dataChannel != null &&
+                dataChannel.state() == DataChannel.State.OPEN &&
+                "status".equals(dataChannel.label())) {
                 sendInitialMediaStatus();
             }
         }
@@ -493,7 +494,7 @@ public class PeerConnectionWrapper {
 
         @Override
         public void onDataChannel(DataChannel dataChannel) {
-            if (dataChannel.label().equals("status") || dataChannel.label().equals("JanusDataChannel")) {
+            if ("status".equals(dataChannel.label()) || "JanusDataChannel".equals(dataChannel.label())) {
                 PeerConnectionWrapper.this.dataChannel = dataChannel;
                 PeerConnectionWrapper.this.dataChannel.registerObserver(new MagicDataChannelObserver());
             }

+ 7 - 5
app/src/main/java/com/nextcloud/talk/webrtc/WebRtcBluetoothManager.java

@@ -109,8 +109,6 @@ public class WebRtcBluetoothManager {
         return bluetoothState;
     }
 
-    ;
-
     /**
      * Activates components required to detect Bluetooth devices and to enable
      * BT SCO (audio is routed via BT SCO) for the headset profile. The end
@@ -502,8 +500,10 @@ public class WebRtcBluetoothManager {
             Log.d(TAG, "onServiceConnected done: BT state=" + bluetoothState);
         }
 
+        /**
+         * Notifies the client when the proxy object has been disconnected from the service.
+         */
         @Override
-        /** Notifies the client when the proxy object has been disconnected from the service. */
         public void onServiceDisconnected(int profile) {
             if (profile != BluetoothProfile.HEADSET || bluetoothState == State.UNINITIALIZED) {
                 return;
@@ -531,7 +531,7 @@ public class WebRtcBluetoothManager {
             // change does not tell us anything about whether we're streaming
             // audio to BT over SCO. Typically received when user turns on a BT
             // headset while audio is active using another audio device.
-            if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
+            if (BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {
                 final int state =
                         intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_DISCONNECTED);
                 Log.d(TAG, "BluetoothHeadsetBroadcastReceiver.onReceive: "
@@ -543,8 +543,10 @@ public class WebRtcBluetoothManager {
                     scoConnectionAttempts = 0;
                     updateAudioDeviceState();
                 } else if (state == BluetoothHeadset.STATE_CONNECTING) {
+                    Log.d(TAG, "+++ Bluetooth is connecting...");
                     // No action needed.
                 } else if (state == BluetoothHeadset.STATE_DISCONNECTING) {
+                    Log.d(TAG, "+++ Bluetooth is disconnecting...");
                     // No action needed.
                 } else if (state == BluetoothHeadset.STATE_DISCONNECTED) {
                     // Bluetooth is probably powered off during the call.
@@ -553,7 +555,7 @@ public class WebRtcBluetoothManager {
                 }
                 // Change in the audio (SCO) connection state of the Headset profile.
                 // Typically received after call to startScoAudio() has finalized.
-            } else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
+            } else if (BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED.equals(action)) {
                 final int state = intent.getIntExtra(
                         BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
                 Log.d(TAG, "BluetoothHeadsetBroadcastReceiver.onReceive: "