Share the platform-neutral Rust mobile contract (#91)
Dependency security audit / rustsec (push) Failing after 22s
Dependency security audit / rustsec (push) Failing after 22s
This commit is contained in:
1 parent
fcb36a0684
commit
180851087b
52 files changed
+8932
-4263
No files matched your search
+36
-1
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import de.rfc1437.ironstorage.bridge.NativeBridgeException
|
||||
import de.rfc1437.ironstorage.bridge.NativeFailureKind
|
||||
import de.rfc1437.ironstorage.bridge.NativeRuntime
|
||||
import de.rfc1437.ironstorage.bridge.generated.MobileIcon
|
||||
import de.rfc1437.ironstorage.bridge.generated.MobileShellState
|
||||
import de.rfc1437.ironstorage.bridge.generated.MobileTab
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
@@ -57,7 +58,13 @@ private fun nativeLoader(context: Context): suspend (ShellState) -> ShellSnapsho
|
||||
withContext(Dispatchers.IO) {
|
||||
val shell = runtime.fixture(state.toNative())
|
||||
val pages = shell.pages.map { page ->
|
||||
ShellPage(page.tab.toFacade(), page.title, page.stateTitle, page.stateDetail)
|
||||
ShellPage(
|
||||
page.tab.toFacade(),
|
||||
page.title,
|
||||
page.stateTitle,
|
||||
page.stateDetail,
|
||||
page.icon.toFacade()
|
||||
)
|
||||
}
|
||||
val actual = shell.pages.firstOrNull()?.state
|
||||
?: throw NativeBridgeException(NativeFailureKind.RustFailure)
|
||||
@@ -99,3 +106,31 @@ private fun NativeFailureKind.toFacade(): NativeFailure = when (this) {
|
||||
NativeFailureKind.RustFailure -> NativeFailure.RustFailure
|
||||
NativeFailureKind.MainThreadCall -> NativeFailure.MainThreadCall
|
||||
}
|
||||
|
||||
private fun MobileIcon.toFacade(): ShellIcon = when (this) {
|
||||
MobileIcon.HOME -> ShellIcon.Home
|
||||
MobileIcon.KEY -> ShellIcon.Key
|
||||
MobileIcon.SEARCH -> ShellIcon.Search
|
||||
MobileIcon.TIMER -> ShellIcon.Timer
|
||||
MobileIcon.SETTINGS -> ShellIcon.Settings
|
||||
MobileIcon.WARNING -> ShellIcon.Warning
|
||||
MobileIcon.BRANCH -> ShellIcon.Branch
|
||||
MobileIcon.SUCCESS -> ShellIcon.Success
|
||||
MobileIcon.SYNC -> ShellIcon.Sync
|
||||
MobileIcon.PROTECTED -> ShellIcon.Protected
|
||||
MobileIcon.REPOSITORY -> ShellIcon.Repository
|
||||
MobileIcon.HISTORY -> ShellIcon.History
|
||||
MobileIcon.INCOMING -> ShellIcon.Incoming
|
||||
MobileIcon.OUTGOING -> ShellIcon.Outgoing
|
||||
MobileIcon.RECIPIENTS -> ShellIcon.Recipients
|
||||
MobileIcon.SIGNATURE -> ShellIcon.Signature
|
||||
MobileIcon.FILE -> ShellIcon.File
|
||||
MobileIcon.MERGE -> ShellIcon.Merge
|
||||
MobileIcon.REFRESH -> ShellIcon.Refresh
|
||||
MobileIcon.FOLDER -> ShellIcon.Folder
|
||||
MobileIcon.USER -> ShellIcon.User
|
||||
MobileIcon.EMAIL -> ShellIcon.Email
|
||||
MobileIcon.WEBSITE -> ShellIcon.Website
|
||||
MobileIcon.TEXT -> ShellIcon.Text
|
||||
MobileIcon.NOTE -> ShellIcon.Note
|
||||
}
|
||||
@@ -5,11 +5,40 @@ import kotlinx.coroutines.flow.StateFlow
|
||||
enum class ShellState { Loading, Empty, Ready, Locked, Error }
|
||||
enum class ShellTab { Home, Passwords, Search, Totp, Preferences }
|
||||
|
||||
enum class ShellIcon {
|
||||
Home,
|
||||
Key,
|
||||
Search,
|
||||
Timer,
|
||||
Settings,
|
||||
Warning,
|
||||
Branch,
|
||||
Success,
|
||||
Sync,
|
||||
Protected,
|
||||
Repository,
|
||||
History,
|
||||
Incoming,
|
||||
Outgoing,
|
||||
Recipients,
|
||||
Signature,
|
||||
File,
|
||||
Merge,
|
||||
Refresh,
|
||||
Folder,
|
||||
User,
|
||||
Email,
|
||||
Website,
|
||||
Text,
|
||||
Note
|
||||
}
|
||||
|
||||
data class ShellPage(
|
||||
val tab: ShellTab,
|
||||
val title: String,
|
||||
val stateTitle: String,
|
||||
val detail: String
|
||||
val detail: String,
|
||||
val icon: ShellIcon
|
||||
)
|
||||
data class ShellSnapshot(
|
||||
val state: ShellState,
|
||||
|
||||
+4
-1
@@ -15,7 +15,10 @@ class NativeFixtureShellRepositoryTest {
|
||||
val pending = CompletableDeferred<Unit>()
|
||||
val repository = NativeFixtureShellRepository(backgroundScope) { state ->
|
||||
if (state == ShellState.Ready) withContext(NonCancellable) { pending.await() }
|
||||
ShellSnapshot(state, listOf(ShellPage(ShellTab.Home, "Home", state.name, "Fixture")))
|
||||
ShellSnapshot(
|
||||
state,
|
||||
listOf(ShellPage(ShellTab.Home, "Home", state.name, "Fixture", ShellIcon.Home))
|
||||
)
|
||||
}
|
||||
runCurrent()
|
||||
repository.showFixture(ShellState.Ready)
|
||||
|
||||
Reference in new issue
Block a user