mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Verify the producer-acquire host after integrating current main
This commit is contained in:
commit
0877e5ce9c
14 files changed
+496
-125
No files matched your search
@@ -28,6 +28,19 @@ float_code() {
|
||||
[ "$result" = ok ]
|
||||
}
|
||||
|
||||
# git pushes through gh's sign-in and commits as the signed-in account, with its no-reply address.
|
||||
configure_git() {
|
||||
gh auth setup-git || return 1
|
||||
[ -n "$(git config --global user.name)" ] && [ -n "$(git config --global user.email)" ] && return 0
|
||||
local user id login name
|
||||
user=$(gh api user -q '"\(.id) \(.login) \(.name // .login)"') || return 1
|
||||
read -r id login name <<<"$user"
|
||||
[ -n "$id" ] && [ -n "$login" ] || return 1
|
||||
[ -n "$(git config --global user.name)" ] || git config --global user.name "${name:-$login}"
|
||||
[ -n "$(git config --global user.email)" ] || git config --global user.email "$id+$login@users.noreply.github.com"
|
||||
}
|
||||
if [ "${1:-}" = --git ]; then configure_git; exit; fi
|
||||
|
||||
coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; }
|
||||
gh_pid=$GH_PID
|
||||
exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}"
|
||||
@@ -48,5 +61,9 @@ while IFS= read -r line <&"$ghout"; do
|
||||
done
|
||||
wait "$gh_pid"
|
||||
status=$?
|
||||
if [ $status = 0 ] && ! configure_git; then
|
||||
echo "Signed in, but git could not be set up: run dd-gh-login --git"
|
||||
status=1
|
||||
fi
|
||||
[ -n "$shown" ] && [ -n "$inbox" ] && [ -d "$inbox" ] && : > "$inbox/device-code"
|
||||
exit $status
|
||||
@@ -75,7 +75,9 @@ object AgentHost {
|
||||
"Never kill by a command-line pattern (pkill -f, pgrep -f piped to kill): your own command line holds the user's message, so the pattern matches you. " +
|
||||
"Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments. " +
|
||||
"To have the user pick between options, end your reply with a fenced code block whose language is choices, one short option per line, " +
|
||||
"and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message."
|
||||
"and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message. " +
|
||||
"To show the user an image (a screenshot, a mockup, a chart), put  on a line of its own: " +
|
||||
"DroidDeck draws the file in the chat."
|
||||
|
||||
val entries = mutableStateListOf<Entry>()
|
||||
val queue = mutableStateListOf<Queued>()
|
||||
|
||||
@@ -226,7 +226,18 @@ object AgentSetup {
|
||||
/** The whole output of a step's last run; the card shows only its last line. */
|
||||
fun logFile(app: Context, step: Step) = File(app.filesDir, "agent/setup-${step.name.lowercase()}.log")
|
||||
|
||||
fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git")
|
||||
/**
|
||||
* An install set up before setup wrote the Gradle init script gets the step again, but only
|
||||
* once the checkout's setup writes it: the step runs that script, and an older one never would.
|
||||
*/
|
||||
fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git") &&
|
||||
(AgentHost.guestFileExists(app, GRADLE_INIT) || !setupWritesGradleInit(app))
|
||||
|
||||
private const val GRADLE_INIT = "/root/.gradle/init.d/droiddeck-device.gradle"
|
||||
|
||||
private fun setupWritesGradleInit(app: Context) = runCatching {
|
||||
File(LinuxRuntime.rootDir(app), "$CHECKOUT/tools/agent/setup".removePrefix("/")).readText().contains(GRADLE_INIT.substringAfterLast('/'))
|
||||
}.getOrDefault(false)
|
||||
|
||||
/** dd-lab-build compiled this install's commit, so a Lab build compiles only what changed. */
|
||||
private fun prepared(app: Context) = runCatching {
|
||||
|
||||
@@ -78,7 +78,7 @@ internal fun AgentEntry(
|
||||
is Entry.Said -> {
|
||||
val reply = remember(entry.text) { choices(entry.text) }
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
if (reply.text.isNotBlank()) SelectionContainer { AgentMarkdown(reply.text, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp)) }
|
||||
if (reply.text.isNotBlank()) SelectionContainer { AgentReply(reply.text, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp)) }
|
||||
if (reply.options.isNotEmpty()) AgentChoices(reply.options, answerable, onSent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,106 @@ import org.commonmark.ext.gfm.tables.TableRow
|
||||
import org.commonmark.node.AbstractVisitor
|
||||
import org.commonmark.node.CustomNode
|
||||
import org.commonmark.node.Node
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import java.io.File
|
||||
|
||||
/** Part of an agent's reply: Markdown text, or an image the agent named on a line of its own. */
|
||||
internal sealed interface ReplyPart {
|
||||
data class Prose(val text: String) : ReplyPart
|
||||
data class Picture(val alt: String, val path: String) : ReplyPart
|
||||
}
|
||||
|
||||
private val PICTURE_LINE = Regex("""^\s*!\[([^\]]*)]\(\s*(?:<(?:file://)?(/[^>]*)>|(?:file://)?(/[^)<>]*?))\s*\)\s*$""")
|
||||
private val FENCE = Regex("""^ {0,3}(`{3,}|~{3,})(.*)$""")
|
||||
|
||||
/** Splits [text] at lines that hold only an image of a local absolute path, outside code fences. */
|
||||
internal fun replyParts(text: String): List<ReplyPart> {
|
||||
val parts = mutableListOf<ReplyPart>()
|
||||
val prose = StringBuilder()
|
||||
fun flush() {
|
||||
if (prose.isNotBlank()) parts += ReplyPart.Prose(prose.toString().trimEnd('\n'))
|
||||
prose.clear()
|
||||
}
|
||||
var fence: String? = null
|
||||
for (line in text.lines()) {
|
||||
val marker = FENCE.matchEntire(line)
|
||||
val picture = if (fence == null) PICTURE_LINE.matchEntire(line) else null
|
||||
val open = fence
|
||||
when {
|
||||
picture != null -> {
|
||||
flush()
|
||||
val path = picture.groupValues[2].ifEmpty { picture.groupValues[3] }
|
||||
parts += ReplyPart.Picture(picture.groupValues[1].trim(), path.trim())
|
||||
continue
|
||||
}
|
||||
marker == null -> Unit
|
||||
open == null -> fence = marker.groupValues[1]
|
||||
marker.groupValues[1].let { it[0] == open[0] && it.length >= open.length } && marker.groupValues[2].isBlank() -> fence = null
|
||||
}
|
||||
prose.append(line).append('\n')
|
||||
}
|
||||
flush()
|
||||
return parts
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the app reads a file the agent named by its guest path: the app's own folders and shared
|
||||
* storage are bound at the same paths in the guest, everything else lives in the rootfs.
|
||||
*/
|
||||
internal fun agentHostFile(context: Context, guestPath: String): File {
|
||||
val app = context.applicationContext
|
||||
val same = listOfNotNull(app.filesDir.path, app.cacheDir.path, LinuxRuntime.sharedStorage(app)?.path)
|
||||
return if (same.any { guestPath == it || guestPath.startsWith("$it/") }) File(guestPath)
|
||||
else File(LinuxRuntime.rootDir(app), guestPath.removePrefix("/"))
|
||||
}
|
||||
|
||||
/** An agent's reply, with the images it names shown in place. */
|
||||
@Composable
|
||||
internal fun AgentReply(text: String, modifier: Modifier) {
|
||||
val parts = remember(text) { replyParts(text) }
|
||||
if (parts.size == 1 && parts[0] is ReplyPart.Prose) {
|
||||
AgentMarkdown(text, modifier)
|
||||
return
|
||||
}
|
||||
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
parts.forEach { part ->
|
||||
when (part) {
|
||||
is ReplyPart.Prose -> AgentMarkdown(part.text, Modifier)
|
||||
is ReplyPart.Picture -> AgentPicture(part)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AgentPicture(picture: ReplyPart.Picture) {
|
||||
val context = LocalContext.current
|
||||
val file = remember(picture.path) { agentHostFile(context, picture.path) }
|
||||
var full by remember(picture.path) { mutableStateOf(false) }
|
||||
if (!file.isFile) {
|
||||
Text(stringResource(R.string.agent_image_missing, picture.alt.ifBlank { picture.path }), color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
return
|
||||
}
|
||||
AsyncImage(
|
||||
model = file, contentDescription = picture.alt.ifBlank { file.name }, contentScale = ContentScale.Fit,
|
||||
modifier = Modifier.widthIn(max = 560.dp).then(if (full) Modifier else Modifier.heightIn(max = 420.dp))
|
||||
.clip(Shape12).clickable { full = !full },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun AgentMarkdown(text: String, modifier: Modifier) {
|
||||
|
||||
@@ -532,7 +532,7 @@ private fun AgentLive() {
|
||||
val pal = LocalPalette.current
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
if (AgentHost.liveThinking.isNotBlank()) AgentThought(AgentHost.liveThinking, live = true)
|
||||
if (AgentHost.live.isNotBlank()) AgentMarkdown(AgentHost.live, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp))
|
||||
if (AgentHost.live.isNotBlank()) AgentReply(AgentHost.live, Modifier.widthIn(max = 760.dp).padding(horizontal = 4.dp))
|
||||
val running = AgentHost.running()
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.padding(4.dp)) {
|
||||
CircularProgressIndicator(Modifier.size(14.dp), strokeWidth = 2.dp, color = pal.primary)
|
||||
|
||||
@@ -22,7 +22,12 @@ internal enum class SessionDrawerPage(val firstControl: String) {
|
||||
}
|
||||
|
||||
internal object DrawerPages {
|
||||
var order by mutableStateOf(SessionDrawerPage.entries.toList())
|
||||
private val defaultOrder = SessionDrawerPage.entries.toMutableList().apply {
|
||||
remove(SessionDrawerPage.VR)
|
||||
add(indexOf(SessionDrawerPage.MORE) + 1, SessionDrawerPage.VR)
|
||||
}.toList()
|
||||
|
||||
var order by mutableStateOf(defaultOrder)
|
||||
private set
|
||||
var hidden by mutableStateOf(emptySet<SessionDrawerPage>())
|
||||
private set
|
||||
@@ -39,6 +44,7 @@ internal object DrawerPages {
|
||||
}
|
||||
|
||||
fun arrange(saved: List<String>): List<SessionDrawerPage> {
|
||||
if (saved.isEmpty()) return defaultOrder
|
||||
val all = SessionDrawerPage.entries
|
||||
val out = saved.mapNotNull { name -> all.firstOrNull { it.name == name } }.distinct().toMutableList()
|
||||
for (page in all.filterNot { it in out }) {
|
||||
@@ -62,14 +68,14 @@ internal object DrawerPages {
|
||||
}
|
||||
|
||||
fun reset(context: Context) {
|
||||
order = SessionDrawerPage.entries.toList()
|
||||
order = defaultOrder
|
||||
hidden = emptySet()
|
||||
if (DevPreview.drawer != null) return
|
||||
SessionPrefs.setDrawerPageOrder(context, order.map { it.name })
|
||||
SessionPrefs.setDrawerPageHidden(context, emptySet())
|
||||
}
|
||||
|
||||
fun isDefault() = order == SessionDrawerPage.entries.toList() && hidden.isEmpty()
|
||||
fun isDefault() = order == defaultOrder && hidden.isEmpty()
|
||||
}
|
||||
|
||||
internal fun offeredDrawerPages(
|
||||
|
||||
@@ -9,7 +9,6 @@ import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.basicMarquee
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
@@ -25,6 +24,9 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.selection.selectable
|
||||
import androidx.compose.foundation.selection.selectableGroup
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -44,6 +46,7 @@ import androidx.compose.material.icons.outlined.Science
|
||||
import androidx.compose.material.icons.outlined.SwapHoriz
|
||||
import androidx.compose.material.icons.outlined.Sync
|
||||
import androidx.compose.material.icons.outlined.Verified
|
||||
import androidx.compose.material.icons.outlined.WarningAmber
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
@@ -109,50 +112,37 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
|
||||
val me = remember { AppUpdates.installed() }
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Column(modifier = modifier) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().padding(bottom = 10.dp),
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.upd_build, me.version, s.buildLabel), fontSize = 12.5.sp, color = colors.onSurfaceVariant,
|
||||
maxLines = 1, modifier = Modifier.weight(1f)
|
||||
.basicMarquee(iterations = Int.MAX_VALUE, initialDelayMillis = 700, velocity = 40.dp),
|
||||
)
|
||||
val checked = u.catalog?.checkedAt?.takeIf { it > 0 }
|
||||
if (!LocalNarrowPane.current) Text(
|
||||
if (u.checking) stringResource(R.string.common_checking) else if (checked != null) stringResource(R.string.upd_checked, ago(checked).replaceFirstChar { it.lowercase() }) else stringResource(R.string.upd_not_checked),
|
||||
fontSize = 13.sp, color = colors.onSurfaceVariant,
|
||||
)
|
||||
val clipboard = LocalClipboardManager.current
|
||||
val context = LocalContext.current
|
||||
val details = buildDetails(me, s.buildLabel)
|
||||
ToolIcon(Icons.Outlined.ContentCopy, stringResource(R.string.upd_copy_build)) {
|
||||
clipboard.setText(AnnotatedString(details))
|
||||
android.widget.Toast.makeText(context, context.getString(R.string.upd_copied), android.widget.Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
ToolIcon(Icons.Outlined.Refresh, stringResource(R.string.store_check_updates), busy = u.checking, enabled = !u.checking && u.stage == null, onClick = ua.onCheck)
|
||||
}
|
||||
BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) {
|
||||
val stacked = LocalNarrowPane.current || maxWidth < 600.dp
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(bottom = 16.dp)) {
|
||||
SectionLabel(stringResource(R.string.upd_installed_label))
|
||||
InstalledCard(s, u, me)
|
||||
CheckRow(u, ua)
|
||||
SectionLabel(stringResource(R.string.upd_channel))
|
||||
if (stacked) {
|
||||
ChannelPicker(u, ua)
|
||||
Box(Modifier.height(14.dp))
|
||||
StatusPanel(s, u, ua, me)
|
||||
Box(Modifier.height(18.dp))
|
||||
ChannelLabel()
|
||||
ChannelPicker(u, ua, s.sessionRunning)
|
||||
} else {
|
||||
ChannelLabel()
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(18.dp)) {
|
||||
Box(Modifier.weight(1f)) { ChannelPicker(u, ua, s.sessionRunning) }
|
||||
Box(Modifier.weight(1f)) { ChannelPicker(u, ua) }
|
||||
Box(Modifier.weight(1.15f)) { StatusPanel(s, u, ua, me) }
|
||||
}
|
||||
}
|
||||
Box(Modifier.padding(top = 18.dp)) {
|
||||
ToggleRow(
|
||||
host, "build-watermark", stringResource(R.string.setup_build_watermark),
|
||||
stringResource(R.string.setup_build_watermark_hint), s.buildWatermark,
|
||||
) { a.onBuildWatermark() }
|
||||
}
|
||||
SectionLabel(stringResource(R.string.upd_testers), top = 22.dp)
|
||||
ToggleRow(
|
||||
host, "build-watermark", stringResource(R.string.setup_build_watermark),
|
||||
stringResource(R.string.setup_build_watermark_hint), s.buildWatermark,
|
||||
) { a.onBuildWatermark() }
|
||||
val context = LocalContext.current
|
||||
val agentReady = com.droiddeck.launcher.agent.AgentHost.installed &&
|
||||
(com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context))
|
||||
LabBuilds(s.sessionRunning, onRebuild = if (agentReady) { info ->
|
||||
com.droiddeck.launcher.agent.AgentHost.send(context, context.getString(R.string.agent_rebuild_lab, info.label))
|
||||
context.startActivity(android.content.Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java)
|
||||
.putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent")
|
||||
.addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP or android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))
|
||||
} else null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,6 +159,112 @@ internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifie
|
||||
)
|
||||
}
|
||||
|
||||
private val TEST_TINT = Color(0xFF9B6CFF)
|
||||
|
||||
@Composable
|
||||
private fun SectionLabel(text: String, top: androidx.compose.ui.unit.Dp = 4.dp) {
|
||||
Text(
|
||||
text, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = top, bottom = 10.dp),
|
||||
)
|
||||
}
|
||||
|
||||
/** What is installed: which kind of build, its version and versionCode, and its commit, as the first thing on the page. */
|
||||
@Composable
|
||||
private fun InstalledCard(s: FrontEndState, u: UpdatesState, me: AppUpdates.Installed) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val catalog = u.catalog
|
||||
val lab = com.droiddeck.launcher.lab.LabOverlay.active
|
||||
val basePr = if (me.pr > 0) me.pr else Regex("""\bpr(\d+)\b""").find(s.buildLabel)?.groupValues?.get(1)?.toIntOrNull() ?: 0
|
||||
val kind = when {
|
||||
lab != null -> stringResource(R.string.upd_kind_lab)
|
||||
me.pr > 0 -> stringResource(R.string.upd_kind_test)
|
||||
catalog?.stable?.let { AppUpdates.isRunning(it, me) } == true -> stringResource(R.string.upd_stable)
|
||||
catalog?.preview?.let { AppUpdates.isRunning(it, me) } == true -> stringResource(R.string.upd_preview)
|
||||
else -> null
|
||||
}
|
||||
val tint = if (lab != null || me.pr > 0) TEST_TINT else pal.signal
|
||||
val title = when {
|
||||
lab != null -> lab.label
|
||||
me.pr > 0 -> stringResource(R.string.upd_pr, me.pr)
|
||||
else -> stringResource(R.string.upd_droiddeck_version, me.version)
|
||||
}
|
||||
val subtitle = when {
|
||||
lab != null && basePr > 0 -> stringResource(R.string.upd_lab_on_pr, basePr)
|
||||
lab != null -> stringResource(R.string.upd_lab_on_version, me.version)
|
||||
me.pr > 0 -> catalog?.tests?.firstOrNull { it.pr == me.pr }?.title?.takeIf { it.isNotBlank() }?.let(::changeTitle)
|
||||
else -> null
|
||||
}
|
||||
val built = lab?.built?.takeIf { it > 0 } ?: me.committedAt
|
||||
val meta = listOfNotNull(
|
||||
me.version.takeIf { lab != null || me.pr > 0 },
|
||||
stringResource(R.string.upd_version_code, me.versionCode),
|
||||
me.commit.take(7).takeIf { it.length == 7 },
|
||||
built.takeIf { it > 0 }?.let { stringResource(R.string.upd_built_ago, ago(it).replaceFirstChar { c -> c.lowercase() }) },
|
||||
).joinToString(" · ")
|
||||
val clipboard = LocalClipboardManager.current
|
||||
val context = LocalContext.current
|
||||
val details = buildDetails(me, s.buildLabel)
|
||||
Row(
|
||||
verticalAlignment = Alignment.Top, horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().clip(Shape16).background(colors.surface).border(1.dp, pal.line, Shape16).padding(start = 18.dp, end = 12.dp, top = 14.dp, bottom = 16.dp),
|
||||
) {
|
||||
Column(Modifier.weight(1f).padding(top = 2.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
if (kind != null) Text(
|
||||
kind.uppercase(), fontSize = 10.5.sp, fontWeight = FontWeight.Bold, letterSpacing = 0.6.sp, color = tint, maxLines = 1,
|
||||
modifier = Modifier.clip(CircleShape).background(tint.copy(alpha = 0.16f)).padding(horizontal = 8.dp, vertical = 3.dp),
|
||||
)
|
||||
Text(title, fontSize = 20.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
if (subtitle != null) Text(subtitle, fontSize = 14.sp, fontWeight = FontWeight.Medium, color = colors.onBackground, maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 6.dp))
|
||||
Text(meta, fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 4.dp))
|
||||
}
|
||||
ToolIcon(Icons.Outlined.ContentCopy, stringResource(R.string.upd_copy_build)) {
|
||||
clipboard.setText(AnnotatedString(details))
|
||||
android.widget.Toast.makeText(context, context.getString(R.string.upd_copied), android.widget.Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CheckRow(u: UpdatesState, ua: UpdatesActions) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val enabled = !u.checking && u.stage == null
|
||||
val checked = u.catalog?.checkedAt?.takeIf { it > 0 }
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 6.dp, bottom = 14.dp),
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.offset(x = (-6).dp).paneItem("updates:check").heightIn(min = 40.dp).clip(Shape12)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent)
|
||||
.glideBorder(hot, Shape12, pal.signal)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, enabled = enabled, role = Role.Button, onClick = ua.onCheck)
|
||||
.controllerConfirm(enabled = enabled, onClick = ua.onCheck)
|
||||
.padding(horizontal = 6.dp),
|
||||
) {
|
||||
if (u.checking) androidx.compose.material3.CircularProgressIndicator(Modifier.size(16.dp), color = pal.signal, strokeWidth = 2.dp)
|
||||
else Icon(Icons.Outlined.Refresh, contentDescription = null, tint = pal.signal.copy(alpha = if (enabled) 1f else 0.5f), modifier = Modifier.size(18.dp))
|
||||
Text(
|
||||
if (u.checking) stringResource(R.string.common_checking) else stringResource(R.string.upd_check_now),
|
||||
fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = pal.signal.copy(alpha = if (enabled || u.checking) 1f else 0.5f),
|
||||
)
|
||||
}
|
||||
Box(Modifier.weight(1f))
|
||||
Text(
|
||||
if (checked != null) stringResource(R.string.upd_checked, ago(checked).replaceFirstChar { it.lowercase() }) else stringResource(R.string.upd_not_checked),
|
||||
fontSize = 12.5.sp, color = colors.onSurfaceVariant, maxLines = 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, me: AppUpdates.Installed) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
@@ -201,12 +297,18 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
||||
Box(Modifier.size(7.dp).clip(CircleShape).background(look.tint))
|
||||
Text(look.status, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = look.tint)
|
||||
if (offered) Text(stringResource(R.string.upd_dot_ago, ago(release!!.publishedAt)), fontSize = 13.sp, color = colors.onSurfaceVariant)
|
||||
}
|
||||
Text(look.headline, fontSize = 22.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, modifier = Modifier.padding(top = 4.dp))
|
||||
if (offered) {
|
||||
ReleaseNotes(changeTitle(release!!.title.ifBlank { release.tag }), release.summary, release.tag)
|
||||
ReleaseFacts(release)
|
||||
val size = release!!.apk?.size?.takeIf { it > 0 }?.let { megabytes(it) }
|
||||
Text(
|
||||
listOfNotNull(stringResource(R.string.upd_released_ago, ago(release.publishedAt)), size).joinToString(" · "),
|
||||
fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 2.dp),
|
||||
)
|
||||
val older = (release.committedAt.takeIf { it > 0 } ?: release.publishedAt).let { it > 0 && me.committedAt > 0 && it < me.committedAt }
|
||||
if (offer == Offer.SWITCH && older) OlderNote(me.committedAt)
|
||||
val title = changeTitle(release.title.ifBlank { release.tag })
|
||||
ReleaseNotes(title.takeUnless { it == look.headline || (release.version != null && it.endsWith(release.version)) }, release.summary, release.tag)
|
||||
}
|
||||
if (release != null && u.follow.channel == Channel.TEST && catalog != null) {
|
||||
androidx.compose.runtime.LaunchedEffect(release.tag, release.commit, release.apk?.sha256) { ua.onSeen(release) }
|
||||
@@ -228,8 +330,10 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m
|
||||
else LinearProgressIndicator(modifier = Modifier.fillMaxWidth().height(6.dp).clip(CircleShape))
|
||||
}
|
||||
offered && installBlock != null -> Unit
|
||||
offer == Offer.UPDATE -> PrimaryButton(stringResource(R.string.upd_update_button, button), enabled = installable, main = true) { ua.onInstall(release!!) }
|
||||
offer == Offer.SWITCH -> PrimaryButton(stringResource(R.string.upd_install_button, button), enabled = installable, main = true) { ua.onInstall(release!!) }
|
||||
offer == Offer.UPDATE -> PrimaryButton(stringResource(R.string.upd_update_button, button), enabled = installable, main = true, fill = true,
|
||||
modifier = Modifier.fillMaxWidth()) { ua.onInstall(release!!) }
|
||||
offer == Offer.SWITCH -> PrimaryButton(stringResource(R.string.upd_switch_to_button, channelTitle(u.follow), button), enabled = installable, main = true,
|
||||
fill = true, modifier = Modifier.fillMaxWidth()) { ua.onInstall(release!!) }
|
||||
offer == Offer.AHEAD && u.follow.channel == Channel.STABLE && installBlock == null ->
|
||||
SecondaryButton(stringResource(R.string.upd_install_anyway, release?.version.orEmpty()), enabled = installable) { ua.onInstall(release!!) }
|
||||
offer == Offer.GONE -> PrimaryButton(stringResource(R.string.upd_follow_preview), main = true) { ua.onFollow(Follow(Channel.NIGHTLY)) }
|
||||
@@ -238,25 +342,53 @@ private fun StatusPanel(s: FrontEndState, u: UpdatesState, ua: UpdatesActions, m
|
||||
if (s.sessionRunning && (offered || offer == Offer.AHEAD)) {
|
||||
Text(stringResource(R.string.upd_stop_session), fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp))
|
||||
}
|
||||
if (offered) ReleaseFacts(release!!)
|
||||
if (u.follow.channel == Channel.NIGHTLY) {
|
||||
PreviewHistory(catalog, me, s, u, ua)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A switch that installs a build made before the installed one; Android keeps the app's data across it. */
|
||||
@Composable
|
||||
private fun ReleaseNotes(title: String, notes: String, key: String) {
|
||||
private fun OlderNote(installedAt: Long) {
|
||||
val context = LocalContext.current
|
||||
val date = android.text.format.DateUtils.formatDateTime(context, installedAt,
|
||||
android.text.format.DateUtils.FORMAT_SHOW_DATE or android.text.format.DateUtils.FORMAT_ABBREV_MONTH)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = Modifier.padding(top = 12.dp).fillMaxWidth().clip(Shape12).background(AttentionAmber.copy(alpha = 0.12f))
|
||||
.padding(horizontal = 12.dp, vertical = 10.dp),
|
||||
) {
|
||||
Icon(Icons.Outlined.WarningAmber, contentDescription = null, tint = AttentionAmber, modifier = Modifier.size(20.dp))
|
||||
Column {
|
||||
Text(stringResource(R.string.upd_older_than_installed, date), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = AttentionAmber)
|
||||
Text(stringResource(R.string.upd_data_stays), fontSize = 12.5.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun channelTitle(f: Follow) = when (f.channel) {
|
||||
Channel.STABLE -> stringResource(R.string.upd_stable)
|
||||
Channel.NIGHTLY -> stringResource(R.string.upd_preview)
|
||||
Channel.TEST -> stringResource(R.string.upd_pr, f.pr)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ReleaseNotes(title: String?, notes: String, key: String) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
var open by rememberSaveable(key) { mutableStateOf(false) }
|
||||
var cut by remember(key) { mutableStateOf(false) }
|
||||
Text(
|
||||
if (title != null) Text(
|
||||
title, fontSize = 15.sp, color = colors.onBackground, maxLines = if (open) Int.MAX_VALUE else 2, overflow = TextOverflow.Ellipsis,
|
||||
onTextLayout = { if (it.hasVisualOverflow) cut = true }, modifier = Modifier.padding(top = 10.dp),
|
||||
)
|
||||
if (notes.isNotBlank()) Text(
|
||||
notes, fontSize = 13.5.sp, color = colors.onSurfaceVariant, maxLines = if (open) Int.MAX_VALUE else 1, overflow = TextOverflow.Ellipsis,
|
||||
onTextLayout = { if (it.hasVisualOverflow) cut = true }, modifier = Modifier.padding(top = 4.dp),
|
||||
notes, fontSize = 13.5.sp, color = colors.onSurfaceVariant, maxLines = if (open) Int.MAX_VALUE else if (title == null) 3 else 1,
|
||||
overflow = TextOverflow.Ellipsis, onTextLayout = { if (it.hasVisualOverflow) cut = true },
|
||||
modifier = Modifier.padding(top = if (title == null) 10.dp else 4.dp),
|
||||
)
|
||||
if (cut || open) {
|
||||
val src = remember { MutableInteractionSource() }
|
||||
@@ -287,47 +419,76 @@ private fun changeTitle(t: String): String =
|
||||
private fun megabytes(bytes: Long) = stringResource(R.string.upd_mb, ((bytes + 524_288) / 1_048_576).toInt())
|
||||
|
||||
@Composable
|
||||
private fun ChannelLabel() {
|
||||
Text(
|
||||
stringResource(R.string.upd_channel), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 10.dp),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions, sessionRunning: Boolean) {
|
||||
private fun ChannelPicker(u: UpdatesState, ua: UpdatesActions) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val catalog = u.catalog
|
||||
val tests = catalog?.tests.orEmpty()
|
||||
val me = remember { AppUpdates.installed() }
|
||||
val ready = tests.count { AppUpdates.installable(it, me) }
|
||||
var showTests by rememberSaveable { mutableStateOf(false) }
|
||||
val listing = (showTests || u.follow.channel == Channel.TEST) && tests.isNotEmpty()
|
||||
val shown = if (listing || showTests) Channel.TEST else u.follow.channel
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
ChannelCard(
|
||||
Icons.Outlined.Verified, stringResource(R.string.upd_stable), stringResource(R.string.upd_stable_hint),
|
||||
catalog?.stable?.let { stringResource(R.string.upd_version_ago, it.version ?: it.tag, ago(it.publishedAt)) }, u.follow.channel == Channel.STABLE,
|
||||
) { ua.onFollow(Follow(Channel.STABLE)) }
|
||||
ChannelCard(
|
||||
Icons.Outlined.Bolt, stringResource(R.string.upd_preview), stringResource(R.string.upd_preview_hint),
|
||||
catalog?.preview?.let { ago(it.publishedAt) }, u.follow.channel == Channel.NIGHTLY,
|
||||
) { ua.onFollow(Follow(Channel.NIGHTLY)) }
|
||||
ChannelCard(
|
||||
Icons.Outlined.Science, stringResource(R.string.upd_tests), stringResource(R.string.upd_tests_hint),
|
||||
if (tests.isEmpty()) stringResource(R.string.upd_tests_none) else pluralStringResource(R.plurals.upd_tests_count, ready, ready),
|
||||
u.follow.channel == Channel.TEST, enabled = tests.isNotEmpty() || u.follow.channel == Channel.TEST,
|
||||
) { showTests = !showTests }
|
||||
AnimatedVisibility((showTests || u.follow.channel == Channel.TEST) && tests.isNotEmpty(), enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
modifier = Modifier.fillMaxWidth().clip(CircleShape).background(colors.surface).border(1.dp, pal.line, CircleShape)
|
||||
.padding(4.dp).selectableGroup(),
|
||||
) {
|
||||
ChannelSegment(Icons.Outlined.Verified, stringResource(R.string.upd_stable), null, shown == Channel.STABLE) {
|
||||
showTests = false; ua.onFollow(Follow(Channel.STABLE))
|
||||
}
|
||||
ChannelSegment(Icons.Outlined.Bolt, stringResource(R.string.upd_preview), null, shown == Channel.NIGHTLY) {
|
||||
showTests = false; ua.onFollow(Follow(Channel.NIGHTLY))
|
||||
}
|
||||
ChannelSegment(
|
||||
Icons.Outlined.Science, stringResource(R.string.upd_tests_short), ready.takeIf { it > 0 }?.toString(),
|
||||
shown == Channel.TEST, enabled = tests.isNotEmpty() || u.follow.channel == Channel.TEST,
|
||||
) { showTests = !showTests }
|
||||
}
|
||||
val hint = when {
|
||||
listing || u.follow.channel == Channel.TEST -> stringResource(R.string.upd_tests_hint)
|
||||
u.follow.channel == Channel.NIGHTLY -> stringResource(R.string.upd_preview_hint) +
|
||||
(catalog?.preview?.let { " · " + stringResource(R.string.upd_latest_ago, ago(it.publishedAt)) } ?: "")
|
||||
else -> stringResource(R.string.upd_stable_hint) +
|
||||
(catalog?.stable?.let { " · " + stringResource(R.string.upd_version_ago, it.version ?: it.tag, ago(it.publishedAt)) } ?: "")
|
||||
}
|
||||
Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 4.dp))
|
||||
if (tests.isEmpty() && catalog != null && showTests) Text(stringResource(R.string.upd_tests_none), fontSize = 12.5.sp, color = colors.onSurfaceVariant)
|
||||
AnimatedVisibility(listing, enter = expandVertically(Motion.sp(1f)) + fadeIn(Motion.sp(1f)), exit = shrinkVertically(Motion.sp(1f)) + fadeOut(Motion.sp(1f))) {
|
||||
TestList(tests, me, u, ua)
|
||||
}
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val agentReady = com.droiddeck.launcher.agent.AgentHost.installed &&
|
||||
(com.droiddeck.launcher.agent.AgentSetup.ready || com.droiddeck.launcher.agent.AgentSetup.completed(context))
|
||||
LabBuilds(sessionRunning, onRebuild = if (agentReady) { info ->
|
||||
com.droiddeck.launcher.agent.AgentHost.send(context, context.getString(R.string.agent_rebuild_lab, info.label))
|
||||
context.startActivity(android.content.Intent(context, com.droiddeck.launcher.FrontEndActivity::class.java)
|
||||
.putExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV, "agent")
|
||||
.addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP or android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))
|
||||
} else null)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowScope.ChannelSegment(
|
||||
icon: ImageVector, title: String, badge: String?, selected: Boolean,
|
||||
enabled: Boolean = true, onClick: () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp, Alignment.CenterHorizontally),
|
||||
modifier = Modifier.weight(1f).heightIn(min = 44.dp).paneItem("channel:$title")
|
||||
.clip(CircleShape)
|
||||
.background(if (selected) pal.signal.copy(alpha = 0.16f) else if (hot) pal.signal.copy(alpha = 0.10f) else Color.Transparent)
|
||||
.glideBorder(hot, CircleShape, pal.signal, if (selected) pal.signal else Color.Transparent)
|
||||
.alpha(if (enabled) 1f else 0.5f)
|
||||
.hoverable(src)
|
||||
.selectable(selected = selected, interactionSource = src, indication = null, enabled = enabled, role = Role.RadioButton, onClick = onClick)
|
||||
.controllerConfirm(enabled = enabled, onClick = onClick)
|
||||
.padding(horizontal = 6.dp),
|
||||
) {
|
||||
Icon(icon, contentDescription = null, tint = if (selected) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(18.dp))
|
||||
Text(title, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = if (selected) colors.onBackground else colors.onSurfaceVariant,
|
||||
maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
|
||||
if (badge != null) Text(
|
||||
badge, fontSize = 11.sp, fontWeight = FontWeight.Bold, color = colors.onSurfaceVariant,
|
||||
modifier = Modifier.clip(CircleShape).background(colors.surfaceVariant).padding(horizontal = 6.dp, vertical = 1.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,41 +703,6 @@ private fun TestList(tests: List<Release>, me: AppUpdates.Installed, u: UpdatesS
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChannelCard(
|
||||
icon: ImageVector, title: String, hint: String, latest: String?, selected: Boolean,
|
||||
enabled: Boolean = true, onClick: () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val fill = if (hot) pal.signal.copy(alpha = 0.14f) else Color.Transparent
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
modifier = Modifier.fillMaxWidth().paneItem("channel:$title")
|
||||
.clip(Shape14).background(colors.surface).background(fill).glideBorder(hot, Shape14, pal.signal, pal.line)
|
||||
.alpha(if (enabled) 1f else 0.55f)
|
||||
.hoverable(src)
|
||||
.clickable(interactionSource = src, indication = null, enabled = enabled, role = Role.RadioButton, onClick = onClick)
|
||||
.controllerConfirm(enabled = enabled, onClick = onClick)
|
||||
.padding(horizontal = 14.dp, vertical = 10.dp),
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(38.dp).clip(Shape12).background(if (selected) pal.signal.copy(alpha = 0.18f) else colors.surfaceVariant)) {
|
||||
Icon(icon, contentDescription = null, tint = if (selected) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(22.dp))
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(title, fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
if (latest != null) Text(latest, fontSize = 12.sp, fontWeight = FontWeight.Medium, color = if (selected) pal.signal else colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
Text(hint, fontSize = 12.5.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
RadioDot(selected)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RadioDot(selected: Boolean, size: androidx.compose.ui.unit.Dp = 22.dp) {
|
||||
val pal = LocalPalette.current
|
||||
|
||||
@@ -1170,6 +1170,21 @@
|
||||
<string name="upd_new_test">PR #%1$d test build</string>
|
||||
<string name="upd_mb">%1$d MB</string>
|
||||
<string name="upd_channel">UPDATE CHANNEL</string>
|
||||
<string name="upd_installed_label">INSTALLED</string>
|
||||
<string name="upd_testers">FOR TESTERS</string>
|
||||
<string name="upd_kind_test">Test build</string>
|
||||
<string name="upd_kind_lab">Lab build</string>
|
||||
<string name="upd_lab_on_pr">On the PR #%1$d test build</string>
|
||||
<string name="upd_lab_on_version">On DroidDeck %1$s</string>
|
||||
<string name="upd_droiddeck_version">DroidDeck %1$s</string>
|
||||
<string name="upd_built_ago">built %1$s</string>
|
||||
<string name="upd_check_now">Check now</string>
|
||||
<string name="upd_tests_short">Tests</string>
|
||||
<string name="upd_latest_ago">latest %1$s</string>
|
||||
<string name="upd_released_ago">Released %1$s</string>
|
||||
<string name="upd_switch_to_button">Switch to %1$s%2$s</string>
|
||||
<string name="upd_older_than_installed">Older than your installed build (%1$s)</string>
|
||||
<string name="upd_data_stays">Your games and settings stay.</string>
|
||||
<string name="upd_stable">Stable</string>
|
||||
<string name="upd_stable_hint">Tested releases, for most people</string>
|
||||
<string name="upd_version_ago">%1$s · %2$s</string>
|
||||
@@ -4375,6 +4390,7 @@
|
||||
<string name="soundtracks_volume">Volume</string>
|
||||
<string name="soundtracks_no_tracks">No audio files found in this soundtrack</string>
|
||||
<string name="stores_rockstar_launch_unavailable">Launch unavailable</string>
|
||||
<string name="agent_image_missing">Image not found: %1$s</string>
|
||||
<string name="agent_browser_unavailable">No web browser is available to open this link.</string>
|
||||
<string name="hud_hint_grab">Grab</string>
|
||||
<string name="hud_hint_drop">Drop</string>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class AgentReplyTest {
|
||||
@Test
|
||||
fun anImageOnItsOwnLineSplitsTheReply() {
|
||||
val parts = replyParts("Here it is:\n\n\n\nWant changes?")
|
||||
assertEquals(
|
||||
listOf(
|
||||
ReplyPart.Prose("Here it is:"),
|
||||
ReplyPart.Picture("Proposed Updates tab", "/tmp/updates.png"),
|
||||
ReplyPart.Prose("\nWant changes?"),
|
||||
),
|
||||
parts,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun fileUrlsAndAngleBracketsNameTheSamePath() {
|
||||
assertEquals(listOf(ReplyPart.Picture("", "/root/a b.png")), replyParts(""))
|
||||
assertEquals(listOf(ReplyPart.Picture("chart", "/root/chart (1).png")), replyParts(".png>)"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun imagesInCodeInlineOrRemoteStayText() {
|
||||
val fenced = "```\n\n```"
|
||||
assertEquals(listOf(ReplyPart.Prose(fenced)), replyParts(fenced))
|
||||
val inline = "See  here"
|
||||
assertEquals(listOf(ReplyPart.Prose(inline)), replyParts(inline))
|
||||
val nested = "````\n```\n\n```python\n\n````"
|
||||
assertEquals(listOf(ReplyPart.Prose(nested)), replyParts(nested))
|
||||
val remote = ""
|
||||
assertEquals(listOf(ReplyPart.Prose(remote)), replyParts(remote))
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,22 @@ import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class SessionDrawerPageTest {
|
||||
@Test fun navigationRunsControllerPerformanceDisplayEffectsGameVrSession() {
|
||||
@Test fun navigationRunsControllerPerformanceFrameGenDisplayEffectsGameSessionMore() {
|
||||
val pages = sessionDrawerPages(hasAgent = false)
|
||||
assertEquals(DrawerPages.arrange(emptyList()).strip(), pages.strip())
|
||||
assertEquals(
|
||||
listOf(SessionDrawerPage.CONTROLLER, SessionDrawerPage.HUD, SessionDrawerPage.FRAMEGEN,
|
||||
SessionDrawerPage.DISPLAY, SessionDrawerPage.EFFECTS, SessionDrawerPage.GAMES,
|
||||
SessionDrawerPage.VR, SessionDrawerPage.SESSION, SessionDrawerPage.MORE),
|
||||
SessionDrawerPage.SESSION, SessionDrawerPage.MORE),
|
||||
pages.strip(),
|
||||
)
|
||||
assertEquals(SessionDrawerPage.MORE, pages.step(SessionDrawerPage.CONTROLLER, -1))
|
||||
assertEquals(SessionDrawerPage.MORE, pages.strip().step(SessionDrawerPage.CONTROLLER, -1))
|
||||
}
|
||||
|
||||
@Test fun achievementsAndTheAgentStartInsideMore() {
|
||||
@Test fun vrAchievementsAndTheAgentStartInsideMore() {
|
||||
val pages = sessionDrawerPages(hasAchievements = true, hasAgent = true)
|
||||
assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS, SessionDrawerPage.AGENT), pages.inMore())
|
||||
assertEquals(listOf(SessionDrawerPage.VR, SessionDrawerPage.ACHIEVEMENTS, SessionDrawerPage.AGENT), pages.inMore())
|
||||
assertEquals(SessionDrawerPage.MORE, pages.tabFor(SessionDrawerPage.VR))
|
||||
assertEquals(SessionDrawerPage.MORE, pages.tabFor(SessionDrawerPage.ACHIEVEMENTS))
|
||||
assertEquals(SessionDrawerPage.GAMES, pages.tabFor(SessionDrawerPage.GAMES))
|
||||
val strip = pages.strip()
|
||||
@@ -27,7 +29,7 @@ class SessionDrawerPageTest {
|
||||
@Test fun achievementsAreOfferedOnlyForAGameThatHasThem() {
|
||||
assertFalse(SessionDrawerPage.ACHIEVEMENTS in sessionDrawerPages(hasAchievements = false, hasAgent = false))
|
||||
assertFalse(SessionDrawerPage.AGENT in sessionDrawerPages(hasAgent = false))
|
||||
assertTrue(sessionDrawerPages(hasAgent = false).inMore().isEmpty())
|
||||
assertEquals(listOf(SessionDrawerPage.VR), sessionDrawerPages(hasAgent = false).inMore())
|
||||
}
|
||||
|
||||
@Test fun anOlderSavedOrderKeepsItsPagesAndGetsAMoreTabAfterSession() {
|
||||
@@ -37,6 +39,15 @@ class SessionDrawerPageTest {
|
||||
assertEquals(SessionDrawerPage.MORE, out[out.indexOf(SessionDrawerPage.SESSION) + 1])
|
||||
assertEquals(listOf(SessionDrawerPage.ACHIEVEMENTS), out.inMore())
|
||||
assertTrue(SessionDrawerPage.AGENT in out.strip())
|
||||
assertTrue(SessionDrawerPage.VR in out.strip())
|
||||
}
|
||||
|
||||
@Test fun aSavedLayoutCanKeepVrOnTheTabStrip() {
|
||||
val saved = listOf("CONTROLLER", "HUD", "VR", "FRAMEGEN", "DISPLAY", "EFFECTS",
|
||||
"GAMES", "SESSION", "MORE", "ACHIEVEMENTS", "AGENT")
|
||||
val out = DrawerPages.arrange(saved)
|
||||
assertEquals(saved, out.map { it.name })
|
||||
assertEquals(SessionDrawerPage.VR, out.tabFor(SessionDrawerPage.VR))
|
||||
}
|
||||
|
||||
@Test fun sessionCanBeKeptInsideMore() {
|
||||
|
||||
@@ -59,7 +59,9 @@ The source is checked out at `/root/DroidDeck` once the Agent tab's build tools
|
||||
process, and the conversation continues on the new build.
|
||||
- Python tests run from the repository root: `python3 -m unittest tools.tests.test_x`. Some fail on
|
||||
the device on `origin/main` too; run them on a worktree of `origin/main` before blaming a change.
|
||||
- Gradle unit tests rarely run on the device. Leave them to CI and say so rather than retrying.
|
||||
- Gradle runs on the device once the build tools are set up, but slowly: run the test classes that cover
|
||||
your change, and leave full suites and native builds to CI. `PreviewRenderTest` cannot run here
|
||||
(Robolectric's native graphics has no aarch64 Linux build).
|
||||
- If `git push` asks for credentials, run `gh auth setup-git` once.
|
||||
- Commits and pull requests you make are the user's own: no co-author line, AI credit or
|
||||
generated-by note.
|
||||
|
||||
@@ -28,6 +28,19 @@ float_code() {
|
||||
[ "$result" = ok ]
|
||||
}
|
||||
|
||||
# git pushes through gh's sign-in and commits as the signed-in account, with its no-reply address.
|
||||
configure_git() {
|
||||
gh auth setup-git || return 1
|
||||
[ -n "$(git config --global user.name)" ] && [ -n "$(git config --global user.email)" ] && return 0
|
||||
local user id login name
|
||||
user=$(gh api user -q '"\(.id) \(.login) \(.name // .login)"') || return 1
|
||||
read -r id login name <<<"$user"
|
||||
[ -n "$id" ] && [ -n "$login" ] || return 1
|
||||
[ -n "$(git config --global user.name)" ] || git config --global user.name "${name:-$login}"
|
||||
[ -n "$(git config --global user.email)" ] || git config --global user.email "$id+$login@users.noreply.github.com"
|
||||
}
|
||||
if [ "${1:-}" = --git ]; then configure_git; exit; fi
|
||||
|
||||
coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; }
|
||||
gh_pid=$GH_PID
|
||||
exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}"
|
||||
@@ -48,5 +61,9 @@ while IFS= read -r line <&"$ghout"; do
|
||||
done
|
||||
wait "$gh_pid"
|
||||
status=$?
|
||||
if [ $status = 0 ] && ! configure_git; then
|
||||
echo "Signed in, but git could not be set up: run dd-gh-login --git"
|
||||
status=1
|
||||
fi
|
||||
[ -n "$shown" ] && [ -n "$inbox" ] && [ -d "$inbox" ] && : > "$inbox/device-code"
|
||||
exit $status
|
||||
@@ -16,6 +16,9 @@ command -v claude >/dev/null || [ -x "$HOME/.local/bin/claude" ] ||
|
||||
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
for tool in dd-agent dd-lab-build dd-gh-login android-open; do install -m755 "$here/$tool" "$HOME/.local/bin/$tool"; done
|
||||
if gh auth status >/dev/null 2>&1 && ! "$here/dd-gh-login" --git; then
|
||||
echo "setup: git could not use the GitHub sign-in; run dd-gh-login --git" >&2
|
||||
fi
|
||||
# DroidDeck passes the live loopback adb port; a fixed one here would go stale whenever wireless debugging is toggled.
|
||||
sed -i 's|ADB_SERIAL=127.0.0.1:5555 |ADB_SERIAL="${ADB_SERIAL:-127.0.0.1:5555}" |' "$HOME/.bashrc" 2>/dev/null || true
|
||||
grep -q 'droiddeck-agent-path' "$HOME/.bashrc" 2>/dev/null ||
|
||||
@@ -63,6 +66,29 @@ if [ ! -x "$sdk/cmdline-tools/latest/bin/sdkmanager" ]; then
|
||||
mv "$sdk/cmdline-tools/cmdline-tools" "$sdk/cmdline-tools/latest"
|
||||
fi
|
||||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64
|
||||
# Ubuntu's default JDK can be newer than the Gradle wrapper supports, so every shell and Gradle run
|
||||
# here uses 17, the SDK above and the qemu-wrapped aapt2, not only dd-lab-build's.
|
||||
sed -i '/^# droiddeck-agent-gradle$/,+1d' "$HOME/.bashrc" 2>/dev/null || true
|
||||
printf '# droiddeck-agent-gradle\nexport JAVA_HOME=%s ANDROID_HOME="$HOME/android-sdk"\n' "$JAVA_HOME" >> "$HOME/.bashrc"
|
||||
mkdir -p "$HOME/.gradle"
|
||||
touch "$HOME/.gradle/gradle.properties"
|
||||
# Gradle's own settings carry the SDK too, for shells that do not read ~/.bashrc.
|
||||
for setting in "org.gradle.java.home=$JAVA_HOME" "android.aapt2FromMavenOverride=$HOME/aapt2/aapt2" "systemProp.android.home=$sdk"; do
|
||||
sed -i "/^${setting%%=*}=/d" "$HOME/.gradle/gradle.properties"
|
||||
echo "$setting" >> "$HOME/.gradle/gradle.properties"
|
||||
done
|
||||
# The NDK's compilers are x86-64 only, so DroidDeck's native code is left to CI, as dd-lab-build does,
|
||||
# and Conscrypt ships no aarch64 Linux library for Robolectric to load.
|
||||
mkdir -p "$HOME/.gradle/init.d"
|
||||
cat > "$HOME/.gradle/init.d/droiddeck-device.gradle" <<'GRADLE'
|
||||
settingsEvaluated { settings ->
|
||||
if (settings.rootProject.name != 'DroidDeck') return
|
||||
gradle.startParameter.excludedTaskNames += ':app:buildVkBridgeServer'
|
||||
gradle.allprojects {
|
||||
tasks.withType(org.gradle.api.tasks.testing.Test).configureEach { systemProperty 'robolectric.conscryptMode', 'OFF' }
|
||||
}
|
||||
}
|
||||
GRADLE
|
||||
(set +o pipefail; yes | "$sdk/cmdline-tools/latest/bin/sdkmanager" --licenses >/dev/null)
|
||||
"$sdk/cmdline-tools/latest/bin/sdkmanager" "platforms;android-34" "build-tools;35.0.0" >/dev/null
|
||||
|
||||
|
||||
Reference in new issue
Block a user