Skip to content

Commit

Permalink
Upgrade AGP, libraries and target version to API 33 (#282)
Browse files Browse the repository at this point in the history
* update libraries + fix build bug

* Fix warnings

* Bump library versions

* Upgrade AGP to 8.0.2

* Update .github/workflows/ci.yml to use Java 17

* Remove outdated command

---------

Co-authored-by: firemaples <[email protected]>
  • Loading branch information
omar and firemaples authored Jul 22, 2023
1 parent d8fe928 commit a6298a4
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: gradle

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.nav_version = "2.5.3"
ext.nav_version = "2.6.0"
repositories {
google()
mavenCentral()
Expand All @@ -13,14 +13,14 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.1'
classpath 'com.android.tools.build:gradle:8.0.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
classpath 'com.google.firebase:perf-plugin:1.4.2'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.7'

// Refactor
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# -XX:MaxPermSize=512m #MaxPermSize is removed in JDK 17
# https://github.com/expo/expo-cli/issues/4196#issuecomment-1035850918
Expand Down
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 @@
#Tue Feb 01 19:53:42 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
54 changes: 27 additions & 27 deletions main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ plugins {
}

android {
compileSdkVersion 32
compileSdkVersion 33
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "tw.firemaples.onscreenocr"
minSdkVersion 21
targetSdkVersion 32
targetSdkVersion 33
versionCode 100
versionName "3.1.15"

Expand Down Expand Up @@ -73,11 +73,11 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
buildFeatures {
viewBinding true
Expand All @@ -92,24 +92,24 @@ android {
dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')

implementation 'androidx.core:core-ktx:1.8.0' // newer version needs API 33 (Android 13)
implementation 'androidx.appcompat:appcompat:1.5.1' // newer version needs API 33 (Android 13)
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' // newer version needs API 33 (Android 13)
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' // newer version needs API 33 (Android 13)
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation "androidx.preference:preference-ktx:1.2.0"
implementation 'androidx.webkit:webkit:1.5.0' // newer version needs API 33 (Android 13)
implementation 'androidx.webkit:webkit:1.7.0'
//noinspection GradleDynamicVersion
testImplementation 'junit:junit:4.+'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.0'
// For using coroutines in tests
// For runBlockingTest, CoroutineDispatcher etc.
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4"
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.0'
// For InstantTaskExecutorRule
testImplementation "androidx.arch.core:core-testing:2.2.0"

Expand All @@ -125,13 +125,13 @@ dependencies {
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"

// required to avoid crash on Android 12 API 31
implementation 'androidx.work:work-runtime-ktx:2.7.1' // newer version needs API 33 (Android 13)
implementation 'androidx.work:work-runtime-ktx:2.8.1'

// Firebase
implementation platform('com.google.firebase:firebase-bom:30.5.0')
implementation platform('com.google.firebase:firebase-bom:32.2.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-core'
// implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-config'
implementation 'com.google.firebase:firebase-perf'

Expand All @@ -155,16 +155,16 @@ dependencies {

// Kotpref
// core
implementation 'com.chibatching.kotpref:kotpref:2.13.1'
implementation 'com.chibatching.kotpref:kotpref:2.13.2'
// optional, auto initialization module
implementation 'com.chibatching.kotpref:initializer:2.13.1'
implementation 'com.chibatching.kotpref:initializer:2.13.2'
// optional, support saving enum value and ordinal
implementation 'com.chibatching.kotpref:enum-support:2.13.1'
implementation 'com.chibatching.kotpref:enum-support:2.13.2'
// optional, support saving json string through Gson
implementation 'com.chibatching.kotpref:gson-support:2.13.1'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.chibatching.kotpref:gson-support:2.13.2'
implementation 'com.google.code.gson:gson:2.10.1'
// optional, support LiveData observable preference
implementation 'com.chibatching.kotpref:livedata-support:2.13.1'
implementation 'com.chibatching.kotpref:livedata-support:2.13.2'
// implementation 'androidx.lifecycle:lifecycle-livedata:2.2.0'
// // experimental, preference screen build dsl
// implementation 'com.chibatching.kotpref:preference-screen-dsl:2.13.1'
Expand All @@ -173,14 +173,14 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.9.0'

// Tesseract
implementation 'cz.adaptech.tesseract4android:tesseract4android:4.3.0'
implementation 'cz.adaptech.tesseract4android:tesseract4android:4.4.0'
// implementation 'cz.adaptech:tesseract4android:4.1.0'

// Microsoft translator
implementation 'io.github.firemaples:microsoft-translator-java-api:0.8.8.1'

// koral--/android-gif-drawable
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'

// // Ad network mediation - Mopub
// implementation('com.mopub:mopub-sdk:+@aar') {
Expand All @@ -200,7 +200,7 @@ dependencies {
// implementation 'com.mopub.mediation:adcolony:4.5.0.1'

// Admob
implementation 'com.google.android.gms:play-services-ads:22.0.0'
implementation 'com.google.android.gms:play-services-ads:22.2.0'
// Facebook Ad network
implementation 'com.google.ads.mediation:facebook:6.14.0.0'
// Adcolony Ad network
Expand All @@ -211,5 +211,5 @@ dependencies {
implementation 'com.facebook.infer.annotation:infer-annotation:0.18.0'

// TouchImageView
implementation 'com.github.MikeOrtiz:TouchImageView:3.2.1' // newer version needs API 33 (Android 13)
implementation 'com.github.MikeOrtiz:TouchImageView:3.3' // newer version needs API 33 (Android 13)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import junit.framework.TestCase
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import tw.firemaples.onscreenocr.pref.AppPref
import tw.firemaples.onscreenocr.recognition.TextRecognitionProviderType

class OCRRepositoryTest : TestCase() {

Expand All @@ -13,18 +14,9 @@ class OCRRepositoryTest : TestCase() {
super.setUp()
}

public override fun tearDown() {}

fun testGetSelectedOCRLangFlow() = runBlocking {
val lang = "zh"
repo.setSelectedOCRLanguage(lang)

assertEquals(lang, repo.selectedOCRLangFlow.first())
}

fun testSetSelectedOCRLanguage() = runBlocking {
val lang = "zh"
repo.setSelectedOCRLanguage(lang)
repo.setSelectedOCRLanguage(lang, TextRecognitionProviderType.GoogleMLKit)

assertEquals(lang, AppPref.selectedOCRLang)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@ import android.graphics.PixelFormat
import android.graphics.Point
import android.os.Build
import android.os.Looper
import android.view.*
import android.view.Gravity
import android.view.LayoutInflater
import android.view.OrientationEventListener
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.annotation.CallSuper
import androidx.annotation.MainThread
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import kotlinx.coroutines.*
import java.io.Closeable
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.cancelChildren
import tw.firemaples.onscreenocr.utils.Logger
import tw.firemaples.onscreenocr.utils.PermissionUtil
import tw.firemaples.onscreenocr.utils.UIUtils
import tw.firemaples.onscreenocr.wigets.BackButtonTrackerView
import tw.firemaples.onscreenocr.wigets.HomeButtonWatcher
import java.io.Closeable
import kotlin.coroutines.CoroutineContext

abstract class FloatingView(protected val context: Context) {

Expand Down Expand Up @@ -230,9 +239,10 @@ abstract class FloatingView(protected val context: Context) {
}

protected class FloatingViewLifecycleOwner : LifecycleOwner {
private val lifecycleRegistry = LifecycleRegistry(this)
private val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this)

override fun getLifecycle(): Lifecycle = lifecycleRegistry
override val lifecycle: Lifecycle
get() = lifecycleRegistry

fun onStateChanged(state: Lifecycle.State) {
lifecycleRegistry.currentState = state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tw.firemaples.onscreenocr.repo
import android.content.Context
import androidx.lifecycle.asFlow
import com.chibatching.kotpref.livedata.asLiveData
import java.io.File
import java.io.IOException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
Expand All @@ -18,8 +20,6 @@ import tw.firemaples.onscreenocr.recognition.TextRecognitionProviderType
import tw.firemaples.onscreenocr.recognition.TextRecognizer
import tw.firemaples.onscreenocr.utils.Logger
import tw.firemaples.onscreenocr.utils.Utils
import java.io.File
import java.io.IOException

class OCRRepository {
private val logger: Logger by lazy { Logger(OCRRepository::class) }
Expand Down

0 comments on commit a6298a4

Please sign in to comment.