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
fun testVibrateShort() {
VibrationUtils.vibrateShort(mockContext)
Mockito.verify(mockVibrator)
.vibrate(
VibrationEffect
.createOneShot(
VibrationUtils.SHORT_VIBRATE,
VibrationEffect.DEFAULT_AMPLITUDE
)
)
Mockito.verify(mockVibrator)
.vibrate(
VibrationEffect
.createOneShot(
VibrationUtils.SHORT_VIBRATE,
VibrationEffect.DEFAULT_AMPLITUDE
)
)
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -256,8 +256,8 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
private fun setupNotificationSettings() {
binding.settingsNotificationsTitle.text = resources!!.getString(
R.string.nc_settings_notification_sounds_post_oreo
)
R.string.nc_settings_notification_sounds_post_oreo
)
setupNotificationSoundsSettings()
setupNotificationPermissionSettings()
}
@ -359,26 +359,25 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
binding.messagesRingtone.text = resources!!.getString(R.string.nc_common_disabled)
}
binding.settingsCallSound.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_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)
}
binding.settingsCallSound.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_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)
}
}
private fun setTroubleshootingClickListenersIfNecessary() {
@ -860,9 +859,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
private fun setupCheckables() {
binding.settingsScreenSecuritySwitch.isChecked = appPreferences.isScreenSecured
binding.settingsIncognitoKeyboardSwitch.isChecked = appPreferences.isKeyboardIncognito
binding.settingsIncognitoKeyboardSwitch.isChecked = appPreferences.isKeyboardIncognito
if (CapabilitiesUtil.isReadStatusAvailable(currentUser!!.capabilities!!.spreedCapability!!)) {
binding.settingsReadPrivacySwitch.isChecked = !CapabilitiesUtil.isReadStatusPrivate(currentUser!!)

View file

@ -99,8 +99,7 @@ object FileUtils {
val cachedFile = File(context.cacheDir, filename)
val aboveOrEqualAPI26Check =
!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())
!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())
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 GROUP_SUMMARY_NOTIFICATION_ID = -1
private fun createNotificationChannel(
context: Context,
notificationChannel: Channel,
@ -151,29 +150,26 @@ object NotificationUtils {
}
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
for (channelGroup in notificationManager.notificationChannelGroups) {
notificationManager.deleteNotificationChannelGroup(channelGroup.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)
}
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? {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
return notificationManager.getNotificationChannel(channelId)
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
return notificationManager.getNotificationChannel(channelId)
}
private inline fun scanNotifications(
@ -283,13 +279,12 @@ object NotificationUtils {
defaultRingtoneUri: String,
channelId: String
): Uri? {
val channel = getNotificationChannel(context, channelId)
if (channel != null) {
return channel.sound
}
// 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.
val channel = getNotificationChannel(context, channelId)
if (channel != null) {
return channel.sound
}
// 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.
return if (TextUtils.isEmpty(ringtonePreferencesString)) {
Uri.parse(defaultRingtoneUri)

View file

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