diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index 646dfea..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index ab8ae7e..87b98e5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -57,6 +57,7 @@ dependencies {
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.auth0.android:jwtdecode:1.1.1'
implementation 'com.annimon:stream:1.2.1'
+ implementation 'com.google.android.gms:play-services-location:16.0.0'
// FloatingBarMenu
implementation 'com.getbase:floatingactionbutton:1.10.1'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5b1bc92..bb4aa0c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -50,6 +50,10 @@
android:name=".activity.SettingsActivity"
android:label="@string/title_activity_settings" />
+
+
{
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java
index 430311b..d0fd9dc 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java
@@ -46,8 +46,4 @@ public class StartupActivity extends AppCompatActivity {
finish();
}
-
-
-
-
}
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java
index ecc460a..82888b2 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java
@@ -105,7 +105,6 @@ public class UsersListFragment extends Fragment {
}
}));
-
}
public void searchUser(String textToSearch) {
@@ -217,11 +216,13 @@ public class UsersListFragment extends Fragment {
}
private void showError(Throwable e) {
- String message = e.toString();
+ String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
+ }else{
+ message = "Network Error !";
}
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java
index 24ebc30..2b3ca3c 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java
@@ -23,6 +23,9 @@ import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
+import com.google.android.gms.location.FusedLocationProviderClient;
+import com.google.android.gms.location.LocationServices;
+import com.google.android.gms.tasks.OnSuccessListener;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.model.Coordinate;
import com.uam.wmi.findmytutor.network.ApiClient;
@@ -31,6 +34,7 @@ import com.uam.wmi.findmytutor.utils.RestApiHelper;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.Executor;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
@@ -58,6 +62,7 @@ public class BackgroundLocalizationService extends Service {
private Handler mHandler = new Handler();
private HandlerThread mHandlerThread = null;
private Runnable mStatusChecker;
+ private FusedLocationProviderClient mFusedLocationClient;
public BackgroundLocalizationService() {
providers.add(LocationManager.GPS_PROVIDER);
@@ -107,6 +112,9 @@ public class BackgroundLocalizationService extends Service {
startForeground(1001, notification);
}
+ mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
+
+
initializeLocationManager();
Integer providerIndex = 0;
@@ -194,8 +202,21 @@ public class BackgroundLocalizationService extends Service {
Log.e("Best localization:", String.valueOf(bestLocation));
- if (bestLocation != null)
+ /* if (bestLocation != null)
fn_update(bestLocation);
+*/
+
+ mFusedLocationClient.getLastLocation().addOnSuccessListener(
+ new OnSuccessListener() {
+ @Override
+ public void onSuccess(Location location) {
+ if (location != null) {
+ mLastLocation = location;
+ fn_update(location);
+ }
+ }
+
+ });
}
private void fn_update(Location location) {
@@ -321,7 +342,5 @@ public class BackgroundLocalizationService extends Service {
return null;
}
-
}
-
}
\ No newline at end of file
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java
index 193e29d..0982f5a 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java
@@ -20,7 +20,6 @@ public class PrefUtils {
return context.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
}
-
public static void getAllKeys(Context context){
Map keys = getSharedPreferences(context).getAll();
@@ -35,9 +34,6 @@ public class PrefUtils {
editor.clear().apply();
}
-
-
-
public static void storeApiKey(Context context, String apiKey) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("API_KEY", apiKey);
@@ -150,5 +146,4 @@ public class PrefUtils {
editor.putBoolean("BACKGROUND_SERVICE_STATUS", status);
editor.apply();
}
-
}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_cancel.xml b/app/src/main/res/drawable/ic_cancel.xml
new file mode 100644
index 0000000..a8b409b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_cancel.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launch.xml b/app/src/main/res/drawable/ic_launch.xml
new file mode 100644
index 0000000..a8b409b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launch.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 198b7f7..60e0d13 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -189,5 +189,10 @@
Log in
Users list
Invalid login format.
+ Locale utils
+ Permission denied
+ permission should be granted
+
+