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
2 changes: 2 additions & 0 deletions core/localization/src/androidMain/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,6 @@
<string name="backup_replace_providers">Anbietereinstellungen ersetzen</string>
<string name="backup_cancel">Abbrechen</string>
<string name="backup_shared_credentials_retained">Gemeinsame Zugangsdaten bleiben für nicht ausgewählte Anbieter erhalten: %1$s.</string>
<string name="settings_item_dim_screen">Display dimmen</string>
<string name="settings_item_dim_screen_warning">*Das Display wird nur gedimmt, wenn die Hintergrundgenerierung ausgeschaltet ist.</string>
</resources>
2 changes: 2 additions & 0 deletions core/localization/src/androidMain/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -739,4 +739,6 @@
<string name="backup_replace_providers">Заменить настройки</string>
<string name="backup_cancel">Отмена</string>
<string name="backup_shared_credentials_retained">Общие учётные данные сохранены для невыбранных провайдеров: %1$s.</string>
<string name="settings_item_dim_screen">Затемнять экран</string>
<string name="settings_item_dim_screen_warning">*Затемнение экрана работает только при отключённой фоновой генерации.</string>
</resources>
2 changes: 2 additions & 0 deletions core/localization/src/androidMain/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -739,4 +739,6 @@
<string name="backup_replace_providers">Sağlayıcı ayarlarını değiştir</string>
<string name="backup_cancel">İptal</string>
<string name="backup_shared_credentials_retained">Seçilmeyen sağlayıcıları korumak için ortak kimlik bilgileri tutuldu: %1$s.</string>
<string name="settings_item_dim_screen">Ekranı karart</string>
<string name="settings_item_dim_screen_warning">*Ekran karartma yalnızca arka planda üretim kapalıyken etkindir.</string>
</resources>
2 changes: 2 additions & 0 deletions core/localization/src/androidMain/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -739,4 +739,6 @@
<string name="backup_replace_providers">Замінити налаштування</string>
<string name="backup_cancel">Скасувати</string>
<string name="backup_shared_credentials_retained">Спільні облікові дані збережено для невибраних провайдерів: %1$s.</string>
<string name="settings_item_dim_screen">Затемнювати екран</string>
<string name="settings_item_dim_screen_warning">*Затемнення екрана працює лише за вимкненої фонової генерації.</string>
</resources>
2 changes: 2 additions & 0 deletions core/localization/src/androidMain/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,6 @@
<string name="backup_replace_providers">替换提供商设置</string>
<string name="backup_cancel">取消</string>
<string name="backup_shared_credentials_retained">为保留未选提供商的设置,共用凭据未更改:%1$s。</string>
<string name="settings_item_dim_screen">调暗屏幕</string>
<string name="settings_item_dim_screen_warning">*仅在关闭后台生成时才会调暗屏幕。</string>
</resources>
2 changes: 2 additions & 0 deletions core/localization/src/androidMain/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,6 @@
<string name="backup_replace_providers">Replace provider settings</string>
<string name="backup_cancel">Cancel</string>
<string name="backup_shared_credentials_retained">Shared sign-in credentials were kept to preserve unselected providers: %1$s.</string>
<string name="settings_item_dim_screen">Dim screen</string>
<string name="settings_item_dim_screen_warning">*Screen dimming is active only when background generation is off.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,15 @@ internal class PreferenceManagerImpl(
get() = keyValueStore.getString(KEY_DESIGN_DARK_TOKEN, "${DarkThemeToken.FRAPPE}")
set(value) = putString(KEY_DESIGN_DARK_TOKEN, value)

/**
* Whether active foreground generation lowers display brightness.
*
* @author Dmitriy Moroz
*/
override var shouldDimScreen: Boolean
get() = keyValueStore.getBoolean(KEY_DIM_SCREEN)
set(value) = putBoolean(KEY_DIM_SCREEN, value)

/**
* Whether generation is scheduled through the background task manager.
*
Expand Down Expand Up @@ -660,6 +669,7 @@ internal class PreferenceManagerImpl(
localDiffusionSchedulerThread = localOnnxSchedulerThread,
monitorConnectivity = monitorConnectivity,
backgroundGeneration = backgroundGeneration,
shouldDimScreen = shouldDimScreen,
autoSaveAiResults = autoSaveAiResults,
saveToMediaStore = saveToMediaStore,
formAdvancedOptionsAlwaysShow = formAdvancedOptionsAlwaysShow,
Expand Down Expand Up @@ -1105,10 +1115,14 @@ internal class PreferenceManagerImpl(
const val KEY_DESIGN_DARK_TOKEN = "key_design_dark_color_token_theme"

/**
* Stable storage key `key_background_generation`; preserve its value to retain existing user settings.
* Stable storage key for the opt-in foreground display dimming preference.
*
* @author Dmitriy Moroz
*/
const val KEY_DIM_SCREEN = "key_dim_screen"

/** Stable storage key for background generation scheduling.
* @author Dmitriy Moroz */
const val KEY_BACKGROUND_GENERATION = "key_background_generation"

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ internal class BackupPreferencesGatewayImpl(
"taggedInput" to BackupValue.Flag(preferences.formPromptTaggedInput),
"connectionTimeout" to BackupValue.Integer(preferences.connectionTimeout.seconds),
"generationTimeout" to BackupValue.Integer(preferences.generationRequestTimeout.seconds),
"dimScreen" to BackupValue.Flag(preferences.shouldDimScreen),
"backgroundGeneration" to BackupValue.Flag(preferences.backgroundGeneration),
"monitorConnection" to BackupValue.Flag(preferences.monitorConnectivity),
"textToImageSteps" to BackupValue.Integer(preferences.textToImageSamplingSteps),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ internal object PortablePreferenceSchema {
"key_generation_request_timeout_seconds",
PortablePreferenceType.INTEGER
),
"dimScreen" to PortablePreferenceField("key_dim_screen", PortablePreferenceType.FLAG),
"backgroundGeneration" to PortablePreferenceField(
"key_background_generation",
PortablePreferenceType.FLAG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,33 @@ package com.shifthackz.aisdv1.data.repository

import com.shifthackz.aisdv1.domain.repository.WakeLock
import com.shifthackz.aisdv1.domain.repository.WakeLockRepository
import platform.Foundation.NSThread
import platform.UIKit.UIApplication
import platform.darwin.dispatch_get_main_queue
import platform.darwin.dispatch_sync

/**
* Implements `WakeLockRepository` behavior for iOS.
* Supplies the shared CPU wake-lock API on iOS, where no Android-style partial lock exists.
* Display idle prevention belongs to the resumed application UI, which restores it on pause.
*
* @author Dmitriy Moroz
*/
internal class IosWakeLockRepository : WakeLockRepository {
/**
* Exposes the `wakeLock` value used by the SDAI data layer.
*
* Shared no-op CPU lock; display protection is managed by the resumed UI.
* @author Dmitriy Moroz
*/
override val wakeLock: WakeLock = IosWakeLock
override val wakeLock: WakeLock = NoOpIosWakeLock
}

private object IosWakeLock : WakeLock {
override fun acquire(timeout: Long) {
runOnMainThread {
UIApplication.sharedApplication.idleTimerDisabled = true
}
}

override fun release() {
runOnMainThread {
UIApplication.sharedApplication.idleTimerDisabled = false
}
}
/**
* CPU wake locks are unsupported on iOS; foreground display protection is owned by the UI.
* @author Dmitriy Moroz */
private object NoOpIosWakeLock : WakeLock {
/**
* Leaves CPU scheduling to iOS.
* @param timeout Android CPU lock timeout in milliseconds; unused on iOS.
* @author Dmitriy Moroz */
override fun acquire(timeout: Long) = Unit

private inline fun runOnMainThread(crossinline block: () -> Unit) {
if (NSThread.isMainThread) {
block()
} else {
dispatch_sync(dispatch_get_main_queue()) {
block()
}
}
}
/**
* Has no CPU resource to release on iOS.
* @author Dmitriy Moroz */
override fun release() = Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import com.shifthackz.aisdv1.core.common.schedulers.SchedulersToken

/**
* Observable application preferences including the selected generation source.
*
* @param shouldDimScreen Whether active foreground generation lowers screen brightness.
* @param providerSelectionRevision Durable source revision used to invalidate earlier queued work.
*
* @author Dmitriy Moroz
*/
data class Settings(
/** Durable source-selection identity used to invalidate work even after an away/back switch.
* @author Dmitriy Moroz */
/**
* Durable source-selection identity used to invalidate work even after an away/back switch.
*
* @author Dmitriy Moroz
*/
val providerSelectionRevision: Long = 0L,
/**
* Deadline for provider setup and metadata requests; defaults to 120 seconds.
Expand All @@ -25,139 +30,145 @@ data class Settings(
*/
val generationRequestTimeout: NetworkTimeout = NetworkTimeout.TWO_MINUTES,
/**
* Exposes the `serverUrl` value used by the SDAI domain layer.
* AUTOMATIC1111 server base URL.
*
* @author Dmitriy Moroz
*/
val serverUrl: String = "",
/**
* Exposes the `sdModel` value used by the SDAI domain layer.
* Selected server checkpoint identifier.
*
* @author Dmitriy Moroz
*/
val sdModel: String = "",
/**
* Exposes the `demoMode` value used by the SDAI domain layer.
* Whether bundled demonstration data is active.
*
* @author Dmitriy Moroz
*/
val demoMode: Boolean = false,
/**
* Exposes the `developerMode` value used by the SDAI domain layer.
* Whether developer tools are visible.
*
* @author Dmitriy Moroz
*/
val developerMode: Boolean = false,
/**
* Exposes the `localDiffusionAllowCancel` value used by the SDAI domain layer.
* Whether local inference exposes cancellation controls.
*
* @author Dmitriy Moroz
*/
val localDiffusionAllowCancel: Boolean = false,
/**
* Exposes the `localDiffusionSchedulerThread` value used by the SDAI domain layer.
* Coroutine scheduler selected for local inference.
*
* @author Dmitriy Moroz
*/
val localDiffusionSchedulerThread: SchedulersToken = SchedulersToken.COMPUTATION,
/**
* Exposes the `monitorConnectivity` value used by the SDAI domain layer.
* Whether server connectivity is monitored.
*
* @author Dmitriy Moroz
*/
val monitorConnectivity: Boolean = false,
/**
* Exposes the `backgroundGeneration` value used by the SDAI domain layer.
* Whether new generation requests use background scheduling.
*
* @author Dmitriy Moroz
*/
val backgroundGeneration: Boolean = false,
/**
* Exposes the `autoSaveAiResults` value used by the SDAI domain layer.
* Enables minimum display brightness during active foreground generation.
*
* @author Dmitriy Moroz
*/
val shouldDimScreen: Boolean = false,
/**
* Whether completed images are automatically persisted to the gallery.
*
* @author Dmitriy Moroz
*/
val autoSaveAiResults: Boolean = false,
/**
* Exposes the `saveToMediaStore` value used by the SDAI domain layer.
* Whether saved images are also exported to the device media library.
*
* @author Dmitriy Moroz
*/
val saveToMediaStore: Boolean = false,
/**
* Exposes the `formAdvancedOptionsAlwaysShow` value used by the SDAI domain layer.
* Whether generation forms initially expand advanced controls.
*
* @author Dmitriy Moroz
*/
val formAdvancedOptionsAlwaysShow: Boolean = false,
/**
* Exposes the `formPromptTaggedInput` value used by the SDAI domain layer.
* Whether prompt editors display tags.
*
* @author Dmitriy Moroz
*/
val formPromptTaggedInput: Boolean = false,
/**
* Exposes the `source` value used by the SDAI domain layer.
* Selected generation provider.
*
* @author Dmitriy Moroz
*/
val source: ServerSource = ServerSource.AUTOMATIC1111,
/**
* Exposes the `hordeApiKey` value used by the SDAI domain layer.
* Credential used for Horde generation requests.
*
* @author Dmitriy Moroz
*/
val hordeApiKey: String = "",
/**
* Exposes the `arliAiModel` value used by the SDAI domain layer.
* Selected Arli AI model identifier.
*
* @author Dmitriy Moroz
*/
val arliAiModel: String = "",
/**
* Exposes the `localUseNNAPI` value used by the SDAI domain layer.
* Whether ONNX inference requests Android NNAPI acceleration.
*
* @author Dmitriy Moroz
*/
val localUseNNAPI: Boolean = false,
/**
* Exposes the `designUseSystemColorPalette` value used by the SDAI domain layer.
* Whether supported platforms use system dynamic colors.
*
* @author Dmitriy Moroz
*/
val designUseSystemColorPalette: Boolean = false,
/**
* Exposes the `designUseSystemDarkTheme` value used by the SDAI domain layer.
* Whether appearance follows system dark mode.
*
* @author Dmitriy Moroz
*/
val designUseSystemDarkTheme: Boolean = false,
/**
* Exposes the `designDarkTheme` value used by the SDAI domain layer.
* Manual dark-mode preference when system appearance is disabled.
*
* @author Dmitriy Moroz
*/
val designDarkTheme: Boolean = false,
/**
* Exposes the `designColorToken` value used by the SDAI domain layer.
* Selected accent palette token.
*
* @author Dmitriy Moroz
*/
val designColorToken: String = "",
/**
* Exposes the `designDarkThemeToken` value used by the SDAI domain layer.
* Selected dark background palette token.
*
* @author Dmitriy Moroz
*/
val designDarkThemeToken: String = "",
/**
* Exposes the `galleryGrid` value used by the SDAI domain layer.
* Gallery column layout preference.
*
* @author Dmitriy Moroz
*/
val galleryGrid: Grid = Grid.Fixed2,
/**
* Exposes the `languageCode` value used by the SDAI domain layer.
* Preferred language code; empty follows the platform language.
*
* @author Dmitriy Moroz
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ interface PreferenceManager {
*/
var backgroundGeneration: Boolean

/**
* Whether foreground generation lowers display brightness while the app is active.
* @author Dmitriy Moroz
*/
var shouldDimScreen: Boolean

/**
* Number of background processes tracked by the existing work UI.
*
Expand Down
Loading
Loading