-
Notifications
You must be signed in to change notification settings - Fork 237
Fix modal contents overlapping screen lock pin #2692 #2874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,20 +32,26 @@ | |
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalUriHandler | ||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import com.bumble.appyx.core.integration.NodeHost | ||
import com.bumble.appyx.core.integrationpoint.NodeActivity | ||
import com.bumble.appyx.core.plugin.NodeReadyObserver | ||
import io.element.android.compound.theme.ElementTheme | ||
import io.element.android.compound.theme.Theme | ||
import io.element.android.compound.theme.isDark | ||
import io.element.android.compound.theme.mapToTheme | ||
import io.element.android.features.lockscreen.api.LockScreenEntryPoint | ||
import io.element.android.features.lockscreen.api.LockScreenLockState | ||
import io.element.android.features.lockscreen.api.LockScreenService | ||
import io.element.android.features.lockscreen.api.handleSecureFlag | ||
import io.element.android.features.lockscreen.api.isLocked | ||
import io.element.android.libraries.architecture.bindings | ||
import io.element.android.libraries.core.log.logger.LoggerTag | ||
import io.element.android.libraries.designsystem.utils.snackbar.LocalSnackbarDispatcher | ||
import io.element.android.x.di.AppBindings | ||
import io.element.android.x.intent.SafeUriHandler | ||
import kotlinx.coroutines.launch | ||
import timber.log.Timber | ||
|
||
private val loggerTag = LoggerTag("MainActivity") | ||
|
@@ -59,27 +65,13 @@ | |
installSplashScreen() | ||
super.onCreate(savedInstanceState) | ||
appBindings = bindings() | ||
appBindings.lockScreenService().handleSecureFlag(this) | ||
setupLockManagement(appBindings.lockScreenService(), appBindings.lockScreenEntryPoint()) | ||
enableEdgeToEdge() | ||
setContent { | ||
MainContent(appBindings) | ||
} | ||
} | ||
|
||
@Deprecated("") | ||
override fun onBackPressed() { | ||
// If the app is locked, we need to intercept onBackPressed before it goes to OnBackPressedDispatcher. | ||
// Indeed, otherwise we would need to trick Appyx backstack management everywhere. | ||
// Without this trick, we would get pop operations on the hidden backstack. | ||
if (appBindings.lockScreenService().isLocked) { | ||
// Do not kill the app in this case, just go to background. | ||
moveTaskToBack(false) | ||
} else { | ||
@Suppress("DEPRECATION") | ||
super.onBackPressed() | ||
} | ||
} | ||
|
||
@Composable | ||
private fun MainContent(appBindings: AppBindings) { | ||
val theme by remember { | ||
|
@@ -96,8 +88,8 @@ | |
) { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(MaterialTheme.colorScheme.background), | ||
.fillMaxSize() | ||
.background(MaterialTheme.colorScheme.background), | ||
) { | ||
if (migrationState.migrationAction.isSuccess()) { | ||
MainNodeHost() | ||
|
@@ -131,6 +123,22 @@ | |
} | ||
} | ||
|
||
private fun setupLockManagement( | ||
lockScreenService: LockScreenService, | ||
lockScreenEntryPoint: LockScreenEntryPoint | ||
) { | ||
lockScreenService.handleSecureFlag(this) | ||
lifecycleScope.launch { | ||
repeatOnLifecycle(Lifecycle.State.RESUMED) { | ||
lockScreenService.lockState.collect { state -> | ||
if (state == LockScreenLockState.Locked) { | ||
startActivity(lockScreenEntryPoint.pinUnlockIntent(this@MainActivity)) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is working, but can we try to use only things from the api module? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok for me to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Called when: | ||
* - the launcher icon is clicked (if the app is already running); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,9 +47,6 @@ import io.element.android.features.createroom.api.CreateRoomEntryPoint | |
import io.element.android.features.ftue.api.FtueEntryPoint | ||
import io.element.android.features.ftue.api.state.FtueService | ||
import io.element.android.features.ftue.api.state.FtueState | ||
import io.element.android.features.lockscreen.api.LockScreenEntryPoint | ||
import io.element.android.features.lockscreen.api.LockScreenLockState | ||
import io.element.android.features.lockscreen.api.LockScreenService | ||
import io.element.android.features.networkmonitor.api.NetworkMonitor | ||
import io.element.android.features.networkmonitor.api.NetworkStatus | ||
import io.element.android.features.preferences.api.PreferencesEntryPoint | ||
|
@@ -100,8 +97,6 @@ class LoggedInFlowNode @AssistedInject constructor( | |
private val coroutineScope: CoroutineScope, | ||
private val networkMonitor: NetworkMonitor, | ||
private val ftueService: FtueService, | ||
private val lockScreenEntryPoint: LockScreenEntryPoint, | ||
private val lockScreenStateService: LockScreenService, | ||
private val roomDirectoryEntryPoint: RoomDirectoryEntryPoint, | ||
private val matrixClient: MatrixClient, | ||
snackbarDispatcher: SnackbarDispatcher, | ||
|
@@ -111,7 +106,7 @@ class LoggedInFlowNode @AssistedInject constructor( | |
savedStateMap = buildContext.savedStateMap, | ||
), | ||
permanentNavModel = PermanentNavModel( | ||
navTargets = setOf(NavTarget.LoggedInPermanent, NavTarget.LockPermanent), | ||
navTargets = setOf(NavTarget.LoggedInPermanent), | ||
savedStateMap = buildContext.savedStateMap, | ||
), | ||
buildContext = buildContext, | ||
|
@@ -189,9 +184,6 @@ class LoggedInFlowNode @AssistedInject constructor( | |
@Parcelize | ||
data object LoggedInPermanent : NavTarget | ||
|
||
@Parcelize | ||
data object LockPermanent : NavTarget | ||
|
||
@Parcelize | ||
data object RoomList : NavTarget | ||
|
||
|
@@ -235,11 +227,6 @@ class LoggedInFlowNode @AssistedInject constructor( | |
NavTarget.LoggedInPermanent -> { | ||
createNode<LoggedInNode>(buildContext) | ||
} | ||
NavTarget.LockPermanent -> { | ||
lockScreenEntryPoint.nodeBuilder(this, buildContext) | ||
.target(LockScreenEntryPoint.Target.Unlock) | ||
.build() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that |
||
NavTarget.RoomList -> { | ||
val callback = object : RoomListEntryPoint.Callback { | ||
override fun onRoomClicked(roomId: RoomId) { | ||
|
@@ -430,15 +417,11 @@ class LoggedInFlowNode @AssistedInject constructor( | |
@Composable | ||
override fun View(modifier: Modifier) { | ||
Box(modifier = modifier) { | ||
val lockScreenState by lockScreenStateService.lockState.collectAsState() | ||
val ftueState by ftueService.state.collectAsState() | ||
BackstackView() | ||
if (ftueState is FtueState.Complete) { | ||
PermanentChild(permanentNavModel = permanentNavModel, navTarget = NavTarget.LoggedInPermanent) | ||
} | ||
if (lockScreenState == LockScreenLockState.Locked) { | ||
PermanentChild(permanentNavModel = permanentNavModel, navTarget = NavTarget.LockPermanent) | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix modal contents overlapping screen lock pin. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- | ||
~ Copyright (c) 2023 New Vector Ltd | ||
bmarty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
<activity | ||
android:name="io.element.android.features.lockscreen.impl.unlock.activity.PinUnlockActivity" | ||
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"/> | ||
</application> | ||
|
||
</manifest> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to find a solution to avoid such change