diff --git a/templates/java/android/notifications/NotificationExtensions.mustache b/templates/java/android/notifications/NotificationExtensions.mustache index 607c63d1..5f211854 100644 --- a/templates/java/android/notifications/NotificationExtensions.mustache +++ b/templates/java/android/notifications/NotificationExtensions.mustache @@ -4,6 +4,7 @@ import android.content.Context import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.core.app.NotificationCompat +import androidx.core.content.ContextCompat fun NotificationCompat.Builder.setStyle( context: Context, @@ -11,5 +12,5 @@ fun NotificationCompat.Builder.setStyle( @ColorRes notificationColorResourceId: Int ): NotificationCompat.Builder = apply { setSmallIcon(notificationIconResourceId) - color = context.getColor(notificationColorResourceId) + color = ContextCompat.getColor(context, notificationColorResourceId) } \ No newline at end of file diff --git a/templates/java/libraries/okhttp-gson/build.gradle.mustache b/templates/java/libraries/okhttp-gson/build.gradle.mustache index a6eebbb6..1807015c 100644 --- a/templates/java/libraries/okhttp-gson/build.gradle.mustache +++ b/templates/java/libraries/okhttp-gson/build.gradle.mustache @@ -40,7 +40,7 @@ if(hasProperty('target') && target == 'android') { compileSdkVersion 33 buildToolsVersion '30.0.3' defaultConfig { - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 33 multiDexEnabled true diff --git a/templates/java/statics/android-uploader/examples/service/build.gradle b/templates/java/statics/android-uploader/examples/service/build.gradle index dbd89ddc..864d3121 100644 --- a/templates/java/statics/android-uploader/examples/service/build.gradle +++ b/templates/java/statics/android-uploader/examples/service/build.gradle @@ -8,7 +8,7 @@ android { defaultConfig { applicationId "video.api.uploader.service.example" - minSdk 24 + minSdk 21 targetSdk 33 versionCode 1 versionName "1.0" diff --git a/templates/java/statics/android-uploader/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt b/templates/java/statics/android-uploader/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt index 627bcd07..42122c4c 100644 --- a/templates/java/statics/android-uploader/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt +++ b/templates/java/statics/android-uploader/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt @@ -16,13 +16,21 @@ class ReadStorePermissionManager( } else { android.Manifest.permission.READ_EXTERNAL_STORAGE } + private val hasPermission: Boolean - get() = activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + } else { + true + } fun requestPermission() { if (hasPermission) { onGranted() } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + throw IllegalStateException("Permission should be granted") + } if (activity.shouldShowRequestPermissionRationale(requiredPermission)) { onShowPermissionRationale(requiredPermission) { requestPermission.launch(requiredPermission) @@ -41,4 +49,4 @@ class ReadStorePermissionManager( onDenied() } } -} \ No newline at end of file +} diff --git a/templates/java/statics/android-uploader/examples/workmanager/build.gradle b/templates/java/statics/android-uploader/examples/workmanager/build.gradle index aaa9dedc..301c25af 100644 --- a/templates/java/statics/android-uploader/examples/workmanager/build.gradle +++ b/templates/java/statics/android-uploader/examples/workmanager/build.gradle @@ -8,7 +8,7 @@ android { defaultConfig { applicationId "video.api.uploader.work.example" - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/templates/java/statics/android-uploader/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt b/templates/java/statics/android-uploader/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt index 4f58a600..6e34e760 100644 --- a/templates/java/statics/android-uploader/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt +++ b/templates/java/statics/android-uploader/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt @@ -16,13 +16,21 @@ class ReadStorePermissionManager( } else { android.Manifest.permission.READ_EXTERNAL_STORAGE } + private val hasPermission: Boolean - get() = activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + } else { + true + } fun requestPermission() { if (hasPermission) { onGranted() } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + throw IllegalStateException("Permission should be granted") + } if (activity.shouldShowRequestPermissionRationale(requiredPermission)) { onShowPermissionRationale(requiredPermission) { requestPermission.launch(requiredPermission) @@ -41,4 +49,4 @@ class ReadStorePermissionManager( onDenied() } } -} \ No newline at end of file +} diff --git a/templates/java/statics/android/examples/service/build.gradle b/templates/java/statics/android/examples/service/build.gradle index 70d8d42a..d69ab5eb 100644 --- a/templates/java/statics/android/examples/service/build.gradle +++ b/templates/java/statics/android/examples/service/build.gradle @@ -8,7 +8,7 @@ android { defaultConfig { applicationId "video.api.client.service.example" - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/templates/java/statics/android/examples/service/src/main/java/video/api/client/service/example/ReadStorePermissionManager.kt b/templates/java/statics/android/examples/service/src/main/java/video/api/client/service/example/ReadStorePermissionManager.kt index 91adf163..680eb8dc 100644 --- a/templates/java/statics/android/examples/service/src/main/java/video/api/client/service/example/ReadStorePermissionManager.kt +++ b/templates/java/statics/android/examples/service/src/main/java/video/api/client/service/example/ReadStorePermissionManager.kt @@ -16,13 +16,21 @@ class ReadStorePermissionManager( } else { android.Manifest.permission.READ_EXTERNAL_STORAGE } + private val hasPermission: Boolean - get() = activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + } else { + true + } fun requestPermission() { if (hasPermission) { onGranted() } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + throw IllegalStateException("Permission should be granted") + } if (activity.shouldShowRequestPermissionRationale(requiredPermission)) { onShowPermissionRationale(requiredPermission) { requestPermission.launch(requiredPermission) @@ -41,4 +49,4 @@ class ReadStorePermissionManager( onDenied() } } -} \ No newline at end of file +} diff --git a/templates/java/statics/android/examples/workmanager/build.gradle b/templates/java/statics/android/examples/workmanager/build.gradle index 7f976dab..cc355f88 100644 --- a/templates/java/statics/android/examples/workmanager/build.gradle +++ b/templates/java/statics/android/examples/workmanager/build.gradle @@ -8,7 +8,7 @@ android { defaultConfig { applicationId "video.api.client.work.example" - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/templates/java/statics/android/examples/workmanager/src/main/java/video/api/client/work/example/ReadStorePermissionManager.kt b/templates/java/statics/android/examples/workmanager/src/main/java/video/api/client/work/example/ReadStorePermissionManager.kt index b1430d55..92bae483 100644 --- a/templates/java/statics/android/examples/workmanager/src/main/java/video/api/client/work/example/ReadStorePermissionManager.kt +++ b/templates/java/statics/android/examples/workmanager/src/main/java/video/api/client/work/example/ReadStorePermissionManager.kt @@ -16,13 +16,21 @@ class ReadStorePermissionManager( } else { android.Manifest.permission.READ_EXTERNAL_STORAGE } + private val hasPermission: Boolean - get() = activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + activity.checkSelfPermission(requiredPermission) == PackageManager.PERMISSION_GRANTED + } else { + true + } fun requestPermission() { if (hasPermission) { onGranted() } else { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + throw IllegalStateException("Permission should be granted") + } if (activity.shouldShowRequestPermissionRationale(requiredPermission)) { onShowPermissionRationale(requiredPermission) { requestPermission.launch(requiredPermission) @@ -41,4 +49,4 @@ class ReadStorePermissionManager( onDenied() } } -} \ No newline at end of file +}