diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f0e043c..b64792d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,8 +23,8 @@ android { applicationId = "com.sedsoftware.blinktracker" minSdk = 26 targetSdk = 33 - versionCode = 100200 - versionName = "1.2.0" + versionCode = 100300 + versionName = "1.3.0" setProperty("archivesBaseName", applicationId) testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/sedsoftware/blinktracker/MainActivity.kt b/app/src/main/java/com/sedsoftware/blinktracker/MainActivity.kt index 35d6cec..121e438 100644 --- a/app/src/main/java/com/sedsoftware/blinktracker/MainActivity.kt +++ b/app/src/main/java/com/sedsoftware/blinktracker/MainActivity.kt @@ -23,7 +23,7 @@ import com.sedsoftware.blinktracker.database.StatisticsRepositoryReal import com.sedsoftware.blinktracker.root.BlinkRoot import com.sedsoftware.blinktracker.root.integration.BlinkRootComponent import com.sedsoftware.blinktracker.settings.AppSettings -import com.sedsoftware.blinktracker.settings.ObservableOpacityProvider +import com.sedsoftware.blinktracker.settings.Settings import com.sedsoftware.blinktracker.tools.AppErrorHandler import com.sedsoftware.blinktracker.tools.AppNotificationsManager import com.sedsoftware.blinktracker.ui.BlinkRootContent @@ -60,7 +60,7 @@ class MainActivity : ComponentActivity(), PictureInPictureLauncher { } private var currentWindowAlpha: Float = 1f - private var opacityProvider: ObservableOpacityProvider? = null + private var settings: Settings? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -75,14 +75,14 @@ class MainActivity : ComponentActivity(), PictureInPictureLauncher { .build() _imageProcessor = FaceDetectorProcessor(faceDetectorOptions) - opacityProvider = ObservableOpacityProvider(applicationContext) + settings = AppSettings(applicationContext) _root = BlinkRootComponent( componentContext = defaultComponentContext(), storeFactory = DefaultStoreFactory(), errorHandler = errorHandler, notificationsManager = AppNotificationsManager(this), - settings = AppSettings(applicationContext), + settings = settings!!, repo = StatisticsRepositoryReal(applicationContext), pipLauncher = this, ) @@ -91,7 +91,7 @@ class MainActivity : ComponentActivity(), PictureInPictureLauncher { .onEach { root.onFaceDataChanged(it) } .launchIn(lifecycleScope) - opacityProvider?.opacity + settings?.observableOpacity ?.onEach { currentWindowAlpha = it } ?.launchIn(lifecycleScope) @@ -123,6 +123,7 @@ class MainActivity : ComponentActivity(), PictureInPictureLauncher { _root = null _imageProcessor?.run { this.stop() } _imageProcessor = null + settings = null enableKeepScreenOn(false) } diff --git a/distribution/changelog.md b/distribution/changelog.md index bf86b59..8e2a414 100644 --- a/distribution/changelog.md +++ b/distribution/changelog.md @@ -1 +1 @@ -* Additional statistic filters +* Added new option to control minimized window opacity (#19) diff --git a/distribution/whatsnew/whatsnew-en-US b/distribution/whatsnew/whatsnew-en-US index 63160c5..a43101a 100644 --- a/distribution/whatsnew/whatsnew-en-US +++ b/distribution/whatsnew/whatsnew-en-US @@ -1 +1 @@ -Additional statistic filters +Added new option to control minimized window opacity diff --git a/distribution/whatsnew/whatsnew-ru-RU b/distribution/whatsnew/whatsnew-ru-RU index 198dbbb..cdd5c96 100644 --- a/distribution/whatsnew/whatsnew-ru-RU +++ b/distribution/whatsnew/whatsnew-ru-RU @@ -1 +1 @@ -Дополнительные фильтры для статистики +Добавлена дополнительная опция для управления непрозрачностью свернутого окна diff --git a/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/AppSettings.kt b/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/AppSettings.kt index 7ba1997..ab6eb72 100644 --- a/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/AppSettings.kt +++ b/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/AppSettings.kt @@ -31,6 +31,11 @@ class AppSettings( private val launchMinimizedEnabledKey: Preferences.Key = booleanPreferencesKey(PreferenceKey.LAUNCH_MINIMIZED) private val minimizedOpacityKey: Preferences.Key = floatPreferencesKey(PreferenceKey.OPACITY) + override val observableOpacity: Flow = + Store.get(context).data.map { preferences -> + preferences[minimizedOpacityKey] ?: 1f + } + override suspend fun getPerMinuteThreshold(): Flow = getPrefsValue(perMinuteThresholdKey, PER_MINUTE_THRESHOLD_DEFAULT) diff --git a/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/ObservableOpacityProvider.kt b/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/ObservableOpacityProvider.kt deleted file mode 100644 index 4a2a300..0000000 --- a/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/ObservableOpacityProvider.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.sedsoftware.blinktracker.settings - -import android.content.Context -import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.core.floatPreferencesKey -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -class ObservableOpacityProvider(context: Context) { - private val minimizedOpacityKey: Preferences.Key = floatPreferencesKey(PreferenceKey.OPACITY) - - val opacity: Flow = context.dataStore.data.map { preferences -> - preferences[minimizedOpacityKey] ?: 0f - } -} diff --git a/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/Settings.kt b/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/Settings.kt index e432b89..d10478a 100644 --- a/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/Settings.kt +++ b/sources/settings/src/main/kotlin/com/sedsoftware/blinktracker/settings/Settings.kt @@ -3,6 +3,8 @@ package com.sedsoftware.blinktracker.settings import kotlinx.coroutines.flow.Flow interface Settings { + val observableOpacity: Flow + suspend fun getPerMinuteThreshold(): Flow suspend fun getNotifySoundEnabled(): Flow suspend fun getNotifyVibrationEnabled(): Flow