From 66b6842516d49bdc352a1ce620c3413560219179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexe=C3=AF=20KADIR?= Date: Sat, 30 Mar 2024 14:29:09 +0100 Subject: [PATCH] Initial commit. Added main activity. --- .gitignore | 10 + app/.gitignore | 1 + app/build.gradle.kts | 39 ++++ app/proguard-rules.pro | 21 ++ app/src/main/AndroidManifest.xml | 32 +++ .../java/fr/iutfbleau/sae/MainActivity.java | 40 ++++ .../java/fr/iutfbleau/sae/MainController.java | 63 ++++++ .../drawable-v24/ic_launcher_foreground.xml | 30 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ app/src/main/res/layout/activity_main.xml | 66 +++++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 6 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 6 + app/src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes app/src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes app/src/main/res/values-night/colors.xml | 6 + app/src/main/res/values-night/themes.xml | 7 + app/src/main/res/values/colors.xml | 12 ++ app/src/main/res/values/strings.xml | 30 +++ app/src/main/res/values/themes.xml | 9 + app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ app/src/main/res/xml/preferences.xml | 23 +++ build.gradle.kts | 4 + gradle.properties | 21 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 185 ++++++++++++++++++ gradlew.bat | 89 +++++++++ settings.gradle.kts | 17 ++ 37 files changed, 925 insertions(+) create mode 100644 .gitignore create mode 100644 app/.gitignore create mode 100644 app/build.gradle.kts create mode 100644 app/proguard-rules.pro create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/fr/iutfbleau/sae/MainActivity.java create mode 100644 app/src/main/java/fr/iutfbleau/sae/MainController.java create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 app/src/main/res/values-night/colors.xml create mode 100644 app/src/main/res/values-night/themes.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/themes.xml create mode 100644 app/src/main/res/xml/backup_rules.xml create mode 100644 app/src/main/res/xml/data_extraction_rules.xml create mode 100644 app/src/main/res/xml/preferences.xml create mode 100644 build.gradle.kts create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle.kts 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 @@ + + + + + +