Uncommented logging (should always have been enabled in develop)
parent
80cbfdc89f
commit
3c3ed65978
|
@ -5,14 +5,14 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
//import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class ConnectionReceiver extends BroadcastReceiver {
|
public class ConnectionReceiver extends BroadcastReceiver {
|
||||||
//private static final String TAG = "ConnectionReceiver";
|
private static final String TAG = "ConnectionReceiver";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
//Log.d(TAG,"onReceive() called");
|
Log.d(TAG,"onReceive() called");
|
||||||
|
|
||||||
// Get connection information
|
// Get connection information
|
||||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
@ -23,11 +23,11 @@ public class ConnectionReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
// Check connection
|
// Check connection
|
||||||
if (networkInfo!=null) {
|
if (networkInfo!=null) {
|
||||||
//Log.d(TAG, "Connected");
|
Log.d(TAG, "Connected");
|
||||||
context.startService(locationServiceIntent);
|
context.startService(locationServiceIntent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Log.d(TAG,"Disconnected");
|
Log.d(TAG,"Disconnected");
|
||||||
context.stopService(locationServiceIntent);
|
context.stopService(locationServiceIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
//import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.gms.common.ConnectionResult;
|
import com.google.android.gms.common.ConnectionResult;
|
||||||
import com.google.android.gms.common.api.GoogleApiClient;
|
import com.google.android.gms.common.api.GoogleApiClient;
|
||||||
|
@ -41,7 +41,7 @@ import java.net.URISyntaxException;
|
||||||
public class LocationService extends Service implements GoogleApiClient.ConnectionCallbacks,
|
public class LocationService extends Service implements GoogleApiClient.ConnectionCallbacks,
|
||||||
GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
||||||
public LocationService() {}
|
public LocationService() {}
|
||||||
//private String TAG = "LocationService";
|
private String TAG = "LocationService";
|
||||||
final static private int ICON_ON = 2;
|
final static private int ICON_ON = 2;
|
||||||
final int ICON_HALF = 1;
|
final int ICON_HALF = 1;
|
||||||
final int ICON_OFF = 0;
|
final int ICON_OFF = 0;
|
||||||
|
@ -70,8 +70,8 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
private NotificationManager mNotificationManager;
|
private NotificationManager mNotificationManager;
|
||||||
private final NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this);
|
private final NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this);
|
||||||
private void setupNotifications(Boolean persist) {
|
private void setupNotifications(Boolean persist) {
|
||||||
//Log.d(TAG,"setupNotification() called");
|
Log.d(TAG,"setupNotification() called");
|
||||||
|
//
|
||||||
if (mNotificationManager == null) {
|
if (mNotificationManager == null) {
|
||||||
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
.setOngoing(persist);
|
.setOngoing(persist);
|
||||||
}
|
}
|
||||||
private void showNotification(CharSequence text, int icon) {
|
private void showNotification(CharSequence text, int icon) {
|
||||||
//Log.d(TAG,"showNotification() called");
|
Log.d(TAG,"showNotification() called");
|
||||||
mNotificationBuilder
|
mNotificationBuilder
|
||||||
.setTicker(text)
|
.setTicker(text)
|
||||||
.setContentText(text);
|
.setContentText(text);
|
||||||
|
@ -113,31 +113,31 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
connectLocationUpdates(300, LocationRequest.PRIORITY_NO_POWER);
|
connectLocationUpdates(300, LocationRequest.PRIORITY_NO_POWER);
|
||||||
//Log.d(TAG, "Priority and interval lowered due to low power");
|
Log.d(TAG, "Priority and interval lowered due to low power");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
//Log.d(TAG, "onCreate called");
|
Log.d(TAG, "onCreate called");
|
||||||
|
|
||||||
// Get preferences
|
// Get preferences
|
||||||
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
setupNotifications(true);
|
setupNotifications(true);
|
||||||
showNotification(getText(R.string.notify_connecting), ICON_OFF);
|
showNotification(getText(R.string.notify_connecting), ICON_OFF);
|
||||||
//Log.d(TAG, "Notification set up");
|
Log.d(TAG, "Notification set up");
|
||||||
|
|
||||||
buildGoogleApiClient();
|
buildGoogleApiClient();
|
||||||
//Log.d(TAG, "Google API Client built");
|
Log.d(TAG, "Google API Client built");
|
||||||
mGoogleApiClient.connect();
|
mGoogleApiClient.connect();
|
||||||
//Log.d(TAG, "Connected to Google API Client");
|
Log.d(TAG, "Connected to Google API Client");
|
||||||
|
|
||||||
IntentFilter lowPowerFilter = new IntentFilter();
|
IntentFilter lowPowerFilter = new IntentFilter();
|
||||||
lowPowerFilter.addAction("android.intent.action.BATTERY_LOW");
|
lowPowerFilter.addAction("android.intent.action.BATTERY_LOW");
|
||||||
registerReceiver(LowPowerReceiver, lowPowerFilter);
|
registerReceiver(LowPowerReceiver, lowPowerFilter);
|
||||||
//Log.d(TAG, "LowPowerReceiver activated");
|
Log.d(TAG, "LowPowerReceiver activated");
|
||||||
|
|
||||||
mUserID = sharedPref.getString("loggedInUserId", null);
|
mUserID = sharedPref.getString("loggedInUserId", null);
|
||||||
mUserSK = sharedPref.getString("loggedInUserSk", null);
|
mUserSK = sharedPref.getString("loggedInUserSk", null);
|
||||||
|
@ -160,7 +160,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
Exception e = (Exception) args[0];
|
Exception e = (Exception) args[0];
|
||||||
//Log.e(TAG, "Transport error: " + e);
|
Log.e(TAG, "Transport error: " + e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
e.getCause().printStackTrace();
|
e.getCause().printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
|
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
showNotification(getText(R.string.server_connection_error), ICON_OFF);
|
showNotification(getText(R.string.server_connection_error), ICON_OFF);
|
||||||
//Log.e(TAG, "Failed to connect to sockets server " + SERVER_ADDRESS, e);
|
Log.e(TAG, "Failed to connect to sockets server " + SERVER_ADDRESS, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -213,10 +213,10 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
|
|
||||||
// Get permission
|
// Get permission
|
||||||
if (!checkLocationPermission(this)) {
|
if (!checkLocationPermission(this)) {
|
||||||
//Log.d(TAG, "Location permission denied");
|
Log.d(TAG, "Location permission denied");
|
||||||
//TODO: Ask the user to try again
|
//TODO: Ask the user to try again
|
||||||
} else {
|
} else {
|
||||||
//Log.d(TAG, "Location permission granted");
|
Log.d(TAG, "Location permission granted");
|
||||||
|
|
||||||
// Request location updates
|
// Request location updates
|
||||||
if (mGoogleApiClient.isConnected()) {
|
if (mGoogleApiClient.isConnected()) {
|
||||||
|
@ -242,7 +242,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnected(Bundle bundle) {
|
public void onConnected(Bundle bundle) {
|
||||||
//Log.d(TAG, "onConnected called");
|
Log.d(TAG, "onConnected called");
|
||||||
|
|
||||||
mLocationRequest = LocationRequest.create();
|
mLocationRequest = LocationRequest.create();
|
||||||
connectLocationUpdates(getIntervalSetting(), getPrioritySetting());
|
connectLocationUpdates(getIntervalSetting(), getPrioritySetting());
|
||||||
|
@ -256,7 +256,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionFailed(ConnectionResult connectionResult) {
|
public void onConnectionFailed(ConnectionResult connectionResult) {
|
||||||
//Log.e(TAG, "onConnectionFailed: " + connectionResult);
|
Log.e(TAG, "onConnectionFailed: " + connectionResult);
|
||||||
showNotification(getText(R.string.google_connection_error), ICON_OFF);
|
showNotification(getText(R.string.google_connection_error), ICON_OFF);
|
||||||
buildGoogleApiClient();
|
buildGoogleApiClient();
|
||||||
}
|
}
|
||||||
|
@ -265,11 +265,11 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
if (args[0].toString().equals("true")) {
|
if (args[0].toString().equals("true")) {
|
||||||
//Log.d(TAG, "Activating realtime updates");
|
Log.d(TAG, "Activating realtime updates");
|
||||||
connectLocationUpdates(getIntervalSetting(), getPrioritySetting());
|
connectLocationUpdates(getIntervalSetting(), getPrioritySetting());
|
||||||
showNotification(getString(R.string.realtime_updates), ICON_ON);
|
showNotification(getString(R.string.realtime_updates), ICON_ON);
|
||||||
} else {
|
} else {
|
||||||
//Log.d(TAG, "Deactivating realtime updates");
|
Log.d(TAG, "Deactivating realtime updates");
|
||||||
connectLocationUpdates(300, LocationRequest.PRIORITY_NO_POWER);
|
connectLocationUpdates(300, LocationRequest.PRIORITY_NO_POWER);
|
||||||
showNotification(getString(R.string.occasional_updates), ICON_HALF);
|
showNotification(getString(R.string.occasional_updates), ICON_HALF);
|
||||||
}
|
}
|
||||||
|
@ -290,13 +290,13 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
mLocationView.put("dir", String.valueOf(location.getBearing()));
|
mLocationView.put("dir", String.valueOf(location.getBearing()));
|
||||||
mLocationView.put("spd", String.valueOf(location.getSpeed()));
|
mLocationView.put("spd", String.valueOf(location.getSpeed()));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
//Log.e(TAG, "Failed to put JSON data");
|
Log.e(TAG, "Failed to put JSON data");
|
||||||
}
|
}
|
||||||
socket.emit("set", mLocationView);
|
socket.emit("set", mLocationView);
|
||||||
//Log.v(TAG, "Location set: " + mLocationView.toString());
|
Log.v(TAG, "Location set: " + mLocationView.toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Log.v(TAG, "Can't set location because user isn't logged in.");
|
Log.v(TAG, "Can't set location because user isn't logged in.");
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,27 +304,27 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionSuspended(int i) {
|
public void onConnectionSuspended(int i) {
|
||||||
//Log.d(TAG, "onConnectionSuspended called");
|
Log.d(TAG, "onConnectionSuspended called");
|
||||||
showNotification(getText(R.string.google_connection_error), ICON_OFF);
|
showNotification(getText(R.string.google_connection_error), ICON_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
//Log.d(TAG, "onDestroy executed");
|
Log.d(TAG, "onDestroy executed");
|
||||||
|
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
socket.off("activate", onActivate);
|
socket.off("activate", onActivate);
|
||||||
//Log.d(TAG, "Disconnected from sockets");
|
Log.d(TAG, "Disconnected from sockets");
|
||||||
|
|
||||||
mGoogleApiClient.disconnect();
|
mGoogleApiClient.disconnect();
|
||||||
//Log.d(TAG, "Google API disconnected");
|
Log.d(TAG, "Google API disconnected");
|
||||||
|
|
||||||
unregisterReceiver(LowPowerReceiver);
|
unregisterReceiver(LowPowerReceiver);
|
||||||
//Log.d(TAG, "LowPowerReceiver deactivated");
|
Log.d(TAG, "LowPowerReceiver deactivated");
|
||||||
|
|
||||||
setupNotifications(false);
|
setupNotifications(false);
|
||||||
showNotification(getText(R.string.disconnected), ICON_OFF);
|
showNotification(getText(R.string.disconnected), ICON_OFF);
|
||||||
//Log.d(TAG, "Notification changed");
|
Log.d(TAG, "Notification changed");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
//import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -44,7 +44,7 @@ import okhttp3.Response;
|
||||||
public class LoginActivity extends AppCompatActivity implements
|
public class LoginActivity extends AppCompatActivity implements
|
||||||
GoogleApiClient.OnConnectionFailedListener,
|
GoogleApiClient.OnConnectionFailedListener,
|
||||||
View.OnClickListener {
|
View.OnClickListener {
|
||||||
//private static final String TAG = "LoginActivity";
|
private static final String TAG = "LoginActivity";
|
||||||
private static final int RC_SIGN_IN = 9001;
|
private static final int RC_SIGN_IN = 9001;
|
||||||
static final int SIGN_OUT = 1;
|
static final int SIGN_OUT = 1;
|
||||||
private static boolean DONT_LOG_IN = false;
|
private static boolean DONT_LOG_IN = false;
|
||||||
|
@ -62,7 +62,7 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
//Log.v(TAG, "created");
|
Log.v(TAG, "created");
|
||||||
|
|
||||||
// Set up layout
|
// Set up layout
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
|
@ -99,16 +99,16 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
//Log.v(TAG, "onStart() called");
|
Log.v(TAG, "onStart() called");
|
||||||
|
|
||||||
// Try to sign in
|
// Try to sign in
|
||||||
if (!DONT_LOG_IN) {
|
if (!DONT_LOG_IN) {
|
||||||
//Log.v(TAG, "Trying to sign in...");
|
Log.v(TAG, "Trying to sign in...");
|
||||||
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
|
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
|
||||||
if (opr.isDone()) {
|
if (opr.isDone()) {
|
||||||
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
|
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
|
||||||
// and the GoogleSignInResult will be available instantly.
|
// and the GoogleSignInResult will be available instantly.
|
||||||
//Log.d(TAG, "Got cached sign-in");
|
Log.d(TAG, "Got cached sign-in");
|
||||||
GoogleSignInResult result = opr.get();
|
GoogleSignInResult result = opr.get();
|
||||||
handleGoogleSignInResult(result);
|
handleGoogleSignInResult(result);
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,12 +141,12 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
SharedPreferences.Editor editor = sharedPref.edit();
|
SharedPreferences.Editor editor = sharedPref.edit();
|
||||||
|
|
||||||
// Stop LocationService
|
// Stop LocationService
|
||||||
//Log.v(TAG, "Stopping location service...");
|
Log.v(TAG, "Stopping location service...");
|
||||||
stopService(new Intent(LoginActivity.this, LocationService.class));
|
stopService(new Intent(LoginActivity.this, LocationService.class));
|
||||||
editor.putBoolean("gps_switch",false);
|
editor.putBoolean("gps_switch",false);
|
||||||
|
|
||||||
// Remove saved loggedInUser
|
// Remove saved loggedInUser
|
||||||
//Log.v(TAG, "Removing saved user...");
|
Log.v(TAG, "Removing saved user...");
|
||||||
editor.remove("loggedInUser");
|
editor.remove("loggedInUser");
|
||||||
editor.remove("loggedInUserId");
|
editor.remove("loggedInUserId");
|
||||||
editor.remove("loggedInUserName");
|
editor.remove("loggedInUserName");
|
||||||
|
@ -158,17 +158,17 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
//Log.v(TAG, "onActivityResult() called");
|
Log.v(TAG, "onActivityResult() called");
|
||||||
|
|
||||||
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
|
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
|
||||||
if (requestCode == RC_SIGN_IN) {
|
if (requestCode == RC_SIGN_IN) {
|
||||||
//Log.v(TAG, "requestCode was RC_SIGN_IN");
|
Log.v(TAG, "requestCode was RC_SIGN_IN");
|
||||||
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
|
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
|
||||||
handleGoogleSignInResult(result);
|
handleGoogleSignInResult(result);
|
||||||
}
|
}
|
||||||
// User just logged out. Don't log in again, stupid
|
// User just logged out. Don't log in again, stupid
|
||||||
else if (requestCode == SIGN_OUT) {
|
else if (requestCode == SIGN_OUT) {
|
||||||
//Log.v(TAG, "requestCode was SIGN_OUT");
|
Log.v(TAG, "requestCode was SIGN_OUT");
|
||||||
DONT_LOG_IN = true;
|
DONT_LOG_IN = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
client.newCall(request).enqueue(new Callback() {
|
client.newCall(request).enqueue(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call call, IOException e) {
|
public void onFailure(Call call, IOException e) {
|
||||||
//Log.e(TAG, "Failed to connect to Tracman server!");
|
Log.e(TAG, "Failed to connect to Tracman server!");
|
||||||
showError(R.string.server_connection_error);
|
showError(R.string.server_connection_error);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
res.body().close();
|
res.body().close();
|
||||||
throw new IOException("Unexpected code: " + res);
|
throw new IOException("Unexpected code: " + res);
|
||||||
} else {
|
} else {
|
||||||
//Log.d(TAG, "Response code: " + res.code());
|
Log.d(TAG, "Response code: " + res.code());
|
||||||
String userString = res.body().string();
|
String userString = res.body().string();
|
||||||
System.out.println("Full response: " + userString);
|
System.out.println("Full response: " + userString);
|
||||||
|
|
||||||
|
@ -215,10 +215,10 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
userID = user.getString("_id");
|
userID = user.getString("_id");
|
||||||
userName = user.getString("name");
|
userName = user.getString("name");
|
||||||
userSK = user.getString("sk32");
|
userSK = user.getString("sk32");
|
||||||
//Log.v(TAG, "User retrieved with ID: " + userID);
|
Log.v(TAG, "User retrieved with ID: " + userID);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
//Log.e(TAG, "Unable to parse user JSON: ", e);
|
Log.e(TAG, "Unable to parse user JSON: ", e);
|
||||||
//Log.e(TAG, "JSON String used: " + userString);
|
Log.e(TAG, "JSON String used: " + userString);
|
||||||
userID = null;
|
userID = null;
|
||||||
userName = null;
|
userName = null;
|
||||||
userSK = null;
|
userSK = null;
|
||||||
|
@ -243,7 +243,7 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleGoogleSignInResult(GoogleSignInResult result) {
|
private void handleGoogleSignInResult(GoogleSignInResult result) {
|
||||||
//Log.d(TAG, "handleSignInResult:" + result.isSuccess());
|
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
|
||||||
if (result.isSuccess()) { // Signed in successfully
|
if (result.isSuccess()) { // Signed in successfully
|
||||||
GoogleSignInAccount acct = result.getSignInAccount();
|
GoogleSignInAccount acct = result.getSignInAccount();
|
||||||
try {
|
try {
|
||||||
|
@ -257,10 +257,10 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
authenticateWithTracmanServer(request);
|
authenticateWithTracmanServer(request);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//Log.e(TAG, "Error sending ID token to backend.", e);
|
Log.e(TAG, "Error sending ID token to backend.", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Log.e(TAG, "Failed to log in: "+result.getStatus().getStatusCode());
|
Log.e(TAG, "Failed to log in: "+result.getStatus().getStatusCode());
|
||||||
if (result.getStatus().getStatusCode()!=4) {
|
if (result.getStatus().getStatusCode()!=4) {
|
||||||
showError(R.string.google_connection_error);
|
showError(R.string.google_connection_error);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void signInWithPassword() {
|
public void signInWithPassword() {
|
||||||
//Log.d(TAG, "signInWithPassword() called");
|
Log.d(TAG, "signInWithPassword() called");
|
||||||
|
|
||||||
// Get params from form
|
// Get params from form
|
||||||
EditText emailText = (EditText)findViewById(R.id.login_email);
|
EditText emailText = (EditText)findViewById(R.id.login_email);
|
||||||
|
@ -290,16 +290,16 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
|
|
||||||
// Send formdata to endpoint
|
// Send formdata to endpoint
|
||||||
try {
|
try {
|
||||||
//Log.v(TAG, "Sending local login POST to server...");
|
Log.v(TAG, "Sending local login POST to server...");
|
||||||
authenticateWithTracmanServer(request);
|
authenticateWithTracmanServer(request);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//Log.e(TAG, "Error sending local login to backend:",e);
|
Log.e(TAG, "Error sending local login to backend:",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void signInWithGoogle() {
|
public void signInWithGoogle() {
|
||||||
//Log.v(TAG, "signInWithGoogle() called");
|
Log.v(TAG, "signInWithGoogle() called");
|
||||||
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
|
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
|
||||||
startActivityForResult(signInIntent, RC_SIGN_IN);
|
startActivityForResult(signInIntent, RC_SIGN_IN);
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionFailed(ConnectionResult connectionResult) {
|
public void onConnectionFailed(ConnectionResult connectionResult) {
|
||||||
showError(R.string.disconnected);
|
showError(R.string.disconnected);
|
||||||
//Log.d(TAG, "onConnectionFailed:" + connectionResult);
|
Log.d(TAG, "onConnectionFailed:" + connectionResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showProgressDialog() {
|
private void showProgressDialog() {
|
||||||
|
@ -351,14 +351,14 @@ public class LoginActivity extends AppCompatActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
//Log.v(TAG, "onClick() called");
|
Log.v(TAG, "onClick() called");
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.login_button:
|
case R.id.login_button:
|
||||||
//Log.v(TAG, "Password login button pressed");
|
Log.v(TAG, "Password login button pressed");
|
||||||
signInWithPassword();
|
signInWithPassword();
|
||||||
break;
|
break;
|
||||||
case R.id.login_button_google:
|
case R.id.login_button_google:
|
||||||
//Log.v(TAG, "Google login button pressed");
|
Log.v(TAG, "Google login button pressed");
|
||||||
signInWithGoogle();
|
signInWithGoogle();
|
||||||
break;
|
break;
|
||||||
// case R.id.login_button_facebook:
|
// case R.id.login_button_facebook:
|
||||||
|
|
|
@ -16,7 +16,7 @@ import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
//import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -36,7 +36,7 @@ import static us.keithirwin.tracman.LoginActivity.SIGN_OUT;
|
||||||
* API Guide</a> for more information on developing a Settings UI.
|
* API Guide</a> for more information on developing a Settings UI.
|
||||||
*/
|
*/
|
||||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
//private static final String TAG = "SettingsActivity";
|
private static final String TAG = "SettingsActivity";
|
||||||
private static final int MY_FINE_LOCATION_PERMISSION = 425;
|
private static final int MY_FINE_LOCATION_PERMISSION = 425;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
MY_FINE_LOCATION_PERMISSION);
|
MY_FINE_LOCATION_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.d(TAG, "Starting LocationService");
|
Log.d(TAG, "Starting LocationService");
|
||||||
startService(new Intent(SettingsActivity.this, LocationService.class));
|
startService(new Intent(SettingsActivity.this, LocationService.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setupActionBar();
|
setupActionBar();
|
||||||
//Log.d(TAG, "activity onCreate called");
|
Log.d(TAG, "activity onCreate called");
|
||||||
|
|
||||||
// Restart LocationService when any related preference is changed
|
// Restart LocationService when any related preference is changed
|
||||||
// findPreference("gps_switch").setOnPreferenceChangeListener(sRestartLocationServiceOnChangeListener);
|
// findPreference("gps_switch").setOnPreferenceChangeListener(sRestartLocationServiceOnChangeListener);
|
||||||
|
@ -147,7 +147,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
//Log.d(TAG, "onStop called");
|
Log.d(TAG, "onStop called");
|
||||||
super.onStop();
|
super.onStop();
|
||||||
// Get updated preferences
|
// Get updated preferences
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
@ -170,7 +170,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start location tracking service
|
// Start location tracking service
|
||||||
//Log.d(TAG, "Starting LocationService");
|
Log.d(TAG, "Starting LocationService");
|
||||||
startService(new Intent(this, LocationService.class));
|
startService(new Intent(this, LocationService.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
//Log.v(TAG,"onBackPressed() called");
|
Log.v(TAG,"onBackPressed() called");
|
||||||
|
|
||||||
// Return to LoginActivity and don't sign back in again
|
// Return to LoginActivity and don't sign back in again
|
||||||
setResult(SIGN_OUT, new Intent());
|
setResult(SIGN_OUT, new Intent());
|
||||||
|
|
Loading…
Reference in New Issue