Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game Menu/Game Activities #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion src/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions src/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.utd_se3354_minutemath.minutemath">
package="com.github.utd_se3354_minutemath.minutemath" >

<uses-sdk android:minSdkVersion="23"
android:targetSdkVersion="23"
android:maxSdkVersion="23" />
<uses-sdk
android:maxSdkVersion="23"
android:minSdkVersion="23"
android:targetSdkVersion="23" />

<!--<android:uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<android:uses-permission android:name="android.permission.READ_PHONE_STATE" />
<android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />-->

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
Expand All @@ -28,6 +33,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".GameSettingsActivity"
android:label="@string/title_activity_game_settings" >
</activity>
<activity
android:name=".GameActivity"
android:label="@string/title_activity_game" >
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.github.utd_se3354_minutemath.minutemath;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class GameActivity extends AppCompatActivity {
//get the intent sent by GameSettingsActivity
Intent intent = getIntent();
int [] settings = intent.getIntArrayExtra(GameSettingsActivity.GAME_SETTINGS);

//Assign the game settings
int duration = settings[0];
int problems = settings[1];
int min_value = settings[2];
int max_value = settings[3];

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_game, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.github.utd_se3354_minutemath.minutemath;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.NumberPicker;

public class GameSettingsActivity extends AppCompatActivity {
public static final String GAME_SETTINGS = "com.github.utd_se3354_minutemath.minutemath.SETTINGS";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_settings);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_game_settings, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}

//function to send an intent with the game settings
public void startGame(View view) {
Intent intent = new Intent(this, GameActivity.class);
int duration = ((NumberPicker) findViewById(R.id.duration)).getValue();
int problems = ((NumberPicker) findViewById(R.id.number_of_problems)).getValue();
int min = ((NumberPicker) findViewById(R.id.range_min)).getValue();
int max = ((NumberPicker) findViewById(R.id.range_max)).getValue();
int [] settings = {duration, problems, min, max};
intent.putExtra(GAME_SETTINGS, settings);
startActivity(intent);
}
}
12 changes: 12 additions & 0 deletions src/app/src/main/res/layout/activity_game.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.github.utd_se3354_minutemath.minutemath.GameActivity">

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</RelativeLayout>
72 changes: 72 additions & 0 deletions src/app/src/main/res/layout/activity_game_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/settings_game">
<TextView
android:layout_height="40sp"
android:layout_width="wrap_content"
android:textSize="30sp"
android:text="@string/game_duration"
android:id="@+id/game_duration"/>
<NumberPicker
android:layout_alignBottom="@id/game_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/problems"
android:id="@+id/duration">
</NumberPicker>
<TextView
android:layout_width="wrap_content"
android:layout_height="40sp"
android:textSize="30sp"
android:text="@string/problems"
android:layout_below="@id/game_duration"
android:id="@+id/problems"/>
<NumberPicker
android:layout_alignBottom="@id/problems"
android:layout_alignTop="@id/problems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/problems"
android:id="@+id/number_of_problems">
</NumberPicker>
<TextView
android:layout_width="wrap_content"
android:layout_height="40sp"
android:textSize="30sp"
android:text="@string/minimum"
android:layout_below="@id/problems"
android:id="@+id/minimum"/>
<NumberPicker
android:layout_alignBottom="@id/minimum"
android:layout_alignTop="@id/minimum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/problems"
android:id="@+id/range_min" >
</NumberPicker>
<TextView
android:layout_width="wrap_content"
android:layout_height="40sp"
android:textSize="30sp"
android:text="@string/maximum"
android:layout_below="@id/minimum"
android:id="@+id/maximum" />
<NumberPicker
android:layout_alignBottom="@id/maximum"
android:layout_alignTop="@id/maximum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/problems"
android:id="@+id/range_max" >
</NumberPicker>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/start_game"
android:onClick="startGame"/>
</RelativeLayout>
7 changes: 7 additions & 0 deletions src/app/src/main/res/menu/menu_game.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.github.utd_se3354_minutemath.minutemath.GameActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>
7 changes: 7 additions & 0 deletions src/app/src/main/res/menu/menu_game_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.github.utd_se3354_minutemath.minutemath.GameSettingsActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
</menu>
12 changes: 12 additions & 0 deletions src/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<resources>
<string name="app_name">MinuteMath</string>


<string name="game_duration">Game Duration: </string>
<string name="problems">Number of Problems: </string>
<string name="minimum">Minimum Number: </string>
<string name="maximum">Maximum Number: </string>
<string name="start_game">Start</string>
<string name="title_activity_game_settings">Game Settings</string>

<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="title_activity_game">Game</string>
</resources>