Skip to content

Commit

Permalink
Add základ blind mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Saljack committed Nov 18, 2012
1 parent a698513 commit 457709a
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 1 deletion.
2 changes: 2 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
android:label="@string/ma_settings"/>
<activity android:name=".activity.MapSelectCoordinates"
android:label="@string/ma_coordinate"/>
<activity android:name=".activity.BlindMode"
android:label="@string/ma_blind"/>
</application>
</manifest>
19 changes: 19 additions & 0 deletions res/layout/blind_mode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include layout="@layout/statistic"
android:id="@+id/included_statistic"
/>
<!-- <com.google.android.maps.MapView
android:id="@+id/nm_map"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/included_statistic"
android:enabled="true"
android:clickable="true"
android:apiKey="0FWL-kvtGWbNHGzJfBDEDEGUfv-3YSFzDjNXJAw"
/>-->

</RelativeLayout>
7 changes: 7 additions & 0 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
android:layout_height="wrap_content"
android:text="@string/ma_maps"
/>

<Button
android:id="@+id/ma_buttonBlind"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ma_blind"
/>
<Button
android:id="@+id/ma_button02"
android:layout_width="fill_parent"
Expand Down
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="ma_friends">Přátelé</string>
<string name="ma_settings">Nastavení</string>
<string name="ma_coordinate">Souřadnice</string>
<string name="ma_blind">Blind mode</string>

<!-- SettingsActivity -->
<string name="sa_first_option">První volba</string>
Expand Down
15 changes: 14 additions & 1 deletion src/cz/cvut/fel/nur/zavody/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import android.view.View;
import android.widget.Button;
import com.google.android.maps.GeoPoint;
import cz.cvut.fel.nur.zavody.activity.NormalMode;
import cz.cvut.fel.nur.zavody.activity.BlindMode;
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.Settings;

/**
Expand All @@ -24,6 +25,7 @@ public class MainActivity extends Activity {
private Button _friendsButton;
private Button _settingsButton;
private Button _mapSelectCoordinates;
private Button _blindMode;

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

private void startMapsActivity() {
Expand Down Expand Up @@ -112,4 +120,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
}

private void startBlindModeActivity() {
Intent intent = new Intent(MainActivity.this, BlindMode.class);
startActivity(intent);
}
}
85 changes: 85 additions & 0 deletions src/cz/cvut/fel/nur/zavody/activity/BlindMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.nur.zavody.activity;


import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import cz.cvut.fel.nur.zavody.R;
import cz.cvut.fel.nur.zavody.maps.Mode;
import cz.cvut.fel.nur.zavody.utils.RaceTool;
import java.util.Timer;

/**
*
* @author saljack
*/
public class BlindMode extends Activity implements Mode{
private TextView _speed;
private TextView _time;
private TextView _remain;
private TextView _elapsed;
private LocationManager _locationManager;
private Timer _timer;
private LocationListener _locationListener;

/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.blind_mode);

//loading statistic
View included = findViewById(R.id.included_statistic);
_speed = (TextView) included.findViewById(R.id.statistic_speed);
_time = (TextView) included.findViewById(R.id.statistic_time);
_remain = (TextView) included.findViewById(R.id.statistic_remain);
_elapsed = (TextView) included.findViewById(R.id.statistic_elapsed);


_locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

_locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
float speed = location.getSpeed();
_speed.setText((int) (speed * 3.6) + "km/h");
}

public void onStatusChanged(String provider, int status, Bundle extras) {
}

public void onProviderEnabled(String provider) {
}

public void onProviderDisabled(String provider) {
}
};
// locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); //throw error on emulator
_locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, _locationListener);
_timer = new Timer();
}

public void touchEnd() {
Toast.makeText(this, "You win!", Toast.LENGTH_LONG).show();
_timer.cancel();
}

public void remainsToFinish(float remains) {
_remain.setText(RaceTool.getLengthWithMetric(remains));
}

public void elapsedTrack(float elapsed) {
_elapsed.setText(RaceTool.getLengthWithMetric(elapsed));
}
}

0 comments on commit 457709a

Please sign in to comment.