Modifs page parametre + debut recup si pion vide
This commit is contained in:
parent
e87e252360
commit
df84ff5644
@ -11,6 +11,7 @@ public class MainActivity extends Activity {
|
|||||||
private Button mORDI;
|
private Button mORDI;
|
||||||
private Button mSettings;
|
private Button mSettings;
|
||||||
private Button mRules;
|
private Button mRules;
|
||||||
|
private boolean pionV;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -25,6 +26,9 @@ public class MainActivity extends Activity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent HotSeat = new Intent(MainActivity.this, GameActivity.class);
|
Intent HotSeat = new Intent(MainActivity.this, GameActivity.class);
|
||||||
HotSeat.putExtra("bot", false);
|
HotSeat.putExtra("bot", false);
|
||||||
|
if(pionV) {
|
||||||
|
HotSeat.putExtra("pionVide", true);
|
||||||
|
}
|
||||||
startActivity(HotSeat);
|
startActivity(HotSeat);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -33,6 +37,9 @@ public class MainActivity extends Activity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent ordi = new Intent(MainActivity.this, GameActivity.class);
|
Intent ordi = new Intent(MainActivity.this, GameActivity.class);
|
||||||
ordi.putExtra("bot", true);
|
ordi.putExtra("bot", true);
|
||||||
|
if(pionV) {
|
||||||
|
ordi.putExtra("pionVide", true);
|
||||||
|
}
|
||||||
startActivity(ordi);
|
startActivity(ordi);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -40,7 +47,7 @@ public class MainActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent settings = new Intent(MainActivity.this, SettingsActivity.class);
|
Intent settings = new Intent(MainActivity.this, SettingsActivity.class);
|
||||||
startActivity(settings);
|
startActivityForResult(settings, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mRules.setOnClickListener(new View.OnClickListener() {
|
mRules.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -51,4 +58,13 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
|
if(requestCode == 1) {
|
||||||
|
pionV = data.getBooleanExtra("pionV", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,33 +1,44 @@
|
|||||||
package com.example.mastermind;
|
package com.example.mastermind;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.Switch;
|
||||||
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
public class SettingsActivity extends Activity {
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
private Button mButton;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
private Switch mSwitch;
|
||||||
|
private boolean pionV;
|
||||||
public class SettingsActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings_activity);
|
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 {
|
mButton = findViewById(R.id.backButton);
|
||||||
|
mSwitch = findViewById(R.id.switchPion);
|
||||||
|
|
||||||
|
mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
setPreferencesFromResource(R.xml.root_preferences, rootKey);
|
if(isChecked) {
|
||||||
|
pionV = true;
|
||||||
|
} else {
|
||||||
|
pionV = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
mButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra("pionV", pionV);
|
||||||
|
setResult(1, intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,10 +1,46 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/cardview_dark_background">
|
android:background="@color/cardview_dark_background"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:ignore="UseSwitchCompatOrMaterialXml">
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
android:id="@+id/settings"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="match_parent" />
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:text="@string/header"
|
||||||
|
android:textColor="#eee"
|
||||||
|
android:textSize="40dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/backButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="60dp"
|
||||||
|
android:background="#aaa"
|
||||||
|
android:padding="7dp"
|
||||||
|
android:text="@string/back_menu"/>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchPion"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:text="@string/pions_title"
|
||||||
|
android:textColor="#eee"
|
||||||
|
android:textSize="20dp"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="40dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="40dp"
|
||||||
|
android:text="@string/summary"
|
||||||
|
android:textColor="#eee"
|
||||||
|
android:textSize="15dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -7,6 +7,7 @@
|
|||||||
<string name="header">Paramètres</string>
|
<string name="header">Paramètres</string>
|
||||||
|
|
||||||
<!-- Sync Preferences -->
|
<!-- Sync Preferences -->
|
||||||
|
<string name="back_menu">< Retour au menu</string>
|
||||||
<string name="pions_title">Autoriser les pions vides</string>
|
<string name="pions_title">Autoriser les pions vides</string>
|
||||||
<string name="summary">Cette fonctionnalité augmente la difficulté du jeu pour l\'attaquant</string>
|
<string name="summary">Cette fonctionnalité augmente la difficulté du jeu pour l\'attaquant</string>
|
||||||
|
|
||||||
|
14
app/src/main/res/xml/preferences.xml
Normal file
14
app/src/main/res/xml/preferences.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<PreferenceCategory app:title="@string/header">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:key="switchPion"
|
||||||
|
app:title="@string/pions_title"
|
||||||
|
app:summaryOff="@string/summary"
|
||||||
|
app:summaryOn="@string/summary" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user