Skip to content
This repository was archived by the owner on Mar 17, 2019. It is now read-only.
Binary file added Apps/Motion/res/drawable-hdpi-v11/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-hdpi-v9/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-hdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-mdpi-v11/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-mdpi-v9/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-mdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-xhdpi-v11/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-xhdpi-v9/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-xhdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-xxhdpi-v11/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Apps/Motion/res/drawable-xxhdpi/ic_stat_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
173 changes: 90 additions & 83 deletions Apps/Motion/src/edu/uml/cs/isense/motion/Motion.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Button;
import android.widget.TextView;

import java.text.DecimalFormat;
import java.util.Timer;
Expand Down Expand Up @@ -118,8 +119,6 @@ public class Motion extends ActionBarActivity {
ViewPager fields;
PagerAdapter fieldAdapter;

private MediaPlayer mMediaPlayer;
private Vibrator vibrator;


static boolean inPausedState = false;
Expand All @@ -135,6 +134,8 @@ public class Motion extends ActionBarActivity {

public static Menu menu;

private TextView tvName;

Intent service;

//Receives info from library to update ui
Expand All @@ -143,6 +144,7 @@ public class Motion extends ActionBarActivity {
/* Action Bar */
private static int actionBarTapCount = 0;


/* Make sure url is updated when useDev is set. */
void setUseDev(boolean useDev) {
api.useDev(useDev);
Expand Down Expand Up @@ -192,16 +194,11 @@ public void run() {

CredentialManager.login(mContext, api);

// Beep sound
mMediaPlayer = MediaPlayer.create(this, R.raw.beep);

// Vibrator for Long Click
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

startStop = (Button) findViewById(R.id.startStop);
uploadButton = (Button) findViewById(R.id.b_upload);
projNumB = (Button) findViewById(R.id.b_project);
nameB = (Button) findViewById(R.id.b_name);
tvName = (TextView) findViewById(R.id.tv_name);
rateB = (Button) findViewById(R.id.b_rate);
lengthB = (Button) findViewById(R.id.b_length);
leftChevronB = (Button) findViewById(R.id.leftChevron);
Expand Down Expand Up @@ -252,6 +249,68 @@ public void run() {

setRateText();
setLengthText();
tvName.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CountDownTimer cdt = null;

// Give user 10 seconds to switch dev/prod mode
if (actionBarTapCount == 0) {
cdt = new CountDownTimer(5000, 5000) {
@Override
public void onTick(long millisUntilFinished) {
}

@Override
public void onFinish() {
actionBarTapCount = 0;
}
}.start();
}

String mode = (useDev) ? "production" : "dev";

switch (++actionBarTapCount) {
case 5:
w.make(getResources().getString(R.string.two_more_taps) + mode
+ getResources().getString(R.string.mode_type));
break;
case 6:
w.make(getResources().getString(R.string.one_more_tap) + mode
+ getResources().getString(R.string.mode_type));
break;
case 7:
w.make(getResources().getString(R.string.now_in_mode) + mode
+ getResources().getString(R.string.mode_type));
useDev = !useDev;

if (cdt != null)
cdt.cancel();

if (api.getCurrentUser() != null) {
Runnable r = new Runnable() {
@Override
public void run() {
api.deleteSession();
api.useDev(useDev);
}
};
new Thread(r).start();
} else {
api.useDev(useDev);
}
CredentialManager.login(mContext, api);
actionBarTapCount = 0;


break;
}

}

});



/* update UI with data passed back from service */
receiver = new BroadcastReceiver() {
Expand Down Expand Up @@ -286,14 +345,6 @@ public void onReceive(Context context, Intent intent) {
@Override
public boolean onLongClick(View arg0) {

mMediaPlayer.setLooping(false);
mMediaPlayer.start();

// Vibrate and beep
vibrator.vibrate(300);
mMediaPlayer.setLooping(false);
mMediaPlayer.start();

if (RecordingService.running) {
startStop.setBackgroundResource(R.drawable.button_rsense);
startStop.setText("Hold to Start");
Expand Down Expand Up @@ -456,73 +507,29 @@ public boolean onPrepareOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.login:
startActivityForResult(new Intent(this, CredentialManager.class),
LOGIN_STATUS_REQUESTED);
return true;
case R.id.upload:
manageUploadQueue();
return true;
case R.id.reset:
startActivityForResult(new Intent(this, ResetToDefaults.class),
RESET_REQUESTED);
return true;
case R.id.presets:
startActivityForResult(new Intent(this, Presets.class),
PRESETS_REQUESTED);
return true;
case R.id.helpMenuItem:
startActivity(new Intent(this, Help.class));
return true;
case android.R.id.home:
CountDownTimer cdt = null;

// Give user 10 seconds to switch dev/prod mode
if (actionBarTapCount == 0) {
cdt = new CountDownTimer(5000, 5000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
actionBarTapCount = 0;
}
}.start();
}

String other = (useDev) ? "production" : "dev";

switch (++actionBarTapCount) {
case 5:
w.make(getResources().getString(R.string.two_more_taps) + other
+ getResources().getString(R.string.mode_type));
break;
case 6:
w.make(getResources().getString(R.string.one_more_tap) + other
+ getResources().getString(R.string.mode_type));
break;
case 7:
w.make(getResources().getString(R.string.now_in_mode) + other
+ getResources().getString(R.string.mode_type));
useDev = !useDev;

if (cdt != null)
cdt.cancel();

setUseDev(useDev);

actionBarTapCount = 0;
break;
}

return true;
}

return false;
}


switch (item.getItemId()) {
case R.id.login:
startActivityForResult(new Intent(this, CredentialManager.class),
LOGIN_STATUS_REQUESTED);
return true;
case R.id.upload:
manageUploadQueue();
return true;
case R.id.reset:
startActivityForResult(new Intent(this, ResetToDefaults.class),
RESET_REQUESTED);
return true;
case R.id.presets:
startActivityForResult(new Intent(this, Presets.class),
PRESETS_REQUESTED);
return true;
case R.id.helpMenuItem:
startActivity(new Intent(this, Help.class));
return true;
default:
return false;
}
}

public static int getApiLevel() {
return android.os.Build.VERSION.SDK_INT;
Expand Down
28 changes: 27 additions & 1 deletion Apps/Motion/src/edu/uml/cs/isense/motion/RecordingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.os.CountDownTimer;
import android.os.IBinder;
import android.os.Vibrator;
import android.support.v4.content.LocalBroadcastManager;

import org.json.JSONArray;
Expand Down Expand Up @@ -42,6 +46,10 @@ public class RecordingService extends Service {
float totalDistance = 0;
long startTime;

private MediaPlayer mMediaPlayer;
private Vibrator vibrator;


Intent intent;
Context serviceContext;

Expand All @@ -61,6 +69,12 @@ public void onCreate() {

serviceContext = this;

// Beep sound
mMediaPlayer = MediaPlayer.create(this, R.raw.beep);

// Vibrator for Long Click
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

//enables all sensors and gps based on the fields
dfm.registerSensors();

Expand All @@ -78,7 +92,9 @@ public void onCreate() {
builder.setContentTitle("iSENSE Motion");
builder.setContentText("Recording Data");
builder.setTicker("Started Recording");
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setSmallIcon(R.drawable.ic_stat_name);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
builder.setLargeIcon(bm);
builder.setContentIntent(pendingIntent);
builder.setOngoing(true);
builder.setPriority(0);
Expand Down Expand Up @@ -136,6 +152,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
int length; //length of dataset
int rate; //interval between datapoints

// Vibrate and beep
vibrator.vibrate(300);
mMediaPlayer.setLooping(false);
mMediaPlayer.start();

running = true;

SharedPreferences prefs = getSharedPreferences(Motion.MY_SAVED_PREFERENCES,
Expand Down Expand Up @@ -178,6 +199,11 @@ public void onDestroy() {
if (running) {
running = false;

// Vibrate and beep
vibrator.vibrate(300);
mMediaPlayer.setLooping(false);
mMediaPlayer.start();

//Stops timer from still counting down after recording has stopped
if (mTimer != null) {
mTimer.cancel();
Expand Down
3 changes: 2 additions & 1 deletion Apps/Motion/src/edu/uml/cs/isense/motion/dialogs/About.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import edu.uml.cs.isense.motion.R;

public class About extends Activity {
public class About extends ActionBarActivity {

private Button okButton;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import edu.uml.cs.isense.comm.API;
import edu.uml.cs.isense.motion.R;
import edu.uml.cs.isense.waffle.Waffle;

public class ContributorKeyDialog extends Activity {
public class ContributorKeyDialog extends ActionBarActivity {

Button ok, cancel;
EditText keyField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import edu.uml.cs.isense.comm.Connection;
import edu.uml.cs.isense.motion.R;

public class DataActivity extends Activity {
public class DataActivity extends ActionBarActivity {

private Button iSENSE_Button;
private Button discard_Button;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
Expand All @@ -13,7 +14,7 @@
import edu.uml.cs.isense.motion.Motion;
import edu.uml.cs.isense.motion.R;

public class DurationDialog extends Activity {
public class DurationDialog extends ActionBarActivity {

Button ok, cancel;
EditText input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import edu.uml.cs.isense.motion.R;

public class MessageDialogTemplate extends Activity {
public class MessageDialogTemplate extends ActionBarActivity {

Button pos, neg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;

import edu.uml.cs.isense.motion.R;

public class Presets extends Activity{
public class Presets extends ActionBarActivity {
public static final String PROJECT = "project";
public static final String LENGTH = "length";
public static final String RATE = "rate";
Expand Down
Loading