Improvements

try to make it run on Android (still unsuccessful)
This commit is contained in:
2024-08-18 10:38:20 +02:00
parent e70c89fe58
commit 9175e54c69
11 changed files with 64 additions and 29 deletions

View File

@@ -1 +1 @@
java temurin-17.0.11+9
java temurin-17.0.12+7

View File

@@ -1,6 +1,6 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
alias(libs.plugins.jetbrains.kotlin.android)
}
@@ -20,7 +20,7 @@ android {
dependencies {
implementation(compose.components.resources)
implementation(compose.runtime)
implementation(compose.foundation)
// implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.components.resources)
@@ -35,8 +35,8 @@ android {
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildTypes {
@@ -51,7 +51,7 @@ android {
}
}
kotlinOptions {
jvmTarget = "17"
jvmTarget = "11"
}
}
dependencies {

View File

@@ -3,7 +3,10 @@ package ch.dissem.android
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import ch.dissem.yaep.ui.common.App
@@ -12,7 +15,13 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
App()
Scaffold(
topBar = {
}
) {insets ->
App(modifier = Modifier.padding(insets))
}
}
}
}

View File

@@ -1,13 +1,15 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
alias(libs.plugins.versions)
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
@@ -18,3 +20,16 @@ tasks.withType<KotlinJvmCompile>().configureEach {
jvmTarget.set(JvmTarget.JVM_11)
}
}
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
fun isNonStable(version: String): Boolean {
return version.contains("dev", ignoreCase = true)
|| version.contains("alpha", ignoreCase = true)
|| version.contains("beta", ignoreCase = true)
|| version.contains("RC", ignoreCase = true)
}

View File

@@ -1,6 +1,6 @@
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
}

View File

@@ -19,6 +19,7 @@ import androidx.compose.material3.CardDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -29,6 +30,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.input.pointer.PointerButton.Companion.Secondary
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp
import ch.dissem.yaep.domain.Clue
import ch.dissem.yaep.domain.Game
@@ -62,6 +65,7 @@ class DisplayClue<C : Clue>(val clue: C) {
fun App(modifier: Modifier = Modifier, game: Game = remember { generateGame() }) {
val horizontalClues = remember { game.horizontalClues.map { DisplayClue(it) } }
val verticalClues = remember { game.verticalClues.map { DisplayClue(it) } }
val time = "00:00:00" // TODO
Row(modifier = modifier) {
PuzzleGrid(
modifier = Modifier.aspectRatio(1f).weight(0.6f).fillMaxHeight(),
@@ -71,11 +75,17 @@ fun App(modifier: Modifier = Modifier, game: Game = remember { generateGame() })
verticalClues.forEach { it.update(game.grid) }
}
)
Column(
modifier = Modifier.padding(start = 16.dp).weight(0.4f).fillMaxHeight()
) {
PuzzleClues(
modifier = Modifier.padding(start = 16.dp).weight(0.4f).fillMaxHeight(),
modifier = Modifier,
horizontalClues,
verticalClues
)
Text(time, fontSize = TextUnit(4f, TextUnitType.Em))
}
}
}

View File

@@ -2,7 +2,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
}

View File

@@ -3,7 +3,7 @@ agp = "8.5.1"
android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"
androidx-activityCompose = "1.9.0"
androidx-activityCompose = "1.9.1"
androidx-compose = "1.6.8"
compose-plugin = "1.6.11"
kotlin = "2.0.0"
@@ -18,10 +18,11 @@ atrium = { module = "ch.tutteli.atrium:atrium-fluent", version = "1.2.0" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
[plugins]
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

20
gradlew.bat vendored
View File

@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail