From 5353378b06f122eb1c038d34081e33a263d3ce83 Mon Sep 17 00:00:00 2001 From: "yvan.calatayud" Date: Wed, 6 Mar 2024 15:39:49 +0100 Subject: [PATCH] init in compose --- Android/app/build.gradle.kts | 74 ++++++++++ Android/app/src/main/AndroidManifest.xml | 12 +- .../com/example/mathseduc/MainActivity.kt | 131 +++++++++++++----- .../com/example/mathseduc/ui/theme/Color.kt | 29 ++++ .../com/example/mathseduc/ui/theme/Theme.kt | 79 +++++++++++ .../com/example/mathseduc/ui/theme/Type.kt | 34 +++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 1 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 1 + Android/app/src/main/res/values/colors.xml | 8 -- Android/app/src/main/res/values/strings.xml | 31 ----- Android/app/src/main/res/values/themes.xml | 20 +-- Android/build.gradle.kts | 5 + .../gradle/wrapper/gradle-wrapper.properties | 6 +- Android/settings.gradle.kts | 1 + 14 files changed, 340 insertions(+), 92 deletions(-) create mode 100644 Android/app/build.gradle.kts create mode 100644 Android/app/src/main/java/com/example/mathseduc/ui/theme/Color.kt create mode 100644 Android/app/src/main/java/com/example/mathseduc/ui/theme/Theme.kt create mode 100644 Android/app/src/main/java/com/example/mathseduc/ui/theme/Type.kt create mode 100644 Android/build.gradle.kts diff --git a/Android/app/build.gradle.kts b/Android/app/build.gradle.kts new file mode 100644 index 0000000..a23ba30 --- /dev/null +++ b/Android/app/build.gradle.kts @@ -0,0 +1,74 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "com.example.mathseduc" + compileSdk = 34 + + defaultConfig { + applicationId = "com.example.mathseduc" + minSdk = 21 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.1" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") + implementation("androidx.activity:activity-compose:1.7.0") + implementation(platform("androidx.compose:compose-bom:2023.08.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + implementation("androidx.compose.material3:material3") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00")) + androidTestImplementation("androidx.compose.ui:ui-test-junit4") + debugImplementation("androidx.compose.ui:ui-tooling") + debugImplementation("androidx.compose.ui:ui-test-manifest") + + + implementation("com.squareup.okhttp3:okhttp:4.10.0") + implementation("com.google.code.gson:gson:2.10.1") + implementation("org.mindrot:jbcrypt:0.4") +} \ No newline at end of file diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml index 5936808..576e266 100644 --- a/Android/app/src/main/AndroidManifest.xml +++ b/Android/app/src/main/AndroidManifest.xml @@ -2,27 +2,33 @@ - - - + + + \ No newline at end of file diff --git a/Android/app/src/main/java/com/example/mathseduc/MainActivity.kt b/Android/app/src/main/java/com/example/mathseduc/MainActivity.kt index 1645d32..b86de44 100644 --- a/Android/app/src/main/java/com/example/mathseduc/MainActivity.kt +++ b/Android/app/src/main/java/com/example/mathseduc/MainActivity.kt @@ -1,46 +1,115 @@ package com.example.mathseduc -import android.content.Intent import android.os.Bundle -import android.widget.Button -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity - -class MainActivity : AppCompatActivity() { - companion object { - var idPlayerConnected: Int = -1 - } +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.example.mathseduc.ui.theme.Colors +import com.example.mathseduc.ui.theme.MathsEducTheme +class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + setContent { + MathsEducTheme { + MainActivityContent() + } + } + } +} + + +@Composable +fun MainActivityContent() { + val modifier = Modifier + .fillMaxSize() + .padding(16.dp) + + Column( + modifier = modifier, + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(id = R.drawable.logo), + contentDescription = null, + modifier = Modifier + .size(160.dp, 130.dp) + .clip(RoundedCornerShape(8.dp)) + ) - val btnSolo = findViewById