Skip to content

Commit

Permalink
Improving build speed
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-ampire committed Oct 27, 2021
1 parent 0fef475 commit 4f76b20
Show file tree
Hide file tree
Showing 22 changed files with 113 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fun CustomGoogleButton(
Text(
style = MaterialTheme.typography.h5,
color = MaterialTheme.colors.surface,
text = stringResource(R.string.txt_connect_with_google)
text = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_connect_with_google)
)
Icon(
tint = Color.Transparent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun TopActionBar(modifier: Modifier = Modifier) {
Image(
modifier = Modifier.height(23.dp),
painter = painterResource(id = R.drawable.ic_lottiefiles_logo),
contentDescription = stringResource(id = R.string.txt_lottie_logo)
contentDescription = stringResource(id = org.zxconnect.android.beserve.i18n.R.string.txt_lottie_logo)
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.ericampire.android.androidstudycase.domain.usecase.FindPopularLottieF
import com.ericampire.android.androidstudycase.domain.usecase.FindRecentLottieFileUseCase
import com.ericampire.android.androidstudycase.util.Result
import com.ericampire.android.androidstudycase.util.data
import com.ericampire.android.androidstudycase.util.mvi.BaseViewModel
import com.ericampire.android.androidstudycase.util.mvi.BViewModel
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
Expand All @@ -23,7 +23,7 @@ class ExploreViewModel @AssistedInject constructor(
private val findPopularLottieFileUseCase: FindPopularLottieFileUseCase,
private val findRecentLottieFileUseCase: FindRecentLottieFileUseCase,
private val findFeaturedLottieFileUseCase: FindFeaturedLottieFileUseCase
) : BaseViewModel<ExploreViewState, ExploreAction>(initialState) {
) : BViewModel<ExploreViewState, ExploreAction>(initialState) {

init {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun ExploreScreen(
val state by viewModel.collectAsState(ExploreViewState::files)
val context = LocalContext.current

val tabItems = stringArrayResource(id = R.array.explore_item)
val tabItems = stringArrayResource(id = org.zxconnect.android.beserve.i18n.R.array.explore_item)
val pagerState = rememberPagerState()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.ericampire.android.androidstudycase.app.hilt.hiltMavericksViewModelFa
import com.ericampire.android.androidstudycase.domain.usecase.*
import com.ericampire.android.androidstudycase.util.PreviewData
import com.ericampire.android.androidstudycase.util.data
import com.ericampire.android.androidstudycase.util.mvi.BaseViewModel
import com.ericampire.android.androidstudycase.util.mvi.BViewModel
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
Expand All @@ -23,7 +23,7 @@ class HomeViewModel @AssistedInject constructor(
private val findUsersUseCase: FindUsersUseCase,
private val findFeaturedLottieFileUseCase: FindFeaturedLottieFileUseCase,
private val saveUserUseCase: SaveUserUseCase
) : BaseViewModel<HomeViewState, HomeAction>(initialState) {
) : BViewModel<HomeViewState, HomeAction>(initialState) {


init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ fun BrowseAllItemView(modifier: Modifier = Modifier) {
modifier = Modifier.padding(end = 12.dp)
) {
Text(
text = stringResource(R.string.txt_browse_all),
text = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_browse_all),
style = MaterialTheme.typography.h4.copy(
color = MaterialTheme.colors.onSurface
),
)

Text(
text = stringResource(R.string.txt_browse_all_desc),
text = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_browse_all_desc),
style = MaterialTheme.typography.body1.copy(
color = MaterialTheme.colors.onSurface
),
Expand All @@ -63,7 +63,7 @@ fun BrowseAllItemView(modifier: Modifier = Modifier) {

TextButton(onClick = { /*TODO*/ }) {
Text(
text = stringResource(R.string.txt_go_to_explore),
text = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_go_to_explore),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fun HomeContent(
Text(
modifier = Modifier.padding(horizontal = 16.dp),
maxLines = 1,
text = stringResource(id = R.string.txt_featured_animator),
text = stringResource(id = org.zxconnect.android.beserve.i18n.R.string.txt_featured_animator),
style = MaterialTheme.typography.h4.copy(
color = MaterialTheme.colors.onSurface
),
Expand Down Expand Up @@ -219,7 +219,7 @@ fun HomeContent(
Text(
modifier = Modifier.padding(horizontal = 16.dp),
maxLines = 1,
text = stringResource(id = R.string.txt_latest_story),
text = stringResource(id = org.zxconnect.android.beserve.i18n.R.string.txt_latest_story),
style = MaterialTheme.typography.h4.copy(
color = MaterialTheme.colors.onSurface
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fun LoginBottomSheet(
)
Text(
textAlign = TextAlign.Center,
text = stringResource(id = R.string.txt_get_started),
text = stringResource(id = org.zxconnect.android.beserve.i18n.R.string.txt_get_started),
style = MaterialTheme.typography.body1.copy(
color = MaterialTheme.colors.onSurface
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun UnLoggedUserHeaderView(
.size(57.dp)
.clip(CircleShape),
painter = painterResource(id = R.drawable.lottiefiles_circle_logo),
contentDescription = stringResource(id = R.string.txt_lottie_logo)
contentDescription = stringResource(id = org.zxconnect.android.beserve.i18n.R.string.txt_lottie_logo)
)
Column(
verticalArrangement = Arrangement.spacedBy(8.dp),
Expand All @@ -51,15 +51,15 @@ fun UnLoggedUserHeaderView(
)
Text(
maxLines = 1,
text = stringResource(R.string.txt_hello_stranger),
text = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_hello_stranger),
style = MaterialTheme.typography.h3.copy(
color = AppColor.PaleBlue
),
)
Text(
modifier = Modifier.clickable(onClick = onLoginClick),
maxLines = 1,
text = stringResource(R.string.txt_login),
text = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_login),
style = MaterialTheme.typography.body1.copy(
color = AppColor.Teal
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ fun PreviewScreen(navController: NavController) {
permissionState = cameraPermissionState,
permissionNotGrantedContent = {
PermissionNotAvailableContent(
descriptionMessage = stringResource(R.string.txt_camera_permssion_required),
descriptionMessage = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_camera_permssion_required),
onPermissionRequest = {
cameraPermissionState.launchPermissionRequest()
}
)
},
permissionNotAvailableContent = {
PermissionNotAvailableContent(
descriptionMessage = stringResource(R.string.txt_permission_denied),
descriptionMessage = stringResource(org.zxconnect.android.beserve.i18n.R.string.txt_permission_denied),
onPermissionRequest = {
cameraPermissionState.launchPermissionRequest()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.annotation.StringRes
import com.ericampire.android.androidstudycase.R

sealed class Destination(val route: String, @StringRes val resourceId: Int) {
object Home : Destination("home", R.string.txt_home)
object Explore : Destination("explore", R.string.txt_explore)
object Preview : Destination("preview", R.string.txt_preview)
object Login : Destination("login", R.string.txt_login)
object Home : Destination("home", org.zxconnect.android.beserve.i18n.R.string.txt_home)
object Explore : Destination("explore", org.zxconnect.android.beserve.i18n.R.string.txt_explore)
object Preview : Destination("preview", org.zxconnect.android.beserve.i18n.R.string.txt_preview)
object Login : Destination("login", org.zxconnect.android.beserve.i18n.R.string.txt_login)
}
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,9 @@ object Libs {

const val junit5_android_test_core = "de.mannodermaus.junit5:android-test-core:_"
const val junit5_android_test_runner = "de.mannodermaus.junit5:android-test-runner:_"

const val mvi_kotlin_core = "com.arkivanov.mvikotlin:mvikotlin:_"
const val mvi_kotlin_main = "com.arkivanov.mvikotlin:mvikotlin-main:_"
const val mvi_kotlin_logging = "com.arkivanov.mvikotlin:mvikotlin-logging:_"
const val mvi_kotlin_extension_coroutine = "com.arkivanov.mvikotlin:mvikotlin-extensions-coroutines:_"
}
9 changes: 8 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache-problems=warn
android.nonTransitiveRClass=true
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" -Dfile.encoding\=UTF-8 -XX:+UseParallelGC
android.useAndroidX=true
android.enableJetifier=true
kapt.incremental.apt=true
7 changes: 2 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
plugins {
id("de.fayard.refreshVersions") version "0.20.0"
//// # available:"0.21.0"
//// # available:"0.22.0"
//// # available:"0.23.0"
id("de.fayard.refreshVersions") version "0.23.0"
}

refreshVersions {
Expand All @@ -17,7 +14,7 @@ dependencyResolutionManagement {
jcenter() // Todo: Warning this repository is going to shut down soon
}
}
rootProject.name = "lottiefiles"
rootProject.name = "lottiefiles-app"
include(":app")
include(":util")
include(":i18n")
Expand Down
2 changes: 2 additions & 0 deletions util/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ android {
dependencies {

api(project(":i18n"))
api("org.reduxkotlin:redux-kotlin-threadsafe:0.5.5")

implementation(Libs.core_ktx)
api(Libs.androidx_lifecycle_viewmodel_ktx)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private fun Context.shareFile(filePath: String) {
)

val shareIntent = ShareCompat.IntentBuilder(this)
.setChooserTitle(getString(R.string.txt_share_lottie_file))
.setChooserTitle(getString(org.zxconnect.android.beserve.i18n.R.string.txt_share_lottie_file))
.setStream(fileUri)
.setType("application/pdf")
.createChooserIntent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.reduxkotlin.Reducer
import org.reduxkotlin.Store
import org.reduxkotlin.createThreadSafeStore

abstract class BaseViewModel<S : MavericksState, A>(
abstract class BViewModel<S : MavericksState, A>(
initialState: S
) : MavericksViewModel<S>(initialState) {
protected val pendingAction = MutableSharedFlow<A>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.ericampire.android.androidstudycase.util.mvi.core

/**
*
*/
interface Action
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.ericampire.android.androidstudycase.util.mvi.core



interface Reducer<S: State, A: Action> {

/**
* Given a [currentState] and some [action] that user took, produce a new [State].
*
* This will give us and predictable state management, that ensures each state is associated
* with some specific user intent or action
*/
fun reduce(currentState: S, action: A): S
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.ericampire.android.androidstudycase.util.mvi.core

/**
*
*/
interface State
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.ericampire.android.androidstudycase.util.mvi.core

import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow


/**
* A [Store] is our state container for a given screen
*
* @param[initialState] this is the initial state of the screen when it is first creates
* @param[reducer] A system for taking in the current state, and a new action, and outputting the
* updated state
*/
abstract class Store<S: State, A: Action>(
initialState: S,
private val reducer: Reducer<S, A>
) {
private val _state = MutableStateFlow(initialState)
val state: StateFlow<S> = _state

fun dispatch(action: A) {
val currentState = _state.value
_state.value = reducer.reduce(currentState, action)
}
}
24 changes: 18 additions & 6 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ version.androidx.preference=1.1.1
version.androidx.appcompat=1.3.0

## unused
version.androidx.compose.compiler=1.0.4
version.androidx.compose.compiler=1.1.0-beta01

## unused
version.androidx.compose.material-icons-extended=1.0.4
version.androidx.compose.material-icons-extended=1.1.0-beta01

## unused
version.androidx.compose.material=1.0.4
version.androidx.compose.material=1.1.0-beta01

## unused
version.androidx.compose.runtime=1.0.4
version.androidx.compose.runtime=1.1.0-beta01

## unused
version.google.accompanist=0.20.0

## unused
version.androidx.compose.ui=1.0.4
version.androidx.compose.ui=1.1.0-beta01

## unused
version.androidx.compose.ui-viewbinding=1.0.4
version.androidx.compose.ui-viewbinding=1.1.0-beta01

## unused
version.androidx.core=1.5.0
Expand Down Expand Up @@ -195,3 +195,15 @@ version.de.mannodermaus.junit5..android-test-runner=1.2.2

## unused
version.de.mannodermaus.junit5..android-test-core=1.2.2

## unused
version.com.arkivanov.mvikotlin..mvikotlin=2.0.4

## unused
version.com.arkivanov.mvikotlin..mvikotlin-main=2.0.4

## unused
version.com.arkivanov.mvikotlin..mvikotlin-logging=2.0.4

## unused
version.com.arkivanov.mvikotlin..mvikotlin-extensions-coroutines=2.0.4

0 comments on commit 4f76b20

Please sign in to comment.