@@ -65,6 +65,7 @@ import androidx.compose.foundation.layout.padding
6565import androidx.compose.foundation.layout.size
6666import androidx.compose.foundation.rememberScrollState
6767import androidx.compose.foundation.shape.RoundedCornerShape
68+ import androidx.compose.foundation.text.input.rememberTextFieldState
6869import androidx.compose.foundation.verticalScroll
6970import androidx.compose.material.icons.Icons
7071import androidx.compose.material.icons.filled.Notifications
@@ -86,11 +87,13 @@ import androidx.compose.ui.Alignment
8687import androidx.compose.ui.Modifier
8788import androidx.compose.ui.draw.clip
8889import androidx.compose.ui.draw.scale
90+ import androidx.compose.ui.focus.FocusRequester
8991import androidx.compose.ui.geometry.Offset
9092import androidx.compose.ui.graphics.Color
9193import androidx.compose.ui.graphics.drawscope.rotate
9294import androidx.compose.ui.graphics.vector.ImageVector
9395import androidx.compose.ui.platform.LocalContext
96+ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
9497import androidx.compose.ui.platform.LocalWindowInfo
9598import androidx.compose.ui.res.stringResource
9699import androidx.compose.ui.res.vectorResource
@@ -120,9 +123,12 @@ import me.kavishdevar.librepods.data.AirPodsNotifications
120123import me.kavishdevar.librepods.data.ControlCommandRepository
121124import me.kavishdevar.librepods.presentation.components.ConfirmationDialog
122125import me.kavishdevar.librepods.presentation.components.DeviceInfoCard
123- import me.kavishdevar.librepods.presentation.components.PlayBypassSheet
126+ import me.kavishdevar.librepods.presentation.components.SelectItem
127+ import me.kavishdevar.librepods.presentation.components.StyledBottomSheet
124128import me.kavishdevar.librepods.presentation.components.StyledButton
125129import me.kavishdevar.librepods.presentation.components.StyledIconButton
130+ import me.kavishdevar.librepods.presentation.components.StyledInputField
131+ import me.kavishdevar.librepods.presentation.components.StyledSelectList
126132import me.kavishdevar.librepods.presentation.screens.AccessibilitySettingsScreen
127133import me.kavishdevar.librepods.presentation.screens.AdaptiveStrengthScreen
128134import me.kavishdevar.librepods.presentation.screens.AirPodsSettingsScreen
@@ -146,6 +152,7 @@ import me.kavishdevar.librepods.presentation.viewmodel.AirPodsViewModel
146152import me.kavishdevar.librepods.presentation.viewmodel.AppSettingsViewModel
147153import me.kavishdevar.librepods.presentation.viewmodel.PurchaseViewModel
148154import me.kavishdevar.librepods.services.AirPodsService
155+ import me.kavishdevar.librepods.utils.XposedState
149156import me.kavishdevar.librepods.utils.isSupported
150157import kotlin.io.encoding.ExperimentalEncodingApi
151158
@@ -157,7 +164,7 @@ lateinit var connectionStatusReceiver: BroadcastReceiver
157164class MainActivity : ComponentActivity () {
158165 companion object {
159166 init {
160- if (BuildConfig . FLAVOR == " xposed " ) {
167+ if (XposedState .isAvailable && XposedState .bluetoothScopeEnabled ) {
161168 System .loadLibrary(" l2c_fcr_hook" )
162169 }
163170 }
@@ -329,23 +336,118 @@ fun Main() {
329336 )
330337
331338 if (BuildConfig .PLAY_BUILD ) {
332- PlayBypassSheet (
339+ StyledBottomSheet (
333340 visible = showPlayBypassVisible.value,
334341 onDismiss = {
335342 showPlayBypassVisible.value = false
336343 showDialog.value = true
337344 },
338- onConfirm = {
339- showPlayBypassVisible.value = false
340- sharedPreferences.edit {
341- putBoolean(" bypass_device_check.v2" , true )
342- val intent = Intent (context, MainActivity ::class .java)
343- intent.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK )
344- context.startActivity(intent)
345- }
346- },
347345 backdrop = backdrop
348- )
346+ ) { innerBackdrop, _ ->
347+ val contentColor = if (isDarkTheme) Color .White else Color .Black
348+
349+ var acknowledged by remember { mutableStateOf(false ) }
350+ val inputState = rememberTextFieldState(" " )
351+
352+ val isValid = acknowledged && inputState.text.trim() == " OK"
353+
354+ val sfPro = FontFamily (Font (R .font.sf_pro))
355+
356+ Column (verticalArrangement = Arrangement .spacedBy(12 .dp)) {
357+ Text (
358+ text = stringResource(R .string.bypass_compatibility_check),
359+ style = TextStyle (
360+ fontFamily = sfPro,
361+ fontWeight = FontWeight .SemiBold ,
362+ fontSize = 18 .sp,
363+ color = contentColor
364+ ),
365+ modifier = Modifier .padding(horizontal = 12 .dp)
366+ )
367+
368+ Text (
369+ text = stringResource(R .string.compatibility_play_dialog_confirmation),
370+ style = TextStyle (
371+ fontFamily = sfPro,
372+ fontWeight = FontWeight .Medium ,
373+ fontSize = 14 .sp,
374+ color = contentColor
375+ ),
376+ modifier = Modifier .padding(horizontal = 12 .dp)
377+ )
378+
379+ StyledSelectList (
380+ items = listOf (
381+ SelectItem (
382+ name = stringResource(R .string.read_compatibility_requirements),
383+ selected = acknowledged,
384+ onClick = { acknowledged = ! acknowledged }
385+ )
386+ )
387+ )
388+
389+ val focusRequester = remember { FocusRequester () }
390+ val keyboardController = LocalSoftwareKeyboardController .current
391+
392+ LaunchedEffect (Unit ) {
393+ focusRequester.requestFocus()
394+ keyboardController?.show()
395+ }
396+
397+ StyledInputField (
398+ inputState = inputState,
399+ focusRequester = focusRequester,
400+ placeholder = stringResource(R .string.type_ok_to_continue, " OK" )
401+ )
402+
403+ Row (
404+ modifier = Modifier .fillMaxWidth(),
405+ horizontalArrangement = Arrangement .spacedBy(24 .dp)
406+ ) {
407+ StyledButton (
408+ onClick = { showPlayBypassVisible.value = false },
409+ backdrop = innerBackdrop,
410+ modifier = Modifier .weight(1f ),
411+ ) {
412+ Text (
413+ text = stringResource(R .string.no),
414+ style = TextStyle (
415+ fontFamily = sfPro,
416+ fontWeight = FontWeight .Medium ,
417+ fontSize = 14 .sp,
418+ color = contentColor
419+ )
420+ )
421+ }
422+ StyledButton (
423+ onClick = {
424+ showPlayBypassVisible.value = false
425+ sharedPreferences.edit {
426+ putBoolean(" bypass_device_check.v2" , true )
427+ val intent = Intent (context, MainActivity ::class .java)
428+ intent.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK )
429+ context.startActivity(intent)
430+ }
431+ },
432+ backdrop = innerBackdrop,
433+ isInteractive = isValid,
434+ modifier = Modifier .weight(1f ),
435+ enabled = isValid,
436+ surfaceColor = if (isDarkTheme) Color (0xFF0091FF ) else Color (0xFF0088FF )
437+ ) {
438+ Text (
439+ text = stringResource(R .string.proceed),
440+ style = TextStyle (
441+ fontFamily = sfPro,
442+ fontWeight = FontWeight .Medium ,
443+ fontSize = 14 .sp,
444+ color = if (isValid) contentColor else contentColor.copy(alpha = 0.4f )
445+ )
446+ )
447+ }
448+ }
449+ }
450+ }
349451 }
350452
351453 return
0 commit comments