First Commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Element Creations Ltd.
|
||||
* Copyright 2022-2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.services.appnavstate.test"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(projects.libraries.matrix.api)
|
||||
api(projects.services.appnavstate.api)
|
||||
implementation(libs.coroutines.core)
|
||||
implementation(libs.androidx.lifecycle.runtime)
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Element Creations Ltd.
|
||||
* Copyright 2023-2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.services.appnavstate.test
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.MAIN_SPACE
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.core.SpaceId
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
import io.element.android.services.appnavstate.api.NavigationState
|
||||
|
||||
const val A_SESSION_OWNER = "aSessionOwner"
|
||||
const val A_SPACE_OWNER = "aSpaceOwner"
|
||||
const val A_ROOM_OWNER = "aRoomOwner"
|
||||
const val A_THREAD_OWNER = "aThreadOwner"
|
||||
|
||||
fun aNavigationState(
|
||||
sessionId: SessionId? = null,
|
||||
spaceId: SpaceId? = MAIN_SPACE,
|
||||
roomId: RoomId? = null,
|
||||
threadId: ThreadId? = null,
|
||||
): NavigationState {
|
||||
if (sessionId == null) {
|
||||
return NavigationState.Root
|
||||
}
|
||||
val session = NavigationState.Session(A_SESSION_OWNER, sessionId)
|
||||
if (spaceId == null) {
|
||||
return session
|
||||
}
|
||||
val space = NavigationState.Space(A_SPACE_OWNER, spaceId, session)
|
||||
if (roomId == null) {
|
||||
return space
|
||||
}
|
||||
val room = NavigationState.Room(A_ROOM_OWNER, roomId, space)
|
||||
if (threadId == null) {
|
||||
return room
|
||||
}
|
||||
return NavigationState.Thread(A_THREAD_OWNER, threadId, room)
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Element Creations Ltd.
|
||||
* Copyright 2023-2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.services.appnavstate.test
|
||||
|
||||
import io.element.android.services.appnavstate.api.AppForegroundStateService
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
class FakeAppForegroundStateService(
|
||||
initialForegroundValue: Boolean = true,
|
||||
initialIsInCallValue: Boolean = false,
|
||||
initialIsSyncingNotificationEventValue: Boolean = false,
|
||||
initialHasRingingCall: Boolean = false,
|
||||
) : AppForegroundStateService {
|
||||
override val isInForeground = MutableStateFlow(initialForegroundValue)
|
||||
override val isInCall = MutableStateFlow(initialIsInCallValue)
|
||||
override val isSyncingNotificationEvent = MutableStateFlow(initialIsSyncingNotificationEventValue)
|
||||
override val hasRingingCall = MutableStateFlow(initialHasRingingCall)
|
||||
|
||||
override fun startObservingForeground() {
|
||||
// No-op
|
||||
}
|
||||
|
||||
fun givenIsInForeground(isInForeground: Boolean) {
|
||||
this.isInForeground.value = isInForeground
|
||||
}
|
||||
|
||||
override fun updateIsInCallState(isInCall: Boolean) {
|
||||
this.isInCall.value = isInCall
|
||||
}
|
||||
|
||||
override fun updateIsSyncingNotificationEvent(isSyncingNotificationEvent: Boolean) {
|
||||
this.isSyncingNotificationEvent.value = isSyncingNotificationEvent
|
||||
}
|
||||
|
||||
override fun updateHasRingingCall(hasRingingCall: Boolean) {
|
||||
this.hasRingingCall.value = hasRingingCall
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Element Creations Ltd.
|
||||
* Copyright 2023-2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.services.appnavstate.test
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.core.SpaceId
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
import io.element.android.services.appnavstate.api.AppNavigationState
|
||||
import io.element.android.services.appnavstate.api.AppNavigationStateService
|
||||
import io.element.android.services.appnavstate.api.NavigationState
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
class FakeAppNavigationStateService(
|
||||
override val appNavigationState: MutableStateFlow<AppNavigationState> = MutableStateFlow(
|
||||
AppNavigationState(
|
||||
navigationState = NavigationState.Root,
|
||||
isInForeground = true,
|
||||
)
|
||||
),
|
||||
) : AppNavigationStateService {
|
||||
override fun onNavigateToSession(owner: String, sessionId: SessionId) = Unit
|
||||
override fun onLeavingSession(owner: String) = Unit
|
||||
|
||||
override fun onNavigateToSpace(owner: String, spaceId: SpaceId) = Unit
|
||||
|
||||
override fun onLeavingSpace(owner: String) = Unit
|
||||
|
||||
override fun onNavigateToRoom(owner: String, roomId: RoomId) = Unit
|
||||
|
||||
override fun onLeavingRoom(owner: String) = Unit
|
||||
|
||||
override fun onNavigateToThread(owner: String, threadId: ThreadId) = Unit
|
||||
|
||||
override fun onLeavingThread(owner: String) = Unit
|
||||
}
|
||||
Reference in New Issue
Block a user