Skip to content

Commit d6ed9c8

Browse files
authored
Horde AI & HTTP Basic auth
* Horde: Server setup, txt2img mode * Horde: img2img mode, setup wizard * Implement generation result PNs * Update app.gradle * Implemented HTTP Basic auth * Setup http validation, password toggle * Update * Force setup screen after update
1 parent 2516394 commit d6ed9c8

File tree

101 files changed

+2001
-172
lines changed

Some content is hidden

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

101 files changed

+2001
-172
lines changed

adb_remove.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
adb uninstall com.shifthackz.aisdv1.app
3+
adb uninstall com.shifthackz.aisdv1.app.foss
4+
exit 0

app/app.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ android {
2222
applicationId "com.shifthackz.aisdv1.app"
2323

2424
buildConfigField "String", "CLOUD_AI_URL", "\"https://sdai.moroz.cc\""
25+
buildConfigField "String", "HORDE_AI_URL", "\"https://stablehorde.net\""
26+
buildConfigField "String", "HORDE_AI_SIGN_UP_URL", "\"https://stablehorde.net/register\""
2527
buildConfigField "String", "UPDATE_API_URL", "\"https://sdai.moroz.cc\""
2628
buildConfigField "String", "DEMO_MODE_API_URL", "\"https://sdai.moroz.cc\""
2729
buildConfigField "String", "POLICY_URL", "\"https://sdai.moroz.cc/policy.html\""
@@ -78,6 +80,7 @@ dependencies {
7880
implementation project(":domain")
7981
implementation project(":feature:ads")
8082
implementation project(":feature:analytics")
83+
implementation project(":feature:auth")
8184
implementation project(":data")
8285
implementation project(":demo")
8386
implementation di.koinCore

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33

4+
<uses-feature
5+
android:name="android.hardware.camera"
6+
android:required="false" />
7+
48
<uses-permission android:name="android.permission.CAMERA" />
59
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
610
<uses-permission android:name="android.permission.INTERNET" />
11+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
712

813
<application
914
android:name=".AiStableDiffusionClientApp"

app/src/main/java/com/shifthackz/aisdv1/app/di/FeatureModule.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ package com.shifthackz.aisdv1.app.di
22

33
import com.shifthackz.aisdv1.feature.ads.di.adFeatureModule
44
import com.shifthackz.aisdv1.feature.analytics.di.analyticsModule
5+
import com.shifthackz.aisdv1.feature.auth.di.authModule
56

6-
val featureModule = (adFeatureModule + analyticsModule).toTypedArray()
7+
val featureModule = (adFeatureModule + analyticsModule + authModule).toTypedArray()

app/src/main/java/com/shifthackz/aisdv1/app/di/ProvidersModule.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import com.shifthackz.aisdv1.core.common.appbuild.BuildVersion
77
import com.shifthackz.aisdv1.core.common.file.FileProviderDescriptor
88
import com.shifthackz.aisdv1.core.common.links.LinksProvider
99
import com.shifthackz.aisdv1.core.common.schedulers.SchedulersProvider
10+
import com.shifthackz.aisdv1.domain.authorization.AuthorizationCredentials
11+
import com.shifthackz.aisdv1.domain.authorization.AuthorizationStore
12+
import com.shifthackz.aisdv1.domain.preference.PreferenceManager
1013
import com.shifthackz.aisdv1.network.qualifiers.ApiUrlProvider
14+
import com.shifthackz.aisdv1.network.qualifiers.CredentialsProvider
15+
import com.shifthackz.aisdv1.network.qualifiers.HordeApiKeyProvider
1116
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
1217
import io.reactivex.rxjava3.core.Scheduler
1318
import io.reactivex.rxjava3.schedulers.Schedulers
@@ -28,12 +33,34 @@ val providersModule = module {
2833
override val stableDiffusionAutomaticApiUrl: String = DEFAULT_SERVER_URL
2934
override val stableDiffusionAppApiUrl: String = BuildConfig.UPDATE_API_URL
3035
override val stableDiffusionCloudAiApiUrl: String = BuildConfig.CLOUD_AI_URL
36+
override val hordeApiUrl: String = BuildConfig.HORDE_AI_URL
37+
}
38+
}
39+
40+
single {
41+
HordeApiKeyProvider { get<PreferenceManager>().hordeApiKey }
42+
}
43+
44+
single<CredentialsProvider> {
45+
object : CredentialsProvider {
46+
override fun invoke(): CredentialsProvider.Data {
47+
val store = get<AuthorizationStore>()
48+
return when (val credentials = store.getAuthorizationCredentials()) {
49+
is AuthorizationCredentials.HttpBasic -> CredentialsProvider.Data.HttpBasic(
50+
login = credentials.login,
51+
password = credentials.password,
52+
)
53+
else -> CredentialsProvider.Data.None
54+
}
55+
}
3156
}
3257
}
3358

3459
single<LinksProvider> {
3560
object : LinksProvider {
3661
override val cloudUrl: String = BuildConfig.CLOUD_AI_URL
62+
override val hordeUrl: String = BuildConfig.HORDE_AI_URL
63+
override val hordeSignUpUrl: String = BuildConfig.HORDE_AI_SIGN_UP_URL
3764
override val privacyPolicyUrl: String = BuildConfig.POLICY_URL
3865
override val gitHubSourceUrl: String = BuildConfig.GITHUB_SOURCE_URL
3966
override val setupInstructionsUrl: String = BuildConfig.SETUP_INSTRUCTIONS_URL

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
buildscript {
22
ext {
3-
appVersion = "0.4.1"
3+
appVersion = "0.4.2"
44
minSdk = 26
55
targetSdk = 33
66
}
77
dependencies {
88
classpath 'com.google.gms:google-services:4.3.15'
9-
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.6'
9+
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.7'
1010
}
1111
}
1212

core/common/src/main/java/com/shifthackz/aisdv1/core/common/links/LinksProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.shifthackz.aisdv1.core.common.links
22

33
interface LinksProvider {
44
val cloudUrl: String
5+
val hordeUrl: String
6+
val hordeSignUpUrl: String
57
val privacyPolicyUrl: String
68
val gitHubSourceUrl: String
79
val setupInstructionsUrl: String
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.shifthackz.aisdv1.core.extensions
2+
3+
import android.app.ActivityManager
4+
import android.app.ActivityManager.RunningAppProcessInfo
5+
import android.content.Context
6+
7+
fun Context.isAppInForeground(): Boolean {
8+
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
9+
val processes = activityManager.runningAppProcesses ?: return false
10+
11+
return processes.any { process ->
12+
process.uid == applicationInfo.uid && process.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND
13+
}
14+
}

core/validation/src/main/java/com/shifthackz/aisdv1/core/validation/ValidationResult.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("unused")
2+
13
package com.shifthackz.aisdv1.core.validation
24

35
data class ValidationResult<T : Any>(

core/validation/src/main/java/com/shifthackz/aisdv1/core/validation/di/ValidatorsModule.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ package com.shifthackz.aisdv1.core.validation.di
22

33
import com.shifthackz.aisdv1.core.validation.dimension.DimensionValidator
44
import com.shifthackz.aisdv1.core.validation.dimension.DimensionValidatorImpl
5+
import com.shifthackz.aisdv1.core.validation.horde.CommonStringValidator
6+
import com.shifthackz.aisdv1.core.validation.horde.CommonStringValidatorImpl
57
import com.shifthackz.aisdv1.core.validation.url.UrlValidator
68
import com.shifthackz.aisdv1.core.validation.url.UrlValidatorImpl
79
import org.koin.core.module.dsl.factoryOf
810
import org.koin.dsl.bind
911
import org.koin.dsl.module
1012

1113
val validatorsModule = module {
14+
// !!! Do not use [factoryOf] for DimensionValidatorImpl, it has 2 default Ints in constructor
1215
factory<DimensionValidator> { DimensionValidatorImpl() }
16+
1317
factoryOf(::UrlValidatorImpl) bind UrlValidator::class
18+
factoryOf(::CommonStringValidatorImpl) bind CommonStringValidator::class
1419
}

0 commit comments

Comments
 (0)