Skip to content

Commit

Permalink
chore: update deps (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
f7deleon authored Jun 18, 2024
1 parent 1d865d1 commit 0c89052
Show file tree
Hide file tree
Showing 31 changed files with 266 additions and 98 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/check_compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Gradle Initialization
run: ./gradlew
- name: Check forbidden comments
Expand Down Expand Up @@ -53,6 +57,10 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Build App
run: ./gradlew build
- name: Upload Report
Expand Down
5 changes: 1 addition & 4 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 25 additions & 27 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id "com.android.application"
id 'com.android.application'
id "kotlin-android"
id "kotlin-parcelize"
id "kotlin-kapt"
id "org.jetbrains.kotlin.plugin.serialization"
id 'com.google.devtools.ksp'
alias(libs.plugins.easyLauncher)
}

Expand All @@ -20,9 +21,6 @@ if (getEnvVariable('KEYSTORE_FILE') != null) {

// TODO: Setup Crashlytics
def CRASHLYTICS_ENABLED = false
if (CRASHLYTICS_ENABLED) {
apply plugin: 'com.google.firebase.crashlytics'
}


android {
Expand All @@ -44,6 +42,7 @@ android {

buildFeatures {
compose true
buildConfig = true
}

signingConfigs {
Expand All @@ -68,8 +67,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

flavorDimensions "env"
flavorDimensions = ["env"]
productFlavors {
dev {
buildConfigField 'String', 'API_BASE_URL', getEnvVariable('API_DEV_SERVER_URL')
Expand All @@ -85,38 +83,36 @@ android {
}

packagingOptions {
exclude 'META-INF/LICENSE' // will not include LICENSE file
resources {
excludes += ['META-INF/LICENSE']
}
}

lintOptions {
lintConfig file("lint.xml")
disable "ObsoleteLintCustomCheck"
fatal 'StopShip'
warningsAsErrors true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
languageVersion = "1.5"
jvmTarget = '11'
languageVersion = "1.9"
jvmTarget = '17'
freeCompilerArgs += [
"-XXLanguage:+InlineClasses",
"-Xallow-result-return-type",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",
"-Xuse-experimental=kotlin.Experimental",
"-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlin.ExperimentalStdlibApi",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.contracts.ExperimentalContracts",
]
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.core.get()
kotlinCompilerExtensionVersion = "1.5.13"
}
namespace 'com.xmartlabs.gong'
lint {
disable 'ObsoleteLintCustomCheck'
disable 'AndroidGradlePluginVersion'
fatal 'StopShip'
lintConfig file('lint.xml')
warningsAsErrors true
}
}

Expand All @@ -132,6 +128,8 @@ dependencies {
implementation libs.androidX.dataStore
implementation libs.coil
implementation libs.once
implementation platform(libs.firebase.bom)
implementation libs.firebase.analytics
implementation libs.firebase.crashlytics
implementation libs.koin.compose
implementation libs.timber
Expand All @@ -143,7 +141,7 @@ dependencies {
implementation libs.bundles.kotlin
implementation libs.bundles.networking.core

kapt libs.androidX.room.compiler
ksp libs.androidX.room.compiler

testImplementation libs.junit
}
9 changes: 9 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@
kotlinx.serialization.KSerializer serializer(...);
}
### End Kotlin serializer
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
6 changes: 3 additions & 3 deletions app/src/dev/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xmartlabs.gong"
>
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application android:name=".App" />

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.xmartlabs.gong"
>

<!-- TODO: Remove networkSecurityConfig -->
<application
android:allowBackup="false"
Expand All @@ -14,7 +12,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="n"
android:fullBackupContent="false"
tools:targetApi="34"
android:dataExtractionRules="@xml/data_extraction_rules"
>

<!-- Enabled in the application -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ class UserLocalSource {
delay(30)
return requireNotNull(localUsers[userId])
}

fun deleteUser(user: User) {
localUsers.remove(user.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import java.util.concurrent.TimeUnit
import kotlin.time.Duration
import kotlin.time.DurationUnit
import kotlin.time.toDuration

/**
* Created by mirland on 28/04/20.
*/
object NetworkLayerCreator {
@SuppressWarnings("MagicNumber")
private val HTTP_CONNECT_TIMEOUT = Duration.seconds(20)
private val HTTP_CONNECT_TIMEOUT = 20.toDuration(DurationUnit.SECONDS)

@SuppressWarnings("MagicNumber")
private val HTTP_READ_TIMEOUT = Duration.seconds(20)
private val HTTP_READ_TIMEOUT = 20.toDuration(DurationUnit.SECONDS)
private val JSON_MEDIA_TYPE = "application/json".toMediaType()

fun createOkHttpClientBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.xmartlabs.gong.domain.usecase.GetLocationUseCase
import com.xmartlabs.gong.domain.usecase.GetSessionTypeUseCase
import com.xmartlabs.gong.domain.usecase.LoadUserUseCase
import com.xmartlabs.gong.domain.usecase.SignInUseCase
import com.xmartlabs.gong.domain.usecase.SignOutUseCase
import com.xmartlabs.gong.domain.usecase.TimeTrackerUseCase
import org.koin.dsl.module

Expand All @@ -15,6 +16,7 @@ object UseCaseDiModule {
factory { GetLocationUseCase(get(), get(DEFAULT_DISPATCHER)) }
factory { GetSessionTypeUseCase(get(), get(DEFAULT_DISPATCHER)) }
factory { LoadUserUseCase(get(), get(DEFAULT_DISPATCHER)) }
factory { SignOutUseCase(get(), get(DEFAULT_DISPATCHER)) }
factory { SignInUseCase(get(), get(DEFAULT_DISPATCHER)) }
factory { TimeTrackerUseCase(get(DEFAULT_DISPATCHER)) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ object ViewModelDiModule {
val viewModels = module {
viewModel { SignInScreenViewModel(get()) }
viewModel { MainActivityViewModel(get()) }
viewModel { WelcomeScreenViewModel(get(), get()) }
viewModel { WelcomeScreenViewModel(get(), get(), get()) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.xmartlabs.gong.domain.repository
import com.xmartlabs.gong.data.repository.auth.UserLocalSource
import com.xmartlabs.gong.data.repository.auth.UserRemoteSource
import com.xmartlabs.gong.data.repository.session.SessionLocalSource
import kotlinx.coroutines.flow.first

/**
* Created by mirland on 25/04/20.
Expand All @@ -21,6 +22,12 @@ class UserRepository(
response.user
}

suspend fun signOut(): Unit =
sessionLocalSource.getSessionUser().first()
?.let { response ->
userLocalSource.deleteUser(response)
} ?: Unit

fun getCurrentUser() = sessionLocalSource.getSessionUser()

suspend fun getUser(userId: String) = userLocalSource.getUser(userId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.xmartlabs.gong.domain.usecase

import com.xmartlabs.gong.domain.repository.UserRepository
import com.xmartlabs.gong.domain.usecase.common.CoroutineUseCase
import kotlinx.coroutines.CoroutineDispatcher

class SignOutUseCase(
private val userRepository: UserRepository,
dispatcher: CoroutineDispatcher,
) : CoroutineUseCase<Unit, Unit>(dispatcher) {

override suspend fun execute(params: Unit): Unit = userRepository.signOut()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import kotlinx.coroutines.flow.flow
import timber.log.Timber
import java.util.Date
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.DurationUnit

/**
Expand All @@ -22,7 +23,7 @@ class TimeTrackerUseCase(
while (true) {
@Suppress("MagicNumber")
delay(1800)
val duration = Duration.milliseconds((Date().time - params.startTime.time))
val duration = (Date().time - params.startTime.time).milliseconds
Timber.d("Duration: %s in millis", duration.toDouble(DurationUnit.MILLISECONDS))
emit(duration)
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/xmartlabs/gong/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import com.xmartlabs.gong.domain.usecase.SessionType
import com.xmartlabs.gong.ui.screens.signin.SignInScreen
import com.xmartlabs.gong.ui.screens.welcome.WelcomeScreen
import com.xmartlabs.gong.ui.theme.AppTheme
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel
import kotlin.time.Duration
import kotlin.time.DurationUnit
import kotlin.time.toDuration

class MainActivity : ComponentActivity() {
companion object {
private val SPLASH_ANIMATION_TIME = Duration.milliseconds(300)
private val SPLASH_ANIMATION_TIME = 300.toDuration(DurationUnit.MILLISECONDS)
}

private val viewModel: MainActivityViewModel by viewModel()
Expand Down Expand Up @@ -88,7 +88,7 @@ fun AppNavigationManager(sessionType: SessionType) {
SignInScreen(navController = navigationController)
}
composable(Screens.WELCOME) {
WelcomeScreen()
WelcomeScreen(navController = navigationController)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ abstract class BaseViewModel<Action, OneShotEvent, State>(initialState: State) :
launch { this@BaseViewModel.withState(block) }
}

protected inline fun <T> Flow<ProcessState<T>>.watchProcessState(
crossinline action: suspend (ProcessState<T>) -> Unit,
protected fun <T> Flow<ProcessState<T>>.watchProcessState(
action: suspend (ProcessState<T>) -> Unit,
) = viewModelScope.launch {
collect(action)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private fun SignInEvents(
popUpTo(Screens.SIGN_IN) { inclusive = true }
}
is SignInViewModelEvent.SignInError -> showSignInError(event.throwable, context)
else -> Unit
}
}
}
Expand Down Expand Up @@ -125,6 +126,7 @@ fun SignInContent(
ConstraintLayout(
modifier = Modifier
.fillMaxSize()
.padding(it)
.padding(start = 15.dp, end = 15.dp)
) {
val (welcomeText, signInText, userIdEditText, passwordEditText, signInButton) = createRefs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SignInScreenViewModel(
when (state) {
is ProcessState.Failure -> sendOneShotEvent(SignInViewModelEvent.SignInError(state.exception))
is ProcessState.Success -> sendOneShotEvent(SignInViewModelEvent.NavigateToDashboard)
ProcessState.Loading -> Unit
}
}
}
Expand Down
Loading

0 comments on commit 0c89052

Please sign in to comment.