Skip to content

Commit 86a6a28

Browse files
committed
android: a very big commit
refactoring ui, mostly
1 parent 7e5ee67 commit 86a6a28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2377
-2093
lines changed

android/app/src/main/java/me/kavishdevar/librepods/MainActivity.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,17 @@ import com.google.accompanist.permissions.rememberMultiplePermissionsState
109109
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
110110
import me.kavishdevar.librepods.constants.AirPodsNotifications
111111
import me.kavishdevar.librepods.screens.AccessibilitySettingsScreen
112+
import me.kavishdevar.librepods.screens.AdaptiveStrengthScreen
112113
import me.kavishdevar.librepods.screens.AirPodsSettingsScreen
113114
import me.kavishdevar.librepods.screens.AppSettingsScreen
114115
import me.kavishdevar.librepods.screens.DebugScreen
115116
import me.kavishdevar.librepods.screens.HeadTrackingScreen
116-
import me.kavishdevar.librepods.screens.HearingAidScreen
117117
import me.kavishdevar.librepods.screens.HearingAidAdjustmentsScreen
118-
import me.kavishdevar.librepods.screens.TransparencySettingsScreen
118+
import me.kavishdevar.librepods.screens.HearingAidScreen
119119
import me.kavishdevar.librepods.screens.LongPress
120120
import me.kavishdevar.librepods.screens.Onboarding
121121
import me.kavishdevar.librepods.screens.RenameScreen
122+
import me.kavishdevar.librepods.screens.TransparencySettingsScreen
122123
import me.kavishdevar.librepods.screens.TroubleshootingScreen
123124
import me.kavishdevar.librepods.services.AirPodsService
124125
import me.kavishdevar.librepods.ui.theme.LibrePodsTheme
@@ -201,15 +202,12 @@ class MainActivity : ComponentActivity() {
201202
if (data != null && data.scheme == "librepods") {
202203
when (data.host) {
203204
"add-magic-keys" -> {
204-
// Extract query parameters
205205
val queryParams = data.queryParameterNames
206206
queryParams.forEach { param ->
207207
val value = data.getQueryParameter(param)
208-
// Handle your parameters here
209208
Log.d("LibrePods", "Parameter: $param = $value")
210209
}
211210

212-
// Process the magic keys addition
213211
handleAddMagicKeys(data)
214212
}
215213
}
@@ -369,7 +367,7 @@ fun Main() {
369367
name = navBackStackEntry.arguments?.getString("bud")!!
370368
)
371369
}
372-
composable("rename") { navBackStackEntry ->
370+
composable("rename") {
373371
RenameScreen(navController)
374372
}
375373
composable("app_settings") {
@@ -396,6 +394,9 @@ fun Main() {
396394
composable("hearing_aid_adjustments") {
397395
HearingAidAdjustmentsScreen(navController)
398396
}
397+
composable("adaptive_strength") {
398+
AdaptiveStrengthScreen(navController)
399+
}
399400
}
400401
}
401402

android/app/src/main/java/me/kavishdevar/librepods/QuickSettingsDialogActivity.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* LibrePods - AirPods liberated from Apple’s ecosystem
3+
*
4+
* Copyright (C) 2025 LibrePods contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published
8+
* by the Free Software Foundation, either version 3 of the License.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
119
@file:OptIn(ExperimentalEncodingApi::class)
220

321
package me.kavishdevar.librepods

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

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,32 @@
2020

2121
package me.kavishdevar.librepods.composables
2222

23-
import android.util.Log
2423
import androidx.compose.foundation.background
2524
import androidx.compose.foundation.isSystemInDarkTheme
2625
import androidx.compose.foundation.layout.Column
2726
import androidx.compose.foundation.layout.fillMaxWidth
2827
import androidx.compose.foundation.layout.padding
2928
import androidx.compose.foundation.shape.RoundedCornerShape
30-
import androidx.compose.material3.Text
3129
import androidx.compose.material3.HorizontalDivider
30+
import androidx.compose.material3.Text
3231
import androidx.compose.runtime.Composable
33-
import androidx.compose.runtime.DisposableEffect
34-
import androidx.compose.runtime.LaunchedEffect
3532
import androidx.compose.ui.Modifier
33+
import androidx.compose.ui.draw.clip
3634
import androidx.compose.ui.graphics.Color
3735
import androidx.compose.ui.res.stringResource
3836
import androidx.compose.ui.text.TextStyle
3937
import androidx.compose.ui.text.font.FontWeight
4038
import androidx.compose.ui.tooling.preview.Preview
4139
import androidx.compose.ui.unit.dp
4240
import androidx.compose.ui.unit.sp
41+
import androidx.navigation.NavController
42+
import androidx.navigation.compose.rememberNavController
4343
import me.kavishdevar.librepods.R
44-
import me.kavishdevar.librepods.services.ServiceManager
44+
import me.kavishdevar.librepods.utils.AACPManager
4545
import kotlin.io.encoding.ExperimentalEncodingApi
4646

4747
@Composable
48-
fun AudioSettings() {
48+
fun AudioSettings(navController: NavController) {
4949
val isDarkTheme = isSystemInDarkTheme()
5050
val textColor = if (isDarkTheme) Color.White else Color.Black
5151

@@ -63,20 +63,31 @@ fun AudioSettings() {
6363

6464
Column(
6565
modifier = Modifier
66+
.clip(RoundedCornerShape(14.dp))
6667
.fillMaxWidth()
6768
.background(backgroundColor, RoundedCornerShape(14.dp))
6869
.padding(top = 2.dp)
6970
) {
7071

71-
PersonalizedVolumeSwitch()
72+
StyledToggle(
73+
label = stringResource(R.string.personalized_volume),
74+
description = stringResource(R.string.personalized_volume_description),
75+
controlCommandIdentifier = AACPManager.Companion.ControlCommandIdentifiers.ADAPTIVE_VOLUME_CONFIG,
76+
independent = false
77+
)
7278
HorizontalDivider(
7379
thickness = 1.5.dp,
7480
color = Color(0x40888888),
7581
modifier = Modifier
7682
.padding(start = 12.dp, end = 0.dp)
7783
)
7884

79-
ConversationalAwarenessSwitch()
85+
StyledToggle(
86+
label = stringResource(R.string.conversational_awareness),
87+
description = stringResource(R.string.conversational_awareness_description),
88+
controlCommandIdentifier = AACPManager.Companion.ControlCommandIdentifiers.CONVERSATION_DETECT_CONFIG,
89+
independent = false
90+
)
8091
HorizontalDivider(
8192
thickness = 1.5.dp,
8293
color = Color(0x40888888),
@@ -92,39 +103,17 @@ fun AudioSettings() {
92103
.padding(start = 12.dp, end = 0.dp)
93104
)
94105

95-
Column(
96-
modifier = Modifier
97-
.fillMaxWidth()
98-
.padding(horizontal = 8.dp, vertical = 10.dp)
99-
) {
100-
Text(
101-
text = stringResource(R.string.adaptive_audio),
102-
modifier = Modifier
103-
.padding(end = 8.dp, bottom = 2.dp, start = 2.dp)
104-
.fillMaxWidth(),
105-
style = TextStyle(
106-
fontSize = 16.sp,
107-
color = textColor
108-
)
109-
)
110-
Text(
111-
text = stringResource(R.string.adaptive_audio_description),
112-
modifier = Modifier
113-
.padding(bottom = 8.dp, top = 2.dp)
114-
.padding(end = 2.dp, start = 2.dp)
115-
.fillMaxWidth(),
116-
style = TextStyle(
117-
fontSize = 12.sp,
118-
color = textColor.copy(alpha = 0.6f)
119-
)
120-
)
121-
AdaptiveStrengthSlider()
122-
}
106+
NavigationButton(
107+
to = "adaptive_strength",
108+
name = stringResource(R.string.adaptive_audio),
109+
navController = navController,
110+
independent = false
111+
)
123112
}
124113
}
125114

126115
@Preview
127116
@Composable
128117
fun AudioSettingsPreview() {
129-
AudioSettings()
118+
AudioSettings(rememberNavController())
130119
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package me.kavishdevar.librepods.composables
2222

23+
import android.content.Context.MODE_PRIVATE
2324
import androidx.compose.foundation.background
2425
import androidx.compose.foundation.clickable
2526
import androidx.compose.foundation.gestures.detectTapGestures
@@ -35,8 +36,8 @@ import androidx.compose.foundation.shape.RoundedCornerShape
3536
import androidx.compose.material3.Text
3637
import androidx.compose.runtime.Composable
3738
import androidx.compose.runtime.DisposableEffect
38-
import androidx.compose.runtime.getValue
3939
import androidx.compose.runtime.LaunchedEffect
40+
import androidx.compose.runtime.getValue
4041
import androidx.compose.runtime.mutableStateOf
4142
import androidx.compose.runtime.remember
4243
import androidx.compose.runtime.setValue
@@ -45,7 +46,6 @@ import androidx.compose.ui.Modifier
4546
import androidx.compose.ui.graphics.Color
4647
import androidx.compose.ui.input.pointer.pointerInput
4748
import androidx.compose.ui.platform.LocalContext
48-
import android.content.Context.MODE_PRIVATE
4949
import androidx.compose.ui.res.stringResource
5050
import androidx.compose.ui.tooling.preview.Preview
5151
import androidx.compose.ui.unit.dp
@@ -59,9 +59,9 @@ import kotlin.io.encoding.ExperimentalEncodingApi
5959
fun AutomaticConnectionSwitch() {
6060
val sharedPreferences = LocalContext.current.getSharedPreferences("settings", MODE_PRIVATE)
6161
val service = ServiceManager.getService()!!
62-
63-
val shared_preference_key = "automatic_connection_ctrl_cmd"
64-
62+
63+
val sharedPreferenceKey = "automatic_connection_ctrl_cmd"
64+
6565
val automaticConnectionEnabledValue = service.aacpManager.controlCommandStatusList.find {
6666
it.identifier == AACPManager.Companion.ControlCommandIdentifiers.AUTOMATIC_CONNECTION_CONFIG
6767
}?.value?.takeIf { it.isNotEmpty() }?.get(0)
@@ -71,7 +71,7 @@ fun AutomaticConnectionSwitch() {
7171
if (automaticConnectionEnabledValue != null) {
7272
automaticConnectionEnabledValue == 1.toByte()
7373
} else {
74-
sharedPreferences.getBoolean(shared_preference_key, false)
74+
sharedPreferences.getBoolean(sharedPreferenceKey, false)
7575
}
7676
)
7777
}
@@ -83,9 +83,9 @@ fun AutomaticConnectionSwitch() {
8383
enabled
8484
)
8585
// todo: send other connected devices smartAudioRoutingDisabled or something, check packets again.
86-
86+
8787
sharedPreferences.edit()
88-
.putBoolean(shared_preference_key, enabled)
88+
.putBoolean(sharedPreferenceKey, enabled)
8989
.apply()
9090
}
9191

@@ -95,14 +95,14 @@ fun AutomaticConnectionSwitch() {
9595
val newValue = controlCommand.value.takeIf { it.isNotEmpty() }?.get(0)
9696
val enabled = newValue == 1.toByte()
9797
automaticConnectionEnabled = enabled
98-
98+
9999
sharedPreferences.edit()
100-
.putBoolean(shared_preference_key, enabled)
100+
.putBoolean(sharedPreferenceKey, enabled)
101101
.apply()
102102
}
103103
}
104104
}
105-
105+
106106
LaunchedEffect(Unit) {
107107
service.aacpManager.registerControlCommandListener(
108108
AACPManager.Companion.ControlCommandIdentifiers.AUTOMATIC_CONNECTION_CONFIG,

0 commit comments

Comments
 (0)