From e197d3586f45d472dde0bf72d6a35cba748ae11e Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 03:56:11 +0000 Subject: [PATCH] Switch order of literals to prevent NullPointerException --- app/src/androidTest/java/com/owncloud/android/AbstractIT.java | 4 ++-- app/src/androidTest/java/com/owncloud/android/UploadIT.java | 2 +- .../android/operations/CreateShareWithShareeOperation.java | 2 +- .../java/third_parties/sufficientlysecure/CalendarSource.java | 4 ++-- .../java/third_parties/sufficientlysecure/ProcessVEvent.java | 2 +- .../java/third_parties/sufficientlysecure/SaveCalendar.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/com/owncloud/android/AbstractIT.java b/app/src/androidTest/java/com/owncloud/android/AbstractIT.java index 52669efd1833..487d2f404c7b 100644 --- a/app/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/app/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -178,7 +178,7 @@ public static void beforeAll() { String darkModeParameter = arguments.getString("DARKMODE"); if (darkModeParameter != null) { - if (darkModeParameter.equalsIgnoreCase("dark")) { + if ("dark".equalsIgnoreCase(darkModeParameter)) { DARK_MODE = "dark"; AppPreferencesImpl.fromContext(targetContext).setDarkThemeMode(DarkMode.DARK); MainApp.setAppTheme(DarkMode.DARK); @@ -187,7 +187,7 @@ public static void beforeAll() { } } - if (DARK_MODE.equalsIgnoreCase("light") && COLOR.equalsIgnoreCase("blue")) { + if ("light".equalsIgnoreCase(DARK_MODE) && "blue".equalsIgnoreCase(COLOR)) { // use already existing names DARK_MODE = ""; COLOR = ""; diff --git a/app/src/androidTest/java/com/owncloud/android/UploadIT.java b/app/src/androidTest/java/com/owncloud/android/UploadIT.java index 087156796a15..22e28428dbd0 100644 --- a/app/src/androidTest/java/com/owncloud/android/UploadIT.java +++ b/app/src/androidTest/java/com/owncloud/android/UploadIT.java @@ -512,7 +512,7 @@ public void testMetadata() throws IOException, AccountUtils.AccountNotFoundExcep OCFile ocFile = null; for (OCFile f : files) { - if (f.getFileName().equals("metadata.jpg")) { + if ("metadata.jpg".equals(f.getFileName())) { ocFile = f; break; } diff --git a/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java b/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java index 71a348d64b69..c1140453a981 100644 --- a/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/CreateShareWithShareeOperation.java @@ -136,7 +136,7 @@ protected RemoteOperationResult run(OwnCloudClient client) { try { String publicKey = EncryptionUtils.getPublicKey(user, shareeName, arbitraryDataProvider); - if (publicKey.equals("")) { + if ("".equals(publicKey)) { NextcloudClient nextcloudClient = new ClientFactoryImpl(context).createNextcloudClient(user); RemoteOperationResult result = new GetPublicKeyRemoteOperation(shareeName).execute(nextcloudClient); if (result.isSuccess()) { diff --git a/app/src/main/java/third_parties/sufficientlysecure/CalendarSource.java b/app/src/main/java/third_parties/sufficientlysecure/CalendarSource.java index e9f2b5871485..479e11877d18 100644 --- a/app/src/main/java/third_parties/sufficientlysecure/CalendarSource.java +++ b/app/src/main/java/third_parties/sufficientlysecure/CalendarSource.java @@ -65,13 +65,13 @@ public URLConnection getConnection() throws IOException { String protocol = mUrl.getProtocol(); String userPass = mUsername + ":" + mPassword; - if (protocol.equalsIgnoreCase("ftp") || protocol.equalsIgnoreCase("ftps")) { + if ("ftp".equalsIgnoreCase(protocol) || "ftps".equalsIgnoreCase(protocol)) { String external = mUrl.toExternalForm(); String end = external.substring(protocol.length() + HTTP_SEP.length()); return new URL(protocol + HTTP_SEP + userPass + "@" + end).openConnection(); } - if (protocol.equalsIgnoreCase("http") || protocol.equalsIgnoreCase("https")) { + if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) { String encoded = new String(new Base64().encode(userPass.getBytes("UTF-8"))); URLConnection connection = mUrl.openConnection(); connection.setRequestProperty("Authorization", "Basic " + encoded); diff --git a/app/src/main/java/third_parties/sufficientlysecure/ProcessVEvent.java b/app/src/main/java/third_parties/sufficientlysecure/ProcessVEvent.java index 249e62c49304..f32b6f610a07 100644 --- a/app/src/main/java/third_parties/sufficientlysecure/ProcessVEvent.java +++ b/app/src/main/java/third_parties/sufficientlysecure/ProcessVEvent.java @@ -578,7 +578,7 @@ private void checkTestValue(VEvent e, ContentValues c, String keyValue, String t String expected = parts.length > 1 ? parts[1] : ""; String got = c.getAsString(key); - if (expected.equals("") && got != null) { + if ("".equals(expected) && got != null) { got = ""; // Sentinel for testing present and non-null } if (got == null) { diff --git a/app/src/main/java/third_parties/sufficientlysecure/SaveCalendar.java b/app/src/main/java/third_parties/sufficientlysecure/SaveCalendar.java index 29586740ad4b..3723e1c06d47 100644 --- a/app/src/main/java/third_parties/sufficientlysecure/SaveCalendar.java +++ b/app/src/main/java/third_parties/sufficientlysecure/SaveCalendar.java @@ -504,7 +504,7 @@ private boolean isUtcTimeZone(final String tz) { return true; } final String utz = tz.toUpperCase(Locale.US); - return utz.equals("UTC") || utz.equals("UTC-0") || utz.equals("UTC+0") || utz.endsWith("/UTC"); + return "UTC".equals(utz) || "UTC-0".equals(utz) || "UTC+0".equals(utz) || utz.endsWith("/UTC"); } private Date getDateTime(Cursor cur, String dbName, String dbTzName, Calendar cal) {