Skip to content

Commit 342745e

Browse files
committed
android: add accessiblity service for camera control
1 parent 8b49440 commit 342745e

13 files changed

Lines changed: 471 additions & 336 deletions

android/app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,17 @@
117117
<action android:name="android.service.quicksettings.action.QS_TILE" />
118118
</intent-filter>
119119
</service>
120-
120+
<service
121+
android:name=".services.AppListenerService"
122+
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
123+
android:exported="true">
124+
<intent-filter>
125+
<action android:name="android.accessibilityservice.AccessibilityService" />
126+
</intent-filter>
127+
<meta-data
128+
android:name="android.accessibilityservice"
129+
android:resource="@xml/app_listener_service_config" />
130+
</service>
121131
<receiver
122132
android:name=".receivers.BootReceiver"
123133
android:enabled="true"

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package me.kavishdevar.librepods.composables
2222

2323
import androidx.compose.foundation.background
2424
import androidx.compose.foundation.isSystemInDarkTheme
25+
import androidx.compose.foundation.layout.Box
2526
import androidx.compose.foundation.layout.Column
2627
import androidx.compose.foundation.layout.fillMaxWidth
2728
import androidx.compose.foundation.layout.padding
@@ -50,15 +51,20 @@ fun AudioSettings(navController: NavController) {
5051
val isDarkTheme = isSystemInDarkTheme()
5152
val textColor = if (isDarkTheme) Color.White else Color.Black
5253

53-
Text(
54-
text = stringResource(R.string.audio),
55-
style = TextStyle(
56-
fontSize = 14.sp,
57-
fontWeight = FontWeight.Bold,
58-
color = textColor.copy(alpha = 0.6f)
59-
),
60-
modifier = Modifier.padding(16.dp, bottom = 4.dp)
61-
)
54+
Box(
55+
modifier = Modifier
56+
.background(if (isDarkTheme) Color(0xFF000000) else Color(0xFFF2F2F7))
57+
.padding(horizontal = 16.dp, vertical = 4.dp)
58+
){
59+
Text(
60+
text = stringResource(R.string.audio),
61+
style = TextStyle(
62+
fontSize = 14.sp,
63+
fontWeight = FontWeight.Bold,
64+
color = textColor.copy(alpha = 0.6f)
65+
)
66+
)
67+
}
6268

6369
val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF)
6470

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,21 @@ fun CallControlSettings(hazeState: HazeState) {
7272
val isDarkTheme = isSystemInDarkTheme()
7373
val textColor = if (isDarkTheme) Color.White else Color.Black
7474
val backgroundColor = if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF)
75-
76-
Text(
77-
text = stringResource(R.string.call_controls),
78-
style = TextStyle(
79-
fontSize = 14.sp,
80-
fontWeight = FontWeight.Bold,
81-
color = textColor.copy(alpha = 0.6f)
82-
),
83-
modifier = Modifier.padding(16.dp, bottom = 4.dp)
84-
)
75+
Box(
76+
modifier = Modifier
77+
.background(if (isDarkTheme) Color(0xFF000000) else Color(0xFFF2F2F7))
78+
.padding(horizontal = 16.dp, vertical = 4.dp)
79+
){
80+
Text(
81+
text = stringResource(R.string.call_controls),
82+
style = TextStyle(
83+
fontSize = 14.sp,
84+
fontWeight = FontWeight.Bold,
85+
color = textColor.copy(alpha = 0.6f)
86+
),
87+
modifier = Modifier.padding(16.dp, bottom = 4.dp)
88+
)
89+
}
8590

