mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-02 20:53:09 +00:00
Reduce number of issues reported by detekt
Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
parent
a234c178a8
commit
b96bba47b5
@ -182,7 +182,9 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun cancelAllNotificationsForAccount(context: Context?, conversationUser: UserEntity) {
|
fun cancelAllNotificationsForAccount(context: Context?, conversationUser: UserEntity) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && conversationUser.id != -1L && context != null) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|
||||||
@ -198,12 +200,11 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun cancelExistingNotificationWithId(context: Context?, conversationUser: UserEntity, notificationId: Long?) {
|
fun cancelExistingNotificationWithId(context: Context?, conversationUser: UserEntity, notificationId: Long?) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && conversationUser.id != -1L &&
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
|
||||||
context != null
|
return
|
||||||
) {
|
}
|
||||||
|
|
||||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|
||||||
@ -222,16 +223,15 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun findNotificationForRoom(
|
fun findNotificationForRoom(
|
||||||
context: Context?,
|
context: Context?,
|
||||||
conversationUser: UserEntity,
|
conversationUser: UserEntity,
|
||||||
roomTokenOrId: String
|
roomTokenOrId: String
|
||||||
): StatusBarNotification? {
|
): StatusBarNotification? {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && conversationUser.id != -1L &&
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
|
||||||
context != null
|
return null
|
||||||
) {
|
}
|
||||||
|
|
||||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|
||||||
@ -249,7 +249,6 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -259,11 +258,9 @@ object NotificationUtils {
|
|||||||
conversationUser: UserEntity,
|
conversationUser: UserEntity,
|
||||||
roomTokenOrId: String
|
roomTokenOrId: String
|
||||||
) {
|
) {
|
||||||
if (
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || conversationUser.id == -1L || context == null) {
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
return
|
||||||
conversationUser.id != -1L &&
|
}
|
||||||
context != null
|
|
||||||
) {
|
|
||||||
|
|
||||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|
||||||
@ -281,7 +278,6 @@ object NotificationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun getRingtoneUri(
|
private fun getRingtoneUri(
|
||||||
context: Context,
|
context: Context,
|
||||||
@ -297,15 +293,15 @@ object NotificationUtils {
|
|||||||
// 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.
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(ringtonePreferencesString)) {
|
return if (TextUtils.isEmpty(ringtonePreferencesString)) {
|
||||||
return Uri.parse(defaultRingtoneUri)
|
Uri.parse(defaultRingtoneUri)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
val ringtoneSettings =
|
val ringtoneSettings =
|
||||||
LoganSquare.parse(ringtonePreferencesString, RingtoneSettings::class.java)
|
LoganSquare.parse(ringtonePreferencesString, RingtoneSettings::class.java)
|
||||||
return ringtoneSettings.ringtoneUri
|
ringtoneSettings.ringtoneUri
|
||||||
} catch (exception: IOException) {
|
} catch (exception: IOException) {
|
||||||
return Uri.parse(defaultRingtoneUri)
|
Uri.parse(defaultRingtoneUri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user