Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Saljack committed Nov 22, 2012
1 parent 5b3b346 commit 9933d56
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 1 deletion.
2 changes: 2 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@
android:label="@string/ma_coordinate"/>
<activity android:name=".activity.BlindMode"
android:label="@string/ma_blind"/>
<activity android:name=".activity.Race"
android:label="@string/ma_new_race"/>
</application>
</manifest>
Binary file added res/drawable/ic_menu_mark.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/ma_button00"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ma_new_race"
/>
<Button
android:id="@+id/ma_button01"
android:layout_width="fill_parent"
Expand Down
42 changes: 42 additions & 0 deletions res/layout/race.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/race_button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/race_choose_oponnent"
/>
<Button
android:id="@+id/race_button02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/race_choose_destination"
/>
<Button
android:id="@+id/race_button03"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/race_choose_mode"
/>
<Button
android:id="@+id/race_button04"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/race_choose_bet"
/>
<Button
android:id="@+id/race_button05"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/race_start"
android:drawableLeft="@drawable/ic_menu_mark"
android:onClick="startRace"
android:enabled="false"
android:layout_marginTop="30sp"
/>

</LinearLayout>
10 changes: 9 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,27 @@
<string name="ma_settings">Nastavení</string>
<string name="ma_coordinate">Souřadnice</string>
<string name="ma_blind">Blind mode</string>
<string name="ma_new_race">Nový závod</string>

<!-- SettingsActivity -->
<string name="sa_first_option">První volba</string>
<string name="sa_second_option">Druhá volba</string>
<string name="sa_normal_mode">Běžný mód</string>
<string name="sa_blind_mode">Mód naslepo</string>


<!-- FriendsActivity -->
<string name="fa_add_friend">Přidat přítele</string>
<string name="fa_choose_friend">Zvolte ze seznamu</string>

<!-- MapSelectCoordinates -->
<string name="msc_wantSelect">Chcete vybrat</string>
<string name="msc_point">Chcete vybrat tento bod:</string>

<!-- RaceActivity -->
<string name="race_title">Nový závod</string>
<string name="race_choose_oponnent">Vybrat soupeře</string>
<string name="race_choose_destination">Vybrat cíl závodu</string>
<string name="race_choose_mode">Vybrat mód závodu</string>
<string name="race_choose_bet">Nastavit sázku</string>
<string name="race_start">Odstartovat</string>
</resources>
13 changes: 13 additions & 0 deletions src/cz/cvut/fel/nur/zavody/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cz.cvut.fel.nur.zavody.activity.Friends;
import cz.cvut.fel.nur.zavody.activity.MapSelectCoordinates;
import cz.cvut.fel.nur.zavody.activity.NormalMode;
import cz.cvut.fel.nur.zavody.activity.Race;
import cz.cvut.fel.nur.zavody.activity.Settings;

/**
Expand All @@ -26,6 +27,7 @@ public class MainActivity extends Activity {
private Button _settingsButton;
private Button _mapSelectCoordinates;
private Button _blindMode;
private Button _newRaceButton;

/**
* Called when the activity is first created.
Expand Down Expand Up @@ -67,6 +69,12 @@ public void onClick(View v) {
MainActivity.this.startBlindModeActivity();
}
});
_newRaceButton = (Button) findViewById(R.id.ma_button00);
_newRaceButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startNewRaceActivity();
}
});
}

private void startMapsActivity() {
Expand All @@ -91,6 +99,11 @@ private void startSettingsActivity() {
Intent intent = new Intent(MainActivity.this, Settings.class);
startActivity(intent);
}

private void startNewRaceActivity() {
Intent intent = new Intent(MainActivity.this, Race.class);
startActivity(intent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand Down
192 changes: 192 additions & 0 deletions src/cz/cvut/fel/nur/zavody/activity/Race.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
package cz.cvut.fel.nur.zavody.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import cz.cvut.fel.nur.zavody.R;

/**
*
* @author p4nther
*/
public class Race extends Activity {

final Context context = this;

private Button _oponnentsButton;
private Button _destinationButton;
private Button _modeButton;
private Button _betButton;
private Button _startButton;

private String oponnent = null;
private String mode = null;
private String coordinates = null;
private int bet = 0;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.race);

_oponnentsButton = (Button) findViewById(R.id.race_button01);
_oponnentsButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Race.this.startOponnentsActivity();
}
});

_destinationButton = (Button) findViewById(R.id.race_button02);
_destinationButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Race.this.startDestinationActivity();
}
});

_modeButton = (Button) findViewById(R.id.race_button03);
_modeButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Race.this.startModeActivity();
}
});

_betButton = (Button) findViewById(R.id.race_button04);
_betButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Race.this.startBetActivity();
}
});

_startButton = (Button) findViewById(R.id.race_button05);
_startButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Race.this.startStartRaceActivity();
}
});
}

private void startOponnentsActivity() {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

alertDialogBuilder.setTitle("S kým chcete závodit?");

final String[] friends = new String[5];
friends[0] = "Jan Novák";
friends[1] = "Tomáš Vomáčka";
friends[2] = "Kateřina Ruská";
friends[3] = "Pavel Hašek";
friends[4] = "Veronika Levá";

alertDialogBuilder
.setCancelable(false)
.setItems(friends, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(Race.this,
"Soupeř: " + friends[which], Toast.LENGTH_LONG)
.show();
Race.this.oponnent = friends[which];
dialog.dismiss();
Race.this.checkRaceConditions();
}
})
.setNegativeButton("Zrušit",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});

AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}

private void startDestinationActivity() {
// Intent intent = new Intent(this, MapSelectCoordinates.class);
// startActivityForResult(intent, 1);
coordinates = "123 456 789";
}

private void startModeActivity() {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

alertDialogBuilder.setTitle("Vyberte mód závodu");

final String[] raceModes = new String[2];
raceModes[0] = "normální";
raceModes[1] = "blind";

alertDialogBuilder
.setCancelable(false)
.setItems(raceModes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(Race.this,
"Vybrán mód: " + raceModes[which], Toast.LENGTH_LONG)
.show();
Race.this.mode = raceModes[which];
dialog.dismiss();
Race.this.checkRaceConditions();
}
})
.setNegativeButton("Zrušit",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});

AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}

private void startBetActivity() {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

alertDialogBuilder.setTitle("Nastavte výši sázky");

final String[] bets = new String[100];
int cBet;
for (int i = 0; i < 100; i++) {
cBet = i+1;
bets[i] = "" + cBet;
}

alertDialogBuilder
.setCancelable(false)
.setItems(bets, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(Race.this,
"Výše sázky: " + bets[which], Toast.LENGTH_LONG)
.show();
Race.this.bet = Integer.parseInt(bets[which]);
dialog.dismiss();
Race.this.checkRaceConditions();
}
})
.setNegativeButton("Zrušit",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});

AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}

private void startStartRaceActivity() {

}

private void checkRaceConditions() {
if (oponnent != null && coordinates != null && mode != null && bet > 0) {
_startButton.setEnabled(true);
_startButton.setBackgroundColor(0xff008500);
}
}
}

0 comments on commit 9933d56

Please sign in to comment.