From 7a9c281a377d51e5ec906dfbcfff32cb8211a333 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 26 Nov 2024 13:35:01 +0100 Subject: [PATCH] reformat code Signed-off-by: Marcel Hibbe --- .../ConversationsListActivity.kt | 19 ++++++++++--------- .../talk/settings/SettingsActivity.kt | 15 ++++++++------- .../com/nextcloud/talk/utils/DrawableUtils.kt | 4 ++-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index bfc7bce2ccf..79c2185d0a9 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -775,9 +775,8 @@ class ConversationsListActivity : ) } - private fun hasActivityActionSendIntent(): Boolean { - return Intent.ACTION_SEND == intent.action || Intent.ACTION_SEND_MULTIPLE == intent.action - } + private fun hasActivityActionSendIntent(): Boolean = + Intent.ACTION_SEND == intent.action || Intent.ACTION_SEND_MULTIPLE == intent.action private fun showSearchView(searchView: SearchView?, searchItem: MenuItem?) { binding.conversationListAppbar.stateListAnimator = AnimatorInflater.loadStateListAnimator( @@ -1286,10 +1285,9 @@ class ConversationsListActivity : !participantPermissions.canIgnoreLobby() } - private fun isReadOnlyConversation(conversation: ConversationModel): Boolean { - return conversation.conversationReadOnlyState === + private fun isReadOnlyConversation(conversation: ConversationModel): Boolean = + conversation.conversationReadOnlyState === ConversationEnums.ConversationReadOnlyState.CONVERSATION_READ_ONLY - } private fun handleSharedData() { collectDataFromIntent() @@ -1514,7 +1512,7 @@ class ConversationsListActivity : } } - private fun shouldShowNotificationWarning() : Boolean { + private fun shouldShowNotificationWarning(): Boolean { val notificationPermissionNotGranted = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !platformPermissionUtil.isPostNotificationsPermissionGranted() val batteryOptimizationNotIgnored = !PowerManagerUtils().isIgnoringBatteryOptimizations() @@ -1525,8 +1523,11 @@ class ConversationsListActivity : val serverNotificationAppInstalled = userManager.currentUser.blockingGet().capabilities?.notificationsCapability?.features?.isNotEmpty() ?: false - val settingsOfUserAreWrong = notificationPermissionNotGranted || batteryOptimizationNotIgnored || - messagesChannelNotEnabled || callsChannelNotEnabled || !serverNotificationAppInstalled + val settingsOfUserAreWrong = notificationPermissionNotGranted || + batteryOptimizationNotIgnored || + messagesChannelNotEnabled || + callsChannelNotEnabled || + !serverNotificationAppInstalled val userWantsToBeNotifiedAboutWrongSettings = appPreferences.getShowNotificationWarning() diff --git a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt index 5ef8ffe5a72..06dd2e80f0d 100644 --- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt @@ -103,7 +103,9 @@ import javax.inject.Inject @Suppress("LargeClass", "TooManyFunctions") @AutoInjector(NextcloudTalkApplication::class) -class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNumberDialogClickListener { +class SettingsActivity : + BaseActivity(), + SetPhoneNumberDialogFragment.SetPhoneNumberDialogClickListener { private lateinit var binding: ActivitySettingsBinding @Inject @@ -351,7 +353,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu resources.getColor(R.color.nc_darkRed, null) ) - if (openedByNotificationWarning){ + if (openedByNotificationWarning) { DrawableUtils.blinkDrawable(binding.settingsNotificationsPermissionWrapper.background) } @@ -388,7 +390,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu ) binding.callsRingtone.text = resources!!.getString(R.string.nc_common_disabled) - if (openedByNotificationWarning){ + if (openedByNotificationWarning) { DrawableUtils.blinkDrawable(binding.settingsCallSound.background) } } @@ -403,7 +405,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu ) binding.messagesRingtone.text = resources!!.getString(R.string.nc_common_disabled) - if (openedByNotificationWarning){ + if (openedByNotificationWarning) { DrawableUtils.blinkDrawable(binding.settingsMessageSound.background) } } @@ -713,8 +715,8 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu startActivity(intent) } - private fun getRingtoneName(context: Context, ringtoneUri: Uri?): String { - return if (ringtoneUri == null) { + private fun getRingtoneName(context: Context, ringtoneUri: Uri?): String = + if (ringtoneUri == null) { resources!!.getString(R.string.nc_settings_no_ringtone) } else if ((NotificationUtils.DEFAULT_CALL_RINGTONE_URI == ringtoneUri.toString()) || (NotificationUtils.DEFAULT_MESSAGE_RINGTONE_URI == ringtoneUri.toString()) @@ -724,7 +726,6 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu val r = RingtoneManager.getRingtone(context, ringtoneUri) r.getTitle(context) } - } private fun themeSwitchPreferences() { binding.run { diff --git a/app/src/main/java/com/nextcloud/talk/utils/DrawableUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/DrawableUtils.kt index bd3ec84b3cd..827cb55b34f 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DrawableUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/DrawableUtils.kt @@ -162,7 +162,7 @@ object DrawableUtils { } } - @Suppress("MagicNumber") + @Suppress("MagicNumber", "TooGenericExceptionCaught") fun blinkDrawable(rippleView: Drawable) { try { (rippleView as RippleDrawable).let { rippleDrawable -> @@ -176,7 +176,7 @@ object DrawableUtils { } } } - } catch (e: Exception){ + } catch (e: Exception) { Log.e(TAG, "Failed to blink Drawable", e) } }