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) #271

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
2 changes: 2 additions & 0 deletions config/android-uploader.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
changelog:
- 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
- 1.3.0 (2023-08-21):
Expand Down
2 changes: 2 additions & 0 deletions config/android.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
changelog:
- 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
- 1.5.0 (2023-08-21):
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)
}
2 changes: 1 addition & 1 deletion templates/java/libraries/okhttp-gson/build.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(hasProperty('target') && target == 'android') {
compileSdkVersion 33
buildToolsVersion '30.0.3'
defaultConfig {
minSdkVersion 24
minSdkVersion 21
targetSdkVersion 33
multiDexEnabled true

Expand Down
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()
}
}
}
}
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()
}
}
}
}
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()
}
}
}
}
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()
}
}
}
}
Loading