commit 4716396f6476838f0f8af10d64c0a43e0cf8ccea Author: Matthew Daubney Date: Mon Oct 12 10:59:08 2026 +0100 Set up Compose app shell, theme and Gitea CI Kotlin + Compose via AGP built-in Kotlin, Material 3 theme mirroring the web UI palette, bottom-nav shell with placeholder screens, cleartext network config for self-hosted servers, and a CI workflow running unit tests, lint and a debug build. Co-Authored-By: Claude Sonnet 5.5 diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..b30540c --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +# Unit tests, lint and a debug build on every push and PR. +on: + push: + branches: ["**"] + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: https://github.com/actions/setup-java@v4 + with: + distribution: temurin + java-version: "21" + - uses: https://github.com/android-actions/setup-android@v3 + - uses: https://github.com/gradle/actions/setup-gradle@v4 + - name: Unit tests + run: ./gradlew testDebugUnitTest + - name: Lint + run: ./gradlew lintDebug + - name: Debug build + run: ./gradlew assembleDebug + - uses: actions/upload-artifact@v3 + if: always() + with: + name: reports + path: | + app/build/reports + app/build/outputs/apk/debug/*.apk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b40e759 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties + +*.keystore +*.jks +.kotlin/ +.idea/ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..3c7d102 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,53 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.compose) +} + +android { + namespace = "dev.daubney.scrobbled" + compileSdk { + version = release(37) + } + + defaultConfig { + applicationId = "dev.daubney.scrobbled" + minSdk = 29 + targetSdk = 37 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildFeatures { + compose = true + } + + buildTypes { + release { + optimization { + enable = true + packageScope = setOf("androidx.**", "kotlin.**", "kotlinx.**") + } + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.lifecycle.runtime.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.navigation.compose) + debugImplementation(libs.androidx.compose.ui.tooling) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(libs.androidx.junit) +} diff --git a/app/src/androidTest/java/dev/daubney/scrobbled/ExampleInstrumentedTest.kt b/app/src/androidTest/java/dev/daubney/scrobbled/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..1fc4c8f --- /dev/null +++ b/app/src/androidTest/java/dev/daubney/scrobbled/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package dev.daubney.scrobbled + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("dev.daubney.scrobbled", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..222d764 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/java/dev/daubney/scrobbled/MainActivity.kt b/app/src/main/java/dev/daubney/scrobbled/MainActivity.kt new file mode 100644 index 0000000..3e6648f --- /dev/null +++ b/app/src/main/java/dev/daubney/scrobbled/MainActivity.kt @@ -0,0 +1,14 @@ +package dev.daubney.scrobbled + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import dev.daubney.scrobbled.ui.ScrobbledApp +import dev.daubney.scrobbled.ui.theme.ScrobbledTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { ScrobbledTheme { ScrobbledApp() } } + } +} diff --git a/app/src/main/java/dev/daubney/scrobbled/ui/Navigation.kt b/app/src/main/java/dev/daubney/scrobbled/ui/Navigation.kt new file mode 100644 index 0000000..b73012d --- /dev/null +++ b/app/src/main/java/dev/daubney/scrobbled/ui/Navigation.kt @@ -0,0 +1,54 @@ +package dev.daubney.scrobbled.ui + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.currentBackStackEntryAsState +import androidx.navigation.compose.rememberNavController + +enum class Destination(val route: String, val label: String) { + Home("home", "Home"), + History("history", "History"), + Add("add", "Add"), + Listen("listen", "Listen"), +} + +@Composable +fun ScrobbledApp() { + val nav = rememberNavController() + val current by nav.currentBackStackEntryAsState() + Scaffold( + bottomBar = { + NavigationBar { + Destination.entries.forEach { d -> + NavigationBarItem( + selected = current?.destination?.route == d.route, + onClick = { nav.navigate(d.route) { launchSingleTop = true } }, + icon = {}, + label = { Text(d.label) }, + ) + } + } + }, + ) { padding -> + NavHost(nav, startDestination = Destination.Home.route, modifier = Modifier.padding(padding)) { + Destination.entries.forEach { d -> + composable(d.route) { Placeholder(d.label) } + } + } + } +} + +@Composable +private fun Placeholder(title: String) { + Box(Modifier, contentAlignment = Alignment.Center) { Text(title) } +} diff --git a/app/src/main/java/dev/daubney/scrobbled/ui/theme/Theme.kt b/app/src/main/java/dev/daubney/scrobbled/ui/theme/Theme.kt new file mode 100644 index 0000000..3a5bf69 --- /dev/null +++ b/app/src/main/java/dev/daubney/scrobbled/ui/theme/Theme.kt @@ -0,0 +1,51 @@ +package dev.daubney.scrobbled.ui.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.ui.unit.dp + +// Mirrors the web UI's paper/ink palette (frontend/css/style.css in ScrobblingService). +val Glow = Color(0xFFF2A541) +val Panel = Color(0xFF1C2330) +val PanelText = Color(0xFFB9C3D2) + +private val Light = lightColorScheme( + primary = Color(0xFF2F5DA8), + background = Color(0xFFE8ECF1), + surface = Color(0xFFE8ECF1), + surfaceVariant = Color(0xFFF4F6F9), + onBackground = Color(0xFF18202C), + onSurface = Color(0xFF18202C), + onSurfaceVariant = Color(0xFF4A5566), + outline = Color(0xFFC9D0DA), + error = Color(0xFFB3412E), +) + +private val Dark = darkColorScheme( + primary = Color(0xFF8FB4F0), + background = Color(0xFF12171F), + surface = Color(0xFF12171F), + surfaceVariant = Color(0xFF19202B), + onBackground = Color(0xFFE3E8EF), + onSurface = Color(0xFFE3E8EF), + onSurfaceVariant = Color(0xFFA7B1C0), + outline = Color(0xFF2C3543), + error = Color(0xFFE0806C), +) + +private val AppShapes = Shapes( + small = RoundedCornerShape(6.dp), + medium = RoundedCornerShape(6.dp), + large = RoundedCornerShape(14.dp), +) + +@Composable +fun ScrobbledTheme(dark: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { + MaterialTheme(colorScheme = if (dark) Dark else Light, shapes = AppShapes, content = content) +} diff --git a/app/src/main/keepRules/rules.keep b/app/src/main/keepRules/rules.keep new file mode 100644 index 0000000..d7e081a --- /dev/null +++ b/app/src/main/keepRules/rules.keep @@ -0,0 +1,12 @@ +# Add project specific R8 rules here. +# AGP will combine all keep rule files in src/main/keepRules to pass to R8 +# +# For more details, see +# https://d.android.com/r/tools/r8/keep-rules + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/app/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..7f26013 --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,3 @@ + +