ktlintFormat

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-11-20 16:05:35 +01:00
parent fc2ff534e9
commit d08167e3dd
No known key found for this signature in database
GPG key ID: F7AA2A8B65B50220
10 changed files with 96 additions and 114 deletions

View file

@ -33,13 +33,13 @@ class VibrationUtilsTest {
@Test @Test
fun testVibrateShort() { fun testVibrateShort() {
VibrationUtils.vibrateShort(mockContext) VibrationUtils.vibrateShort(mockContext)
Mockito.verify(mockVibrator) Mockito.verify(mockVibrator)
.vibrate( .vibrate(
VibrationEffect VibrationEffect
.createOneShot( .createOneShot(
VibrationUtils.SHORT_VIBRATE, VibrationUtils.SHORT_VIBRATE,
VibrationEffect.DEFAULT_AMPLITUDE VibrationEffect.DEFAULT_AMPLITUDE
) )
) )
} }
} }

View file

@ -166,10 +166,7 @@ class ContactItem(
} }
} }
private fun setGenericAvatar( private fun setGenericAvatar(holder: ContactItemViewHolder, roundPlaceholderDrawable: Int) {
holder: ContactItemViewHolder,
roundPlaceholderDrawable: Int
) {
val avatar = val avatar =
viewThemeUtils.talk.themePlaceholderAvatar( viewThemeUtils.talk.themePlaceholderAvatar(
holder.binding.avatarView, holder.binding.avatarView,

View file

@ -194,12 +194,12 @@ class ConversationItem(
} }
ConversationEnums.ObjectType.FILE -> { ConversationEnums.ObjectType.FILE -> {
holder.binding.dialogAvatar.loadUserAvatar( holder.binding.dialogAvatar.loadUserAvatar(
viewThemeUtils.talk.themePlaceholderAvatar( viewThemeUtils.talk.themePlaceholderAvatar(
holder.binding.dialogAvatar, holder.binding.dialogAvatar,
R.drawable.ic_avatar_document R.drawable.ic_avatar_document
)
) )
)
false false
} }

View file

@ -116,22 +116,22 @@ class MentionAutocompleteItem(
SOURCE_CALLS -> { SOURCE_CALLS -> {
run {} run {}
run { run {
holder.binding.avatarView.loadUserAvatar(
viewThemeUtils.talk.themePlaceholderAvatar(
holder.binding.avatarView,
R.drawable.ic_avatar_group
)
)
}
}
SOURCE_GROUPS -> {
holder.binding.avatarView.loadUserAvatar( holder.binding.avatarView.loadUserAvatar(
viewThemeUtils.talk.themePlaceholderAvatar( viewThemeUtils.talk.themePlaceholderAvatar(
holder.binding.avatarView, holder.binding.avatarView,
R.drawable.ic_avatar_group R.drawable.ic_avatar_group
) )
) )
}
}
SOURCE_GROUPS -> {
holder.binding.avatarView.loadUserAvatar(
viewThemeUtils.talk.themePlaceholderAvatar(
holder.binding.avatarView,
R.drawable.ic_avatar_group
)
)
} }
SOURCE_FEDERATION -> { SOURCE_FEDERATION -> {

View file

@ -206,11 +206,10 @@ fun ImageView.loadThumbnail(url: String, user: User): io.reactivex.disposables.D
.target(this) .target(this)
.transformations(CircleCropTransformation()) .transformations(CircleCropTransformation())
val layers = arrayOfNulls<Drawable>(2)
val layers = arrayOfNulls<Drawable>(2) layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background) layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground)
layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground) requestBuilder.placeholder(LayerDrawable(layers))
requestBuilder.placeholder(LayerDrawable(layers))
if (url.startsWith(user.baseUrl!!) && if (url.startsWith(user.baseUrl!!) &&
(url.contains("index.php/core/preview") || url.contains("/avatar/")) (url.contains("index.php/core/preview") || url.contains("/avatar/"))
@ -271,12 +270,11 @@ fun ImageView.loadUserAvatar(any: Any?): io.reactivex.disposables.Disposable {
} }
fun ImageView.loadSystemAvatar(): io.reactivex.disposables.Disposable { fun ImageView.loadSystemAvatar(): io.reactivex.disposables.Disposable {
val layers = arrayOfNulls<Drawable>(2)
val layers = arrayOfNulls<Drawable>(2) layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background) layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground)
layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground) val layerDrawable = LayerDrawable(layers)
val layerDrawable = LayerDrawable(layers) val data: Any = layerDrawable
val data: Any = layerDrawable
return DisposableWrapper( return DisposableWrapper(
load(data) { load(data) {
@ -286,13 +284,11 @@ fun ImageView.loadSystemAvatar(): io.reactivex.disposables.Disposable {
} }
fun ImageView.loadNoteToSelfAvatar(): io.reactivex.disposables.Disposable { fun ImageView.loadNoteToSelfAvatar(): io.reactivex.disposables.Disposable {
val layers = arrayOfNulls<Drawable>(2)
val layers = arrayOfNulls<Drawable>(2) layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)
layers[0] = ContextCompat.getDrawable(context, R.drawable.ic_launcher_background) layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_note_to_self)
layers[1] = ContextCompat.getDrawable(context, R.drawable.ic_note_to_self) val layerDrawable = LayerDrawable(layers)
val layerDrawable = LayerDrawable(layers) val data: Any = layerDrawable
val data: Any = layerDrawable
return DisposableWrapper( return DisposableWrapper(
load(data) { load(data) {
@ -306,12 +302,11 @@ fun ImageView.loadChangelogBotAvatar(): io.reactivex.disposables.Disposable {
} }
fun ImageView.loadBotsAvatar(): io.reactivex.disposables.Disposable { fun ImageView.loadBotsAvatar(): io.reactivex.disposables.Disposable {
val layers = arrayOfNulls<Drawable>(2)
val layers = arrayOfNulls<Drawable>(2) layers[0] = ColorDrawable(context.getColor(R.color.black))
layers[0] = ColorDrawable(context.getColor(R.color.black)) layers[1] = TextDrawable(context, ">")
layers[1] = TextDrawable(context, ">") val layerDrawable = LayerDrawable(layers)
val layerDrawable = LayerDrawable(layers) val data: Any = layerDrawable
val data: Any = layerDrawable
return DisposableWrapper( return DisposableWrapper(
load(data) { load(data) {

View file

@ -535,18 +535,18 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
notificationBuilder.setExtras(notificationInfoBundle) notificationBuilder.setExtras(notificationInfoBundle)
when (pushMessage.type) { when (pushMessage.type) {
TYPE_CHAT, TYPE_CHAT,
TYPE_ROOM, TYPE_ROOM,
TYPE_RECORDING, TYPE_RECORDING,
TYPE_REMINDER, TYPE_REMINDER,
TYPE_ADMIN_NOTIFICATIONS, TYPE_ADMIN_NOTIFICATIONS,
TYPE_REMOTE_TALK_SHARE -> { TYPE_REMOTE_TALK_SHARE -> {
notificationBuilder.setChannelId( notificationBuilder.setChannelId(
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name
) )
}
} }
}
notificationBuilder.setContentIntent(pendingIntent) notificationBuilder.setContentIntent(pendingIntent)
val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id

View file

@ -256,8 +256,8 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
private fun setupNotificationSettings() { private fun setupNotificationSettings() {
binding.settingsNotificationsTitle.text = resources!!.getString( binding.settingsNotificationsTitle.text = resources!!.getString(
R.string.nc_settings_notification_sounds_post_oreo R.string.nc_settings_notification_sounds_post_oreo
) )
setupNotificationSoundsSettings() setupNotificationSoundsSettings()
setupNotificationPermissionSettings() setupNotificationPermissionSettings()
} }
@ -359,26 +359,25 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
binding.messagesRingtone.text = resources!!.getString(R.string.nc_common_disabled) binding.messagesRingtone.text = resources!!.getString(R.string.nc_common_disabled)
} }
binding.settingsCallSound.setOnClickListener { binding.settingsCallSound.setOnClickListener {
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS) val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID) intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
intent.putExtra( intent.putExtra(
Settings.EXTRA_CHANNEL_ID, Settings.EXTRA_CHANNEL_ID,
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_CALLS_V4.name NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_CALLS_V4.name
) )
startActivity(intent)
}
binding.settingsMessageSound.setOnClickListener {
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
intent.putExtra(
Settings.EXTRA_CHANNEL_ID,
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name
)
startActivity(intent)
}
startActivity(intent)
}
binding.settingsMessageSound.setOnClickListener {
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
intent.putExtra(
Settings.EXTRA_CHANNEL_ID,
NotificationUtils.NotificationChannels.NOTIFICATION_CHANNEL_MESSAGES_V4.name
)
startActivity(intent)
}
} }
private fun setTroubleshootingClickListenersIfNecessary() { private fun setTroubleshootingClickListenersIfNecessary() {
@ -860,9 +859,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
private fun setupCheckables() { private fun setupCheckables() {
binding.settingsScreenSecuritySwitch.isChecked = appPreferences.isScreenSecured binding.settingsScreenSecuritySwitch.isChecked = appPreferences.isScreenSecured
binding.settingsIncognitoKeyboardSwitch.isChecked = appPreferences.isKeyboardIncognito
binding.settingsIncognitoKeyboardSwitch.isChecked = appPreferences.isKeyboardIncognito
if (CapabilitiesUtil.isReadStatusAvailable(currentUser!!.capabilities!!.spreedCapability!!)) { if (CapabilitiesUtil.isReadStatusAvailable(currentUser!!.capabilities!!.spreedCapability!!)) {
binding.settingsReadPrivacySwitch.isChecked = !CapabilitiesUtil.isReadStatusPrivate(currentUser!!) binding.settingsReadPrivacySwitch.isChecked = !CapabilitiesUtil.isReadStatusPrivate(currentUser!!)

View file

@ -99,8 +99,7 @@ object FileUtils {
val cachedFile = File(context.cacheDir, filename) val cachedFile = File(context.cacheDir, filename)
val aboveOrEqualAPI26Check = val aboveOrEqualAPI26Check =
!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath()) !cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())
val isOutsideCacheDir = aboveOrEqualAPI26Check val isOutsideCacheDir = aboveOrEqualAPI26Check

View file

@ -54,7 +54,6 @@ object NotificationUtils {
const val KEY_UPLOAD_GROUP = "com.nextcloud.talk.utils.KEY_UPLOAD_GROUP" const val KEY_UPLOAD_GROUP = "com.nextcloud.talk.utils.KEY_UPLOAD_GROUP"
const val GROUP_SUMMARY_NOTIFICATION_ID = -1 const val GROUP_SUMMARY_NOTIFICATION_ID = -1
private fun createNotificationChannel( private fun createNotificationChannel(
context: Context, context: Context,
notificationChannel: Channel, notificationChannel: Channel,
@ -151,29 +150,26 @@ object NotificationUtils {
} }
fun removeOldNotificationChannels(context: Context) { fun removeOldNotificationChannels(context: Context) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // Current version does not use notification channel groups - delete all groups
for (channelGroup in notificationManager.notificationChannelGroups) {
notificationManager.deleteNotificationChannelGroup(channelGroup.id)
}
// Current version does not use notification channel groups - delete all groups val channelsToKeep = NotificationChannels.values().map { it.name }
for (channelGroup in notificationManager.notificationChannelGroups) {
notificationManager.deleteNotificationChannelGroup(channelGroup.id) // Delete all notification channels created by previous versions
for (channel in notificationManager.notificationChannels) {
if (!channelsToKeep.contains(channel.id)) {
notificationManager.deleteNotificationChannel(channel.id)
} }
}
val channelsToKeep = NotificationChannels.values().map { it.name }
// Delete all notification channels created by previous versions
for (channel in notificationManager.notificationChannels) {
if (!channelsToKeep.contains(channel.id)) {
notificationManager.deleteNotificationChannel(channel.id)
}
}
} }
private fun getNotificationChannel(context: Context, channelId: String): NotificationChannel? { private fun getNotificationChannel(context: Context, channelId: String): NotificationChannel? {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
return notificationManager.getNotificationChannel(channelId) return notificationManager.getNotificationChannel(channelId)
} }
private inline fun scanNotifications( private inline fun scanNotifications(
@ -283,13 +279,12 @@ object NotificationUtils {
defaultRingtoneUri: String, defaultRingtoneUri: String,
channelId: String channelId: String
): Uri? { ): Uri? {
val channel = getNotificationChannel(context, channelId)
val channel = getNotificationChannel(context, channelId) if (channel != null) {
if (channel != null) { return channel.sound
return channel.sound }
} // Notification channel will not be available when starting the application for the first time.
// Notification channel will not be available when starting the application for the first time. // Ringtone uris are required to register the notification channels -> get uri from preferences.
// Ringtone uris are required to register the notification channels -> get uri from preferences.
return if (TextUtils.isEmpty(ringtonePreferencesString)) { return if (TextUtils.isEmpty(ringtonePreferencesString)) {
Uri.parse(defaultRingtoneUri) Uri.parse(defaultRingtoneUri)

View file

@ -7,7 +7,6 @@
package com.nextcloud.talk.utils package com.nextcloud.talk.utils
import android.content.Context import android.content.Context
import android.os.Build
import android.os.VibrationEffect import android.os.VibrationEffect
import android.os.Vibrator import android.os.Vibrator