Skip to content

Commit 6c9a63b

Browse files
authored
Tagged input (#140)
* Tagged input * Tagged input | Patch 2 * Settings refactor * Server setup modal refactor * Gallery detail modal refactor * Gallery modal refactor * Color tags for extras * Tag edit dialog * Update strings * Update * Update min/max values * Handle connectivity view * Fix str state
1 parent 08927e8 commit 6c9a63b

File tree

57 files changed

+1408
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1408
-459
lines changed

data/src/main/java/com/shifthackz/aisdv1/data/gateway/ServerConnectivityGatewayImpl.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package com.shifthackz.aisdv1.data.gateway
33
import com.shifthackz.aisdv1.data.provider.ServerUrlProvider
44
import com.shifthackz.aisdv1.domain.gateway.ServerConnectivityGateway
55
import com.shifthackz.aisdv1.network.connectivity.ConnectivityMonitor
6-
import io.reactivex.rxjava3.core.Observable
6+
import io.reactivex.rxjava3.core.BackpressureStrategy
7+
import io.reactivex.rxjava3.core.Flowable
78

89
internal class ServerConnectivityGatewayImpl(
910
private val connectivityMonitor: ConnectivityMonitor,
1011
private val serverUrlProvider: ServerUrlProvider,
1112
) : ServerConnectivityGateway {
1213

13-
override fun observe(): Observable<Boolean> = serverUrlProvider("")
14+
override fun observe(): Flowable<Boolean> = serverUrlProvider("")
1415
.flatMapObservable(connectivityMonitor::observe)
16+
.toFlowable(BackpressureStrategy.LATEST)
1517
}

data/src/main/java/com/shifthackz/aisdv1/data/preference/PreferenceManagerImpl.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class PreferenceManagerImpl(
6262
.apply()
6363
.also { onPreferencesChanged() }
6464

65+
override var formPromptTaggedInput: Boolean
66+
get() = preferences.getBoolean(KEY_FORM_PROMPT_TAGGED_INPUT, true)
67+
set(value) = preferences.edit()
68+
.putBoolean(KEY_FORM_PROMPT_TAGGED_INPUT, value)
69+
.apply()
70+
.also { onPreferencesChanged() }
71+
6572
override var source: ServerSource
6673
get() = (preferences.getString(KEY_SERVER_SOURCE, ServerSource.AUTOMATIC1111.key) ?: ServerSource.AUTOMATIC1111.key)
6774
.let(ServerSource.Companion::parse)
@@ -132,6 +139,7 @@ class PreferenceManagerImpl(
132139
autoSaveAiResults = autoSaveAiResults,
133140
saveToMediaStore = saveToMediaStore,
134141
formAdvancedOptionsAlwaysShow = formAdvancedOptionsAlwaysShow,
142+
formPromptTaggedInput = formPromptTaggedInput,
135143
source = source,
136144
hordeApiKey = hordeApiKey,
137145
localUseNNAPI = localUseNNAPI,
@@ -147,6 +155,7 @@ class PreferenceManagerImpl(
147155
private const val KEY_AI_AUTO_SAVE = "key_ai_auto_save"
148156
private const val KEY_SAVE_TO_MEDIA_STORE = "key_save_to_media_store"
149157
private const val KEY_FORM_ALWAYS_SHOW_ADVANCED_OPTIONS = "key_always_show_advanced_options"
158+
private const val KEY_FORM_PROMPT_TAGGED_INPUT = "key_prompt_tagged_input"
150159
private const val KEY_SERVER_SOURCE = "key_server_source"
151160
private const val KEY_HORDE_API_KEY = "key_horde_api_key"
152161
private const val KEY_OPEN_AI_API_KEY = "key_open_ai_api_key"

dependencies.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ext {
2020
imagePickerVersion = 'v2.0.3'
2121
mviVersion = '1.0.1'
2222
timberVersion = '5.0.1'
23+
apacheLangVersion = '3.14.0'
2324
gsonVersion = '2.10.1'
2425
googleMaterialVersion = '1.9.0'
2526
accompanistSystemUiControllerVersion = '0.30.1'
@@ -93,6 +94,9 @@ ext {
9394
log = [
9495
timber: "com.jakewharton.timber:timber:$timberVersion",
9596
]
97+
apache = [
98+
stringutils: "org.apache.commons:commons-lang3:$apacheLangVersion"
99+
]
96100
test = [
97101
junit: "junit:junit:$testJunitVersion",
98102
]

domain/src/main/java/com/shifthackz/aisdv1/domain/entity/Settings.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ data class Settings(
77
val autoSaveAiResults: Boolean,
88
val saveToMediaStore: Boolean,
99
val formAdvancedOptionsAlwaysShow: Boolean,
10+
val formPromptTaggedInput: Boolean,
1011
val source: ServerSource,
1112
val hordeApiKey: String,
1213
val localUseNNAPI: Boolean,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.shifthackz.aisdv1.domain.gateway
22

3-
import io.reactivex.rxjava3.core.Observable
3+
import io.reactivex.rxjava3.core.Flowable
44

55
fun interface ServerConnectivityGateway {
6-
fun observe(): Observable<Boolean>
6+
fun observe(): Flowable<Boolean>
77
}

domain/src/main/java/com/shifthackz/aisdv1/domain/preference/PreferenceManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface PreferenceManager {
1111
var autoSaveAiResults: Boolean
1212
var saveToMediaStore: Boolean
1313
var formAdvancedOptionsAlwaysShow: Boolean
14+
var formPromptTaggedInput: Boolean
1415
var source: ServerSource
1516
var hordeApiKey: String
1617
var openAiApiKey: String
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.shifthackz.aisdv1.domain.usecase.connectivity
22

3-
import io.reactivex.rxjava3.core.Observable
3+
import io.reactivex.rxjava3.core.Flowable
44

55
interface ObserveSeverConnectivityUseCase {
6-
operator fun invoke(): Observable<Boolean>
6+
operator fun invoke(): Flowable<Boolean>
77
}

presentation/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
implementation androidx.pagingRx3
3434

3535
implementation google.material
36+
implementation apache.stringutils
3637

3738
implementation reactive.rxjava
3839
implementation reactive.rxkotlin
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.shifthackz.aisdv1.presentation.core
22

33
import com.shifthackz.aisdv1.domain.entity.AiGenerationResult
4+
import io.reactivex.rxjava3.core.BackpressureStrategy
45
import io.reactivex.rxjava3.subjects.PublishSubject
56

67
class GenerationFormUpdateEvent {
@@ -12,14 +13,14 @@ class GenerationFormUpdateEvent {
1213
fun update(generation: AiGenerationResult, route: AiGenerationResult.Type) {
1314
sRoute.onNext(route)
1415
when (route) {
15-
AiGenerationResult.Type.TEXT_TO_IMAGE -> sTxt2Img
16-
AiGenerationResult.Type.IMAGE_TO_IMAGE -> sImg2Img
17-
}.onNext(generation)
16+
AiGenerationResult.Type.TEXT_TO_IMAGE -> sTxt2Img.onNext(generation)
17+
AiGenerationResult.Type.IMAGE_TO_IMAGE -> sImg2Img.onNext(generation)
18+
}
1819
}
1920

20-
fun observeRoute() = sRoute
21+
fun observeRoute() = sRoute.toFlowable(BackpressureStrategy.LATEST)
2122

22-
fun observeTxt2ImgForm() = sTxt2Img
23+
fun observeTxt2ImgForm() = sTxt2Img.toFlowable(BackpressureStrategy.LATEST)
2324

24-
fun observeImg2ImgForm() = sImg2Img
25+
fun observeImg2ImgForm() = sImg2Img.toFlowable(BackpressureStrategy.LATEST)
2526
}

presentation/src/main/java/com/shifthackz/aisdv1/presentation/core/GenerationMviState.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ abstract class GenerationMviState : MviState {
1414
abstract val mode: ServerSource
1515
abstract val advancedToggleButtonVisible: Boolean
1616
abstract val advancedOptionsVisible: Boolean
17+
abstract val formPromptTaggedInput: Boolean
1718
abstract val prompt: String
1819
abstract val negativePrompt: String
1920
abstract val width: String
@@ -36,6 +37,16 @@ abstract class GenerationMviState : MviState {
3637
abstract val batchCount: Int
3738
abstract val generateButtonEnabled: Boolean
3839

40+
open val promptKeywords: List<String>
41+
get() = prompt.split(",")
42+
.map { it.trim() }
43+
.filter { it.isNotEmpty() }
44+
45+
open val negativePromptKeywords: List<String>
46+
get() = negativePrompt.split(",")
47+
.map { it.trim() }
48+
.filter { it.isNotEmpty() }
49+
3950
open val hasValidationErrors: Boolean
4051
get() = widthValidationError != null || heightValidationError != null
4152

@@ -44,6 +55,7 @@ abstract class GenerationMviState : MviState {
4455
mode: ServerSource = this.mode,
4556
advancedToggleButtonVisible: Boolean = this.advancedToggleButtonVisible,
4657
advancedOptionsVisible: Boolean = this.advancedOptionsVisible,
58+
formPromptTaggedInput: Boolean = this.formPromptTaggedInput,
4759
prompt: String = this.prompt,
4860
negativePrompt: String = this.negativePrompt,
4961
width: String = this.width,

0 commit comments

Comments
 (0)