From 658043011b503e4532a73b951297052ce0985708 Mon Sep 17 00:00:00 2001 From: ThibaultBee Date: Tue, 26 Sep 2023 08:34:44 +0000 Subject: [PATCH] feat(java): add support from Android 21 (instead of 24) --- CHANGELOG.md | 3 +++ README.md | 6 +++--- build.gradle | 4 ++-- examples/service/build.gradle | 2 +- .../service/example/ReadStorePermissionManager.kt | 12 ++++++++++-- examples/workmanager/build.gradle | 2 +- .../work/example/ReadStorePermissionManager.kt | 12 ++++++++++-- maven-push.gradle | 4 ++-- pom.xml | 2 +- src/main/java/video/api/uploader/api/ApiClient.java | 2 +- .../api/notifications/NotificationExtensions.kt | 3 ++- 11 files changed, 36 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5aaedb..8a04d2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [1.3.2] - 2023-09-26 +- Extend Android minSdkVersion to 21 + ## [1.3.1] - 2023-08-22 - Fix cancellation of upload workers for the WorkManager API diff --git a/README.md b/README.md index f4bcaa0..37225eb 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Add this dependency to your project's POM: video.api android-video-uploader - 1.3.1 + 1.3.2 compile ``` @@ -59,7 +59,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -implementation "video.api:android-video-uploader:1.3.1" +implementation "video.api:android-video-uploader:1.3.2" ``` ### Others @@ -72,7 +72,7 @@ mvn clean package Then manually install the following JARs: -* `target/android-video-uploader-1.3.1.jar` +* `target/android-video-uploader-1.3.2.jar` * `target/lib/*.jar` ## Code sample diff --git a/build.gradle b/build.gradle index 91aa5d6..ea12e64 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'maven-publish' apply plugin: 'kotlin-android' group = 'video.api' -version = '1.3.1' +version = '1.3.2' buildscript { repositories { @@ -36,7 +36,7 @@ if(hasProperty('target') && target == 'android') { compileSdkVersion 33 buildToolsVersion '30.0.3' defaultConfig { - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 33 multiDexEnabled true diff --git a/examples/service/build.gradle b/examples/service/build.gradle index dbd89dd..864d312 100644 --- a/examples/service/build.gradle +++ b/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/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt b/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt index 627bcd0..42122c4 100644 --- a/examples/service/src/main/java/video/api/uploader/service/example/ReadStorePermissionManager.kt +++ b/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/examples/workmanager/build.gradle b/examples/workmanager/build.gradle index aaa9ded..301c25a 100644 --- a/examples/workmanager/build.gradle +++ b/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/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt b/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt index 4f58a60..6e34e76 100644 --- a/examples/workmanager/src/main/java/video/api/uploader/work/example/ReadStorePermissionManager.kt +++ b/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/maven-push.gradle b/maven-push.gradle index cd18fd4..a83eece 100644 --- a/maven-push.gradle +++ b/maven-push.gradle @@ -18,7 +18,7 @@ apply plugin: 'maven-publish' apply plugin: 'signing' def isReleaseBuild() { - return !"1.3.1".contains("SNAPSHOT") + return !"1.3.2".contains("SNAPSHOT") } def getReleaseRepositoryUrl() { @@ -47,7 +47,7 @@ afterEvaluate { project -> groupId = "video.api" artifactId = "android-video-uploader" - version = "1.3.1" + version = "1.3.2" pom { name = "video.api:android-video-uploader" diff --git a/pom.xml b/pom.xml index 02c5d0a..f895911 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ android-video-uploader jar ${project.groupId}:${project.artifactId} - 1.3.1 + 1.3.2 https://github.com/apivideo/api.video-android-uploader api.video Android API video uploader diff --git a/src/main/java/video/api/uploader/api/ApiClient.java b/src/main/java/video/api/uploader/api/ApiClient.java index 7d78432..ab870fd 100644 --- a/src/main/java/video/api/uploader/api/ApiClient.java +++ b/src/main/java/video/api/uploader/api/ApiClient.java @@ -118,7 +118,7 @@ private OkHttpClient initHttpClient(List interceptors) { private void init() { verifyingSsl = true; json = new JSON(); - addDefaultHeader("AV-Origin-Client", "android-uploader:1.3.1"); + addDefaultHeader("AV-Origin-Client", "android-uploader:1.3.2"); } private boolean isValid(String regex, String field) { diff --git a/src/main/java/video/api/uploader/api/notifications/NotificationExtensions.kt b/src/main/java/video/api/uploader/api/notifications/NotificationExtensions.kt index 84a54bf..e9c9a7e 100644 --- a/src/main/java/video/api/uploader/api/notifications/NotificationExtensions.kt +++ b/src/main/java/video/api/uploader/api/notifications/NotificationExtensions.kt @@ -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