init in compose
continuous-integration/drone/push Build is passing Details

androidCompose
Yvan CALATAYUD 1 year ago
parent 8e11a953d4
commit 5353378b06

@ -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")
}

@ -2,27 +2,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.MathsEduc" android:theme="@style/Theme.MathsEduc"
tools:targetApi="31"> tools:targetApi="31">
<activity android:name=".MainActivity" android:exported="true"> <activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.MathsEduc">
<intent-filter> <intent-filter>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
</intent-filter> </intent-filter>
</activity> </activity>
<!--
<activity android:name=".MultiActivity" /> <activity android:name=".MultiActivity" />
<activity android:name=".ServerDetailsActivity" /> <activity android:name=".ServerDetailsActivity" />
<activity android:name=".CreateLobbyActivity" /> <activity android:name=".CreateLobbyActivity" />
<activity android:name=".ConnexionPlayerActivity" /> <activity android:name=".ConnexionPlayerActivity" />
<activity android:name=".QuizMultiActivity" /> <activity android:name=".QuizMultiActivity" />
-->
</application> </application>
</manifest> </manifest>

@ -1,46 +1,115 @@
package com.example.mathseduc package com.example.mathseduc
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Button import androidx.activity.ComponentActivity
import android.widget.Toast import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
class MainActivity : AppCompatActivity() { import androidx.compose.foundation.layout.fillMaxSize
companion object { import androidx.compose.foundation.layout.fillMaxWidth
var idPlayerConnected: Int = -1 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?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContent {
MathsEducTheme {
MainActivityContent()
}
}
}
}
@Composable
fun MainActivityContent() {
val modifier = Modifier
.fillMaxSize()
.padding(16.dp)
val btnSolo = findViewById<Button>(R.id.btnSolo) Column(
val btnMulti = findViewById<Button>(R.id.btnMulti) modifier = modifier,
val btnConnexion = findViewById<Button>(R.id.btnConnexion) 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))
)
btnSolo.setOnClickListener { Spacer(modifier = Modifier.height(16.dp))
// Traitement pour le bouton Solo
// Vous pouvez ajouter le code correspondant ici Button(
val intent = Intent(this, QuizMultiActivity::class.java) onClick = { /* Handle solo button click */ },
startActivity(intent) shape = RoundedCornerShape(15),
colors = ButtonDefaults.buttonColors(Colors.Green),
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
) {
Text(
text = "Solo",
color = Color.White,
fontWeight = FontWeight.Bold
)
} }
btnMulti.setOnClickListener { Spacer(modifier = Modifier.height(16.dp))
if (MainActivity.idPlayerConnected != -1){
val intent = Intent(this, MultiActivity::class.java) Button(
startActivity(intent) onClick = { /* Handle multi button click */ },
shape = RoundedCornerShape(15),
colors = ButtonDefaults.buttonColors(Colors.Orange),
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
) {
Text(
text = "Multiplayer",
color = Color.White,
fontWeight = FontWeight.Bold
)
} }
else {
Toast.makeText(this, "Vous n'êtes pas connecté", Toast.LENGTH_SHORT).show() Spacer(modifier = Modifier.height(16.dp))
val intent = Intent(this, ConnexionPlayerActivity::class.java)
startActivity(intent) Button(
onClick = { /* Handle connexion button click */ },
shape = RoundedCornerShape(15),
colors = ButtonDefaults.buttonColors(Colors.Grey),
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
.padding(horizontal = 16.dp)
) {
Text(
text = "Connexion",
color = Color.White
)
} }
} }
btnConnexion.setOnClickListener {
val intent = Intent(this, ConnexionPlayerActivity::class.java)
startActivity(intent)
} }
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
MathsEducTheme {
MainActivityContent()
} }
} }

@ -0,0 +1,29 @@
package com.example.mathseduc.ui.theme
import androidx.compose.ui.graphics.Color
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
object Colors {
val Purple200 = Color(0xFFBB86FC)
val Purple500 = Color(0xFF6200EE)
val Purple700 = Color(0xFF3700B3)
val Teal200 = Color(0xFF03DAC5)
val Teal700 = Color(0xFF018786)
val Black = Color(0xFF000000)
val White = Color(0xFFFFFFFF)
val Green = Color(0xFF008000)
val Orange = Color(0xFFFFA500)
val Grey = Color(0xFF8C92AC)
val Blue = Color(0xFF0D6EFD)
val Red = Color(0xFFFF0000)
val BlackGrey = Color(0xFF5C636A)
val Cyan = Color(0xFF00FFFF)
val Turquoise = Color(0xFF40E0D0)
}

@ -0,0 +1,79 @@
package com.example.mathseduc.ui.theme
import android.app.Activity
import android.os.Build
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.core.view.WindowCompat
import com.example.mathseduc.R
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
@Composable
fun MathsEducTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}

@ -0,0 +1,34 @@
package com.example.mathseduc.ui.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)

@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" /> <background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon> </adaptive-icon>

@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" /> <background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" /> <foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon> </adaptive-icon>

@ -7,12 +7,4 @@
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="green">#008000</color>
<color name="orange">#FFA500</color>
<color name="grey">#8C92AC</color>
<color name="blue">#0d6efd</color>
<color name="red">#FF0000</color>
<color name="blackgrey">#5c636a</color>
<color name="cyan">#00FFFF</color>
<color name="turquoise">#40E0D0</color>
</resources> </resources>

@ -1,34 +1,3 @@
<resources> <resources>
<string name="app_name">MathsEduc</string> <string name="app_name">MathsEduc</string>
<string name="solo">Solo</string>
<string name="multiplayer">Multiplayer</string>
<string name="connexion">Connexion</string>
<string name="profile">Profile</string>
<string name="retour">Retour</string>
<string name="addLobby">Ajouter un lobby</string>
<string name="lobby">lobby</string>
<string name="nbPlayer">nombre de joueurs</string>
<string name="listLobbies">Liste des lobbies</string>
<string name="difficulty_prompt">Selectionne la difficulty</string>
<string name="chapter_prompt">Selectionne un chapter</string>
<string name="se_connecter">Se connecter</string>
<string name="mot_de_passe">Mot de passe</string>
<string name="s_inscrire">S\'inscrire</string>
<string name="nom_d_utilisateur">Nom d\'utilisateur</string>
<string name="creer_compte">Créer son compte</string>
<string name="fermer">Fermer</string>
<string name="enregistrer">Enregistrer</string>
<string name="fleche"></string>
<string-array name="difficulty_array">
<item>Facile</item>
<item>Moyen</item>
<item>Difficile</item>
</string-array>
<string-array name="chapter_array">
<item>Chapter 1</item>
<item>Chapter 2</item>
<item>Chapter 3</item>
</string-array>
</resources> </resources>

@ -1,19 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <?xml version="1.0" encoding="utf-8"?>
<!-- Base application theme. --> <resources>
<style name="Theme.MathsEduc" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. --> <style name="Theme.MathsEduc" parent="android:Theme.Material.Light.NoActionBar">
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:windowBackground">@drawable/background</item> <item name="android:windowBackground">@drawable/background</item>
<!--<item name="android:fontFamily">@font/math_educ_font</item> -->
<item name="android:homeAsUpIndicator"></item>
</style> </style>
</resources> </resources>

@ -0,0 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.2.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}

@ -1,6 +1,6 @@
#Tue Feb 27 10:25:39 CET 2024 #Wed Mar 06 13:56:05 CET 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

@ -15,3 +15,4 @@ dependencyResolutionManagement {
rootProject.name = "MathsEduc" rootProject.name = "MathsEduc"
include(":app") include(":app")
Loading…
Cancel
Save