Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.util.Properties
plugins {
alias(libs.plugins.generic.application)
alias(libs.plugins.generic.baseline.profm)
alias(libs.plugins.compose.compiler)
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ApplicationConventionPlugin : Plugin<Project> {
apply("org.jetbrains.kotlin.android")
apply("org.jetbrains.kotlin.kapt")
apply("generic.jacoco")
apply("org.jetbrains.kotlin.plugin.serialization")
}

extensions.configure<ApplicationExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ComposeConventionPlugin : Plugin<Project> {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
apply("generic.jacoco")
apply("org.jetbrains.kotlin.plugin.compose")
}

val extension = extensions.getByType<LibraryExtension>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal fun Project.configureCompose(
add("implementation", libs.findLibrary("google.accompanist.systemuicontroller").get())
add("implementation", libs.findLibrary("rx.java").get())
add("implementation", libs.findLibrary("shifthackz.mvi").get())
add("implementation", libs.findLibrary("kotlinx.serialization.json").get())
}
}
}
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.jetbrains.kotlin.serialization) apply false
alias(libs.plugins.compose.compiler) apply false
}
1 change: 1 addition & 0 deletions feature/mediapipe/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ dependencies {
implementation(libs.rx.kotlin)
fullImplementation(libs.google.mediapipe.image.generator)
playstoreImplementation(libs.google.mediapipe.image.generator)
testImplementation(libs.test.junit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class ExampleUnitTest {
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
}
28 changes: 16 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ targetSdk = "34"
compileSdk = "34"
minSdk = "24"
agp = "8.6.0"
kotlin = "1.9.21"
kotlin = "2.0.20"
appcompat = "1.7.0"
composeCompiler = "1.5.7"
composeBom = "2024.08.00"
Expand Down Expand Up @@ -47,13 +47,14 @@ turbine = "1.1.0"
roboelectric = "4.13"
testCoroutines = "1.8.1"
mediaPipeGenerator = "0.10.14"
serialization = "1.7.2"

[libraries]
android-tools-build-gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "agp"}
android-tools-build-gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
apache-stringutils = { group = "org.apache.commons", name = "commons-lang3", version.ref = "apacheStringUtils" }
androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat"}
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
androidx-compose-activity = { group = "androidx.activity", name = "activity-compose", version.ref = "composeActivity" }
androidx-compose-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewModel" }
androidx-lifecycle-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewModel" }
Expand Down Expand Up @@ -82,8 +83,8 @@ google-mediapipe-image-generator = { group = "com.google.mediapipe", name = "tas
retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
retrofit-converter-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit" }
retrofit-adapter-rxjava3 = { group = "com.squareup.retrofit2", name = "adapter-rxjava3", version.ref = "retrofit" }
okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp"}
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp"}
okhttp-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" }
koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin" }
koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
koin-compose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koinCompose" }
Expand All @@ -93,16 +94,16 @@ rx-java = { group = "io.reactivex.rxjava3", name = "rxjava", version.ref = "rxJa
rx-kotlin = { group = "io.reactivex.rxjava3", name = "rxkotlin", version.ref = "rxKotlinVersion" }
rx-network = { group = "io.github.softartdev", name = "reactivenetwork-rx3", version.ref = "rxNetworkVersion" }
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
test-junit = { group = "junit", name = "junit", version.ref = "junit"}
test-mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk"}
test-mockito = { group = "com.nhaarman.mockitokotlin2", name = "mockito-kotlin", version.ref = "mockito"}
test-junit = { group = "junit", name = "junit", version.ref = "junit" }
test-mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
test-mockito = { group = "com.nhaarman.mockitokotlin2", name = "mockito-kotlin", version.ref = "mockito" }
test-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "testCoroutines" }
test-koin = { group = "io.insert-koin", name = "koin-test", version.ref = "koin" }
test-koin-junit = { group = "io.insert-koin", name = "koin-test-junit4", version.ref = "koin" }
test-turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
test-roboelectric = { group = "org.robolectric", name = "robolectric", version.ref = "roboelectric"}
test-compose-junit = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "composeJunit"}
test-compose-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest", version.ref = "composeJunit"}
test-roboelectric = { group = "org.robolectric", name = "robolectric", version.ref = "roboelectric" }
test-compose-junit = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "composeJunit" }
test-compose-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest", version.ref = "composeJunit" }
compose-gestures = { group = "com.github.SmartToolFactory", name = "Compose-Extended-Gestures", version.ref = "composeGestures" }
compose-crop = { group = "io.github.mr0xf00", name = "easycrop", version.ref = "crop" }
shifthackz-mvi = { group = "com.github.ShiftHackZ", name = "AndroidCoreMVI", version.ref = "mvi" }
Expand All @@ -111,14 +112,17 @@ shifthackz-daynightswitch = { group = "com.github.ShiftHackZ", name = "DayNightS
shifthackz-catppuccin-legacy = { group = "com.github.ShiftHackZ.Catppuccin-Android-Library", name = "palette-legacy", version.ref = "catppuccin" }
shifthackz-catppuccin-compose = { group = "com.github.ShiftHackZ.Catppuccin-Android-Library", name = "compose", version.ref = "catppuccin" }
shifthackz-catppuccin-splash = { group = "com.github.ShiftHackZ.Catppuccin-Android-Library", name = "splashscreen", version.ref = "catppuccin" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jetbrains-kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version="unspecified" }
jetbrains-kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version = "unspecified" }
jetbrains-kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
generic-flavors = { id = "generic.flavors", version = "unspecified" }
generic-library = { id = "generic.library", version = "unspecified" }
generic-baseline-profm = { id = "generic.baseline.profm", version = "unspecified" }
generic-compose = { id = "generic.compose", version = "unspecified" }
generic-application = { id = "generic.application", version = "unspecified" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
2 changes: 2 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
alias(libs.plugins.generic.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.jetbrains.kotlin.serialization)
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.core.animation.doOnEnd
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.navigation.NavDestination.Companion.hasRoute
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.shifthackz.aisdv1.core.common.log.debugLog
import com.shifthackz.aisdv1.core.ui.MviComponent
import com.shifthackz.aisdv1.presentation.extensions.navigatePopUpToCurrent
import com.shifthackz.aisdv1.presentation.navigation.NavigationEffect
import com.shifthackz.aisdv1.presentation.navigation.NavigationRoute
import com.shifthackz.aisdv1.presentation.navigation.graph.mainNavGraph
import com.shifthackz.aisdv1.presentation.screen.drawer.DrawerScreen
import com.shifthackz.aisdv1.presentation.theme.global.AiSdAppTheme
import com.shifthackz.aisdv1.presentation.utils.Constants
import com.shifthackz.aisdv1.presentation.utils.PermissionUtil
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel
Expand Down Expand Up @@ -77,15 +78,16 @@ class AiStableDiffusionActivity : AppCompatActivity() {
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
val scope = rememberCoroutineScope()

var homeRouteEntry: String? by remember { mutableStateOf(null) }
var homeRouteEntry: NavigationRoute? by remember { mutableStateOf(null) }

BackHandler(enabled = drawerState.isOpen) {
scope.launch { drawerState.close() }
}

LaunchedEffect(backStackEntry) {
if (!viewModel.state.value.isShowSplash) return@LaunchedEffect
if (backStackEntry?.destination?.route != Constants.ROUTE_SPLASH) {
backStackEntry?.let { entry ->
if (entry.destination.hasRoute(NavigationRoute.Splash::class)) return@LaunchedEffect
viewModel.processIntent(AppIntent.HideSplash)
}
}
Expand All @@ -98,15 +100,17 @@ class AiStableDiffusionActivity : AppCompatActivity() {
NavigationEffect.Back -> navController.navigateUp()

is NavigationEffect.Navigate.Route -> {
navController.navigate(effect.route)
navController.navigate(effect.navRoute)
}

is NavigationEffect.Navigate.RouteBuilder -> navController.navigate(
effect.route, effect.builder,
)
is NavigationEffect.Navigate.RouteBuilder -> {
navController.navigate(
effect.navRoute, effect.builder,
)
}

is NavigationEffect.Navigate.RoutePopUp -> {
navController.navigatePopUpToCurrent(effect.route)
navController.navigatePopUpToCurrent(effect.navRoute)
}

NavigationEffect.Drawer.Close -> scope.launch {
Expand All @@ -118,7 +122,7 @@ class AiStableDiffusionActivity : AppCompatActivity() {
}

is NavigationEffect.Home -> {
homeRouteEntry = effect.route
homeRouteEntry = effect.navRoute
}
}
},
Expand All @@ -134,7 +138,7 @@ class AiStableDiffusionActivity : AppCompatActivity() {
) {
NavHost(
navController = navController,
startDestination = Constants.ROUTE_SPLASH,
startDestination = NavigationRoute.Splash,
builder = { mainNavGraph() },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AiStableDiffusionViewModel(
}

is AppIntent.HomeRoute -> {
homeRouter.navigateToRoute(intent.route)
homeRouter.navigateToRoute(intent.navRoute)
}

AppIntent.HideSplash -> updateState { state ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.shifthackz.aisdv1.presentation.activity

import com.shifthackz.aisdv1.presentation.navigation.NavigationRoute
import com.shifthackz.android.core.mvi.MviIntent

sealed interface AppIntent : MviIntent {

data object GrantStoragePermission : AppIntent
data object HideSplash : AppIntent

data class HomeRoute(val route: String) : AppIntent
data class HomeRoute(val navRoute: NavigationRoute) : AppIntent
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.shifthackz.aisdv1.presentation.extensions

import androidx.navigation.NavController
import com.shifthackz.aisdv1.presentation.navigation.NavigationRoute

fun NavController.navigatePopUpToCurrent(route: String) {
navigate(route) {
fun NavController.navigatePopUpToCurrent(navRoute: NavigationRoute) {
navigate(navRoute) {
currentBackStackEntry?.destination?.route?.let {
popUpTo(it) { inclusive = true }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import androidx.compose.runtime.Immutable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import com.shifthackz.aisdv1.core.model.UiText
import com.shifthackz.aisdv1.presentation.navigation.NavigationRoute

@Immutable
data class NavItem(
val name: UiText,
val route: String,
val navRoute: NavigationRoute,
val icon: Icon,
val content: (@Composable () -> Unit)? = null,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ sealed interface NavigationEffect : MviEffect {
data object Back : NavigationEffect

sealed interface Navigate : NavigationEffect {
val navRoute: NavigationRoute

val route: String

data class Route(override val route: String) : Navigate
data class Route(override val navRoute: NavigationRoute) : Navigate

data class RouteBuilder(
override val route: String,
override val navRoute: NavigationRoute,
val builder: NavOptionsBuilder.() -> Unit,
) : Navigate

data class RoutePopUp(override val route: String) : Navigate
data class RoutePopUp(override val navRoute: NavigationRoute) : Navigate
}

sealed interface Drawer : NavigationEffect {
Expand All @@ -29,10 +28,10 @@ sealed interface NavigationEffect : MviEffect {
}

sealed interface Home : NavigationEffect {
val route: String
val navRoute: NavigationRoute

data class Route(override val route: String) : Home
data class Route(override val navRoute: NavigationRoute) : Home

data class Update(override val route: String) : Home
data class Update(override val navRoute: NavigationRoute) : Home
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.shifthackz.aisdv1.presentation.navigation

import com.shifthackz.aisdv1.presentation.model.LaunchSource
import kotlinx.serialization.Serializable

sealed interface NavigationRoute {
@Serializable
data object Splash : NavigationRoute

@Serializable
data object Home : NavigationRoute

@Serializable
data object ConfigLoader : NavigationRoute

@Serializable
data object WebUi : NavigationRoute

@Serializable
data object Debug : NavigationRoute

@Serializable
data object Logger : NavigationRoute

@Serializable
data object InPaint : NavigationRoute

@Serializable
data object Donate : NavigationRoute

@Serializable
data class Onboarding(val source: LaunchSource) : NavigationRoute

@Serializable
data class GalleryDetail(val itemId: Long) : NavigationRoute

@Serializable
data class ServerSetup(val source: LaunchSource) : NavigationRoute

sealed interface HomeNavigation : NavigationRoute {
@Serializable
data object TxtToImg : HomeNavigation

@Serializable
data object ImgToImg : HomeNavigation

@Serializable
data object Gallery : HomeNavigation

@Serializable
data object Settings : HomeNavigation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.shifthackz.aisdv1.domain.entity.ServerSource
import com.shifthackz.aisdv1.domain.entity.Settings
import com.shifthackz.aisdv1.presentation.model.LaunchSource
import com.shifthackz.aisdv1.presentation.model.NavItem
import com.shifthackz.aisdv1.presentation.utils.Constants
import com.shifthackz.aisdv1.presentation.navigation.NavigationRoute
import com.shifthackz.aisdv1.presentation.widget.source.getNameUiText
import com.shifthackz.aisdv1.core.localization.R as LocalizationR

Expand All @@ -36,23 +36,23 @@ private fun webUi(source: ServerSource) = NavItem(
source.getNameUiText(),
")".asUiText(),
),
route = Constants.ROUTE_WEB_UI,
navRoute = NavigationRoute.WebUi,
icon = NavItem.Icon.Vector(
vector = Icons.Default.Web,
),
)

private fun configuration() = NavItem(
name = LocalizationR.string.settings_item_config.asUiText(),
route = "${Constants.ROUTE_SERVER_SETUP}/${LaunchSource.SETTINGS.ordinal}",
navRoute = NavigationRoute.ServerSetup(source = LaunchSource.SETTINGS),
icon = NavItem.Icon.Vector(
vector = Icons.Default.SettingsEthernet,
),
)

private fun developerMode() = NavItem(
name = LocalizationR.string.title_debug_menu.asUiText(),
route = Constants.ROUTE_DEBUG,
navRoute = NavigationRoute.Debug,
icon = NavItem.Icon.Vector(
vector = Icons.Default.DeveloperMode,
)
Expand Down
Loading