Added documentation.
This commit is contained in:
parent
66b6842516
commit
63c865e82a
@ -7,21 +7,38 @@ import android.os.Bundle;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code MainActivity} is the activity that displays the main menu.
|
||||||
|
*
|
||||||
|
* @autor Alexeï Kadir, Lyanis Souidi, Hugo Dimitrijevic
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
/**
|
||||||
|
* The {@code Button} that starts the game when clicked.
|
||||||
|
*/
|
||||||
private Button play;
|
private Button play;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code Button} that opens the settings when clicked.
|
||||||
|
*/
|
||||||
private Button settings;
|
private Button settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code Button} that exits the application when clicked.
|
||||||
|
*/
|
||||||
private Button exit;
|
private Button exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code MainController} that controls the main menu.
|
||||||
|
*/
|
||||||
private MainController mainController;
|
private MainController mainController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the main menu.
|
||||||
|
*
|
||||||
|
* @param savedInstanceState The saved instance state.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -9,23 +9,41 @@ import android.view.View;
|
|||||||
|
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code MainController} is a class that controls the main menu by recieving
|
||||||
|
* events from the {@code MainActivity}.
|
||||||
|
*
|
||||||
|
* @autor Alexeï Kadir, Lyanis Souidi, Hugo Dimitrijevic
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
public class MainController implements View.OnClickListener {
|
public class MainController implements View.OnClickListener {
|
||||||
|
/**
|
||||||
|
* The key of the preference that stores the size of the cross.
|
||||||
|
*/
|
||||||
private static final String SIZE_PREFERENCE_KEY = "size_preference";
|
private static final String SIZE_PREFERENCE_KEY = "size_preference";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key of the preference that stores whether the game is in hard mode.
|
||||||
|
*/
|
||||||
private static final String HARD_MODE_PREFERENCE_KEY = "hard_mode_preference";
|
private static final String HARD_MODE_PREFERENCE_KEY = "hard_mode_preference";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code Activity} that contains the main menu.
|
||||||
|
*/
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the main menu controller.
|
||||||
|
*
|
||||||
|
* @param activity The {@code Activity} that contains the main menu.
|
||||||
|
*/
|
||||||
public MainController(Activity activity) {
|
public MainController(Activity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a new game with the settings from the preferences.
|
||||||
|
*/
|
||||||
public void play() {
|
public void play() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.activity);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.activity);
|
||||||
|
|
||||||
@ -40,17 +58,25 @@ public class MainController implements View.OnClickListener {
|
|||||||
this.activity.startActivity(intent);
|
this.activity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the settings.
|
||||||
|
*/
|
||||||
public void openSettings() {
|
public void openSettings() {
|
||||||
this.activity.startActivity(new Intent(this.activity, SettingsActivity.class));
|
this.activity.startActivity(new Intent(this.activity, SettingsActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits the application.
|
||||||
|
*/
|
||||||
public void exit() {
|
public void exit() {
|
||||||
this.activity.finish();
|
this.activity.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a click event from the main menu.
|
||||||
|
*
|
||||||
|
* @param view The {@code View} that was clicked.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
int id = view.getId();
|
int id = view.getId();
|
||||||
|
Loading…
Reference in New Issue
Block a user