8691
Column(
8792
modifier = Modifier

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

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.compose.animation.core.tween
2323
import androidx.compose.foundation.background
2424
import androidx.compose.foundation.gestures.detectTapGestures
2525
import androidx.compose.foundation.isSystemInDarkTheme
26+
import androidx.compose.foundation.layout.Box
2627
import androidx.compose.foundation.layout.Column
2728
import androidx.compose.foundation.layout.Row
2829
import androidx.compose.foundation.layout.Spacer
@@ -56,13 +57,30 @@ fun NavigationButton(
5657
name: String,
5758
navController: NavController, onClick: (() -> Unit)? = null,
5859
independent: Boolean = true,
60+
title: String? = null,
5961
description: String? = null,
6062
currentState: String? = null
6163
) {
6264
val isDarkTheme = isSystemInDarkTheme()
6365
var backgroundColor by remember { mutableStateOf(if (isDarkTheme) Color(0xFF1C1C1E) else Color(0xFFFFFFFF)) }
6466
val animatedBackgroundColor by animateColorAsState(targetValue = backgroundColor, animationSpec = tween(durationMillis = 500))
6567
Column {
68+
if (title != null) {
69+
Box(
70+
modifier = Modifier
71+
.background(if (isDarkTheme) Color(0xFF000000) else Color(0xFFF2F2F7))
72+
.padding(start = 16.dp, end = 16.dp, top = 8.dp, bottom = 4.dp)
73+
){
74+
Text(
75+
text = title,
76+
style = TextStyle(
77+
fontSize = 14.sp,
78+
fontWeight = FontWeight.Bold,
79+
color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy(alpha = 0.6f),
80+
)
81+
)
82+
}
83+
}
6684
Row(
6785
modifier = Modifier
6886
.background(animatedBackgroundColor, RoundedCornerShape(if (independent) 28.dp else 0.dp))
@@ -113,16 +131,22 @@ fun NavigationButton(
113131
)
114132
}
115133
if (description != null) {
116-
Text(
117-
text = description,
118-
style = TextStyle(
119-
fontSize = 12.sp,
120-
fontWeight = FontWeight.Light,
121-
color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy(alpha = 0.6f),
122-
fontFamily = FontFamily(Font(R.font.sf_pro))
123-
),
124-
modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp)
125-
)
134+
Box(
135+
modifier = Modifier
136+
.background(if (isDarkTheme) Color(0xFF000000) else Color(0xFFF2F2F7)) // because blur effect doesn't work for some reason
137+
.padding(horizontal = 16.dp, vertical = 4.dp),
138+
) {
139+
Text(
140+
text = description,
141+
style = TextStyle(
142+
fontSize = 12.sp,
143+
fontWeight = FontWeight.Light,
144+
color = if (isDarkTheme) Color.White.copy(alpha = 0.6f) else Color.Black.copy(alpha = 0.6f),
145+
fontFamily = FontFamily(Font(R.font.sf_pro))
146+
),
147+
// modifier = Modifier.padding(horizontal = 16.dp)
148+
)
149+
}
126150
}
127151
}
128152
}

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,20 @@ fun NoiseControlSettings(
179179
} else {
180180
context.registerReceiver(noiseControlReceiver, noiseControlIntentFilter)
181181
}
182-
183-
Text(
184-
text = stringResource(R.string.noise_control),
185-
style = TextStyle(
186-
fontSize = 14.sp,
187-
fontWeight = FontWeight.Bold,
188-
color = textColor.copy(alpha = 0.6f),
189-
),
190-
modifier = Modifier.padding(8.dp, bottom = 2.dp)
191-
)
182+
Box(
183+
modifier = Modifier
184+
.background(if (isDarkTheme) Color(0xFF000000) else Color(0xFFF2F2F7))
185+
.padding(horizontal = 16.dp, vertical = 4.dp)
186+
){
187+
Text(
188+
text = stringResource(R.string.noise_control),
189+
style = TextStyle(
190+
fontSize = 14.sp,
191+
fontWeight = FontWeight.Bold,
192+
color = textColor.copy(alpha = 0.6f),
193+
)
194+
)
195+
}
192196
@Suppress("COMPOSE_APPLIER_CALL_MISMATCH")
193197
BoxWithConstraints(
194198
modifier = Modifier

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import android.content.Context
2222
import android.content.res.Configuration
2323
import androidx.compose.foundation.background
2424
import androidx.compose.foundation.isSystemInDarkTheme
25+
import androidx.compose.foundation.layout.Box
2526
import androidx.compose.foundation.layout.Column
2627
import androidx.compose.foundation.layout.Spacer
2728
import androidx.compose.foundation.layout.fillMaxWidth
@@ -70,20 +71,21 @@ fun PressAndHoldSettings(navController: NavController) {
7071
StemAction.DIGITAL_ASSISTANT -> "Digital Assistant"
7172
else -> "INVALID!!"
7273
}
73-
74-
Text(
75-
text = stringResource(R.string.press_and_hold_airpods),
76-
style = TextStyle(
77-
fontSize = 14.sp,
78-
fontWeight = FontWeight.Bold,
79-
color = textColor.copy(alpha = 0.6f),
80-
fontFamily = FontFamily(Font(R.font.sf_pro))
81-
),
82-
modifier = Modifier.padding(16.dp, bottom = 4.dp)
83-
)
84-
85-
Spacer(modifier = Modifier.height(1.dp))
86-
74+
Box(
75+
modifier = Modifier
76+
.background(if (isDarkTheme) Color(0xFF000000) else Color(0xFFF2F2F7))
77+
.padding(horizontal = 16.dp, vertical = 4.dp)
78+
){
79+
Text(
80+
text = stringResource(R.string.press_and_hold_airpods),
81+
style = TextStyle(
82+
fontSize = 14.sp,
83+
fontWeight = FontWeight.Bold,
84+
color = textColor.copy(alpha = 0.6f),
85+
fontFamily = FontFamily(Font(R.font.sf_pro))
86+
)
87+
)
88+
}
8789
Column(
8890
modifier = Modifier
8991
.fillMaxWidth()

0 commit comments

Comments
 (0)