Merge branch 'presence-wifi-approach' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
eb30100183
@ -10,7 +10,7 @@ android {
|
|||||||
applicationId "com.uam.wmi.findmytutor"
|
applicationId "com.uam.wmi.findmytutor"
|
||||||
minSdkVersion 22
|
minSdkVersion 22
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 63
|
versionCode 64
|
||||||
versionName "1.0.0"
|
versionName "1.0.0"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
@ -6,9 +6,9 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.utils.Const;
|
import com.uam.wmi.findmytutor.utils.Const;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import static org.acra.ReportField.*;
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.annotation.AcraLimiter;
|
import org.acra.annotation.AcraLimiter;
|
||||||
import org.acra.annotation.AcraNotification;
|
import org.acra.annotation.AcraNotification;
|
||||||
@ -17,15 +17,28 @@ import org.acra.config.HttpSenderConfigurationBuilder;
|
|||||||
import org.acra.config.ToastConfigurationBuilder;
|
import org.acra.config.ToastConfigurationBuilder;
|
||||||
import org.acra.data.StringFormat;
|
import org.acra.data.StringFormat;
|
||||||
import org.acra.sender.HttpSender;
|
import org.acra.sender.HttpSender;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.acra.ReportField.ANDROID_VERSION;
|
||||||
|
import static org.acra.ReportField.BUILD_CONFIG;
|
||||||
|
import static org.acra.ReportField.CUSTOM_DATA;
|
||||||
|
import static org.acra.ReportField.LOGCAT;
|
||||||
|
import static org.acra.ReportField.PHONE_MODEL;
|
||||||
|
import static org.acra.ReportField.REPORT_ID;
|
||||||
|
import static org.acra.ReportField.SHARED_PREFERENCES;
|
||||||
|
import static org.acra.ReportField.STACK_TRACE;
|
||||||
|
import static org.acra.ReportField.USER_APP_START_DATE;
|
||||||
|
import static org.acra.ReportField.USER_CRASH_DATE;
|
||||||
|
|
||||||
|
|
||||||
@AcraNotification(resText = R.string.notification_text,
|
@AcraNotification(resText = R.string.notification_text,
|
||||||
resTitle = R.string.notification_title,
|
resTitle = R.string.notification_title,
|
||||||
resChannelName = R.string.notification_channel)
|
resChannelName = R.string.notification_channel)
|
||||||
@AcraLimiter(failedReportLimit = 2)
|
@AcraLimiter(failedReportLimit = 2)
|
||||||
public class FindMyTutor extends Application {
|
public class FindMyTutor extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context base) {
|
protected void attachBaseContext(Context base) {
|
||||||
super.attachBaseContext(base);
|
super.attachBaseContext(base);
|
||||||
@ -45,16 +58,17 @@ public class FindMyTutor extends Application {
|
|||||||
ToastConfigurationBuilder.class
|
ToastConfigurationBuilder.class
|
||||||
).setResText(R.string.acra_toast_text);
|
).setResText(R.string.acra_toast_text);
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||||
Map header = new HashMap();
|
Map header = new HashMap();
|
||||||
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
||||||
header.put("Authorization","Bearer " + token);
|
header.put("Authorization", "Bearer " + token);
|
||||||
|
|
||||||
// Api POST
|
// Api POST
|
||||||
builder.getPluginConfigurationBuilder(
|
builder.getPluginConfigurationBuilder(
|
||||||
HttpSenderConfigurationBuilder.class
|
HttpSenderConfigurationBuilder.class
|
||||||
// ).setUri("http://192.168.0.15:3000/api/acra")
|
// ).setUri("http://192.168.0.15:3000/api/acra")
|
||||||
).setUri(Const.BASE_URL +"api/Feedback/autoFeedback")
|
).setUri(Const.BASE_URL + "api/Feedback/autoFeedback")
|
||||||
.setHttpMethod(HttpSender.Method.POST)
|
.setHttpMethod(HttpSender.Method.POST)
|
||||||
.setHttpHeaders(header)
|
.setHttpHeaders(header)
|
||||||
.setEnabled(true);
|
.setEnabled(true);
|
||||||
|
@ -38,6 +38,7 @@ import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
|||||||
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
||||||
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||||
|
|
||||||
@ -161,6 +162,7 @@ public abstract class BaseActivity
|
|||||||
protected void logout(){
|
protected void logout(){
|
||||||
storeBackgroundLocationStatus(getApplication(), false);
|
storeBackgroundLocationStatus(getApplication(), false);
|
||||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||||
|
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), true);
|
||||||
|
|
||||||
Intent i = getBaseContext().getPackageManager()
|
Intent i = getBaseContext().getPackageManager()
|
||||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||||
@ -425,7 +427,7 @@ public abstract class BaseActivity
|
|||||||
sharingFragment = SharingFragment.newInstance();
|
sharingFragment = SharingFragment.newInstance();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.activity_content, sharingFragment);
|
ft.replace(R.id.activity_content, sharingFragment);
|
||||||
ft.addToBackStack(null);
|
//ft.addToBackStack(null);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +437,7 @@ public abstract class BaseActivity
|
|||||||
userListFragment = UsersListFragment.newInstance();
|
userListFragment = UsersListFragment.newInstance();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.activity_content, userListFragment);
|
ft.replace(R.id.activity_content, userListFragment);
|
||||||
ft.addToBackStack(null);
|
//ft.addToBackStack(null);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.uam.wmi.findmytutor.model.ValidateUser;
|
|||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.LdapService;
|
import com.uam.wmi.findmytutor.service.LdapService;
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
import com.uam.wmi.findmytutor.service.UserService;
|
||||||
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
|
|
||||||
@ -190,6 +191,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
getUserProfile(userId.asString());
|
getUserProfile(userId.asString());
|
||||||
|
|
||||||
|
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
String txt = "Main Activity";
|
String txt = "Main Activity";
|
||||||
data.setData(Uri.parse(txt));
|
data.setData(Uri.parse(txt));
|
||||||
|
@ -23,6 +23,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||||
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -48,8 +49,8 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
Intent loginIntent = new Intent(this, LoginActivity.class);
|
Intent loginIntent = new Intent(this, LoginActivity.class);
|
||||||
// Intent loginIntent = new Intent(this, ScrollingActivity.class);
|
|
||||||
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -34,9 +34,11 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
|||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
||||||
|
import com.uam.wmi.findmytutor.utils.Const;
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||||
|
import com.uam.wmi.findmytutor.utils.WifiUtils;
|
||||||
|
|
||||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||||
|
|
||||||
@ -122,6 +124,12 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
mCurrentLocation = locationResult.getLastLocation();
|
mCurrentLocation = locationResult.getLastLocation();
|
||||||
sendCoordinateToBackend(mCurrentLocation);
|
sendCoordinateToBackend(mCurrentLocation);
|
||||||
changeBackgroundMode();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -140,10 +148,34 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
startForeground(1001, notification);
|
startForeground(1001, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
if (!stopService) {
|
||||||
|
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) {
|
||||||
|
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
||||||
|
Location presenceFakeLoc = new Location("");
|
||||||
|
|
||||||
|
presenceFakeLoc.setLatitude(Const.presenceLatitude);
|
||||||
|
presenceFakeLoc.setLongitude(Const.presenceLongitude);
|
||||||
|
presenceFakeLoc.setAltitude(0);
|
||||||
|
createPresenceLooper(presenceFakeLoc);
|
||||||
|
} else {
|
||||||
createFusedLocationClient();
|
createFusedLocationClient();
|
||||||
} else if (!stopService &&
|
}
|
||||||
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
} else if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.EXACT.toString())
|
||||||
|
|| PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.APPROXIMATED.toString())
|
||||||
|
) {
|
||||||
|
createFusedLocationClient();
|
||||||
|
} else if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||||
|
Location manualFakeLoc = new Location("");
|
||||||
|
|
||||||
|
manualFakeLoc.setLatitude(0);
|
||||||
|
manualFakeLoc.setLongitude(0);
|
||||||
|
manualFakeLoc.setAltitude(0);
|
||||||
|
createLowBatteryLooper(manualFakeLoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createLowBatteryLooper(Location fakeLoc) {
|
||||||
mStatusChecker = () -> {
|
mStatusChecker = () -> {
|
||||||
try {
|
try {
|
||||||
sendCoordinateToBackend(fakeLoc);
|
sendCoordinateToBackend(fakeLoc);
|
||||||
@ -151,10 +183,24 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
AsyncTask.execute(mStatusChecker);
|
AsyncTask.execute(mStatusChecker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createPresenceLooper(Location fakeLoc) {
|
||||||
|
mStatusChecker = () -> {
|
||||||
|
try {
|
||||||
|
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
||||||
|
sendCoordinateToBackend(fakeLoc);
|
||||||
|
} else {
|
||||||
|
restartService();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AsyncTask.execute(mStatusChecker);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createFusedLocationClient() {
|
private void createFusedLocationClient() {
|
||||||
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
|
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
|
||||||
@ -294,7 +340,7 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
latitude = location.getLatitude();
|
latitude = location.getLatitude();
|
||||||
longitude = location.getLongitude();
|
longitude = location.getLongitude();
|
||||||
altitude = location.getAltitude();
|
altitude = location.getAltitude();
|
||||||
Log.e(TAG,"TASK" + latitude + " " + longitude);
|
Log.e(TAG, "TASK" + latitude + " " + longitude);
|
||||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||||
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
|
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
|
||||||
}
|
}
|
||||||
@ -307,6 +353,7 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
|
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
|
||||||
if (!MapUtils.checkIfCoordinateIsValid(latitude, longitude)) {
|
if (!MapUtils.checkIfCoordinateIsValid(latitude, longitude)) {
|
||||||
|
coordinatesHistory.add(fakeLoc);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,5 +20,7 @@ public class Const {
|
|||||||
public final static Range<Double> outsideLatitudeRange = Range.create(52.4651, 52.468837);
|
public final static Range<Double> outsideLatitudeRange = Range.create(52.4651, 52.468837);
|
||||||
public final static Range<Double> outsideLongitudeRange = Range.create(16.9186, 16.936004);
|
public final static Range<Double> outsideLongitudeRange = Range.create(16.9186, 16.936004);
|
||||||
public final static List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
public final static List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
||||||
|
public final static String WMI_SSID_NAME = "wmi";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,12 +3,10 @@ package com.uam.wmi.findmytutor.utils;
|
|||||||
import android.animation.TypeEvaluator;
|
import android.animation.TypeEvaluator;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
@ -25,6 +23,7 @@ import java.io.InputStream;
|
|||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLatitudeRange;
|
import static com.uam.wmi.findmytutor.utils.Const.outsideLatitudeRange;
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLongitudeRange;
|
import static com.uam.wmi.findmytutor.utils.Const.outsideLongitudeRange;
|
||||||
|
import static com.uam.wmi.findmytutor.utils.PrefUtils.shouldBatteryExclusionBeShown;
|
||||||
|
|
||||||
public class MapUtils {
|
public class MapUtils {
|
||||||
|
|
||||||
@ -90,6 +89,27 @@ public class MapUtils {
|
|||||||
return Const.buildingLatitudeRange.contains(latitude) && Const.buildingLongitudeRange.contains(longitude);
|
return Const.buildingLatitudeRange.contains(latitude) && Const.buildingLongitudeRange.contains(longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void BatteryOptimizationsExceptionCheck(Context context) {
|
||||||
|
if (shouldBatteryExclusionBeShown(getApplicationContext())) {
|
||||||
|
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), false);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle(R.string.batter_exclusions_title);
|
||||||
|
builder.setMessage(R.string.batter_exclusions_message)
|
||||||
|
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||||
|
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null);
|
||||||
|
intent.setData(uri);
|
||||||
|
context.startActivity(intent);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||||
|
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function for marker animation
|
// Function for marker animation
|
||||||
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||||
// Method is used to interpolate the marker animation.
|
// Method is used to interpolate the marker animation.
|
||||||
@ -106,19 +126,4 @@ public class MapUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void BatteryOptimizationsExceptionCheck(Context context) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(R.string.batter_exclusions_title);
|
|
||||||
builder.setMessage(R.string.batter_exclusions_message)
|
|
||||||
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
|
||||||
Intent intentBatteryUsage = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
|
|
||||||
context.startActivity(intentBatteryUsage);
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
|
||||||
// User cancelled the dialog
|
|
||||||
}).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -243,4 +243,13 @@ public class PrefUtils {
|
|||||||
return getSharedPreferences(context).getBoolean("whitelisting", false);
|
return getSharedPreferences(context).getBoolean("whitelisting", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean shouldBatteryExclusionBeShown(Context context) {
|
||||||
|
return getSharedPreferences(context).getBoolean("show_battery_exclusion", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBatteryExlusionInfoStatus(Context context, Boolean flag) {
|
||||||
|
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||||
|
editor.putBoolean("show_battery_exclusion", flag);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class WifiUtils {
|
||||||
|
|
||||||
|
public static String getWifiName(Context context) {
|
||||||
|
WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
|
if (Objects.requireNonNull(manager).isWifiEnabled()) {
|
||||||
|
WifiInfo wifiInfo = manager.getConnectionInfo();
|
||||||
|
if (wifiInfo != null) {
|
||||||
|
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
|
||||||
|
if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
|
||||||
|
return wifiInfo.getSSID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean checkIfUserIsInRangeOfWmiWifi(Context context) {
|
||||||
|
return Objects.equals(getWifiName(context), Const.WMI_SSID_NAME);
|
||||||
|
}
|
||||||
|
}
|
@ -289,7 +289,7 @@
|
|||||||
<string name="available_now">Dostępny teraz</string>
|
<string name="available_now">Dostępny teraz</string>
|
||||||
<string name="profile_activity_title">Profil użytkownika</string>
|
<string name="profile_activity_title">Profil użytkownika</string>
|
||||||
<string name="batter_exclusions_title">Uwaga</string>
|
<string name="batter_exclusions_title">Uwaga</string>
|
||||||
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątków w oszczędzaniu baterii. Po wciśnięciu przycisku "ok" zostaniesz przeniesiony do opcji zarządzania baterią. W panelu "optymalizacja użycia baterii" upewnij się, że opcja optymalizacji jest wyłączona.</string>
|
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątków w oszczędzaniu baterii. Po wciśnięciu przycisku \"ok\" zostaniesz przeniesiony do opcji zarządzania baterią. W panelu \"Bateria\" upewnij się, że opcja optymalizacji jest wyłączona.</string>
|
||||||
|
|
||||||
<string name="never_logged_in">Nigdy</string>
|
<string name="never_logged_in">Nigdy</string>
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@
|
|||||||
<string name="user_status_label" translatable="false">Status</string>
|
<string name="user_status_label" translatable="false">Status</string>
|
||||||
<string name="available_now">Available now</string>
|
<string name="available_now">Available now</string>
|
||||||
<string name="last_sign">Last seen</string>
|
<string name="last_sign">Last seen</string>
|
||||||
<string name="batter_exclusions_message">To make app fully functional, add FMT to battery saving exclusions. You can change battery options in "Optimise battery usage". Unfortunately, you have to do it manually. Click "ok" to open battery settings and make sure that the application is not optimised.</string>
|
<string name="batter_exclusions_message">To make app fully functional add FMT to battery saving exclusions. You can change battery options in \"Optimise battery usage\". Unfortunately, you have to do it manually. Click \"ok\" to open battery settings and make sure that the application is not optimised.</string>
|
||||||
<string name="batter_exclusions_title">Please note</string>
|
<string name="batter_exclusions_title">Please note</string>
|
||||||
<string name="never_logged_in">Never</string>
|
<string name="never_logged_in">Never</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user