From e1c266263a870e663abe85809fa69cf7f7f50bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Sun, 13 Jan 2019 14:10:50 +0100 Subject: [PATCH] Fix low battery mode --- app/build.gradle | 2 +- .../uam/wmi/findmytutor/activity/BaseActivity.java | 4 ++-- .../service/BackgroundLocalizationService.java | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ebe0a81..dab6905 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "com.uam.wmi.findmytutor" minSdkVersion 22 targetSdkVersion 27 - versionCode 63 + versionCode 64 versionName "1.0.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java index 0e54e1e..19a6dac 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -427,7 +427,7 @@ public abstract class BaseActivity sharingFragment = SharingFragment.newInstance(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.activity_content, sharingFragment); - ft.addToBackStack(null); + //ft.addToBackStack(null); ft.commit(); } @@ -437,7 +437,7 @@ public abstract class BaseActivity userListFragment = UsersListFragment.newInstance(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.activity_content, userListFragment); - ft.addToBackStack(null); + //ft.addToBackStack(null); ft.commit(); } 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 21c8bce..a374c44 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 @@ -124,6 +124,12 @@ public class BackgroundLocalizationService extends Service { mCurrentLocation = locationResult.getLastLocation(); sendCoordinateToBackend(mCurrentLocation); changeBackgroundMode(); + + //Restart service when a user started using presence in GPS mode and wmi is currently available + if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext()) + && PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) { + restartService(); + } } } }; @@ -220,12 +226,6 @@ public class BackgroundLocalizationService extends Service { mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.getMainLooper()); - - //Restart service when a user started using presence in GPS mode and wmi is currently available - if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext()) - && PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) { - restartService(); - } } } -- 2.20.1