Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8037c165 authored by frankpreel's avatar frankpreel
Browse files

fix: Find my Device activated without validation

The back button is not handled correctly

Refs: https://gitlab.e.foundation/e/os/backlog/-/issues/3365
parent fdbbcf70
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import foundation.e.findmydevice.data.Pages
import foundation.e.findmydevice.storage.PersistentStorage
import foundation.e.findmydevice.ui.GenerationPasswordScreen
import foundation.e.findmydevice.ui.WelcomeScreen
import foundation.e.findmydevice.ui.isSwitchChecked
import foundation.e.findmydevice.ui.text.customTopAppBar
import foundation.e.findmydevice.ui.theme.findMyDeviceTheme
import foundation.e.findmydevice.util.PermissionManager
@@ -105,20 +106,19 @@ class FindMyDeviceActivity : FragmentActivity() {
                        ) {
                            when (page) {
                                Pages.ActivateFeature -> WelcomeScreen.displayScreen(
                                    onBackPressed = {
                                        Log.d(TAG, "A BACK")
                                        onExitApp() },
                                    onBackPressed = { onExitApp() },
                                    onSelection = {
                                        Log.d(TAG, "A SEL")
                                        if (persistentStorage.getStatus())
                                        if (isSwitchChecked)
                                            displayPage(Pages.GeneratePassword)
                                        else
                                            displayPage(Pages.ActivateFeature) }
                                        else {
                                            persistentStorage.saveStatus(false)
                                            displayPage(Pages.ActivateFeature)
                                        }
                                    }
                                )
                                Pages.GeneratePassword ->GenerationPasswordScreen.displayScreen(
                                    onBackPressed = { Log.d(TAG, "G BACK")},
                                    onBackPressed = {},
                                    onSelection = {
                                        Log.d(TAG, "G SEL")
                                        onExitApp(true) },
                                    findMyDeviceActivity = this@FindMyDeviceActivity
                                )
+2 −0
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ fun generatePasswordScreenContent(onSelection: () -> Unit,
                onClick = {
                    scope.launch {
                        persistentStorage.savePassword(currentPassword)
                        persistentStorage.saveStatus(true)
                        if(isProvisioned) {
                            onSelection()
                        }
@@ -247,6 +248,7 @@ fun generatePasswordScreenContent(onSelection: () -> Unit,
                        scope.launch {
                            onSelection()
                            persistentStorage.savePassword(currentPassword)
                            persistentStorage.saveStatus(true)
                        }
                    },
                    colors = buttonColor()
+2 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ object WelcomeScreen {
        welcomeScreenContent(onSelection, onBackPressed)
    }
}
var isSwitchChecked by mutableStateOf(false)

@SuppressLint("ComposableNaming")
@Composable
@@ -67,7 +68,7 @@ fun welcomeScreenContent(onSelection: () -> Unit,
    val context = LocalContext.current
    val persistentStorage = PersistentStorage(context)
    val scope = rememberCoroutineScope()
    var isSwitchChecked by remember { mutableStateOf(false) }


    val hasSimSupport = hasSimSupport(context)

@@ -103,7 +104,6 @@ fun welcomeScreenContent(onSelection: () -> Unit,
            isChecked = isSwitchChecked,
            fontWeight = FontWeight.Medium,
            onCheckedChange = { isChecked ->
                persistentStorage.saveStatus(isChecked)
                isSwitchChecked = isChecked
                Log.d(WelcomeScreen.TAG, "Switch is now ${if (isChecked) "ON" else "OFF"}")
                onSelection()