diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml index db00dfd..5c3e91c 100644 --- a/phoneClients/android/.idea/workspace.xml +++ b/phoneClients/android/.idea/workspace.xml @@ -41,7 +41,11 @@ + + + + @@ -96,8 +100,8 @@ @@ -105,47 +109,39 @@ - + - - + + - - - - - - - - - - - - - + + + + + + + + + + - - + + - - - + + + + + - - - - - - - - - + + @@ -922,19 +918,22 @@ @@ -979,7 +978,6 @@ - @@ -1056,16 +1054,73 @@ + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1085,9 +1140,14 @@ - + + + + + + @@ -1127,19 +1187,6 @@ - - - + + + - + + @@ -1304,20 +1365,19 @@ - - + + - - + + - @@ -1327,15 +1387,15 @@ - - - + + + - + @@ -1348,8 +1408,8 @@ - + @@ -1376,22 +1436,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + @@ -1409,19 +1536,16 @@ - - - - - - - - - - - - - + + + + + + + + + + @@ -1439,19 +1563,16 @@ - - - - - - - - - - - - - + + + + + + + + + + @@ -1469,19 +1590,16 @@ - - - - - - - - - - - - - + + + + + + + + + + @@ -1582,7 +1700,6 @@ - @@ -1600,17 +1717,6 @@ - - - - - - - - - - - @@ -1618,25 +1724,22 @@ - - - - - - + + + - - + + - + - - + + @@ -1649,28 +1752,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java index 2824179..b25d9b4 100644 --- a/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java +++ b/phoneClients/android/app/src/main/java/com/websmithing/gpstracker/GpsTrackerActivity.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.Color; import android.os.Bundle; import android.os.SystemClock; import android.support.v7.app.ActionBarActivity; @@ -33,7 +34,6 @@ private static EditText txtUserName; private static EditText txtWebsite; private static Button trackingButton; - private static Button saveButton; private boolean currentlyTracking; private RadioGroup intervalRadioGroup; @@ -53,7 +53,6 @@ txtWebsite = (EditText)findViewById(R.id.txtWebsite); txtUserName = (EditText)findViewById(R.id.txtUserName); trackingButton = (Button)findViewById(R.id.trackingButton); - saveButton = (Button)findViewById(R.id.saveButton); txtUserName.setImeOptions(EditorInfo.IME_ACTION_DONE); SharedPreferences sharedPreferences = this.getSharedPreferences("com.websmithing.gpstracker.prefs", Context.MODE_PRIVATE); @@ -64,12 +63,6 @@ trackLocation(v); } }); - - saveButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - saveUserSettings(); - } - }); } private void startAlarmManager(Context context) { @@ -97,15 +90,8 @@ SharedPreferences sharedPreferences = this.getSharedPreferences("com.websmithing.gpstracker.prefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); - if (textFieldsAreEmptyOrHaveSpaces()) { + if (!saveUserSettings()) { return; - } else { - // just in case user forgets to save username - String tempUser = sharedPreferences.getString("userName", ""); - if (tempUser.trim().length() == 0) { - editor.putString("userName", txtUserName.getText().toString().trim()); - editor.commit(); - } } if (!checkIfGooglePlayEnabled()) { @@ -113,7 +99,7 @@ } if (currentlyTracking) { - ((Button) v).setText(getText(R.string.start_tracking)); + Toast.makeText(getApplicationContext(), R.string.tracking_has_now_stopped, Toast.LENGTH_LONG).show(); cancelAlarm(); @@ -121,7 +107,7 @@ editor.putBoolean("currentlyTracking", false); editor.putString("sessionID", ""); } else { - ((Button) v).setText(getText(R.string.stop_tracking)); + Toast.makeText(getApplicationContext(), R.string.tracking_has_now_started, Toast.LENGTH_LONG).show(); startAlarmManager(getBaseContext()); @@ -131,11 +117,12 @@ } editor.commit(); + setTrackingButtonState(); } - private void saveUserSettings() { + private boolean saveUserSettings() { if (textFieldsAreEmptyOrHaveSpaces()) { - return; + return false; } checkIfWebsiteIsReachable(); @@ -166,7 +153,7 @@ editor.commit(); - Toast.makeText(this, R.string.setting_saved, Toast.LENGTH_SHORT).show(); + return true; } private boolean textFieldsAreEmptyOrHaveSpaces() { @@ -211,12 +198,6 @@ txtWebsite.setText(sharedPreferences.getString("defaultUploadWebsite", defaultUploadWebsite)); txtUserName.setText(sharedPreferences.getString("userName", "")); - - if (currentlyTracking) { - trackingButton.setText(getText(R.string.stop_tracking)); - } else { - trackingButton.setText(getText(R.string.start_tracking)); - } } private boolean checkIfGooglePlayEnabled() { @@ -243,12 +224,25 @@ }); } + private void setTrackingButtonState() { + if (currentlyTracking) { + trackingButton.setBackgroundResource(R.drawable.green_tracking_button); + trackingButton.setTextColor(Color.BLACK); + trackingButton.setText(R.string.tracking_is_on); + } else { + trackingButton.setBackgroundResource(R.drawable.red_tracking_button); + trackingButton.setTextColor(Color.WHITE); + trackingButton.setText(R.string.tracking_is_off); + } + } + @Override public void onResume() { Log.d(TAG, "onResume"); super.onResume(); // Always call the superclass method first displayUserSettings(); + setTrackingButtonState(); } @Override diff --git a/phoneClients/android/app/src/main/res/drawable/green_tracking_button.xml b/phoneClients/android/app/src/main/res/drawable/green_tracking_button.xml new file mode 100644 index 0000000..d97efe0 --- /dev/null +++ b/phoneClients/android/app/src/main/res/drawable/green_tracking_button.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/phoneClients/android/app/src/main/res/drawable/red_tracking_button.xml b/phoneClients/android/app/src/main/res/drawable/red_tracking_button.xml new file mode 100644 index 0000000..0a5089d --- /dev/null +++ b/phoneClients/android/app/src/main/res/drawable/red_tracking_button.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/phoneClients/android/app/src/main/res/layout/activity_gpstracker.xml b/phoneClients/android/app/src/main/res/layout/activity_gpstracker.xml index 656e59f..c8189fe 100644 --- a/phoneClients/android/app/src/main/res/layout/activity_gpstracker.xml +++ b/phoneClients/android/app/src/main/res/layout/activity_gpstracker.xml @@ -88,16 +88,12 @@ android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="horizontal" > -