Skip to content

Commit

Permalink
refactor: Refactor code to work with the latest refactor.
Browse files Browse the repository at this point in the history
* Separate the login sequence for each backend into their own type so
  they can apply domain specific logic. All the routes are still shared,
  but at least one can express different requirements that were not
  possible before.
* Remove usage of service in favor of Android WorkManager workers. The
  new setup works entirely from the database and presists all relevant
  state into it.
* Fix proxy settings not saved between tests.
* Improve reporting by displaying the last polled time for this account.
* Improve log outputs.
* Add small space between refresh and settings buttons.
* Improve account details area.
* Clean up code and add comments.
* Fix invalid https proxy mode.
  • Loading branch information
Leander Beernaert authored and Leander Beernaert committed Aug 3, 2024
1 parent e0a92ec commit 8f5e5a2
Show file tree
Hide file tree
Showing 50 changed files with 3,083 additions and 5,209 deletions.
71 changes: 51 additions & 20 deletions you-have-mail-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.android.tools.profgen.ArtProfileKt
import com.android.tools.profgen.ArtProfileSerializer
import com.android.tools.profgen.DexFile
import org.gradle.internal.os.OperatingSystem

plugins {
id 'com.android.application'
Expand All @@ -13,14 +14,14 @@ plugins {

android {
namespace 'dev.lbeernaert.youhavemail'
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "dev.lbeernaert.youhavemail"
minSdk 29
targetSdk 33
versionCode 31
versionName "0.15.0"
versionCode 32
versionName "0.16.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -35,11 +36,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
buildFeatures {
compose true
Expand All @@ -66,26 +67,26 @@ dependencies {
// WorkManager dependency
implementation "androidx.work:work-runtime-ktx:$versions_work"

implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
implementation 'androidx.activity:activity-compose:1.9.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.4.3'
implementation 'androidx.compose.material:material:1.6.8'
implementation 'androidx.security:security-crypto-ktx:1.1.0-alpha06'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
implementation 'androidx.navigation:navigation-compose:2.6.0'
implementation 'androidx.navigation:navigation-compose:2.7.7'
implementation "androidx.compose.material:material-icons-extended:$compose_ui_version"

// Required for JNI
implementation "net.java.dev.jna:jna:5.7.0@aar"
implementation 'net.java.dev.jna:jna:5.14.0@aar'
}

apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
Expand All @@ -97,10 +98,6 @@ cargo {
targetIncludes = ["libyouhavemail.so", "libgo-srp.so"]
targetDirectory = "/tmp/build-yhm"
profile = "release"
// Uncomment for testing only.
/*features {
defaultAnd("null_backend")
}*/

// Ensure paths are consistent for reproducible builds.
exec { spec, _ ->
Expand All @@ -113,13 +110,40 @@ cargo {
extraCargoBuildArguments = ['--locked']
}

task bindingBuild(type: Exec) {
workingDir "../../you-have-mail-mobile"
commandLine "cargo", "build"
}

var ext = "so"
if (OperatingSystem.current().isMacOsX()) {
ext = "dylib"
}

task genBindings(type: Exec) {
workingDir "../../you-have-mail-mobile"
commandLine "cargo", "run", "--bin", "uniffi-bindgen", "--", "generate", "--library",
"target/debug/libyouhavemail.$ext",
"--language", "kotlin", "--config", "uniffi.toml",
"--out-dir", "../you-have-mail-android/app/src/main/java"
}

tasks.whenTaskAdded { task ->
// Require cargo to be run before copying native libraries.
if ((task.name == 'mergeDebugJniLibFolders' || task.name == 'mergeReleaseJniLibFolders')) {
task.dependsOn 'cargoBuild'
}

if (task.name == 'preBuild') {
task.dependsOn genBindings
}

if (task.name == 'genBindings') {
task.dependsOn 'cargoBuild'
}
}


afterEvaluate {

// The `cargoBuild` task isn't available until after evaluation.
Expand Down Expand Up @@ -159,3 +183,10 @@ project.afterEvaluate {
}
}
}

afterEvaluate {
genBindings.dependsOn(bindingBuild, cargoBuild)
android.applicationVariants.all { variant ->
variant.javaCompiler.dependsOn(genBindings)
}
}
9 changes: 3 additions & 6 deletions you-have-mail-android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
android:theme="@style/Theme.YouHaveMail"
tools:targetApi="31">

<service
android:name=".service.ObserverService"
android:enabled="true"
android:exported="false" />

<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.YouHaveMail">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -43,12 +39,13 @@
</activity>

<receiver
android:name=".service.StartReceiver"
android:name=".app.StartReceiver"
android:enabled="true"
android:exported="true"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
youhavemail.kt

This file was deleted.

Loading

0 comments on commit 8f5e5a2

Please sign in to comment.