Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4fd3c2b authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

Merge branch '2995-replace_gson_with_kotlin_sreialization' into 'main'

tech:2995:Use kotlinx-serialization instead of Gson

See merge request !184
parents e5aab176 15af7569
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 MURENA SAS
 * Copyright (C) 2022 - 2024 E FOUNDATION
 * Copyright (C) 2022 - 2025 E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
@@ -183,6 +183,7 @@ dependencies {
        libs.eos.telemetry,

        libs.google.material,
        libs.kotlinx.serialization,

        libs.maplibre,
        libs.mpandroidcharts,
+14 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 E FOUNDATION
 * Copyright (C) 2023 - 2024 MURENA SAS
 *
 * This program is free software: you can redistribute it and/or modify
@@ -60,6 +61,7 @@ import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.serialization.json.Json
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.androidx.viewmodel.dsl.viewModelOf
@@ -81,6 +83,18 @@ val appModule = module {
        )
    }

    single<Json> {
        Json {
            // the parser will not fail on unknown properties in the JSON and will simply ignore them.
            ignoreUnknownKeys = true
            // the parser will strictly follow the JSON specification and not allow non-compliant JSON.
            isLenient = false
            // default values of Kotlin properties will be included in the JSON during serialization.
            encodeDefaults = true
            useAlternativeNames = true
        }
    }

    factory<Resources> { androidContext().resources }
    single<LocalStateRepository> {
        LocalStateRepositoryImpl(context = androidContext())
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023-2025 MURENA SAS
 * Copyright (C) 2022 E FOUNDATION
 * Copyright (C) 2022 - 2025 E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
@@ -50,6 +50,7 @@ plugins {
    alias libs.plugins.android.application apply false
    alias libs.plugins.androidx.navigation.safeargs apply false
    alias libs.plugins.android.library apply false
    alias libs.plugins.kotlin.serialization apply false
}

allprojects {
+2 −1
Original line number Diff line number Diff line
@@ -27,11 +27,11 @@ eos-elib = { group = "foundation.e", name = "elib", version = "0.0.1-alpha11" }
eos-orbotservice = { group = "foundation.e", name = "orbotservice", version.ref = "orbotservice" }
eos-telemetry = { group = "foundation.e.lib", name = "telemetry", version = "0.0.11-alpha" }
google-material = { group = "com.google.android.material", name = "material", version = "1.12.0" }
google-gson = { group = "com.google.code.gson", name = "gson", version = "2.10.1" }
junit = { group = "junit", name = "junit", version = "4.13.2" }
koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin" }
koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version = "1.8.0" }
leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version = "2.10" }
maplibre = { group = "org.maplibre.gl", name = "android-sdk", version = "11.8.2" }
mpandroidcharts = { group = "com.github.PhilJay", name = "MPAndroidChart", version = "v3.1.0" }
@@ -56,3 +56,4 @@ benmanes-versions = { id = "com.github.ben-manes.versions", version = "0.38.0" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref =  "kotlin" }
spotless = { id = "com.diffplug.spotless", version = "6.23.3" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version  = "2.1.10" }
+7 −3
Original line number Diff line number Diff line
/*
 Copyright (C) 2025 E FOUNDATION
 Copyright (C) 2023 MURENA SAS
 Copyright (C) 2022 ECORP

@@ -18,8 +19,11 @@

 */

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
plugins {
    alias libs.plugins.android.library
    alias libs.plugins.kotlin.android
    alias libs.plugins.kotlin.serialization
}

android {
    compileSdkVersion buildConfig.compileSdk
@@ -49,7 +53,7 @@ dependencies {
        libs.androidx.work.ktx,
        libs.bundles.koin,
        libs.bundles.kotlin.android.coroutines,
        libs.google.gson,
        libs.kotlinx.serialization,
        libs.pcap4j,
        libs.retrofit,
        libs.retrofit.scalars,
Loading