@@ -52,7 +52,6 @@ import androidx.compose.animation.slideInHorizontally
5252import androidx.compose.animation.slideOutHorizontally
5353import androidx.compose.foundation.Canvas
5454import androidx.compose.foundation.background
55- import androidx.compose.foundation.gestures.detectTapGestures
5655import androidx.compose.foundation.isSystemInDarkTheme
5756import androidx.compose.foundation.layout.Arrangement
5857import androidx.compose.foundation.layout.Box
@@ -64,7 +63,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
6463import androidx.compose.foundation.layout.height
6564import androidx.compose.foundation.layout.padding
6665import androidx.compose.foundation.layout.size
67- import androidx.compose.foundation.layout.width
6866import androidx.compose.foundation.rememberScrollState
6967import androidx.compose.foundation.shape.RoundedCornerShape
7068import androidx.compose.foundation.verticalScroll
@@ -81,8 +79,6 @@ import androidx.compose.material3.Text
8179import androidx.compose.runtime.Composable
8280import androidx.compose.runtime.LaunchedEffect
8381import androidx.compose.runtime.getValue
84- import androidx.compose.runtime.mutableIntStateOf
85- import androidx.compose.runtime.mutableLongStateOf
8682import androidx.compose.runtime.mutableStateOf
8783import androidx.compose.runtime.remember
8884import androidx.compose.runtime.setValue
@@ -94,8 +90,6 @@ import androidx.compose.ui.geometry.Offset
9490import androidx.compose.ui.graphics.Color
9591import androidx.compose.ui.graphics.drawscope.rotate
9692import androidx.compose.ui.graphics.vector.ImageVector
97- import androidx.compose.ui.input.pointer.PointerEventPass
98- import androidx.compose.ui.input.pointer.pointerInput
9993import androidx.compose.ui.platform.LocalContext
10094import androidx.compose.ui.platform.LocalWindowInfo
10195import androidx.compose.ui.res.stringResource
@@ -122,12 +116,11 @@ import com.kyant.backdrop.backdrops.rememberLayerBackdrop
122116import dev.chrisbanes.haze.hazeSource
123117import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
124118import dev.chrisbanes.haze.rememberHazeState
125- import kotlinx.coroutines.delay
126- import me.kavishdevar.librepods.billing.BillingManager
127- import me.kavishdevar.librepods.billing.BillingProviderFactory
128119import me.kavishdevar.librepods.data.AirPodsNotifications
129120import me.kavishdevar.librepods.data.ControlCommandRepository
130121import me.kavishdevar.librepods.presentation.components.ConfirmationDialog
122+ import me.kavishdevar.librepods.presentation.components.DeviceInfoCard
123+ import me.kavishdevar.librepods.presentation.components.PlayBypassSheet
131124import me.kavishdevar.librepods.presentation.components.StyledButton
132125import me.kavishdevar.librepods.presentation.components.StyledIconButton
133126import me.kavishdevar.librepods.presentation.screens.AccessibilitySettingsScreen
@@ -148,6 +141,7 @@ import me.kavishdevar.librepods.presentation.screens.TransparencySettingsScreen
148141import me.kavishdevar.librepods.presentation.screens.TroubleshootingScreen
149142import me.kavishdevar.librepods.presentation.screens.UpdateHearingTestScreen
150143import me.kavishdevar.librepods.presentation.screens.VersionScreen
144+ import me.kavishdevar.librepods.presentation.theme.LibrePodsTheme
151145import me.kavishdevar.librepods.presentation.viewmodel.AirPodsViewModel
152146import me.kavishdevar.librepods.presentation.viewmodel.AppSettingsViewModel
153147import me.kavishdevar.librepods.presentation.viewmodel.PurchaseViewModel
@@ -175,7 +169,7 @@ class MainActivity : ComponentActivity() {
175169 enableEdgeToEdge()
176170
177171 setContent {
178- _root_ide_package_ .me.kavishdevar.librepods.presentation.theme. LibrePodsTheme {
172+ LibrePodsTheme {
179173 Main ()
180174 }
181175 }
@@ -224,81 +218,72 @@ fun Main() {
224218 val sharedPreferences = context.getSharedPreferences(" settings" , MODE_PRIVATE )
225219 if (! isSupported(sharedPreferences)) {
226220 val showDialog = remember { mutableStateOf(false ) }
227-
221+ val showPlayBypassVisible = remember { mutableStateOf( false ) }
228222 val hazeState = rememberHazeState()
223+ val backdrop = rememberLayerBackdrop()
224+ val isDarkTheme = isSystemInDarkTheme()
225+ val textColor = if (isDarkTheme) Color .White else Color .Black
226+ val backgroundColor = if (isSystemInDarkTheme()) Color (0xFF1C1C1E ) else Color (0xFFFFFFFF )
229227
230228 Box (
231229 modifier = Modifier
232230 .fillMaxSize()
233231 .hazeSource(hazeState)
234- .background(if (isSystemInDarkTheme()) Color .Black else Color (0xFFF2F2F7 )),
232+ .layerBackdrop(backdrop)
233+ .background(if (isDarkTheme) Color .Black else Color (0xFFF2F2F7 )),
235234 contentAlignment = Alignment .Center
236235 ) {
237- Box (
238- modifier = Modifier
239- .fillMaxSize()
240- )
241236 Column (
242- verticalArrangement = Arrangement .spacedBy(8 .dp)
237+ modifier = Modifier .padding(horizontal = 16 .dp),
238+ verticalArrangement = Arrangement
239+ .spacedBy(16 .dp)
243240 ) {
244- Text (
245- text = stringResource(R .string.not_supported),
246- style = TextStyle (
247- fontFamily = FontFamily (Font (R .font.sf_pro)),
248- fontWeight = FontWeight .SemiBold ,
249- color = if (isSystemInDarkTheme()) Color .White else Color .Black ,
250- fontSize = 20 .sp
251- ),
252- textAlign = TextAlign .Center ,
253- modifier = Modifier .fillMaxWidth()
254- )
255- Row (
256- modifier = Modifier .fillMaxWidth(),
257- horizontalArrangement = Arrangement .Center
241+ val innerBackdrop = rememberLayerBackdrop()
242+
243+ Column (
244+ modifier = Modifier .layerBackdrop(innerBackdrop),
245+ verticalArrangement = Arrangement
246+ .spacedBy(16 .dp)
258247 ) {
259248 Text (
260- text = " Device Info: " ,
249+ text = stringResource( R .string.not_supported) ,
261250 style = TextStyle (
262251 fontFamily = FontFamily (Font (R .font.sf_pro)),
263- fontWeight = FontWeight .Medium ,
264- color = if (isSystemInDarkTheme()) Color .White else Color .Black ,
265- fontSize = 16 .sp
266- ),
267- textAlign = TextAlign .End ,
268- )
269- Spacer (modifier = Modifier .width(4 .dp))
270- Text (
271- text =
272- " MANUFACTURER=${Build .MANUFACTURER } \n " +
273- " MODEL=${Build .MODEL } \n " +
274- " BUILD_ID=${Build .ID } \n " +
275- " SDK_INT_FULL= ${Build .VERSION .SDK_INT_FULL } \n " ,
276- style = TextStyle (
277- fontFamily = FontFamily (Font (R .font.hack)),
278- fontWeight = FontWeight .Medium ,
279- color = if (isSystemInDarkTheme()) Color .White else Color .Black ,
280- fontSize = 16 .sp
252+ fontWeight = FontWeight .SemiBold ,
253+ color = textColor,
254+ fontSize = 20 .sp,
255+ textAlign = TextAlign .Center
281256 ),
282- textAlign = TextAlign . Start ,
257+ modifier = Modifier .fillMaxWidth()
283258 )
259+
260+ DeviceInfoCard ()
261+
262+ Box (
263+ modifier = Modifier
264+ .fillMaxWidth()
265+ .background(backgroundColor, RoundedCornerShape (28 .dp))
266+ .clip(RoundedCornerShape (28 .dp))
267+ ) {
268+ Text (
269+ text = stringResource(R .string.check_the_repository_for_more_info),
270+ style = TextStyle (
271+ fontFamily = FontFamily (Font (R .font.sf_pro)),
272+ fontWeight = FontWeight .Medium ,
273+ color = if (isSystemInDarkTheme()) Color .White else Color .Black ,
274+ fontSize = 16 .sp
275+ ),
276+ modifier = Modifier
277+ .fillMaxWidth()
278+ .padding(horizontal = 12 .dp, vertical = 16 .dp)
279+ )
280+ }
284281 }
285- Text (
286- text = stringResource(R .string.check_the_repository_for_more_info),
287- style = TextStyle (
288- fontFamily = FontFamily (Font (R .font.sf_pro)),
289- fontWeight = FontWeight .Medium ,
290- color = if (isSystemInDarkTheme()) Color .White else Color .Black ,
291- fontSize = 18 .sp
292- ),
293- textAlign = TextAlign .Center ,
294- modifier = Modifier .fillMaxWidth()
295- )
296282 StyledButton (
297283 onClick = { showDialog.value = true },
298- backdrop = rememberLayerBackdrop() ,
284+ backdrop = innerBackdrop ,
299285 modifier = Modifier
300286 .fillMaxWidth()
301- .padding(8 .dp)
302287 ) {
303288 Text (
304289 text = stringResource(R .string.bypass_compatibility_check),
@@ -317,15 +302,19 @@ fun Main() {
317302 showDialog = showDialog,
318303 title = stringResource(R .string.bypass_compatibility_check),
319304 message = stringResource(R .string.bypass_compatiblity_check_confirmation),
320- confirmText = " Yes " ,
321- dismissText = " No " ,
305+ confirmText = stringResource( R .string.yes) ,
306+ dismissText = stringResource( R .string.no) ,
322307 onConfirm = {
323308 showDialog.value = false
324- sharedPreferences.edit {
325- putBoolean(" bypass_device_check" , true )
326- val intent = Intent (context, MainActivity ::class .java)
327- intent.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK )
328- context.startActivity(intent)
309+ if (BuildConfig .PLAY_BUILD ) {
310+ showPlayBypassVisible.value = true
311+ } else {
312+ sharedPreferences.edit {
313+ putBoolean(" bypass_device_check" , true )
314+ val intent = Intent (context, MainActivity ::class .java)
315+ intent.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK )
316+ context.startActivity(intent)
317+ }
329318 }
330319 },
331320 onDismiss = {
@@ -334,6 +323,26 @@ fun Main() {
334323 hazeState = hazeState
335324 )
336325
326+ if (BuildConfig .PLAY_BUILD ) {
327+ PlayBypassSheet (
328+ visible = showPlayBypassVisible.value,
329+ onDismiss = {
330+ showPlayBypassVisible.value = false
331+ showDialog.value = true
332+ },
333+ onConfirm = {
334+ showPlayBypassVisible.value = false
335+ sharedPreferences.edit {
336+ putBoolean(" bypass_device_check" , true )
337+ val intent = Intent (context, MainActivity ::class .java)
338+ intent.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK )
339+ context.startActivity(intent)
340+ }
341+ },
342+ backdrop = backdrop
343+ )
344+ }
345+
337346 return
338347 }
339348
@@ -347,8 +356,6 @@ fun Main() {
347356 )
348357 }
349358
350- BillingManager .provider = BillingProviderFactory .create(context)
351-
352359 val bluetoothPermissions = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .S ) {
353360 listOf (
354361 " android.permission.BLUETOOTH_CONNECT" ,
@@ -484,7 +491,7 @@ fun Main() {
484491 if (airPodsViewModel != null ) VersionScreen (airPodsViewModel)
485492 }
486493 composable(" hearing_protection" ) {
487- if (airPodsViewModel != null ) HearingProtectionScreen (airPodsViewModel)
494+ if (airPodsViewModel != null ) HearingProtectionScreen (airPodsViewModel, navController )
488495 }
489496 composable(" purchase_screen" ) {
490497 val purchaseViewModel: PurchaseViewModel = viewModel()
0 commit comments