Skip to content

Commit 1fc2f4e

Browse files
authored
Develop - Generalize root for shizuku, Blur toggle and more fixes (#255)
This pull request introduces a new user setting to toggle progressive blur effects throughout the app, and refactors how blur is applied in the UI to respect this setting. Additionally, it improves permission checks and fallback logic for several Quick Settings tile services, enhancing reliability and compatibility. **Blur Feature Toggle and UI Refactor:** - Added a new "Use blur" toggle in settings, backed by a new `KEY_USE_BLUR` in `SettingsRepository`, allowing users to enable or disable progressive blur effects globally. All relevant activities and composables now observe `isBlurEnabled` and conditionally apply the `progressiveBlur` modifier. [[1]](diffhunk://#diff-576ba73ddab3e3ff415e6dc1c0b3b670b182d923408666f9be5a506cd6f9f5a1R355-R361) [[2]](diffhunk://#diff-3034452163f09f9c5b913dccd6f93b4a3fefaf773460d401d8904f6f151eb1a7R166) [[3]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R168) [[4]](diffhunk://#diff-ad4ba0c464c3da383256c4282daceee29c13d8de8e60416fef688e3a78f49effR244) [[5]](diffhunk://#diff-f54a52cfb3305491fb1aec48f384bde9ee59f7bf2f161f2b18e2f7f5e9642c04R125) [[6]](diffhunk://#diff-f54a52cfb3305491fb1aec48f384bde9ee59f7bf2f161f2b18e2f7f5e9642c04R199-R203) - Refactored all usages of the `progressiveBlur` modifier to be conditional based on the new setting, ensuring a consistent user experience and improved performance when blur is disabled. [[1]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60L321-R351) [[2]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R639-R642) [[3]](diffhunk://#diff-ad4ba0c464c3da383256c4282daceee29c13d8de8e60416fef688e3a78f49effL454-R463) [[4]](diffhunk://#diff-ad4ba0c464c3da383256c4282daceee29c13d8de8e60416fef688e3a78f49effL612-R624) [[5]](diffhunk://#diff-576ba73ddab3e3ff415e6dc1c0b3b670b182d923408666f9be5a506cd6f9f5a1R134-R148) [[6]](diffhunk://#diff-576ba73ddab3e3ff415e6dc1c0b3b670b182d923408666f9be5a506cd6f9f5a1L155-R169) [[7]](diffhunk://#diff-f54a52cfb3305491fb1aec48f384bde9ee59f7bf2f161f2b18e2f7f5e9642c04L146-R155) **UI/UX Improvements:** - Adjusted padding and layout for the "Quick settings tiles" settings screen and other feature settings to improve visual consistency, including status bar and toolbar padding. [[1]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60L536-R553) [[2]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R639-R642) **Quick Settings Tile Services – Permission and Fallback Enhancements:** - Updated permission checks in `AlwaysOnDisplayTileService`, `MonoAudioTileService`, `ChargeQuickTileService`, and `NfcTileService` to use a unified logic: first check for `WRITE_SECURE_SETTINGS` permission, then fallback to shell-based access if available. This increases compatibility on devices without root or with limited permissions. [[1]](diffhunk://#diff-ea86b38b418987193c89563b8af5aac3bfa274e75628ade41e662e567687cbc0L27-R29) [[2]](diffhunk://#diff-fd9e0dcc51ccbcd5c0432f550d625c650b94f276719b3c2220b8632a6be1708dL80-R81) [[3]](diffhunk://#diff-481a5aa17827cbbfa60b282fc2fd65a2ac0e6331a5ed7410b68a89bf234a3732L17-R19) [[4]](diffhunk://#diff-bc613912911065be6f191fc62d60e83942355644f9b7e5cbf1ad9fef5873a4b0L58-R60) - In `NfcTileService`, added a fallback to shell commands for toggling NFC if the reflection method fails, improving reliability on more devices. **Codebase Maintenance:** - Added necessary imports for `ShellUtils` and `PaddingValues` to support the new logic and UI changes. [[1]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R13) [[2]](diffhunk://#diff-ea86b38b418987193c89563b8af5aac3bfa274e75628ade41e662e567687cbc0R12) [[3]](diffhunk://#diff-bc613912911065be6f191fc62d60e83942355644f9b7e5cbf1ad9fef5873a4b0R10) [[4]](diffhunk://#diff-fd9e0dcc51ccbcd5c0432f550d625c650b94f276719b3c2220b8632a6be1708dR12) **References:** [[1]](diffhunk://#diff-576ba73ddab3e3ff415e6dc1c0b3b670b182d923408666f9be5a506cd6f9f5a1R355-R361) [[2]](diffhunk://#diff-3034452163f09f9c5b913dccd6f93b4a3fefaf773460d401d8904f6f151eb1a7R166) [[3]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R168) [[4]](diffhunk://#diff-ad4ba0c464c3da383256c4282daceee29c13d8de8e60416fef688e3a78f49effR244) [[5]](diffhunk://#diff-f54a52cfb3305491fb1aec48f384bde9ee59f7bf2f161f2b18e2f7f5e9642c04R125) [[6]](diffhunk://#diff-f54a52cfb3305491fb1aec48f384bde9ee59f7bf2f161f2b18e2f7f5e9642c04R199-R203) [[7]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60L321-R351) [[8]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R639-R642) [[9]](diffhunk://#diff-ad4ba0c464c3da383256c4282daceee29c13d8de8e60416fef688e3a78f49effL454-R463) [[10]](diffhunk://#diff-ad4ba0c464c3da383256c4282daceee29c13d8de8e60416fef688e3a78f49effL612-R624) [[11]](diffhunk://#diff-576ba73ddab3e3ff415e6dc1c0b3b670b182d923408666f9be5a506cd6f9f5a1R134-R148) [[12]](diffhunk://#diff-576ba73ddab3e3ff415e6dc1c0b3b670b182d923408666f9be5a506cd6f9f5a1L155-R169) [[13]](diffhunk://#diff-f54a52cfb3305491fb1aec48f384bde9ee59f7bf2f161f2b18e2f7f5e9642c04L146-R155) [[14]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60L536-R553) [[15]](diffhunk://#diff-ea86b38b418987193c89563b8af5aac3bfa274e75628ade41e662e567687cbc0L27-R29) [[16]](diffhunk://#diff-fd9e0dcc51ccbcd5c0432f550d625c650b94f276719b3c2220b8632a6be1708dL80-R81) [[17]](diffhunk://#diff-481a5aa17827cbbfa60b282fc2fd65a2ac0e6331a5ed7410b68a89bf234a3732L17-R19) [[18]](diffhunk://#diff-bc613912911065be6f191fc62d60e83942355644f9b7e5cbf1ad9fef5873a4b0L58-R60) [[19]](diffhunk://#diff-bc613912911065be6f191fc62d60e83942355644f9b7e5cbf1ad9fef5873a4b0L83-R87) [[20]](diffhunk://#diff-dd3d9f46d2b3a6d22fe1e3d6c01d0731ea48d3f11f5890898dde2d0e7f40ce60R13) [[21]](diffhunk://#diff-ea86b38b418987193c89563b8af5aac3bfa274e75628ade41e662e567687cbc0R12) [[22]](diffhunk://#diff-bc613912911065be6f191fc62d60e83942355644f9b7e5cbf1ad9fef5873a4b0R10) [[23]](diffhunk://#diff-fd9e0dcc51ccbcd5c0432f550d625c650b94f276719b3c2220b8632a6be1708dR12)
2 parents 6ca65e5 + 36ffd91 commit 1fc2f4e

14 files changed

Lines changed: 167 additions & 65 deletions

File tree

app/src/main/java/com/sameerasw/essentials/FeatureSettingsActivity.kt

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.activity.enableEdgeToEdge
1010
import androidx.compose.foundation.background
1111
import androidx.compose.foundation.layout.Box
1212
import androidx.compose.foundation.layout.Column
13+
import androidx.compose.foundation.layout.PaddingValues
1314
import androidx.compose.foundation.layout.WindowInsets
1415
import androidx.compose.foundation.layout.asPaddingValues
1516
import androidx.compose.foundation.layout.fillMaxSize
@@ -164,6 +165,7 @@ class FeatureSettingsActivity : FragmentActivity() {
164165
remember(context) { viewModel.check(context) }
165166

166167
val isPitchBlackThemeEnabled by viewModel.isPitchBlackThemeEnabled
168+
val isBlurEnabled by viewModel.isBlurEnabled
167169
val pinnedFeatureKeys by viewModel.pinnedFeatureKeys
168170

169171
EssentialsTheme(pitchBlackTheme = isPitchBlackThemeEnabled) {
@@ -318,25 +320,35 @@ class FeatureSettingsActivity : FragmentActivity() {
318320
modifier = Modifier
319321
.fillMaxSize()
320322
.background(MaterialTheme.colorScheme.surfaceContainer)
321-
.progressiveBlur(
322-
blurRadius = 40f,
323-
height = statusBarHeightPx * 1.15f,
324-
direction = BlurDirection.TOP
323+
.then(
324+
if (isBlurEnabled) {
325+
Modifier.progressiveBlur(
326+
blurRadius = 40f,
327+
height = statusBarHeightPx * 1.15f,
328+
direction = BlurDirection.TOP
329+
)
330+
} else Modifier
325331
)
326332
) {
327333
val hasScroll = featureId != "Sound mode tile" && featureId != "Quick settings tiles"
328334
Column(
329335
modifier = Modifier
330336
.fillMaxSize()
331-
.progressiveBlur(
332-
blurRadius = 40f,
333-
height = with(LocalDensity.current) { 150.dp.toPx() },
334-
direction = BlurDirection.BOTTOM
337+
.then(
338+
if (isBlurEnabled) {
339+
Modifier.progressiveBlur(
340+
blurRadius = 40f,
341+
height = with(LocalDensity.current) { 150.dp.toPx() },
342+
direction = BlurDirection.BOTTOM
343+
)
344+
} else Modifier
335345
)
336346
.then(if (hasScroll) Modifier.verticalScroll(rememberScrollState()) else Modifier)
337347
) {
338348
// Top padding for status bar
339-
androidx.compose.foundation.layout.Spacer(modifier = Modifier.height(statusBarHeight))
349+
if (featureId != "Quick settings tiles") {
350+
androidx.compose.foundation.layout.Spacer(modifier = Modifier.height(statusBarHeight))
351+
}
340352

341353
if (featureId == "Watch") {
342354
WatchSettingsUI(
@@ -533,8 +545,12 @@ class FeatureSettingsActivity : FragmentActivity() {
533545

534546
"Quick settings tiles" -> {
535547
QuickSettingsTilesSettingsUI(
536-
modifier = Modifier.padding(top = 16.dp),
537-
highlightSetting = highlightSetting
548+
modifier = Modifier.fillMaxSize(),
549+
highlightSetting = highlightSetting,
550+
contentPadding = PaddingValues(
551+
top = statusBarHeight,
552+
bottom = 150.dp
553+
)
538554
)
539555
}
540556

@@ -620,7 +636,9 @@ class FeatureSettingsActivity : FragmentActivity() {
620636

621637
}
622638
// Bottom padding for toolbar
623-
androidx.compose.foundation.layout.Spacer(modifier = Modifier.height(150.dp))
639+
if (featureId != "Quick settings tiles") {
640+
androidx.compose.foundation.layout.Spacer(modifier = Modifier.height(150.dp))
641+
}
624642
}
625643

626644
SettingsFloatingToolbar(

app/src/main/java/com/sameerasw/essentials/MainActivity.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class MainActivity : FragmentActivity() {
241241
viewModel.check(this)
242242
setContent {
243243
val isPitchBlackThemeEnabled by viewModel.isPitchBlackThemeEnabled
244+
val isBlurEnabled by viewModel.isBlurEnabled
244245
EssentialsTheme(pitchBlackTheme = isPitchBlackThemeEnabled) {
245246
androidx.compose.runtime.CompositionLocalProvider(
246247
com.sameerasw.essentials.ui.state.LocalMenuStateManager provides remember { com.sameerasw.essentials.ui.state.MenuStateManager() }
@@ -451,10 +452,14 @@ class MainActivity : FragmentActivity() {
451452
Box(
452453
modifier = Modifier
453454
.fillMaxSize()
454-
.progressiveBlur(
455-
blurRadius = 40f,
456-
height = statusBarHeightPx * 1.15f,
457-
direction = BlurDirection.TOP
455+
.then(
456+
if (isBlurEnabled) {
457+
Modifier.progressiveBlur(
458+
blurRadius = 40f,
459+
height = statusBarHeightPx * 1.15f,
460+
direction = BlurDirection.TOP
461+
)
462+
} else Modifier
458463
)
459464
) {
460465
val currentTab = remember(tabs, currentPage) {
@@ -609,10 +614,14 @@ class MainActivity : FragmentActivity() {
609614
modifier = Modifier
610615
.scale(1f - (backProgress.value * 0.05f))
611616
.alpha(1f - (backProgress.value * 0.3f))
612-
.progressiveBlur(
613-
blurRadius = 40f,
614-
height = with(androidx.compose.ui.platform.LocalDensity.current) { 130.dp.toPx() },
615-
direction = BlurDirection.BOTTOM
617+
.then(
618+
if (isBlurEnabled) {
619+
Modifier.progressiveBlur(
620+
blurRadius = 40f,
621+
height = with(androidx.compose.ui.platform.LocalDensity.current) { 130.dp.toPx() },
622+
direction = BlurDirection.BOTTOM
623+
)
624+
} else Modifier
616625
),
617626
label = "Tab Transition"
618627
) { targetPage ->

app/src/main/java/com/sameerasw/essentials/SettingsActivity.kt

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,20 @@ class SettingsActivity : ComponentActivity() {
131131
}
132132
val statusBarHeight = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
133133

134+
val isBlurEnabled by viewModel.isBlurEnabled
135+
134136
Box(
135137
modifier = Modifier
136138
.fillMaxSize()
137139
.background(MaterialTheme.colorScheme.surfaceContainer)
138-
.progressiveBlur(
139-
blurRadius = 40f,
140-
height = statusBarHeightPx * 1.15f,
141-
direction = BlurDirection.TOP
140+
.then(
141+
if (isBlurEnabled) {
142+
Modifier.progressiveBlur(
143+
blurRadius = 40f,
144+
height = statusBarHeightPx * 1.15f,
145+
direction = BlurDirection.TOP
146+
)
147+
} else Modifier
142148
)
143149
) {
144150
val contentPadding = androidx.compose.foundation.layout.PaddingValues(
@@ -152,10 +158,14 @@ class SettingsActivity : ComponentActivity() {
152158
viewModel = viewModel,
153159
contentPadding = contentPadding,
154160
modifier = Modifier
155-
.progressiveBlur(
156-
blurRadius = 40f,
157-
height = with(LocalDensity.current) { 150.dp.toPx() },
158-
direction = BlurDirection.BOTTOM
161+
.then(
162+
if (isBlurEnabled) {
163+
Modifier.progressiveBlur(
164+
blurRadius = 40f,
165+
height = with(LocalDensity.current) { 150.dp.toPx() },
166+
direction = BlurDirection.BOTTOM
167+
)
168+
} else Modifier
159169
)
160170
)
161171

@@ -342,6 +352,13 @@ fun SettingsContent(
342352
isChecked = viewModel.isPitchBlackThemeEnabled.value,
343353
onCheckedChange = { viewModel.setPitchBlackThemeEnabled(it, context) }
344354
)
355+
IconToggleItem(
356+
iconRes = R.drawable.rounded_blur_on_24,
357+
title = "Use blur",
358+
description = "Enable progressive blur elements across the UI",
359+
isChecked = viewModel.isBlurEnabled.value,
360+
onCheckedChange = { viewModel.setBlurEnabled(it, context) }
361+
)
345362
IconToggleItem(
346363
iconRes = R.drawable.rounded_numbers_24,
347364
title = stringResource(R.string.setting_use_root_title),

app/src/main/java/com/sameerasw/essentials/data/repository/SettingsRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class SettingsRepository(private val context: Context) {
163163
const val KEY_NOTIFICATION_GLANCE_SELECTED_APPS = "notification_glance_selected_apps"
164164
const val KEY_AOD_FORCE_TURN_OFF_ENABLED = "aod_force_turn_off_enabled"
165165
const val KEY_AUTO_ACCESSIBILITY_ENABLED = "auto_accessibility_enabled"
166+
const val KEY_USE_BLUR = "use_blur"
166167
}
167168

168169
// Observe changes

app/src/main/java/com/sameerasw/essentials/services/tiles/AlwaysOnDisplayTileService.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.service.quicksettings.Tile
99
import androidx.annotation.RequiresApi
1010
import com.sameerasw.essentials.R
1111
import com.sameerasw.essentials.data.repository.SettingsRepository
12+
import com.sameerasw.essentials.utils.ShellUtils
1213

1314
@RequiresApi(Build.VERSION_CODES.N)
1415
class AlwaysOnDisplayTileService : BaseTileService() {
@@ -24,7 +25,8 @@ class AlwaysOnDisplayTileService : BaseTileService() {
2425
}
2526

2627
override fun hasFeaturePermission(): Boolean {
27-
return checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS) == PackageManager.PERMISSION_GRANTED
28+
return com.sameerasw.essentials.utils.PermissionUtils.canWriteSecureSettings(this) ||
29+
(ShellUtils.isAvailable(this) && ShellUtils.hasPermission(this))
2830
}
2931

3032
override fun getTileIcon(): Icon? {
@@ -60,11 +62,11 @@ class AlwaysOnDisplayTileService : BaseTileService() {
6062
}
6163

6264
private fun isAodEnabled(): Boolean {
63-
return Settings.Secure.getInt(contentResolver, "doze_always_on", 0) == 1
65+
return getSecureInt("doze_always_on", 0) == 1
6466
}
65-
67+
6668
private fun setAodEnabled(enabled: Boolean) {
67-
Settings.Secure.putInt(contentResolver, "doze_always_on", if (enabled) 1 else 0)
69+
putSecureInt("doze_always_on", if (enabled) 1 else 0)
6870
}
6971

7072
private fun isGlanceEnabled(): Boolean {

app/src/main/java/com/sameerasw/essentials/services/tiles/ChargeQuickTileService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.annotation.RequiresApi
99
import com.sameerasw.essentials.FeatureSettingsActivity
1010
import com.sameerasw.essentials.R
1111
import com.sameerasw.essentials.utils.PermissionUtils
12+
import com.sameerasw.essentials.utils.ShellUtils
1213

1314
@RequiresApi(Build.VERSION_CODES.N)
1415
class ChargeQuickTileService : BaseTileService() {
@@ -77,9 +78,7 @@ class ChargeQuickTileService : BaseTileService() {
7778
}
7879

7980
override fun hasFeaturePermission(): Boolean {
80-
return PermissionUtils.canWriteSecureSettings(this) &&
81-
com.sameerasw.essentials.utils.ShellUtils.hasPermission(this) &&
82-
com.sameerasw.essentials.utils.ShellUtils.isAvailable(this)
81+
return ShellUtils.isAvailable(this) && ShellUtils.hasPermission(this)
8382
}
8483

8584

app/src/main/java/com/sameerasw/essentials/services/tiles/MonoAudioTileService.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ class MonoAudioTileService : BaseTileService() {
1414
}
1515

1616
override fun hasFeaturePermission(): Boolean {
17-
// Private secure settings can only be modified by ADB, system apps, or
18-
// apps with a target sdk of Android 5.1 and lower.
19-
return com.sameerasw.essentials.utils.ShellUtils.hasPermission(this) && com.sameerasw.essentials.utils.ShellUtils.isAvailable(
20-
this
21-
)
17+
return com.sameerasw.essentials.utils.PermissionUtils.canWriteSecureSettings(this) ||
18+
(com.sameerasw.essentials.utils.ShellUtils.isAvailable(this) &&
19+
com.sameerasw.essentials.utils.ShellUtils.hasPermission(this))
2220
}
2321

2422
override fun getTileIcon(): Icon {

app/src/main/java/com/sameerasw/essentials/services/tiles/NfcTileService.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.os.Build
77
import android.service.quicksettings.Tile
88
import androidx.annotation.RequiresApi
99
import com.sameerasw.essentials.R
10+
import com.sameerasw.essentials.utils.ShellUtils
1011
import java.lang.reflect.Method
1112

1213
@RequiresApi(Build.VERSION_CODES.N)
@@ -55,8 +56,8 @@ class NfcTileService : BaseTileService() {
5556
}
5657

5758
override fun hasFeaturePermission(): Boolean {
58-
// We need WRITE_SECURE_SETTINGS to toggle NFC via reflection
59-
return checkCallingOrSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) == android.content.pm.PackageManager.PERMISSION_GRANTED
59+
return com.sameerasw.essentials.utils.PermissionUtils.canWriteSecureSettings(this) ||
60+
(ShellUtils.isAvailable(this) && ShellUtils.hasPermission(this))
6061
}
6162

6263
override fun getTileIcon(): Icon {
@@ -80,8 +81,10 @@ class NfcTileService : BaseTileService() {
8081
val method: Method = nfcAdapter.javaClass.getMethod(methodName)
8182
method.invoke(nfcAdapter) as Boolean
8283
} catch (e: Exception) {
83-
e.printStackTrace()
84-
false
84+
// Fallback to shell if reflection fails
85+
val command = if (enable) "svc nfc enable" else "svc nfc disable"
86+
ShellUtils.runCommand(context, command)
87+
true
8588
}
8689
}
8790
}

app/src/main/java/com/sameerasw/essentials/ui/activities/YourAndroidActivity.kt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class YourAndroidActivity : ComponentActivity() {
122122
setContent {
123123
val mainViewModel: com.sameerasw.essentials.viewmodels.MainViewModel = androidx.lifecycle.viewmodel.compose.viewModel()
124124
val isPitchBlackThemeEnabled by mainViewModel.isPitchBlackThemeEnabled
125+
val isBlurEnabled by mainViewModel.isBlurEnabled
125126

126127
val viewModel: YourAndroidViewModel = androidx.lifecycle.viewmodel.compose.viewModel()
127128
val deviceSpecs by viewModel.deviceSpecs.collectAsState()
@@ -143,10 +144,14 @@ class YourAndroidActivity : ComponentActivity() {
143144
modifier = Modifier
144145
.fillMaxSize()
145146
.background(MaterialTheme.colorScheme.surfaceContainer)
146-
.progressiveBlur(
147-
blurRadius = 40f,
148-
height = statusBarHeightPx * 1.15f,
149-
direction = BlurDirection.TOP
147+
.then(
148+
if (isBlurEnabled) {
149+
Modifier.progressiveBlur(
150+
blurRadius = 40f,
151+
height = statusBarHeightPx * 1.15f,
152+
direction = BlurDirection.TOP
153+
)
154+
} else Modifier
150155
)
151156
) {
152157
YourAndroidContent(
@@ -191,9 +196,11 @@ fun YourAndroidContent(
191196
}
192197
}
193198

199+
val mainViewModel: com.sameerasw.essentials.viewmodels.MainViewModel = androidx.lifecycle.viewmodel.compose.viewModel()
194200
val configuration = LocalConfiguration.current
195201
val screenHeight = configuration.screenHeightDp.dp
196202
val initialImageOffset = (screenHeight / 2) - 240.dp - 64.dp
203+
val isBlurEnabled by mainViewModel.isBlurEnabled
197204

198205
val imageOffsetState = animateDpAsState(
199206
targetValue = if (isStartupAnimationRunning) 0.dp else initialImageOffset,
@@ -220,10 +227,14 @@ fun YourAndroidContent(
220227
Column(
221228
modifier = modifier
222229
.fillMaxSize()
223-
.progressiveBlur(
224-
blurRadius = 40f,
225-
height = with(LocalDensity.current) { 150.dp.toPx() },
226-
direction = BlurDirection.BOTTOM
230+
.then(
231+
if (isBlurEnabled) {
232+
Modifier.progressiveBlur(
233+
blurRadius = 40f,
234+
height = with(LocalDensity.current) { 150.dp.toPx() },
235+
direction = BlurDirection.BOTTOM
236+
)
237+
} else Modifier
227238
)
228239
.verticalScroll(rememberScrollState())
229240
.padding(

app/src/main/java/com/sameerasw/essentials/ui/components/SettingsFloatingToolbar.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenu
3232
import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenuItem
3333
import androidx.compose.foundation.layout.RowScope
3434
import androidx.compose.ui.Alignment
35+
import androidx.compose.ui.platform.LocalView
36+
import com.sameerasw.essentials.utils.HapticUtil
3537

3638
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
3739
@Composable
@@ -42,6 +44,7 @@ fun SettingsFloatingToolbar(
4244
menuContent: (@Composable SettingsMenuScope.() -> Unit)? = null
4345
) {
4446
var menuExpanded by remember { mutableStateOf(false) }
47+
val view = LocalView.current
4548

4649
if (menuContent != null) {
4750
HorizontalFloatingToolbar(
@@ -52,7 +55,10 @@ fun SettingsFloatingToolbar(
5255
floatingActionButton = {
5356
Box {
5457
FloatingActionButton(
55-
onClick = { menuExpanded = true },
58+
onClick = {
59+
HapticUtil.performVirtualKeyHaptic(view)
60+
menuExpanded = true
61+
},
5662
containerColor = MaterialTheme.colorScheme.primaryContainer,
5763
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
5864
shape = MaterialTheme.shapes.large,
@@ -104,8 +110,12 @@ private fun RowScope.ToolbarContent(
104110
title: String,
105111
onBackClick: () -> Unit
106112
) {
113+
val view = LocalView.current
107114
IconButton(
108-
onClick = onBackClick,
115+
onClick = {
116+
HapticUtil.performVirtualKeyHaptic(view)
117+
onBackClick()
118+
},
109119
modifier = Modifier.align(Alignment.CenterVertically),
110120
colors = IconButtonDefaults.filledIconButtonColors(
111121
contentColor = MaterialTheme.colorScheme.primary,

0 commit comments

Comments
 (0)