Merged release-0.6.1 into master
commit
0aff25a632
|
@ -1,7 +1,4 @@
|
|||
## VIM
|
||||
*.swp
|
||||
|
||||
# Created by https://www.gitignore.io/api/android,linux
|
||||
# Created by https://www.gitignore.io/api/android
|
||||
|
||||
### Android ###
|
||||
# Built application files
|
||||
|
@ -41,11 +38,7 @@ captures/
|
|||
# Intellij
|
||||
/.idea/
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
.idea/misc.xml
|
||||
.idea/
|
||||
projectFilesBackup/
|
||||
|
||||
# Keystore files
|
||||
|
@ -66,19 +59,6 @@ freeline_project_description.json
|
|||
### Android Patch ###
|
||||
gen-external-apklibs
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# End of https://www.gitignore.io/api/android,linux
|
||||
# For google play signing
|
||||
encrypted_private_key
|
||||
upload_certificate.pem
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Tracman.iml" filepath="$PROJECT_DIR$/Tracman.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tracman-android.iml" filepath="$PROJECT_DIR$/tracman-android.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
14
README.md
14
README.md
|
@ -1,5 +1,5 @@
|
|||
# <img align="left" src="https://tracman.org/static/img/icon/by/48.png" alt="[]" title="The Tracman Logo">Tracman for Android
|
||||
###### v 0.6.0
|
||||
# <img align="left" src="https://www.tracman.org/static/img/icon/by/48.png" alt="[]" title="The Tracman Logo">Tracman for Android
|
||||
###### v 0.6.1
|
||||
|
||||
Android app to upload a user's GPS location to the [tracman server](https://github.com/tracman-org/Server).
|
||||
|
||||
|
@ -13,14 +13,18 @@ In order to apply changes to settings, you need to hit the back button and retur
|
|||
|
||||
The app will switch between "realtime updates" (Every second, or whatever interval you set up in the settings) and "occasional updates", depending on if there are visitors to your map. This prevents the app from draining your battery when nobody's looking at your location anyway.
|
||||
|
||||
More information is available on the [help page](https://tracman.org/help#android).
|
||||
More information is available on the [help page](https://www.tracman.org/help#android).
|
||||
|
||||
## Contributing
|
||||
|
||||
Tracman for Android is in perpetually poor condition. I just don't know enough about android/java to create a top-quality app. I think this project would benefit greatly from being torn down and rebuilt from scratch. If you know anything about Android, you probably know more than me. Feel free to check out the [issues marked help wanted](https://github.com/Tracman-org/Android/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) (or [any issues](https://github.com/Tracman-org/Android/issues), really) or [contact me](https://keithirwin.us/contact) about getting involved.
|
||||
Tracman for Android is in perpetually poor condition. I don't do much work with Android. This project would benefit greatly from being torn down and rebuilt from scratch. Feel free to check out the [issues marked help wanted](https://github.com/Tracman-org/Android/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) (or [any issues](https://github.com/Tracman-org/Android/issues), really) or [contact me](https://www.keithirwin.us/contact) about getting involved.
|
||||
|
||||
## Changelog
|
||||
|
||||
#### v0.6.1
|
||||
|
||||
* Updated server URLs
|
||||
|
||||
#### v0.6.0
|
||||
|
||||
* [#1](https://github.com/Tracman-org/Android/issues/1) Deals with lost connections
|
||||
|
@ -37,7 +41,7 @@ Tracman for Android is in perpetually poor condition. I just don't know enough
|
|||
###### see [LICENSE.md](https://github.com/Tracman-org/Android/blob/master/LICENSE.md)
|
||||
|
||||
Tracman: GPS tracking app for android
|
||||
Copyright © 2017 [Keith Irwin](https://keithirwin.us/)
|
||||
Copyright © 2018 [Keith Irwin](https://www.keithirwin.us/)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ android {
|
|||
}
|
||||
}
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '25.0.0'
|
||||
buildToolsVersion '26.0.2'
|
||||
defaultConfig {
|
||||
applicationId "us.keithirwin.tracman"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 12
|
||||
versionName "0.6.0"
|
||||
versionCode 13
|
||||
versionName "0.6.1"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<!-- Login Activity -->
|
||||
<activity android:name=".LoginActivity">
|
||||
<intent-filter android:label="@string/app_name">
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
@ -23,8 +25,9 @@
|
|||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
|
||||
<!-- Settings Activity -->
|
||||
<activity android:name=".SettingsActivity"
|
||||
android:label="@string/settings_name"
|
||||
android:parentActivityName=".LoginActivity">
|
||||
|
||||
|
@ -34,14 +37,13 @@
|
|||
android:value=".LoginActivity"/>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".LocationService"
|
||||
<!-- Location Service -->
|
||||
<service android:name=".LocationService"
|
||||
android:exported="false">
|
||||
</service>
|
||||
|
||||
<!--Startup on boot-->
|
||||
<receiver
|
||||
android:name=".BootReceiver"
|
||||
<!-- Startup on boot -->
|
||||
<receiver android:name=".BootReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
|
||||
|
@ -53,9 +55,8 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!--Check for Disconnection-->
|
||||
<receiver
|
||||
android:name=".ConnectionReceiver"
|
||||
<!-- Check for Disconnection -->
|
||||
<receiver android:name=".ConnectionReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
|
|
|
@ -5,14 +5,14 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
//import android.util.Log;
|
||||
import android.util.Log;
|
||||
|
||||
public class ConnectionReceiver extends BroadcastReceiver {
|
||||
//private static final String TAG = "ConnectionReceiver";
|
||||
private static final String TAG = "ConnectionReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
//Log.d(TAG,"onReceive() called");
|
||||
Log.d(TAG,"onReceive() called");
|
||||
|
||||
// Get connection information
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
@ -23,11 +23,11 @@ public class ConnectionReceiver extends BroadcastReceiver {
|
|||
|
||||
// Check connection
|
||||
if (networkInfo!=null) {
|
||||
//Log.d(TAG, "Connected");
|
||||
Log.d(TAG, "Connected");
|
||||
context.startService(locationServiceIntent);
|
||||
}
|
||||
else {
|
||||
//Log.d(TAG,"Disconnected");
|
||||
Log.d(TAG,"Disconnected");
|
||||
context.stopService(locationServiceIntent);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import android.preference.PreferenceManager;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
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.api.GoogleApiClient;
|
||||
|
@ -36,19 +36,20 @@ import org.json.JSONException;
|
|||
import org.json.JSONObject;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class LocationService extends Service implements GoogleApiClient.ConnectionCallbacks,
|
||||
GoogleApiClient.OnConnectionFailedListener, LocationListener {
|
||||
public LocationService() {}
|
||||
//private String TAG = "LocationService";
|
||||
private String TAG = "LocationService";
|
||||
final static private int ICON_ON = 2;
|
||||
final int ICON_HALF = 1;
|
||||
final int ICON_OFF = 0;
|
||||
final static private int ICON_HALF = 1;
|
||||
final static private int ICON_OFF = 0;
|
||||
// Development
|
||||
// final String SERVER_ADDRESS = "https://dev.tracman.org";
|
||||
// Production
|
||||
final String SERVER_ADDRESS = "https://tracman.org";
|
||||
final String SERVER_ADDRESS = "https://www.tracman.org";
|
||||
|
||||
private Socket socket;
|
||||
private String mUserID;
|
||||
|
@ -70,8 +71,8 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
private NotificationManager mNotificationManager;
|
||||
private final NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this);
|
||||
private void setupNotifications(Boolean persist) {
|
||||
//Log.d(TAG,"setupNotification() called");
|
||||
|
||||
Log.d(TAG,"setupNotification() called");
|
||||
//
|
||||
if (mNotificationManager == null) {
|
||||
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
.setOngoing(persist);
|
||||
}
|
||||
private void showNotification(CharSequence text, int icon) {
|
||||
//Log.d(TAG,"showNotification() called");
|
||||
Log.d(TAG,"showNotification() called");
|
||||
mNotificationBuilder
|
||||
.setTicker(text)
|
||||
.setContentText(text);
|
||||
|
@ -113,31 +114,31 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
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
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
//Log.d(TAG, "onCreate called");
|
||||
Log.d(TAG, "onCreate called");
|
||||
|
||||
// Get preferences
|
||||
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
setupNotifications(true);
|
||||
showNotification(getText(R.string.notify_connecting), ICON_OFF);
|
||||
//Log.d(TAG, "Notification set up");
|
||||
Log.d(TAG, "Notification set up");
|
||||
|
||||
buildGoogleApiClient();
|
||||
//Log.d(TAG, "Google API Client built");
|
||||
Log.d(TAG, "Google API Client built");
|
||||
mGoogleApiClient.connect();
|
||||
//Log.d(TAG, "Connected to Google API Client");
|
||||
Log.d(TAG, "Connected to Google API Client");
|
||||
|
||||
IntentFilter lowPowerFilter = new IntentFilter();
|
||||
lowPowerFilter.addAction("android.intent.action.BATTERY_LOW");
|
||||
registerReceiver(LowPowerReceiver, lowPowerFilter);
|
||||
//Log.d(TAG, "LowPowerReceiver activated");
|
||||
Log.d(TAG, "LowPowerReceiver activated");
|
||||
|
||||
mUserID = sharedPref.getString("loggedInUserId", null);
|
||||
mUserSK = sharedPref.getString("loggedInUserSk", null);
|
||||
|
@ -160,7 +161,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
@Override
|
||||
public void call(Object... args) {
|
||||
Exception e = (Exception) args[0];
|
||||
//Log.e(TAG, "Transport error: " + e);
|
||||
Log.e(TAG, "Transport error: " + e);
|
||||
e.printStackTrace();
|
||||
e.getCause().printStackTrace();
|
||||
}
|
||||
|
@ -182,7 +183,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
|
||||
} catch (URISyntaxException e) {
|
||||
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 +214,10 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
|
||||
// Get permission
|
||||
if (!checkLocationPermission(this)) {
|
||||
//Log.d(TAG, "Location permission denied");
|
||||
Log.d(TAG, "Location permission denied");
|
||||
//TODO: Ask the user to try again
|
||||
} else {
|
||||
//Log.d(TAG, "Location permission granted");
|
||||
Log.d(TAG, "Location permission granted");
|
||||
|
||||
// Request location updates
|
||||
if (mGoogleApiClient.isConnected()) {
|
||||
|
@ -242,7 +243,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
|
||||
@Override
|
||||
public void onConnected(Bundle bundle) {
|
||||
//Log.d(TAG, "onConnected called");
|
||||
Log.d(TAG, "onConnected called");
|
||||
|
||||
mLocationRequest = LocationRequest.create();
|
||||
connectLocationUpdates(getIntervalSetting(), getPrioritySetting());
|
||||
|
@ -256,7 +257,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
|
||||
@Override
|
||||
public void onConnectionFailed(ConnectionResult connectionResult) {
|
||||
//Log.e(TAG, "onConnectionFailed: " + connectionResult);
|
||||
Log.e(TAG, "onConnectionFailed: " + connectionResult);
|
||||
showNotification(getText(R.string.google_connection_error), ICON_OFF);
|
||||
buildGoogleApiClient();
|
||||
}
|
||||
|
@ -265,11 +266,11 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
@Override
|
||||
public void call(final Object... args) {
|
||||
if (args[0].toString().equals("true")) {
|
||||
//Log.d(TAG, "Activating realtime updates");
|
||||
Log.d(TAG, "Activating realtime updates");
|
||||
connectLocationUpdates(getIntervalSetting(), getPrioritySetting());
|
||||
showNotification(getString(R.string.realtime_updates), ICON_ON);
|
||||
} else {
|
||||
//Log.d(TAG, "Deactivating realtime updates");
|
||||
Log.d(TAG, "Deactivating realtime updates");
|
||||
connectLocationUpdates(300, LocationRequest.PRIORITY_NO_POWER);
|
||||
showNotification(getString(R.string.occasional_updates), ICON_HALF);
|
||||
}
|
||||
|
@ -285,18 +286,19 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
try {
|
||||
mLocationView.put("usr", mUserID);
|
||||
mLocationView.put("tok", mUserSK);
|
||||
mLocationView.put("ts", String.valueOf(System.currentTimeMillis()));
|
||||
mLocationView.put("lat", String.valueOf(location.getLatitude()));
|
||||
mLocationView.put("lon", String.valueOf(location.getLongitude()));
|
||||
mLocationView.put("dir", String.valueOf(location.getBearing()));
|
||||
mLocationView.put("spd", String.valueOf(location.getSpeed()));
|
||||
} catch (JSONException e) {
|
||||
//Log.e(TAG, "Failed to put JSON data");
|
||||
Log.e(TAG, "Failed to put JSON data");
|
||||
}
|
||||
socket.emit("set", mLocationView);
|
||||
//Log.v(TAG, "Location set: " + mLocationView.toString());
|
||||
Log.v(TAG, "Location set: " + mLocationView.toString());
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -304,27 +306,27 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
|
||||
@Override
|
||||
public void onConnectionSuspended(int i) {
|
||||
//Log.d(TAG, "onConnectionSuspended called");
|
||||
Log.d(TAG, "onConnectionSuspended called");
|
||||
showNotification(getText(R.string.google_connection_error), ICON_OFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
//Log.d(TAG, "onDestroy executed");
|
||||
Log.d(TAG, "onDestroy executed");
|
||||
|
||||
socket.disconnect();
|
||||
socket.off("activate", onActivate);
|
||||
//Log.d(TAG, "Disconnected from sockets");
|
||||
Log.d(TAG, "Disconnected from sockets");
|
||||
|
||||
mGoogleApiClient.disconnect();
|
||||
//Log.d(TAG, "Google API disconnected");
|
||||
Log.d(TAG, "Google API disconnected");
|
||||
|
||||
unregisterReceiver(LowPowerReceiver);
|
||||
//Log.d(TAG, "LowPowerReceiver deactivated");
|
||||
Log.d(TAG, "LowPowerReceiver deactivated");
|
||||
|
||||
setupNotifications(false);
|
||||
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.os.Bundle;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
//import android.util.Log;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -44,7 +44,7 @@ import okhttp3.Response;
|
|||
public class LoginActivity extends AppCompatActivity implements
|
||||
GoogleApiClient.OnConnectionFailedListener,
|
||||
View.OnClickListener {
|
||||
//private static final String TAG = "LoginActivity";
|
||||
private static final String TAG = "LoginActivity";
|
||||
private static final int RC_SIGN_IN = 9001;
|
||||
static final int SIGN_OUT = 1;
|
||||
private static boolean DONT_LOG_IN = false;
|
||||
|
@ -53,7 +53,7 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
// private final String SERVER_ADDRESS = "https://dev.tracman.org/";
|
||||
// private static final String GOOGLE_WEB_CLIENT_ID = "483494341936-hps4p2pcu3ctshjvqm3pqdbg0t0q281o.apps.googleusercontent.com";
|
||||
// Production
|
||||
private final String SERVER_ADDRESS = "https://tracman.org/";
|
||||
private final String SERVER_ADDRESS = "https://www.tracman.org/";
|
||||
private static final String GOOGLE_WEB_CLIENT_ID = "483494341936-hrn0ms1tebgdtfs5f4i6ebmkt3qmo16o.apps.googleusercontent.com";
|
||||
|
||||
private GoogleApiClient mGoogleApiClient;
|
||||
|
@ -62,7 +62,7 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//Log.v(TAG, "created");
|
||||
Log.v(TAG, "created");
|
||||
|
||||
// Set up layout
|
||||
setContentView(R.layout.activity_login);
|
||||
|
@ -99,16 +99,16 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
//Log.v(TAG, "onStart() called");
|
||||
Log.v(TAG, "onStart() called");
|
||||
|
||||
// Try to sign 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);
|
||||
if (opr.isDone()) {
|
||||
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
|
||||
// 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();
|
||||
handleGoogleSignInResult(result);
|
||||
} else {
|
||||
|
@ -141,12 +141,12 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
|
||||
// Stop LocationService
|
||||
//Log.v(TAG, "Stopping location service...");
|
||||
Log.v(TAG, "Stopping location service...");
|
||||
stopService(new Intent(LoginActivity.this, LocationService.class));
|
||||
editor.putBoolean("gps_switch",false);
|
||||
|
||||
// Remove saved loggedInUser
|
||||
//Log.v(TAG, "Removing saved user...");
|
||||
Log.v(TAG, "Removing saved user...");
|
||||
editor.remove("loggedInUser");
|
||||
editor.remove("loggedInUserId");
|
||||
editor.remove("loggedInUserName");
|
||||
|
@ -158,17 +158,17 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent 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(...);
|
||||
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);
|
||||
handleGoogleSignInResult(result);
|
||||
}
|
||||
// User just logged out. Don't log in again, stupid
|
||||
else if (requestCode == SIGN_OUT) {
|
||||
//Log.v(TAG, "requestCode was SIGN_OUT");
|
||||
Log.v(TAG, "requestCode was SIGN_OUT");
|
||||
DONT_LOG_IN = true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
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);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -205,22 +205,20 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
res.body().close();
|
||||
throw new IOException("Unexpected code: " + res);
|
||||
} else {
|
||||
//Log.d(TAG, "Response code: " + res.code());
|
||||
Log.d(TAG, "Response code: " + res.code());
|
||||
String userString = res.body().string();
|
||||
System.out.println("Full response: " + userString);
|
||||
|
||||
String userID, userName, userSK;
|
||||
String userID, userSK;
|
||||
try {
|
||||
JSONObject user = new JSONObject(userString);
|
||||
userID = user.getString("_id");
|
||||
userName = user.getString("name");
|
||||
userSK = user.getString("sk32");
|
||||
//Log.v(TAG, "User retrieved with ID: " + userID);
|
||||
Log.v(TAG, "User retrieved with ID: " + userID);
|
||||
} catch (JSONException e) {
|
||||
//Log.e(TAG, "Unable to parse user JSON: ", e);
|
||||
//Log.e(TAG, "JSON String used: " + userString);
|
||||
Log.e(TAG, "Unable to parse user JSON: ", e);
|
||||
Log.e(TAG, "JSON String used: " + userString);
|
||||
userID = null;
|
||||
userName = null;
|
||||
userSK = null;
|
||||
}
|
||||
|
||||
|
@ -229,7 +227,6 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putString("loggedInUser", userString);
|
||||
editor.putString("loggedInUserId", userID);
|
||||
editor.putString("loggedInUserName", userName);
|
||||
editor.putString("loggedInUserSk", userSK);
|
||||
editor.commit();
|
||||
|
||||
|
@ -243,7 +240,7 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
}
|
||||
|
||||
private void handleGoogleSignInResult(GoogleSignInResult result) {
|
||||
//Log.d(TAG, "handleSignInResult:" + result.isSuccess());
|
||||
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
|
||||
if (result.isSuccess()) { // Signed in successfully
|
||||
GoogleSignInAccount acct = result.getSignInAccount();
|
||||
try {
|
||||
|
@ -257,10 +254,10 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
authenticateWithTracmanServer(request);
|
||||
|
||||
} catch (Exception e) {
|
||||
//Log.e(TAG, "Error sending ID token to backend.", e);
|
||||
Log.e(TAG, "Error sending ID token to backend.", e);
|
||||
}
|
||||
} 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) {
|
||||
showError(R.string.google_connection_error);
|
||||
}
|
||||
|
@ -268,7 +265,7 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
}
|
||||
|
||||
public void signInWithPassword() {
|
||||
//Log.d(TAG, "signInWithPassword() called");
|
||||
Log.d(TAG, "signInWithPassword() called");
|
||||
|
||||
// Get params from form
|
||||
EditText emailText = (EditText)findViewById(R.id.login_email);
|
||||
|
@ -290,16 +287,16 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
|
||||
// Send formdata to endpoint
|
||||
try {
|
||||
//Log.v(TAG, "Sending local login POST to server...");
|
||||
Log.v(TAG, "Sending local login POST to server...");
|
||||
authenticateWithTracmanServer(request);
|
||||
} 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() {
|
||||
//Log.v(TAG, "signInWithGoogle() called");
|
||||
Log.v(TAG, "signInWithGoogle() called");
|
||||
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
|
||||
startActivityForResult(signInIntent, RC_SIGN_IN);
|
||||
}
|
||||
|
@ -321,7 +318,7 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
@Override
|
||||
public void onConnectionFailed(ConnectionResult connectionResult) {
|
||||
showError(R.string.disconnected);
|
||||
//Log.d(TAG, "onConnectionFailed:" + connectionResult);
|
||||
Log.d(TAG, "onConnectionFailed:" + connectionResult);
|
||||
}
|
||||
|
||||
private void showProgressDialog() {
|
||||
|
@ -351,14 +348,14 @@ public class LoginActivity extends AppCompatActivity implements
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//Log.v(TAG, "onClick() called");
|
||||
Log.v(TAG, "onClick() called");
|
||||
switch (v.getId()) {
|
||||
case R.id.login_button:
|
||||
//Log.v(TAG, "Password login button pressed");
|
||||
Log.v(TAG, "Password login button pressed");
|
||||
signInWithPassword();
|
||||
break;
|
||||
case R.id.login_button_google:
|
||||
//Log.v(TAG, "Google login button pressed");
|
||||
Log.v(TAG, "Google login button pressed");
|
||||
signInWithGoogle();
|
||||
break;
|
||||
// case R.id.login_button_facebook:
|
||||
|
|
|
@ -16,7 +16,7 @@ import android.support.v4.app.ActivityCompat;
|
|||
import android.support.v7.app.ActionBar;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
//import android.util.Log;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
MY_FINE_LOCATION_PERMISSION);
|
||||
}
|
||||
|
||||
//Log.d(TAG, "Starting LocationService");
|
||||
Log.d(TAG, "Starting LocationService");
|
||||
startService(new Intent(SettingsActivity.this, LocationService.class));
|
||||
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setupActionBar();
|
||||
//Log.d(TAG, "activity onCreate called");
|
||||
Log.d(TAG, "activity onCreate called");
|
||||
|
||||
// Restart LocationService when any related preference is changed
|
||||
// findPreference("gps_switch").setOnPreferenceChangeListener(sRestartLocationServiceOnChangeListener);
|
||||
|
@ -147,7 +147,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
//Log.d(TAG, "onStop called");
|
||||
Log.d(TAG, "onStop called");
|
||||
super.onStop();
|
||||
// Get updated preferences
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
@ -170,7 +170,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
}
|
||||
|
||||
// Start location tracking service
|
||||
//Log.d(TAG, "Starting LocationService");
|
||||
Log.d(TAG, "Starting LocationService");
|
||||
startService(new Intent(this, LocationService.class));
|
||||
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//Log.v(TAG,"onBackPressed() called");
|
||||
Log.v(TAG,"onBackPressed() called");
|
||||
|
||||
// Return to LoginActivity and don't sign back in again
|
||||
setResult(SIGN_OUT, new Intent());
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<string name="google_connection_error">FEHLER: Könnte nicht zum Google API Server verbinden. </string>
|
||||
<string name="help_name">Hilfe</string>
|
||||
<string name="loading">Ladet…</string>
|
||||
<string name="login_description">Einloggen oder <a href="https://tracman.org/login#join">ein neues Konto erstellen</a>. </string>
|
||||
<string name="login_description">Einloggen oder <a href="https://www.tracman.org/login#join">ein neues Konto erstellen</a>. </string>
|
||||
<string name="login_name">Einloggen</string>
|
||||
<string name="login_no_user_error">FEHLER: Nutzer nicht gefunden. </string>
|
||||
<string name="logout_name">Ausloggen</string>
|
||||
|
@ -47,7 +47,7 @@
|
|||
</string-array>
|
||||
<string name="pref_title_gps_broadcast">Sendungen einschalten</string>
|
||||
<string name="pref_title_broadcast_priority">Aktualisierung Vorrang</string>
|
||||
<string name="login_forgot_password"><a href="https://tracman.org/login/forgot">Passwort vergessen?</a></string>
|
||||
<string name="login_forgot_password"><a href="https://www.tracman.org/login/forgot">Passwort vergessen?</a></string>
|
||||
<string name="login_button_text">Einloggen</string>
|
||||
<string name="email">Email</string>
|
||||
<string name="password">Passwort</string>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<string name="broadcast_disabled">Transmisiónes apagado</string>
|
||||
<string name="google_connection_error">ERROR: No se puede conectar al Google API servidor. </string>
|
||||
<string name="help_name">Ayuda</string>
|
||||
<string name="login_description">Iniciar una sesión o <a href="https://tracman.org/login">participar</a>. </string>
|
||||
<string name="login_description">Iniciar una sesión o <a href="https://www.tracman.org/login">participar</a>. </string>
|
||||
<string name="login_name">Iniciar sesión</string>
|
||||
<string name="login_no_user_error">ERROR: Usario no encontrado</string>
|
||||
<string name="logout_name">Cerrar sesión</string>
|
||||
|
@ -47,7 +47,7 @@
|
|||
</string-array>
|
||||
<string name="pref_title_gps_broadcast">Encender transmisiónes</string>
|
||||
<string name="pref_broadcast_category_title">Actualizaciones de ubicación</string>
|
||||
<string name="login_forgot_password"><a href="https://tracman.org/login/forgot">Olividé su contrasena?</a></string>
|
||||
<string name="login_forgot_password"><a href="https://www.tracman.org/login/forgot">Olividé su contrasena?</a></string>
|
||||
<string name="login_button_text">Inciar session</string>
|
||||
<string name="email">email</string>
|
||||
<string name="password">contrasena</string>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<resources>
|
||||
<string name="app_name" translatable="false">Tracman</string>
|
||||
<string name="app_address" translatable="false">us.keithirwin.tracman</string>
|
||||
<string name="version_code" translatable="false">10</string>
|
||||
<string name="version" translatable="false">0.5.0</string>
|
||||
<string name="version_code" translatable="false">13</string>
|
||||
<string name="version" translatable="false">0.6.1</string>
|
||||
|
||||
<string name="loading">Loading…</string>
|
||||
<string name="logo_description" translatable="false">[T]</string>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<!-- Strings related to login -->
|
||||
<string name="login_name">Login</string>
|
||||
<string name="logout_name">Logout</string>
|
||||
<string name="login_description">Log in or <a href="https://tracman.org/login#join">create an account</a>. </string>
|
||||
<string name="login_description">Log in or <a href="https://www.tracman.org/login#join">create an account</a>. </string>
|
||||
<string name="server_connection_error">ERROR: Unable to connect to Tracman server. </string>
|
||||
|
||||
<!-- Strings related to notifications -->
|
||||
|
@ -95,7 +95,7 @@
|
|||
|
||||
<!--Strings related to bugs-->
|
||||
<string name="bugs_name">Bug report</string>
|
||||
<string name="login_forgot_password"><a href="https://tracman.org/login/forgot">Forgot your password?</a></string>
|
||||
<string name="login_forgot_password"><a href="https://www.tracman.org/login/forgot">Forgot your password?</a></string>
|
||||
<string name="login_button_text">Login</string>
|
||||
<string name="email">email</string>
|
||||
<string name="password">password</string>
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.1'
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#Fri Mar 03 16:00:54 EST 2017
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
#Tue Jan 30 09:02:00 ECT 2018
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":13},"path":"app-release.apk","properties":{"packageId":"us.keithirwin.tracman","split":"","minSdkVersion":"15"}}]
|
Loading…
Reference in New Issue