From 6bbc7dd84af860757e29a10a16347c971ff48ef9 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger <info@andy-scherzinger.de> Date: Wed, 7 Apr 2021 17:10:56 +0200 Subject: [PATCH] spotbugs: remove unused code, replace multiple strings with constants Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de> --- .../talk/jobs/NotificationWorker.java | 10 ++++++---- .../nextcloud/talk/utils/DisplayUtils.java | 20 ------------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index 240915f61..12362217c 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -107,6 +107,8 @@ import retrofit2.Retrofit; @AutoInjector(NextcloudTalkApplication.class) public class NotificationWorker extends Worker { public static final String TAG = "NotificationWorker"; + private static final String CHAT = "chat"; + private static final String ROOM = "room"; @Inject AppPreferences appPreferences; @@ -274,7 +276,7 @@ public class NotificationWorker extends Worker { smallIcon = R.drawable.ic_logo; - if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) { + if (CHAT.equals(decryptedPushMessage.getType()) || ROOM.equals(decryptedPushMessage.getType())) { category = Notification.CATEGORY_MESSAGE; } else { category = Notification.CATEGORY_CALL; @@ -289,7 +291,7 @@ public class NotificationWorker extends Worker { break; default: // assuming one2one - if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) { + if (CHAT.equals(decryptedPushMessage.getType()) || ROOM.equals(decryptedPushMessage.getType())) { largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_comment); } else { largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_call_black_24dp); @@ -339,7 +341,7 @@ public class NotificationWorker extends Worker { Long.toString(crc32.getValue()), groupName);*/ - if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) { + if (CHAT.equals(decryptedPushMessage.getType()) || ROOM.equals(decryptedPushMessage.getType())) { AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder().setContentType (AudioAttributes.CONTENT_TYPE_SONIFICATION); audioAttributesBuilder.setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT); @@ -517,7 +519,7 @@ public class NotificationWorker extends Worker { AudioAttributes.Builder audioAttributesBuilder = new AudioAttributes.Builder().setContentType (AudioAttributes.CONTENT_TYPE_SONIFICATION); - if (decryptedPushMessage.getType().equals("chat") || decryptedPushMessage.getType().equals("room")) { + if (CHAT.equals(decryptedPushMessage.getType()) || ROOM.equals(decryptedPushMessage.getType())) { audioAttributesBuilder.setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT); } else { audioAttributesBuilder.setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST); diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index 12d007c89..a0b1fc9da 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -318,7 +318,6 @@ public class DisplayUtils { return chip; } - public static Spannable searchAndReplaceWithMentionSpan(Context context, Spannable text, String id, String label, String type, UserEntity conversationUser, @@ -355,7 +354,6 @@ public class DisplayUtils { } return spannableString; - } public static Spannable searchAndColor(Spannable text, String searchText, @ColorInt int color) { @@ -469,26 +467,8 @@ public class DisplayUtils { */ public static void themeSearchView(SearchView searchView, Context context) { // hacky as no default way is provided - int fontColor = context.getResources().getColor(R.color.fontAppbar); SearchView.SearchAutoComplete editText = searchView.findViewById(R.id.search_src_text); editText.setTextSize(16); editText.setHintTextColor(context.getResources().getColor(R.color.fontSecondaryAppbar)); } - - public static boolean isDarkModeActive(Context context, AppPreferences prefs) { - if (prefs.getTheme().equals("night_yes")) { - return true; - } - - int currentNightMode = - context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - switch (currentNightMode) { - case Configuration.UI_MODE_NIGHT_NO: - return false; - case Configuration.UI_MODE_NIGHT_YES: - return true; - default: - return false; - } - } }