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

Update Android SDK target to 14 #7233

Merged
merged 2 commits into from
Jul 19, 2024
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
78 changes: 37 additions & 41 deletions app-android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id "org.jetbrains.kotlin.kapt"
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.21'
id 'com.google.devtools.ksp'
}

group = "de.tutao"
Expand All @@ -12,15 +12,15 @@ android {
compileSdk 34
applicationId "de.tutao.tutanota"
minSdkVersion 26
targetSdkVersion 33
targetSdkVersion 34
versionCode 396361
versionName "235.240712.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
// https://issuetracker.google.com/issues/181593646
ksp {
arg("room.schemaLocation", "$projectDir/schemas".toString())
arg("room.generateKotlin", "true")
}
externalNativeBuild {
cmake {
Expand Down Expand Up @@ -132,68 +132,64 @@ tasks.withType(Test).configureEach {


dependencies {
def room_version = "2.4.2"
def lifecycle_version = "2.4.1"
def activity_version = "1.4.0"
def coroutines_version = "1.8.0"
def room_version = '2.6.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option to enable Kotlin code generation (or “Kotlin CodeGen”) is now available in Room KSP. (4297ec0). To turn on Kotlin CodeGen in Room, add the room.generateKotlin option name to your processor options for KSP. For more details on how to pass processor options for KSP, see the KSP documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an option to let KSP generate Kotlin in gradle.

def lifecycle_version = '2.8.3'
def activity_version = '1.9.0'
def coroutines_version = '1.8.1'

implementation "de.tutao:tutasdk"

// Important: cannot be updated without additional measures as Android 6 and 7 do not have Java 9
//noinspection GradleDependency
implementation 'commons-io:commons-io:2.5'
implementation 'commons-io:commons-io:2.16.1'

implementation "androidx.core:core-ktx:1.8.0"
implementation 'androidx.core:core-ktx:1.13.1'
implementation "androidx.activity:activity-ktx:$activity_version"
implementation "androidx.browser:browser:1.8.0"
implementation "androidx.browser:browser:1.8.0"
implementation "androidx.biometric:biometric:1.1.0"
implementation "androidx.core:core-splashscreen:1.0.1"
implementation "androidx.datastore:datastore-preferences:1.1.1"
implementation "androidx.core:core-splashscreen:1.0.1"
implementation "androidx.datastore:datastore-preferences:1.1.1"

if (file("../libs/android-database-sqlcipher-4.5.0.aar").exists()) {
implementation fileTree(include: ['*.aar'], dir: '../libs')
} else {
implementation "net.zetetic:android-database-sqlcipher:4.5.0"
}
implementation "androidx.sqlite:sqlite:2.0.1"
implementation 'androidx.sqlite:sqlite-ktx:2.4.0'

implementation "androidx.room:room-runtime:$room_version"
// For Kotlin use kapt instead of annotationProcessor
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
ksp "androidx.room:room-compiler:$room_version"

if (file("../libs/android-database-sqlcipher-4.5.0.aar").exists()) {
implementation fileTree(include: ['*.aar'], dir: '../libs')
} else {
implementation "net.zetetic:android-database-sqlcipher:4.5.0"
}
implementation "androidx.sqlite:sqlite:2.0.1"
implementation 'androidx.sqlite:sqlite-ktx:2.4.0'

implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.3'

implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2"
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

// TLS1.3 backwards compatibility for Android < 10
implementation 'org.conscrypt:conscrypt-android:2.5.2'
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'

implementation "net.java.dev.jna:jna:5.13.0@aar"
implementation 'net.java.dev.jna:jna:5.14.0@aar'

testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testImplementation 'androidx.test.ext:junit-ktx:1.1.3'
testImplementation 'androidx.test.ext:junit-ktx:1.2.1'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.robolectric:robolectric:4.11.1"
testImplementation "org.mockito.kotlin:mockito-kotlin:5.2.1"
// JVM-based unit tests (that don't need a real device or emulator)
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"

androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation "org.mockito:mockito-android:5.11.0"
androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
androidTestImplementation 'androidx.room:room-testing:2.4.2'
testImplementation 'org.robolectric:robolectric:4.13'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.4.0'
// JVM-based unit tests (that don't need a real device or emulator)
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"

androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test:runner:1.6.1'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.2.1'
androidTestImplementation 'androidx.test:rules:1.6.1'
androidTestImplementation 'org.mockito:mockito-android:5.12.0'
androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
androidTestImplementation 'androidx.room:room-testing:2.6.1'
}
2 changes: 2 additions & 0 deletions app-android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<uses-permission
android:name="android.permission.SCHEDULE_EXACT_ALARM"
android:maxSdkVersion="32"/>
Expand Down Expand Up @@ -133,6 +134,7 @@
android:name=".push.PushNotificationService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="dataSync"
android:permission="android.permission.BIND_JOB_SERVICE"
android:process=":pushprocess"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,10 @@ class AndroidFileFacade(
var chunk = 0
while (chunk * maxChunkSizeBytes <= fileSize) {
val tmpFilename = Integer.toHexString(file.hashCode()) + "." + chunk + ".blob"
val chunkedInputStream = BoundedInputStream(inputStream, maxChunkSizeBytes.toLong())
val chunkedInputStream = BoundedInputStream.builder()
.setInputStream(inputStream)
.setMaxCount(maxChunkSizeBytes.toLong())
.get()
val tmpFile = File(tempDir.decrypt, tmpFilename)
writeFileStream(tmpFile, chunkedInputStream)
chunkUris.add(tmpFile.toUri().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import android.net.Uri
import androidx.annotation.Keep
import androidx.annotation.VisibleForTesting
import de.tutao.tutanota.ipc.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
import org.apache.commons.io.input.CountingInputStream
import org.apache.commons.io.input.BoundedInputStream
import java.io.*
import java.math.BigInteger
import java.security.*
Expand Down Expand Up @@ -254,10 +256,14 @@ class AndroidNativeCryptoFacade(
override suspend fun aesEncryptFile(key: DataWrapper, fileUri: String, iv: DataWrapper): EncryptedFileInfo {
val parsedFileUri = Uri.parse(fileUri)
val outputFile = File(tempDir.encrypt, getFileInfo(context, parsedFileUri).name)
val inputStream = CountingInputStream(context.contentResolver.openInputStream(parsedFileUri))
val out: OutputStream = FileOutputStream(outputFile)
val inputStream = BoundedInputStream.builder()
.setInputStream(context.contentResolver.openInputStream(parsedFileUri))
.get()
val out: OutputStream = withContext(Dispatchers.IO) {
FileOutputStream(outputFile)
}
aesEncrypt(key.data, inputStream, out, iv.data, usePadding = true, useMac = true)
return EncryptedFileInfo(outputFile.toUri(), inputStream.byteCount.toInt())
return EncryptedFileInfo(outputFile.toUri(), inputStream.count.toInt())
}

@Throws(IOException::class, CryptoError::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import android.content.res.Configuration.UI_MODE_NIGHT_MASK
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import android.graphics.drawable.ColorDrawable
import android.util.Log
import android.view.View
import androidx.annotation.ColorInt
import androidx.core.view.WindowInsetsControllerCompat
import de.tutao.tutanota.ipc.ThemeFacade
import org.json.JSONException
import org.json.JSONObject
Expand Down Expand Up @@ -105,17 +105,16 @@ class AndroidThemeFacade(
// It is not an accident that navBg and headerBg seem to be swapped, the original color scheme was reused in
// this way.

val decorView = activity.window.decorView
val navBg = getColor(theme, "header_bg")

@ColorInt val navColor = parseColor(navBg)
val isNavBarLight = navBg.isLightHexColor()
var visibilityFlags = 0
if (atLeastOreo()) {
activity.window.navigationBarColor = navColor
if (isNavBarLight) {
visibilityFlags = visibilityFlags or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}
activity.window.navigationBarColor = navColor

val windowInsetController = WindowInsetsControllerCompat(activity.window, activity.window.decorView)

if (isNavBarLight) {
windowInsetController.isAppearanceLightNavigationBars = true
}

val headerBg = getColor(theme, "navigation_bg")
Expand All @@ -130,10 +129,8 @@ class AndroidThemeFacade(
// we change lightStatusBar flag accordingly.
activity.window.statusBarColor = statusBarColor
if (isStatusBarLight) {
visibilityFlags = visibilityFlags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
windowInsetController.isAppearanceLightStatusBars = true
}

decorView.systemUiVisibility = visibilityFlags
}

private fun getColor(theme: Map<String, String>, key: String): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ abstract class LifecycleJobService : JobService(), LifecycleOwner {
super.onCreate()
}

override fun onStart(intent: Intent?, startId: Int) {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
super.onStart(intent, startId)
return super.onStartCommand(intent, flags, startId)
}

override fun onDestroy() {
Expand All @@ -26,7 +26,6 @@ abstract class LifecycleJobService : JobService(), LifecycleOwner {
super.onDestroy()
}

override fun getLifecycle(): Lifecycle {
return lifecycleRegistry
}
override val lifecycle: Lifecycle
get() = lifecycleRegistry
}
Loading