diff --git a/app/src/main/java/com/theveloper/pixelplay/MainActivity.kt b/app/src/main/java/com/theveloper/pixelplay/MainActivity.kt index 2d7ea1993..f0af8ceb7 100644 --- a/app/src/main/java/com/theveloper/pixelplay/MainActivity.kt +++ b/app/src/main/java/com/theveloper/pixelplay/MainActivity.kt @@ -665,6 +665,8 @@ class MainActivity : ComponentActivity() { val useSmoothCorners by playerViewModel.useSmoothCorners.collectAsStateWithLifecycle() val isMiniPlayerDismissing by playerViewModel.isMiniPlayerDismissing.collectAsStateWithLifecycle() val hapticsEnabled by playerViewModel.hapticsEnabled.collectAsStateWithLifecycle() + val disableBlurAllOver by playerViewModel.disableBlurAllOver.collectAsStateWithLifecycle() + val predictiveBackCollapseFraction by playerViewModel.predictiveBackCollapseFraction.collectAsStateWithLifecycle() val rootView = LocalView.current val platformHapticFeedback = LocalHapticFeedback.current val appHapticsConfig = remember(hapticsEnabled) { @@ -942,12 +944,17 @@ class MainActivity : ComponentActivity() { .fillMaxSize() .graphicsLayer { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - val fraction = expansionFractionProvider() - // Quantize to 4px steps: rebuild the RenderEffect only - // when the blur crosses a step, reuse the cached object - // every other frame. - val quantizedBlurPx = (fraction * 100f / 4f).roundToInt() * 4f - renderEffect = blurEffectCache.get(quantizedBlurPx) + if (disableBlurAllOver) { + renderEffect = null + } else { + val expansion = expansionFractionProvider() + val fraction = (expansion * (1f - predictiveBackCollapseFraction)).coerceIn(0f, 1f) + // Quantize to 2px steps: rebuild the RenderEffect only + // when the blur crosses a step, reuse the cached object + // every other frame. + val quantizedBlurPx = (fraction * 120f / 2f).roundToInt() * 2f + renderEffect = blurEffectCache.get(quantizedBlurPx) + } } } ) { diff --git a/app/src/main/java/com/theveloper/pixelplay/data/preferences/UserPreferencesRepository.kt b/app/src/main/java/com/theveloper/pixelplay/data/preferences/UserPreferencesRepository.kt index 276c57a42..8dbd02f64 100644 --- a/app/src/main/java/com/theveloper/pixelplay/data/preferences/UserPreferencesRepository.kt +++ b/app/src/main/java/com/theveloper/pixelplay/data/preferences/UserPreferencesRepository.kt @@ -215,6 +215,7 @@ constructor( val USE_ANIMATED_LYRICS = booleanPreferencesKey("use_animated_lyrics") val ANIMATED_LYRICS_BLUR_ENABLED = booleanPreferencesKey("animated_lyrics_blur_enabled") val ANIMATED_LYRICS_BLUR_STRENGTH = androidx.datastore.preferences.core.floatPreferencesKey("animated_lyrics_blur_strength") + val DISABLE_BLUR_ALL_OVER = booleanPreferencesKey("disable_blur_all_over") // Genre View Preference val IS_GENRE_GRID_VIEW = booleanPreferencesKey("is_genre_grid_view") @@ -1422,6 +1423,17 @@ constructor( } } + val disableBlurAllOverFlow: Flow = dataStore.data + .map { preferences -> + preferences[PreferencesKeys.DISABLE_BLUR_ALL_OVER] ?: false + } + + suspend fun setDisableBlurAllOver(disabled: Boolean) { + dataStore.edit { preferences -> + preferences[PreferencesKeys.DISABLE_BLUR_ALL_OVER] = disabled + } + } + val libraryTabsOrderFlow: Flow = dataStore.data .map { preferences -> preferences[PreferencesKeys.LIBRARY_TABS_ORDER] diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/components/LyricsSheet.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/components/LyricsSheet.kt index 21bdf6273..caca46b7f 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/components/LyricsSheet.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/components/LyricsSheet.kt @@ -348,6 +348,11 @@ fun LyricsSheet( } val animatedLyricsBlurEnabled by animatedLyricsBlurEnabledFlow.collectAsStateWithLifecycle(initialValue = true) + val disableBlurAllOverFlow = remember(context) { + context.dataStore.data.map { it[booleanPreferencesKey("disable_blur_all_over")] ?: false } + } + val disableBlurAllOver by disableBlurAllOverFlow.collectAsStateWithLifecycle(initialValue = false) + val animatedLyricsBlurStrengthFlow = remember(context) { context.dataStore.data.map { it[androidx.datastore.preferences.core.floatPreferencesKey("animated_lyrics_blur_strength")] ?: 2.5f } } @@ -790,7 +795,7 @@ fun LyricsSheet( highlightOffsetDp = highlightOffsetDp, autoscrollAnimationSpec = resolvedAutoscrollSpec, useAnimatedLyrics = useAnimatedLyrics, - animatedLyricsBlurEnabled = animatedLyricsBlurEnabled, + animatedLyricsBlurEnabled = animatedLyricsBlurEnabled && !disableBlurAllOver, animatedLyricsBlurStrength = animatedLyricsBlurStrength, immersiveMode = immersiveMode, lyricsAlignment = lyricsAlignment, diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/SettingsCategoryScreen.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/SettingsCategoryScreen.kt index e7bfaf99b..ae3925394 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/SettingsCategoryScreen.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/SettingsCategoryScreen.kt @@ -74,6 +74,7 @@ import androidx.compose.material.icons.outlined.PlayCircle import androidx.compose.material.icons.outlined.Style import androidx.compose.material.icons.outlined.Warning import androidx.compose.material.icons.automirrored.rounded.ArrowBack +import androidx.compose.material.icons.rounded.BlurOff import androidx.compose.material.icons.rounded.Check import androidx.compose.material.icons.rounded.ChevronRight import androidx.compose.material.icons.rounded.Close @@ -552,6 +553,13 @@ fun SettingsCategoryScreen( onCheckedChange = settingsViewModel::setUseSmoothCorners, leadingIcon = { Icon(painterResource(R.drawable.rounded_rounded_corner_24), null, tint = MaterialTheme.colorScheme.secondary) } ) + SwitchSettingItem( + title = stringResource(R.string.setcat_disable_blur_all_over_title), + subtitle = stringResource(R.string.setcat_disable_blur_all_over_subtitle), + checked = uiState.disableBlurAllOver, + onCheckedChange = { settingsViewModel.setDisableBlurAllOver(it) }, + leadingIcon = { Icon(Icons.Rounded.BlurOff, null, tint = MaterialTheme.colorScheme.secondary) } + ) } SettingsSubsection(title = stringResource(R.string.setcat_now_playing)) { diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/PlayerViewModel.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/PlayerViewModel.kt index c19b0c16e..54e89c128 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/PlayerViewModel.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/PlayerViewModel.kt @@ -658,6 +658,13 @@ class PlayerViewModel @Inject constructor( initialValue = true ) + val disableBlurAllOver: StateFlow = userPreferencesRepository.disableBlurAllOverFlow + .stateIn( + scope = viewModelScope, + started = SharingStarted.WhileSubscribed(5000), + initialValue = false + ) + private val _isInitialThemePreloadComplete = MutableStateFlow(false) diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/SettingsViewModel.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/SettingsViewModel.kt index fe4251e8c..698ba610c 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/SettingsViewModel.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/viewmodel/SettingsViewModel.kt @@ -96,6 +96,7 @@ data class SettingsUiState( val useAnimatedLyrics: Boolean = false, val animatedLyricsBlurEnabled: Boolean = true, val animatedLyricsBlurStrength: Float = 2.5f, + val disableBlurAllOver: Boolean = false, val backupInfoDismissed: Boolean = false, val isDataTransferInProgress: Boolean = false, val restorePlan: RestorePlan? = null, @@ -166,7 +167,8 @@ private sealed interface SettingsUiUpdate { val immersiveLyricsEnabled: Boolean, val immersiveLyricsTimeout: Long, val animatedLyricsBlurEnabled: Boolean, - val animatedLyricsBlurStrength: Float + val animatedLyricsBlurStrength: Float, + val disableBlurAllOver: Boolean ) : SettingsUiUpdate } @@ -559,7 +561,8 @@ class SettingsViewModel @Inject constructor( userPreferencesRepository.immersiveLyricsEnabledFlow, userPreferencesRepository.immersiveLyricsTimeoutFlow, userPreferencesRepository.animatedLyricsBlurEnabledFlow, - userPreferencesRepository.animatedLyricsBlurStrengthFlow + userPreferencesRepository.animatedLyricsBlurStrengthFlow, + userPreferencesRepository.disableBlurAllOverFlow ) { values -> SettingsUiUpdate.Group2( keepPlayingInBackground = values[0] as Boolean, @@ -578,7 +581,8 @@ class SettingsViewModel @Inject constructor( immersiveLyricsEnabled = values[13] as Boolean, immersiveLyricsTimeout = values[14] as Long, animatedLyricsBlurEnabled = values[15] as Boolean, - animatedLyricsBlurStrength = values[16] as Float + animatedLyricsBlurStrength = values[16] as Float, + disableBlurAllOver = values[17] as Boolean ) }.collect { update -> _uiState.update { state -> @@ -599,7 +603,8 @@ class SettingsViewModel @Inject constructor( immersiveLyricsEnabled = update.immersiveLyricsEnabled, immersiveLyricsTimeout = update.immersiveLyricsTimeout, animatedLyricsBlurEnabled = update.animatedLyricsBlurEnabled, - animatedLyricsBlurStrength = update.animatedLyricsBlurStrength + animatedLyricsBlurStrength = update.animatedLyricsBlurStrength, + disableBlurAllOver = update.disableBlurAllOver ) } } @@ -993,6 +998,12 @@ class SettingsViewModel @Inject constructor( } } + fun setDisableBlurAllOver(disabled: Boolean) { + viewModelScope.launch { + userPreferencesRepository.setDisableBlurAllOver(disabled) + } + } + fun refreshLibrary() { viewModelScope.launch { if (isSyncing.value) return@launch diff --git a/app/src/main/res/values-tr/strings_presentation_batch_a.xml b/app/src/main/res/values-tr/strings_presentation_batch_a.xml index 56e5122ff..22c1a0161 100644 --- a/app/src/main/res/values-tr/strings_presentation_batch_a.xml +++ b/app/src/main/res/values-tr/strings_presentation_batch_a.xml @@ -8,8 +8,8 @@ Google Drive kuruluyor… - Google Drive'ı Bağla - Müzik dosyalarını doğrudan Google Drive'ınızdan yayınlayın + Google Drive\'ı Bağla + Müzik dosyalarını doğrudan Google Drive\'ınızdan yayınlayın Google ile oturum açın Bir müzik klasörü seçin Müzik kaynağınız olarak kullanmak için bir klasör seçin veya oluşturun diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index c09da26a4..9b107d33c 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -132,6 +132,10 @@ Use complex shaped corners effectively improving aesthetics but may affect performance on low-end devices + Disable Blur Effects + Turn off blur effects across the app to save battery and resources. Now Playing Player Theme