Refactor: Premier lancement et effets sonores
- Affichage de la boite de dialog 'Comment jouer ?' au premier lancement de l'application. - Modification des effets sonores.
This commit is contained in:
parent
037497bab9
commit
f1a17d8f0d
@ -102,8 +102,8 @@ L'objectif est de faire glisser les tuiles sur une grille pour combiner celles d
|
||||
|
||||
## Auteurs
|
||||
|
||||
Ce projet a été réalisé par l'équipe **La Legion de Muyue** :
|
||||
* Muyue (Leader)
|
||||
* Autres Membres
|
||||
1. Augustin ROUX
|
||||
2. Deryan Trebeau
|
||||
3. Jules BRICOU
|
||||
|
||||
Projet universitaire
|
||||
|
@ -14,7 +14,7 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Best2048"
|
||||
tools:targetApi="31">
|
||||
tools:targetApi="33">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
@ -74,6 +74,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
private static final String PERIODIC_NOTIFICATION_WORK_TAG = "periodic-notification-work";
|
||||
/** Intervalle de répétition (en heures) pour le worker de notification. */
|
||||
private static final long WORKER_REPEAT_INTERVAL_HOURS = 12;
|
||||
/** Clé SharedPreferences pour savoir si le dialogue "How to Play" a déjà été montré. */
|
||||
private static final String HOW_TO_PLAY_SHOWN_KEY = "how_to_play_shown";
|
||||
|
||||
// --- UI Elements ---
|
||||
/** Layout de grille pour le plateau de jeu. */
|
||||
@ -164,6 +166,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main); // Définit le layout de l'activité
|
||||
|
||||
preferences = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
|
||||
checkAndShowHowToPlayOnFirstLaunch();
|
||||
|
||||
findViews(); // Récupère les références des vues
|
||||
NotificationHelper.createNotificationChannel(this); // Crée le canal de notification (requis pour Android O+)
|
||||
initializeSoundPool(); // Initialise les effets sonores
|
||||
@ -183,6 +188,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si c'est le premier lancement de l'application.
|
||||
* Si oui, affiche le dialogue "How to Play" et marque que le dialogue a été vu.
|
||||
*/
|
||||
private void checkAndShowHowToPlayOnFirstLaunch() {
|
||||
boolean howToPlayShown = preferences.getBoolean(HOW_TO_PLAY_SHOWN_KEY, false);
|
||||
|
||||
if (!howToPlayShown) {
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean(HOW_TO_PLAY_SHOWN_KEY, true);
|
||||
editor.apply();
|
||||
|
||||
showHowToPlayDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode appelée lorsque l'activité revient au premier plan.
|
||||
* Réinitialise l'heure de début de la partie pour le suivi du temps de jeu de la session actuelle.
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -60,7 +60,7 @@
|
||||
<string name="how_to_play_title">How to Play</string>
|
||||
<string name="how_to_play_instructions">Swipe the screen (Up, Down, Left, Right) to move all the tiles.\n\nWhen two tiles with the same number touch, they merge into one!\n\nReach the 2048 tile to win.\n\nThe game is over if the board is full and no moves are possible.</string>
|
||||
<string name="about_title">About Best 2048</string>
|
||||
<string name="about_message">Version: 1.0 (University Project)\nDeveloped by: La Legion de Muyue\n(Leader: Muyue, Members: 2 others)\n\nBased on the popular game 2048.</string>
|
||||
<string name="about_message">Version: 1.0 (University Project)\nDeveloped by: La Legion de Muyue\n(Leader: Muyue, Members: 2 others best members)\n\nBased on the popular game 2048.</string>
|
||||
<string name="about_website_text">Website: legion-muyue.fr</string>
|
||||
<string name="about_website_url">https://legion-muyue.fr</string>
|
||||
<string name="ok">OK</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user