Skip to content

Commit

Permalink
Merge pull request #87 from apivideo/feature/android_21_support
Browse files Browse the repository at this point in the history
feat(java): add support from Android 21 (instead of 24)
  • Loading branch information
bot-api-video authored Sep 26, 2023
2 parents 991d321 + 93cafd7 commit b9c82bd
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [1.5.2] - 2023-09-26
- Extend Android minSdkVersion to 21

## [1.5.1] - 2023-08-22
- Fix cancellation of upload workers for the WorkManager API

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>video.api</groupId>
<artifactId>android-api-client</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -67,7 +67,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:

```groovy
implementation "video.api:android-api-client:1.5.1"
implementation "video.api:android-api-client:1.5.2"
```

### Others
Expand All @@ -80,7 +80,7 @@ mvn clean package

Then manually install the following JARs:

* `target/android-api-client-1.5.1.jar`
* `target/android-api-client-1.5.2.jar`
* `target/lib/*.jar`

## Code sample
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'maven-publish'
apply plugin: 'kotlin-android'

group = 'video.api'
version = '1.5.1'
version = '1.5.2'

buildscript {
repositories {
Expand Down Expand Up @@ -36,7 +36,7 @@ if(hasProperty('target') && target == 'android') {
compileSdkVersion 33
buildToolsVersion '30.0.3'
defaultConfig {
minSdkVersion 24
minSdkVersion 21
targetSdkVersion 33
multiDexEnabled true

Expand Down
2 changes: 1 addition & 1 deletion examples/service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {

defaultConfig {
applicationId "video.api.client.service.example"
minSdkVersion 24
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -41,4 +49,4 @@ class ReadStorePermissionManager(
onDenied()
}
}
}
}
2 changes: 1 addition & 1 deletion examples/workmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {

defaultConfig {
applicationId "video.api.client.work.example"
minSdkVersion 24
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -41,4 +49,4 @@ class ReadStorePermissionManager(
onDenied()
}
}
}
}
4 changes: 2 additions & 2 deletions maven-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

def isReleaseBuild() {
return !"1.5.1".contains("SNAPSHOT")
return !"1.5.2".contains("SNAPSHOT")
}

def getReleaseRepositoryUrl() {
Expand Down Expand Up @@ -47,7 +47,7 @@ afterEvaluate { project ->

groupId = "video.api"
artifactId = "android-api-client"
version = "1.5.1"
version = "1.5.2"

pom {
name = "video.api:android-api-client"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>android-api-client</artifactId>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<version>1.5.1</version>
<version>1.5.2</version>
<url>https://github.com/apivideo/api.video-android-client</url>
<description>api.video Android API client</description>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/video/api/client/api/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private OkHttpClient initHttpClient(List<Interceptor> interceptors) {
private void init() {
verifyingSsl = true;
json = new JSON();
addDefaultHeader("AV-Origin-Client", "android:1.5.1");
addDefaultHeader("AV-Origin-Client", "android:1.5.2");
}

private boolean isValid(String regex, String field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ 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,
@DrawableRes notificationIconResourceId: Int,
@ColorRes notificationColorResourceId: Int
): NotificationCompat.Builder = apply {
setSmallIcon(notificationIconResourceId)
color = context.getColor(notificationColorResourceId)
color = ContextCompat.getColor(context, notificationColorResourceId)
}

0 comments on commit b9c82bd

Please sign in to comment.