Skip to content

Commit

Permalink
Update to target SDK 34, update dependencies (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed Aug 11, 2024
1 parent 8024c91 commit 3293c84
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
defaultConfig {
applicationId = "io.github.fate_grand_automata"
minSdk = 24
targetSdk = 33
targetSdk = 34
versionCode = System.getenv("FGA_VERSION_CODE")?.toInt() ?: 1
versionName = System.getenv("FGA_VERSION_NAME") ?: System.getenv("FGA_VERSION_CODE") ?: "0.1.0"
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.fate_grand_automata.imaging

import android.annotation.SuppressLint
import android.graphics.PixelFormat
import android.hardware.display.VirtualDisplay
import android.media.ImageReader
import android.media.projection.MediaProjection
import io.github.fate_grand_automata.util.StorageProvider
Expand Down Expand Up @@ -31,7 +32,13 @@ class MediaProjectionScreenshotService(

@SuppressLint("WrongConstant")
private val imageReader = ImageReader.newInstance(imageSize.width, imageSize.height, PixelFormat.RGBA_8888, 2)
private val virtualDisplay = mediaProjection.createVirtualDisplay(
private val virtualDisplay = mediaProjection.apply {
this.registerCallback(object : MediaProjection.Callback() {
override fun onStop() {
close()
}
}, null)
}.createVirtualDisplay(
"ScreenCapture",
imageSize.width, imageSize.height, screenDensity,
0, imageReader.surface, null, null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.content.pm.ServiceInfo
import android.os.Build
import android.os.VibrationEffect
import android.os.Vibrator
Expand Down Expand Up @@ -112,7 +113,18 @@ class ScriptRunnerNotification @Inject constructor(
fun show() {
val builder = startBuildNotification()

service.startForeground(Ids.foregroundNotification, builder.build())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
service.startForeground(
Ids.foregroundNotification,
builder.build(),
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
)
} else {
service.startForeground(
Ids.foregroundNotification,
builder.build()
)
}
}

fun message(msg: String) {
Expand All @@ -135,17 +147,17 @@ class ScriptRunnerNotification @Inject constructor(
vibrate(100.milliseconds)
}

private fun vibrate(Duration: Duration) {
private fun vibrate(duration: Duration) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vibrator.vibrate(
VibrationEffect.createOneShot(
Duration.inWholeMilliseconds,
duration.inWholeMilliseconds,
VibrationEffect.DEFAULT_AMPLITUDE
)
)
} else {
@Suppress("DEPRECATION")
vibrator.vibrate(Duration.inWholeMilliseconds)
vibrator.vibrate(duration.inWholeMilliseconds)
}
}

Expand Down
22 changes: 11 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[versions]
appcompat_version = "1.6.1"
assertk_version = "0.28.0"
appcompat_version = "1.7.0"
assertk_version = "0.28.1"
constraintlayout_version = "2.1.4"
core_ktx_version = "1.12.0"
core_ktx_version = "1.13.1"
documentfile_version = "1.0.1"
flow_preferences_version = "1.9.1"
hilt_navigation_compose_version = "1.2.0"
kotlinx_coroutines_core_version = "1.8.0"
lifecycle_version = "2.7.0"
kotlinx_coroutines_core_version = "1.8.1"
lifecycle_version = "2.8.4"
hilt_version = "2.51.1"
gson_version = "2.10.1"
gson_version = "2.11.0"


kotlin_version = "2.0.0"
ksp_version = "2.0.0-1.0.21"
ksp_version = "2.0.0-1.0.24"

gradle_version = "8.4.1"
gradle_version = "8.4.2"


ben-manes_versions = "0.51.0"
accompanist_version = "0.34.0"

google_android_play_version = "2.1.0"

activity_version = "1.8.2"
mockk_version = "1.13.10"
activity_version = "1.9.1"
mockk_version = "1.13.12"
navigation_compose_version = "2.7.7"
opencv_android_version = "4.8.1r2"
recyclerview_version = "1.3.2"
tesseract4android_version = "4.7.0"

timber_version = "5.0.1"

compose_bom_version = "2024.03.00"
compose_bom_version = "2024.06.00"



Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("com.gradle.enterprise") version("3.16.2")
id("com.gradle.enterprise") version("3.17.6")
}
gradleEnterprise {
buildScan {
Expand Down

0 comments on commit 3293c84

Please sign in to comment.