Skip to content
Snippets Groups Projects
Commit 27cce9c4 authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Added :data:version module

parent 47cfc619
No related branches found
No related tags found
No related merge requests found
Showing
with 139 additions and 27 deletions
......@@ -50,12 +50,6 @@ android {
"x86_64"
)
)
buildConfigField(
"double",
"APP_VERSION",
android.defaultConfig.versionName ?: "1.0"
)
}
buildTypes {
......@@ -131,7 +125,6 @@ dependencies {
implementation(Libs.Ui.NAVIGATION_UI)
implementation(Libs.Data.PHONE_NUMBER)
implementation(Libs.Data.GSON)
implementation(Libs.Data.PROTOBUF)
implementation(Libs.DI.HILT)
......
......@@ -14,7 +14,7 @@ buildscript {
classpath("com.google.gms:google-services:${Plugins.GOOGLE_SVCS}")
classpath("com.google.firebase:firebase-crashlytics-gradle:${Plugins.CRASHLYTICS}")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${Plugins.NAVIGATION_SAFEARGS}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Plugins.KOTLIN}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("com.google.dagger:hilt-android-gradle-plugin:${Libs.DI.HILT_VERSION}")
}
}
......
/build
\ No newline at end of file
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}
android {
compileSdk = Versions.COMPILE_SDK
defaultConfig {
minSdk = Versions.MIN_SDK
targetSdk = Versions.TARGET_SDK
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
buildConfigField(
"double",
"APP_VERSION",
android.defaultConfig.versionName ?: "1.0"
)
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation(project(":depconstraints"))
implementation(project(":core:logging"))
implementation(Libs.Core.ANDROIDX_APPCOMPAT)
implementation(Libs.Core.CORE_KTX)
implementation(Libs.Core.CORE_COROUTINES)
implementation(Libs.Data.GSON)
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package io.elixxir.data.version
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("io.elixxir.data.version.test", appContext.packageName)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.elixxir.data.version">
</manifest>
\ No newline at end of file
package io.elixxir.data.version
sealed class VersionState
class Checking: VersionState()
class VersionOk : VersionState()
class UpdateRecommended(val updateUrl: String) : VersionState()
class UpdateRequired(val message: String, val updateUrl: String) : VersionState()
\ No newline at end of file
package io.elixxir.feature.splash.model
package io.elixxir.data.version.model
import com.google.gson.JsonElement
import io.xxlabs.messenger.BuildConfig
import io.elixxir.core.logging.BuildConfig
import io.elixxir.data.version.BuildConfig.APP_VERSION
data class VersionData(
internal data class VersionData(
val cmixOldest: String = "",
val cmixLatest: String = "",
val minVersion: Double = 1.0,
......@@ -13,7 +14,7 @@ data class VersionData(
val minPopupMessage: String = "",
) {
companion object {
fun from(jsonElement: JsonElement): VersionData {
internal fun from(jsonElement: JsonElement): VersionData {
val cmix = jsonElement.asJsonObject["cmix-client"].asJsonObject
val dappId = jsonElement.asJsonObject["dapp-id"].asJsonObject
......
package io.elixxir.data.version
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
\ No newline at end of file
......@@ -42,6 +42,8 @@ dependencies {
implementation(project(":depconstraints"))
implementation(project(":core:ui"))
implementation(project(":core:logging"))
implementation(project(":data:version"))
implementation(project(":data:session"))
implementation(Libs.Core.ANDROIDX_APPCOMPAT)
implementation(Libs.Core.CORE_KTX)
......
package io.elixxir.feature.splash.model
import io.elixxir.data.version.VersionState
data class AppState(
val userState: UserState,
val versionState: VersionState
......
package io.elixxir.feature.splash.model
import io.elixxir.feature.splash.ui.VersionAlertUi
sealed class VersionState
class Checking: VersionState()
class VersionOk : VersionState()
class UpdateRecommended(val alertUi: VersionAlertUi) : VersionState()
class UpdateRequired(val alertUi: VersionAlertUi) : VersionState()
\ No newline at end of file
......@@ -10,9 +10,6 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import io.elixxir.core.ui.util.openLink
import io.elixxir.feature.splash.model.UpdateRecommended
import io.elixxir.feature.splash.model.UpdateRequired
import io.elixxir.feature.splash.model.VersionOk
import kotlinx.coroutines.launch
/**
......
......@@ -88,7 +88,7 @@ class SplashScreenViewModel @Inject constructor(
}
private fun parseJson(json: JsonElement): VersionState {
val registrationWrapper = VersionData.from(json)
val registrationWrapper = io.elixxir.data.version.VersionData.from(json)
val appVersion = registrationWrapper.appVersion
val minVersion = registrationWrapper.minVersion
val recommendedVersion = registrationWrapper.recommendedVersion
......
......@@ -37,3 +37,4 @@ project(":cmix").projectDir = File("elixxir-dapps-sdk-kotlin/cmix")
// Protobuf
include(":proto")
include(":data:version")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment