Skip to content

Commit 8e670c2

Browse files
committed
android: fix last commit; update copyright notice to "LibrePods Contributors"
1 parent aec9c71 commit 8e670c2

File tree

7 files changed

+68
-40
lines changed

7 files changed

+68
-40
lines changed

android/app/src/main/java/me/kavishdevar/librepods/composables/ControlCenterButton.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LibrePods - AirPods liberated from Apple’s ecosystem
33
*
4-
* Copyright (C) 2025 Kavish Devar
4+
* Copyright (C) 2025 LibrePods Contributors
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Affero General Public License as published

android/app/src/main/java/me/kavishdevar/librepods/composables/ControlCenterNoiseControlSegmentedButton.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LibrePods - AirPods liberated from Apple’s ecosystem
33
*
4-
* Copyright (C) 2025 Kavish Devar
4+
* Copyright (C) 2025 LibrePods Contributors
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Affero General Public License as published

android/app/src/main/java/me/kavishdevar/librepods/composables/VerticalVolumeSlider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LibrePods - AirPods liberated from Apple’s ecosystem
33
*
4-
* Copyright (C) 2025 Kavish Devar
4+
* Copyright (C) 2025 LibrePods Contributors
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Affero General Public License as published

android/app/src/main/java/me/kavishdevar/librepods/screens/AppSettingsScreen.kt

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ import androidx.compose.runtime.remember
6464
import androidx.compose.runtime.setValue
6565
import androidx.compose.ui.Alignment
6666
import androidx.compose.ui.Modifier
67+
import androidx.compose.ui.draw.drawBehind
6768
import androidx.compose.ui.draw.scale
6869
import androidx.compose.ui.draw.shadow
70+
import androidx.compose.ui.geometry.Offset
6971
import androidx.compose.ui.graphics.Color
7072
import androidx.compose.ui.input.nestedscroll.nestedScroll
7173
import androidx.compose.ui.platform.LocalContext
@@ -78,16 +80,18 @@ import androidx.compose.ui.text.style.TextOverflow
7880
import androidx.compose.ui.unit.dp
7981
import androidx.compose.ui.unit.sp
8082
import androidx.navigation.NavController
81-
import dev.chrisbanes.haze.HazeDefaults
83+
import dev.chrisbanes.haze.HazeEffectScope
8284
import dev.chrisbanes.haze.HazeState
83-
import dev.chrisbanes.haze.haze
84-
import dev.chrisbanes.haze.hazeChild
85+
import dev.chrisbanes.haze.hazeEffect
86+
import dev.chrisbanes.haze.hazeSource
87+
import dev.chrisbanes.haze.materials.CupertinoMaterials
88+
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
8589
import me.kavishdevar.librepods.R
8690
import me.kavishdevar.librepods.composables.StyledSwitch
8791
import me.kavishdevar.librepods.utils.RadareOffsetFinder
8892
import kotlin.math.roundToInt
8993

