Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(java): add support from Android 21 (instead of 24) #74

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.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

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>video.api</groupId>
<artifactId>android-video-uploader</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -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
Expand All @@ -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
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.3.1'
version = '1.3.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.uploader.service.example"
minSdk 24
minSdk 21
targetSdk 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.uploader.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.3.1".contains("SNAPSHOT")
return !"1.3.2".contains("SNAPSHOT")
}

def getReleaseRepositoryUrl() {
Expand Down Expand Up @@ -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"
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-video-uploader</artifactId>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<version>1.3.1</version>
<version>1.3.2</version>
<url>https://github.com/apivideo/api.video-android-uploader</url>
<description>api.video Android API video uploader</description>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/video/api/uploader/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-uploader:1.3.1");
addDefaultHeader("AV-Origin-Client", "android-uploader:1.3.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)
}