commit bb894c2ca127675581e0620b9fc37cadadb0cbda Author: martins Date: Sun Mar 19 22:36:49 2023 +0100 debutMenu 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 b/app/build.gradle new file mode 100644 index 0000000..68cdd7c --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'com.example.mastermind' + compileSdk 33 + + defaultConfig { + applicationId "com.example.mastermind" + minSdk 19 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled 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' + } + buildToolsVersion '33' +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/mastermind/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/mastermind/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..8119dd2 --- /dev/null +++ b/app/src/androidTest/java/com/example/mastermind/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.mastermind + +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("com.example.mastermind", 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..3b848c9 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/mastermind/MasterMindActivity.java b/app/src/main/java/com/example/mastermind/MasterMindActivity.java new file mode 100644 index 0000000..7b045f4 --- /dev/null +++ b/app/src/main/java/com/example/mastermind/MasterMindActivity.java @@ -0,0 +1,19 @@ +package com.example.mastermind; + +import android.content.Intent; +import android.os.Bundle; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +public class MasterMindActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_master_mind); + Intent data=this.getIntent(); + System.out.println(data.getBooleanExtra("vide", false)); + System.out.println(data.getIntExtra("nbJoeur", 1)); + } +} diff --git a/app/src/main/java/com/example/mastermind/MenuActivity.java b/app/src/main/java/com/example/mastermind/MenuActivity.java new file mode 100644 index 0000000..db717cd --- /dev/null +++ b/app/src/main/java/com/example/mastermind/MenuActivity.java @@ -0,0 +1,23 @@ +package com.example.mastermind; + +import android.os.Bundle; +import android.widget.CheckBox; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.example.mastermind.controller.menu.ObservateurMenuDebutPartie; +import com.example.mastermind.util.UtilTypePartie; + +public class MenuActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_menu); + this.findViewById(R.id.unJoeur) + .setOnClickListener(new ObservateurMenuDebutPartie(this, UtilTypePartie.UN_JOEUR, (CheckBox) this.findViewById(R.id.vide))); + this.findViewById(R.id.deuxJoeur) + .setOnClickListener(new ObservateurMenuDebutPartie(this, UtilTypePartie.DEUX_JOEUR, (CheckBox) this.findViewById(R.id.vide))); + } +} diff --git a/app/src/main/java/com/example/mastermind/controller/menu/ObservateurMenuDebutPartie.java b/app/src/main/java/com/example/mastermind/controller/menu/ObservateurMenuDebutPartie.java new file mode 100644 index 0000000..87fe4d1 --- /dev/null +++ b/app/src/main/java/com/example/mastermind/controller/menu/ObservateurMenuDebutPartie.java @@ -0,0 +1,33 @@ +package com.example.mastermind.controller.menu; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.CheckBox; + +import androidx.appcompat.app.AppCompatActivity; +import com.example.mastermind.MasterMindActivity; + +public class ObservateurMenuDebutPartie implements View.OnClickListener { + + private AppCompatActivity menu; + + private int typePartie; + + private CheckBox vide; + + + public ObservateurMenuDebutPartie(AppCompatActivity menu, int type, CheckBox vide){ + this.menu=menu; + this.typePartie=type; + this.vide=vide; + } + + @Override + public void onClick(View view) { + Intent mastermind = new Intent(menu, MasterMindActivity.class); + mastermind.putExtra("nbJoeur", typePartie); + mastermind.putExtra("vide", vide.isActivated()); + menu.startActivity(mastermind); + } +} diff --git a/app/src/main/java/com/example/mastermind/util/UtilTypePartie.java b/app/src/main/java/com/example/mastermind/util/UtilTypePartie.java new file mode 100644 index 0000000..f0c6e67 --- /dev/null +++ b/app/src/main/java/com/example/mastermind/util/UtilTypePartie.java @@ -0,0 +1,6 @@ +package com.example.mastermind.util; + +public abstract class UtilTypePartie { + public static final int UN_JOEUR=1; + public static final int DEUX_JOEUR=2; +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ 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/layout/activity_master_mind.xml b/app/src/main/res/layout/activity_master_mind.xml new file mode 100644 index 0000000..ce385f9 --- /dev/null +++ b/app/src/main/res/layout/activity_master_mind.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_menu.xml b/app/src/main/res/layout/activity_menu.xml new file mode 100644 index 0000000..0c7a6d4 --- /dev/null +++ b/app/src/main/res/layout/activity_menu.xml @@ -0,0 +1,77 @@ + + + + + + + + +