commit 66b6842516d49bdc352a1ce620c3413560219179 Author: Alexeï KADIR Date: Sat Mar 30 14:29:09 2024 +0100 Initial commit. Added main activity. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10cfdbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +/.idea +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties 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..297e0ab --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "fr.iutfbleau.sae" + compileSdk = 34 + + defaultConfig { + applicationId = "fr.iutfbleau.sae" + minSdk = 19 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.11.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") +} \ 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/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ff33cc2 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/fr/iutfbleau/sae/MainActivity.java b/app/src/main/java/fr/iutfbleau/sae/MainActivity.java new file mode 100644 index 0000000..c89f7af --- /dev/null +++ b/app/src/main/java/fr/iutfbleau/sae/MainActivity.java @@ -0,0 +1,40 @@ +package fr.iutfbleau.sae; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.widget.Button; + + +public class MainActivity extends AppCompatActivity { + + private Button play; + + + private Button settings; + + + private Button exit; + + + private MainController mainController; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.setContentView(R.layout.activity_main); + + this.play = (Button) this.findViewById(R.id.play); + this.settings = (Button) this.findViewById(R.id.settings); + this.exit = (Button) this.findViewById(R.id.exit); + + this.mainController = new MainController(this); + + this.play.setOnClickListener(this.mainController); + this.settings.setOnClickListener(this.mainController); + this.exit.setOnClickListener(this.mainController); + } +} \ No newline at end of file diff --git a/app/src/main/java/fr/iutfbleau/sae/MainController.java b/app/src/main/java/fr/iutfbleau/sae/MainController.java new file mode 100644 index 0000000..cb5f20d --- /dev/null +++ b/app/src/main/java/fr/iutfbleau/sae/MainController.java @@ -0,0 +1,63 @@ +package fr.iutfbleau.sae; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.view.View; + +import java.util.prefs.Preferences; + + +public class MainController implements View.OnClickListener { + + private static final String SIZE_PREFERENCE_KEY = "size_preference"; + + + private static final String HARD_MODE_PREFERENCE_KEY = "hard_mode_preference"; + + + private final Activity activity; + + + public MainController(Activity activity) { + this.activity = activity; + } + + + public void play() { + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.activity); + + int size = Integer.parseInt(preferences.getString(SIZE_PREFERENCE_KEY, Integer.toString(GameActivity.DEFAULT_SIZE))); + boolean hardMode = preferences.getBoolean(HARD_MODE_PREFERENCE_KEY, GameActivity.DEFAULT_HARD_MODE); + + Intent intent = new Intent(this.activity, GameActivity.class); + + intent.putExtra(GameActivity.SIZE_KEY, size); + intent.putExtra(GameActivity.HARD_MODE_KEY, hardMode); + + this.activity.startActivity(intent); + } + + + public void openSettings() { + this.activity.startActivity(new Intent(this.activity, SettingsActivity.class)); + } + + + public void exit() { + this.activity.finish(); + } + + + @Override + public void onClick(View view) { + int id = view.getId(); + + if (id == R.id.play) this.play(); + else if (id == R.id.settings) this.openSettings(); + else if (id == R.id.exit) this.exit(); + else throw new IllegalStateException("Unhandled click event source."); + } +} 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_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..6ab752a --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,66 @@ + + + + + +