From c951c71f82511489455a9c5fbc85a0c3a941852f Mon Sep 17 00:00:00 2001 From: xXJsonDeruloXx Date: Wed, 23 Sep 2026 21:38:46 -0400 Subject: [PATCH] Show build identity on launcher --- .github/workflows/build.yml | 19 ++++++++ app/build.gradle | 41 +++++++++++++++++ .../com/droiddeck/launcher/MainActivity.kt | 4 ++ .../droiddeck/launcher/ui/FrontEndScreen.kt | 44 +++++++++++++++++++ 4 files changed, 108 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5965ffe22..8511575544 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,5 @@ name: Build APK +run-name: ${{ github.event_name == 'pull_request_target' && format('building pr {0} on {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('building {0} on {1}', github.ref_name, github.sha) }} # One job: the two glibc preload libraries the session needs, then the app around them. # Nothing is built on a developer machine - this workflow is the only thing that produces an apk. @@ -140,6 +141,22 @@ jobs: echo "NDK $VERSION at $NDK" echo "NDK_VERSION=$VERSION" >> "$GITHUB_ENV" + - name: Set the APK build label + id: build-label + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + BUILD_REF: ${{ github.ref_name }} + BUILD_SHA: ${{ github.sha }} + run: | + if [[ -n "$PR_NUMBER" ]]; then + label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}" + else + label="${BUILD_REF} at ${BUILD_SHA:0:7}" + fi + echo "label=$label" >> "$GITHUB_OUTPUT" + echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY" + # ── The session's preloads ─────────────────────────────────────────────────────────── # Both are glibc aarch64 libraries that live inside the rootfs, so they are cross-compiled # here rather than by the NDK. They ship in assets (not in the runtime tarball) so a fix in @@ -306,6 +323,8 @@ jobs: # The whole log is kept so a failed build's errors can be quoted back on a pull request. - name: Build id: build + env: + DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }} run: | set -o pipefail ./gradlew assembleRelease --console=plain -PndkVersion="$NDK_VERSION" 2>&1 | tee /tmp/build.log diff --git a/app/build.gradle b/app/build.gradle index 413b4e2238..821f2afb2e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,6 +4,45 @@ plugins { apply plugin: 'kotlin-android' apply plugin: 'org.jetbrains.kotlin.plugin.compose' +def gitValue = { List arguments -> + try { + def output = providers.exec { + commandLine(['git'] + arguments) + workingDir rootProject.projectDir + ignoreExitValue = true + } + output.result.get().exitValue == 0 ? output.standardOutput.asText.get().trim() : '' + } catch (Exception ignored) { + '' + } +} + +def buildLabel = providers.environmentVariable('DROIDDECK_BUILD_LABEL').getOrNull() +if (buildLabel == null || buildLabel.trim().isEmpty()) { + def eventName = providers.environmentVariable('GITHUB_EVENT_NAME').getOrNull() + def eventPath = providers.environmentVariable('GITHUB_EVENT_PATH').getOrNull() + if (eventName == 'pull_request_target' && eventPath) { + try { + def eventFile = layout.file(providers.provider { new File(eventPath) }) + def eventText = providers.fileContents(eventFile).asText.get() + def pullRequest = new groovy.json.JsonSlurper().parseText(eventText).pull_request + if (pullRequest?.number && pullRequest?.head?.sha) { + buildLabel = "pr${pullRequest.number} at ${pullRequest.head.sha.take(7)}" + } + } catch (Exception ignored) { + // Local builds and unusual CI events can omit the pull-request payload. + } + } + if (buildLabel == null || buildLabel.trim().isEmpty()) { + def branch = providers.environmentVariable('GITHUB_REF_NAME').getOrNull() + ?: gitValue(['branch', '--show-current']) ?: 'local' + def commit = providers.environmentVariable('GITHUB_SHA').getOrNull() + ?.take(7) ?: gitValue(['rev-parse', '--short=7', 'HEAD']) ?: 'unknown' + buildLabel = "${branch} at ${commit}" + } +} +def escapedBuildLabel = buildLabel.replace('\\', '\\\\').replace('"', '\\"') + android { namespace 'com.droiddeck.launcher' compileSdk 34 @@ -20,6 +59,7 @@ android { targetSdkVersion 28 versionCode 7 versionName "0.1.6" + buildConfigField "String", "BUILD_LABEL", "\"${escapedBuildLabel}\"" ndk { abiFilters 'arm64-v8a' @@ -87,6 +127,7 @@ android { buildFeatures { compose true + buildConfig true } compileOptions { diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index ca68e8e057..7e78b691ad 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -244,6 +244,7 @@ class MainActivity : ComponentActivity() { packagePercent = pkgPercent, sessionRunning = SessionState.running, backActionsInverted = backActionsInverted, + buildLabel = BuildConfig.BUILD_LABEL, ), FrontEndActions( onPlay = { startSession(Intent(this, SessionActivity::class.java)) }, @@ -308,6 +309,9 @@ class MainActivity : ComponentActivity() { SessionPrefs.setBackActionsInverted(this, inverted) backActionsInverted = inverted }, + onCheckLatestBuild = { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/The412Banner/DroidDeck/actions/workflows/build.yml"))) + }, ), page = page, ) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 92774857a6..93bc551852 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -59,11 +59,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Refresh import androidx.compose.material.icons.filled.Settings import androidx.compose.material3.Icon import androidx.compose.material3.LinearProgressIndicator @@ -98,6 +100,7 @@ import androidx.compose.ui.layout.positionInRoot import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.painterResource +import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.IntOffset @@ -143,6 +146,7 @@ class FrontEndState( val packagePercent: Int = -1, val sessionRunning: Boolean = false, val backActionsInverted: Boolean = false, + val buildLabel: String = "local", ) class FrontEndActions( @@ -172,6 +176,7 @@ class FrontEndActions( val onHomeApp: () -> Unit = {}, val onAndroidApp: (com.droiddeck.launcher.HomeApp.LaunchableApp) -> Unit = {}, val onBackActionsInverted: (Boolean) -> Unit = {}, + val onCheckLatestBuild: () -> Unit = {}, ) @@ -466,6 +471,45 @@ private fun Pane(s: FrontEndState, selected: String, a: FrontEndActions, page: ( }, label = "pane", ) { key -> if (page != null && key == s.pageKey) page() else Content(s, key, a, Modifier.fillMaxSize(), onSelect) } + if (page == null && s.pageKey == null && selected == "steam") { + BuildStatus( + label = s.buildLabel, + onCheckLatest = a.onCheckLatestBuild, + modifier = Modifier.align(Alignment.TopEnd).padding(12.dp), + ) + } + } +} + +@Composable +private fun BuildStatus(label: String, onCheckLatest: () -> Unit, modifier: Modifier = Modifier) { + val colors = MaterialTheme.colorScheme + val pal = LocalPalette.current + val interaction = remember { MutableInteractionSource() } + val hot = rememberHot(interaction) + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(9.dp), + modifier = modifier + .widthIn(max = 360.dp) + .clip(Shape12) + .background(colors.surface.copy(alpha = 0.96f)) + .border(1.5.dp, if (hot) pal.signal else pal.line2, Shape12) + .hoverable(interaction) + .clickable( + interactionSource = interaction, + indication = LocalIndication.current, + role = Role.Button, + onClick = onCheckLatest, + ) + .padding(horizontal = 11.dp, vertical = 7.dp), + ) { + Column(modifier = Modifier.weight(1f)) { + Text("BUILD", fontSize = 9.sp, letterSpacing = 1.sp, color = colors.onSurfaceVariant) + Text(label, fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) + } + Icon(Icons.Filled.Refresh, contentDescription = null, tint = if (hot) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(15.dp)) + Text("Check latest", fontSize = 11.sp, fontWeight = FontWeight.SemiBold, color = if (hot) pal.signal else colors.onBackground, maxLines = 1) } }