Add @ChecksSdkIntAtLeast
annotation.
This commit is contained in:
parent
1ff4a5f212
commit
bb2eb56ee6
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.api.util
|
package org.matrix.android.sdk.api.util
|
||||||
|
|
||||||
|
import androidx.annotation.ChecksSdkIntAtLeast
|
||||||
|
|
||||||
interface BuildVersionSdkIntProvider {
|
interface BuildVersionSdkIntProvider {
|
||||||
/**
|
/**
|
||||||
* Return the current version of the Android SDK.
|
* Return the current version of the Android SDK.
|
||||||
@ -26,6 +28,7 @@ interface BuildVersionSdkIntProvider {
|
|||||||
* Checks the if the current OS version is equal or greater than [version].
|
* Checks the if the current OS version is equal or greater than [version].
|
||||||
* @return A `non-null` result if true, `null` otherwise.
|
* @return A `non-null` result if true, `null` otherwise.
|
||||||
*/
|
*/
|
||||||
|
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
|
||||||
fun <T> whenAtLeast(version: Int, result: () -> T): T? {
|
fun <T> whenAtLeast(version: Int, result: () -> T): T? {
|
||||||
return if (get() >= version) {
|
return if (get() >= version) {
|
||||||
result()
|
result()
|
||||||
|
@ -20,6 +20,7 @@ import android.content.Context
|
|||||||
import android.content.pm.ShortcutInfo
|
import android.content.pm.ShortcutInfo
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.annotation.ChecksSdkIntAtLeast
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.core.content.pm.ShortcutInfoCompat
|
import androidx.core.content.pm.ShortcutInfoCompat
|
||||||
import androidx.core.content.pm.ShortcutManagerCompat
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
@ -32,6 +33,7 @@ import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
|||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
||||||
private val useAdaptiveIcon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
private val useAdaptiveIcon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
private const val adaptiveIconSizeDp = 108
|
private const val adaptiveIconSizeDp = 108
|
||||||
private const val adaptiveIconOuterSidesDp = 18
|
private const val adaptiveIconOuterSidesDp = 18
|
||||||
|
@ -34,6 +34,7 @@ import android.text.Spannable
|
|||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.ChecksSdkIntAtLeast
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
@ -102,6 +103,7 @@ class NotificationUtils @Inject constructor(
|
|||||||
const val SILENT_NOTIFICATION_CHANNEL_ID = "DEFAULT_SILENT_NOTIFICATION_CHANNEL_ID_V2"
|
const val SILENT_NOTIFICATION_CHANNEL_ID = "DEFAULT_SILENT_NOTIFICATION_CHANNEL_ID_V2"
|
||||||
private const val CALL_NOTIFICATION_CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL_ID_V2"
|
private const val CALL_NOTIFICATION_CHANNEL_ID = "CALL_NOTIFICATION_CHANNEL_ID_V2"
|
||||||
|
|
||||||
|
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
|
||||||
fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
fun supportNotificationChannels() = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
|
|
||||||
fun openSystemSettingsForSilentCategory(fragment: Fragment) {
|
fun openSystemSettingsForSilentCategory(fragment: Fragment) {
|
||||||
@ -126,7 +128,6 @@ class NotificationUtils @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* Create notification channels.
|
* Create notification channels.
|
||||||
*/
|
*/
|
||||||
@TargetApi(Build.VERSION_CODES.O)
|
|
||||||
fun createNotificationChannels() {
|
fun createNotificationChannels() {
|
||||||
if (!supportNotificationChannels()) {
|
if (!supportNotificationChannels()) {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user