From 2dc7b838c62d6538b42d3fc7fc209cc2f9c228de Mon Sep 17 00:00:00 2001 From: Claire G Date: Mon, 3 Apr 2023 15:39:44 +0200 Subject: [PATCH] Ajout page parametre --- app/src/main/AndroidManifest.xml | 19 +++++++++-- .../com/example/mastermind/MainActivity.java | 6 ++-- .../example/mastermind/SettingsActivity.java | 33 +++++++++++++++++++ app/src/main/res/values/strings.xml | 8 +++++ 4 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/example/mastermind/SettingsActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9204475..a4562b7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + package="com.example.mastermind" > + tools:targetApi="31" > + + + + android:exported="true" > + + diff --git a/app/src/main/java/com/example/mastermind/MainActivity.java b/app/src/main/java/com/example/mastermind/MainActivity.java index 8685123..920b257 100644 --- a/app/src/main/java/com/example/mastermind/MainActivity.java +++ b/app/src/main/java/com/example/mastermind/MainActivity.java @@ -34,13 +34,13 @@ public class MainActivity extends Activity { startActivity(tp2Intent); } });*/ - /*mSettings.setOnClickListener(new View.OnClickListener() { + mSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent tp3Intent = new Intent(MainActivity.this, Settings.class); + Intent tp3Intent = new Intent(MainActivity.this, SettingsActivity.class); startActivity(tp3Intent); } - });*/ + }); /*mTP4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/example/mastermind/SettingsActivity.java b/app/src/main/java/com/example/mastermind/SettingsActivity.java new file mode 100644 index 0000000..d14d52e --- /dev/null +++ b/app/src/main/java/com/example/mastermind/SettingsActivity.java @@ -0,0 +1,33 @@ +package com.example.mastermind; + +import android.os.Bundle; + +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.preference.PreferenceFragmentCompat; + +public class SettingsActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.settings_activity); + if (savedInstanceState == null) { + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.settings, new SettingsFragment()) + .commit(); + } + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + } + } + + public static class SettingsFragment extends PreferenceFragmentCompat { + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { + setPreferencesFromResource(R.xml.root_preferences, rootKey); + } + } +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7fa6bf8..c80fd6d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,11 @@ MasterMind + SettingsActivity + + + Paramètres + + + Autoriser les pions vides + Cette fonctionnalité augmente la difficultédu jeu pour l\'attaquant \ No newline at end of file