90-
@OptIn(ExperimentalMaterial3Api::class)
94+
@OptIn(ExperimentalMaterial3Api::class, ExperimentalHazeMaterialsApi::class)
9195
@Composable
9296
fun AppSettingsScreen(navController: NavController) {
9397
val sharedPreferences = LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
@@ -115,19 +119,31 @@ fun AppSettingsScreen(navController: NavController) {
115119
var disconnectWhenNotWearing by remember {
116120
mutableStateOf(sharedPreferences.getBoolean("disconnect_when_not_wearing", false))
117121
}
118-
122+
var mDensity by remember { mutableFloatStateOf(0f) }
119123
Scaffold(
120124
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
121125
topBar = {
122126
CenterAlignedTopAppBar(
123-
modifier = Modifier.hazeChild(
127+
modifier = Modifier.hazeEffect(
124128
state = hazeState,
125-
style = HazeDefaults.style(
126-
backgroundColor = if (isDarkTheme) Color(0xFF000000).copy(alpha = 0.7f)
127-
else Color(0xFFF2F2F7).copy(alpha = 0.7f),
128-
tint = Color.White.copy(alpha = 0.2f)
129-
)
130-
),
129+
style = CupertinoMaterials.thick(),
130+
block = fun HazeEffectScope.() {
131+
alpha =
132+
if (scrollState.value > 60.dp.value * mDensity) 1f else 0f
133+
})
134+
.drawBehind {
135+
mDensity = density
136+
val strokeWidth = 0.7.dp.value * density
137+
val y = size.height - strokeWidth / 2
138+
if (scrollState.value > 60.dp.value * density) {
139+
drawLine(
140+
if (isDarkTheme) Color.DarkGray else Color.LightGray,
141+
Offset(0f, y),
142+
Offset(size.width, y),
143+
strokeWidth
144+
)
145+
}
146+
},
131147
title = {
132148
Text(
133149
text = stringResource(R.string.app_settings),
@@ -177,10 +193,7 @@ fun AppSettingsScreen(navController: NavController) {
177193
.padding(paddingValues)
178194
.padding(horizontal = 16.dp)
179195
.verticalScroll(scrollState)
180-
.haze(
181-
state = hazeState,
182-
style = HazeDefaults.style(backgroundColor = Color.Transparent)
183-
)
196+
.hazeSource(state = hazeState)
184197
) {
185198
val isDarkTheme = isSystemInDarkTheme()
186199
val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF)
@@ -200,7 +213,7 @@ fun AppSettingsScreen(navController: NavController) {
200213
)
201214

202215
Spacer(modifier = Modifier.height(2.dp))
203-
216+
204217
Column (
205218
modifier = Modifier
206219
.fillMaxWidth()
@@ -468,9 +481,9 @@ fun AppSettingsScreen(navController: NavController) {
468481
),
469482
modifier = Modifier.padding(8.dp, bottom = 2.dp, top = 24.dp)
470483
)
471-
484+
472485
Spacer(modifier = Modifier.height(2.dp))
473-
486+
474487
Column(
475488
modifier = Modifier
476489
.fillMaxWidth()

android/app/src/main/java/me/kavishdevar/librepods/screens/HeadTrackingScreen.kt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import androidx.compose.runtime.rememberCoroutineScope
7272
import androidx.compose.runtime.setValue
7373
import androidx.compose.ui.Alignment
7474
import androidx.compose.ui.Modifier
75+
import androidx.compose.ui.draw.drawBehind
7576
import androidx.compose.ui.draw.scale
7677
import androidx.compose.ui.geometry.CornerRadius
7778
import androidx.compose.ui.geometry.Offset
@@ -101,10 +102,12 @@ import androidx.compose.ui.tooling.preview.Preview
101102
import androidx.compose.ui.unit.dp
102103
import androidx.compose.ui.unit.sp
103104
import androidx.navigation.NavController
104-
import dev.chrisbanes.haze.HazeDefaults
105+
import dev.chrisbanes.haze.HazeEffectScope
105106
import dev.chrisbanes.haze.HazeState
106-
import dev.chrisbanes.haze.haze
107-
import dev.chrisbanes.haze.hazeChild
107+
import dev.chrisbanes.haze.hazeEffect
108+
import dev.chrisbanes.haze.hazeSource
109+
import dev.chrisbanes.haze.materials.CupertinoMaterials
110+
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
108111
import kotlinx.coroutines.CoroutineScope
109112
import kotlinx.coroutines.delay
110113
import kotlinx.coroutines.launch
@@ -117,6 +120,7 @@ import kotlin.math.cos
117120
import kotlin.math.sin
118121
import kotlin.random.Random
119122

123+
@ExperimentalHazeMaterialsApi
120124
@RequiresApi(Build.VERSION_CODES.Q)
121125
@OptIn(ExperimentalMaterial3Api::class, ExperimentalAnimationApi::class)
122126
@Composable
@@ -131,23 +135,36 @@ fun HeadTrackingScreen(navController: NavController) {
131135
val isDarkTheme = isSystemInDarkTheme()
132136
val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF)
133137
val textColor = if (isDarkTheme) Color.White else Color.Black
134-
138+
135139
val scrollState = rememberScrollState()
136140
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
137141
val hazeState = remember { HazeState() }
138-
142+
143+
var mDensity by remember { mutableFloatStateOf(0f) }
139144
Scaffold(
140145
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
141146
topBar = {
142147
CenterAlignedTopAppBar(
143-
modifier = Modifier.hazeChild(
148+
modifier = Modifier.hazeEffect(
144149
state = hazeState,
145-
style = HazeDefaults.style(
146-
backgroundColor = if (isDarkTheme) Color(0xFF000000).copy(alpha = 0.7f)
147-
else Color(0xFFF2F2F7).copy(alpha = 0.7f),
148-
tint = Color.White.copy(alpha = 0.2f)
149-
)
150-
),
150+
style = CupertinoMaterials.thick(),
151+
block = fun HazeEffectScope.() {
152+
alpha =
153+
if (scrollState.value > 60.dp.value * mDensity) 1f else 0f
154+
})
155+
.drawBehind {
156+
mDensity = density
157+
val strokeWidth = 0.7.dp.value * density
158+
val y = size.height - strokeWidth / 2
159+
if (scrollState.value > 60.dp.value * density) {
160+
drawLine(
161+
if (isDarkTheme) Color.DarkGray else Color.LightGray,
162+
Offset(0f, y),
163+
Offset(size.width, y),
164+
strokeWidth
165+
)
166+
}
167+
},
151168
title = {
152169
Text(
153170
stringResource(R.string.head_tracking),
@@ -246,10 +263,7 @@ fun HeadTrackingScreen(navController: NavController) {
246263
.padding(horizontal = 16.dp)
247264
.padding(top = 8.dp)
248265
.verticalScroll(scrollState)
249-
.haze(
250-
state = hazeState,
251-
style = HazeDefaults.style(backgroundColor = Color.Transparent)
252-
)
266+
.hazeSource(state = hazeState)
253267
) {
254268
val sharedPreferences =
255269
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
@@ -833,6 +847,7 @@ private fun AccelerationPlot() {
833847
}
834848
}
835849

850+
@ExperimentalHazeMaterialsApi
836851
@RequiresApi(Build.VERSION_CODES.Q)
837852
@Preview
838853
@Composable

android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsQSService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LibrePods - AirPods liberated from Apple’s ecosystem
33
*
4-
* Copyright (C) 2025 Kavish Devar
4+
* Copyright (C) 2025 LibrePods Contributors
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Affero General Public License as published

android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LibrePods - AirPods liberated from Apple’s ecosystem
33
*
4-
* Copyright (C) 2025 Kavish Devar
4+
* Copyright (C) 2025 LibrePods Contributors
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU Affero General Public License as published

0 commit comments

Comments
 (0)