Compare commits
29 Commits
fix-last-s
...
master
Author | SHA1 | Date | |
---|---|---|---|
faed9e05b7 | |||
1095386659 | |||
b7e1e4a984 | |||
4473834218 | |||
5a96d93d37 | |||
33cfa90a28 | |||
6fa458d198 | |||
2ca95e0ba0 | |||
eb30100183 | |||
e1c266263a | |||
d88525a764 | |||
430914bab1 | |||
786a73c963 | |||
1f2867cb43 | |||
5770217c45 | |||
17b7f4c9a2 | |||
f46d9cc60e | |||
325f8a99a2 | |||
0ec0e95798 | |||
085dc1e4d6 | |||
9f78eaf688 | |||
b528ec68bb | |||
7b79a5339a | |||
6e98eeff16 | |||
fae7a5f0fe | |||
e64f5d380c | |||
2f25f06d18 | |||
a4c0881300 | |||
7e043c9826 |
@ -10,7 +10,7 @@ android {
|
||||
applicationId "com.uam.wmi.findmytutor"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 27
|
||||
versionCode 59
|
||||
versionCode 66
|
||||
versionName "1.0.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
@ -6,8 +6,9 @@ import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.Const;
|
||||
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.annotation.AcraLimiter;
|
||||
import org.acra.annotation.AcraNotification;
|
||||
@ -16,18 +17,32 @@ import org.acra.config.HttpSenderConfigurationBuilder;
|
||||
import org.acra.config.ToastConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
import org.acra.sender.HttpSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
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,
|
||||
resTitle = R.string.notification_title,
|
||||
resChannelName = R.string.notification_channel)
|
||||
@AcraLimiter(failedReportLimit = 2)
|
||||
public class FindMyTutor extends Application {
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
//super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
|
||||
// ACRA core
|
||||
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
|
||||
@ -43,16 +58,17 @@ public class FindMyTutor extends Application {
|
||||
ToastConfigurationBuilder.class
|
||||
).setResText(R.string.acra_toast_text);
|
||||
|
||||
|
||||
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||
Map header = new HashMap();
|
||||
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
||||
header.put("Authorization","Bearer " + token);
|
||||
header.put("Authorization", "Bearer " + token);
|
||||
|
||||
// Api POST
|
||||
builder.getPluginConfigurationBuilder(
|
||||
HttpSenderConfigurationBuilder.class
|
||||
// ).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)
|
||||
.setHttpHeaders(header)
|
||||
.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.LocaleHelper;
|
||||
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.RxSearchObservable;
|
||||
|
||||
@ -126,17 +127,9 @@ public abstract class BaseActivity
|
||||
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
stopBackgroundLocalizationTask();
|
||||
}
|
||||
logout();
|
||||
|
||||
storeBackgroundLocationStatus(getApplication(), false);
|
||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||
|
||||
Intent i = getBaseContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||
if (i != null) {
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
}
|
||||
startActivity(i);
|
||||
finish();
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||
|
||||
@ -165,6 +158,21 @@ public abstract class BaseActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void logout(){
|
||||
storeBackgroundLocationStatus(getApplication(), false);
|
||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), true);
|
||||
|
||||
Intent i = getBaseContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||
if (i != null) {
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
}
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
protected void checkPermissions() {
|
||||
final List<String> missingPermissions = new ArrayList<String>();
|
||||
|
||||
@ -419,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();
|
||||
}
|
||||
|
||||
@ -429,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();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.uam.wmi.findmytutor.model.ValidateUser;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.LdapService;
|
||||
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.RestApiHelper;
|
||||
|
||||
@ -190,6 +191,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
getUserProfile(userId.asString());
|
||||
|
||||
|
||||
Intent data = new Intent();
|
||||
String txt = "Main Activity";
|
||||
data.setData(Uri.parse(txt));
|
||||
|
@ -8,6 +8,7 @@ import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
@ -126,6 +127,7 @@ public class MapActivity extends BaseActivity
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
if (shouldFetchNewCoords) {
|
||||
checkIfUsesCanBeTutor();
|
||||
fetchTopCoords();
|
||||
}
|
||||
} finally {
|
||||
@ -134,7 +136,6 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
};
|
||||
|
||||
|
||||
selectLocationButton = findViewById(R.id.select_location_button);
|
||||
removeLocationButton = findViewById(R.id.remove_location_button);
|
||||
mapView = findViewById(R.id.mapView);
|
||||
@ -145,6 +146,11 @@ public class MapActivity extends BaseActivity
|
||||
handleBackgroundTaskLifeCycle();
|
||||
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||
|
||||
if(isTutor){
|
||||
MapUtils.BatteryOptimizationsExceptionCheck(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -403,6 +409,30 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), resp.getPredefinedCoordinateId());
|
||||
}
|
||||
|
||||
|
||||
private void checkIfUsesCanBeTutor(){
|
||||
disposable.add(
|
||||
userService.getSelf(myId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<User>() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
boolean tutorFromBackend = user.getTitle().equals("tutor");
|
||||
|
||||
if(tutorFromBackend != PrefUtils.getIsTutor(getApplicationContext())){
|
||||
logout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showError(e);
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private void fetchTopCoords() {
|
||||
|
||||
disposable.add(
|
||||
|
@ -1,18 +1,29 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -21,6 +32,11 @@ public class StartupActivity extends AppCompatActivity {
|
||||
private static final int AUTHENTICATION_REQUEST_CODE = 666;
|
||||
String currentLang;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -33,12 +49,11 @@ public class StartupActivity extends AppCompatActivity {
|
||||
finish();
|
||||
} else {
|
||||
Intent loginIntent = new Intent(this, LoginActivity.class);
|
||||
// Intent loginIntent = new Intent(this, ScrollingActivity.class);
|
||||
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
||||
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,4 +66,8 @@ public class StartupActivity extends AppCompatActivity {
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,9 +34,11 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
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.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||
import com.uam.wmi.findmytutor.utils.WifiUtils;
|
||||
|
||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||
|
||||
@ -122,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -140,22 +148,60 @@ public class BackgroundLocalizationService extends Service {
|
||||
startForeground(1001, notification);
|
||||
}
|
||||
|
||||
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||
createFusedLocationClient();
|
||||
} else if (!stopService &&
|
||||
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
sendCoordinateToBackend(fakeLoc);
|
||||
} finally {
|
||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||
}
|
||||
};
|
||||
if (!stopService) {
|
||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) {
|
||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
||||
Location presenceFakeLoc = new Location("");
|
||||
|
||||
AsyncTask.execute(mStatusChecker);
|
||||
presenceFakeLoc.setLatitude(Const.presenceLatitude);
|
||||
presenceFakeLoc.setLongitude(Const.presenceLongitude);
|
||||
presenceFakeLoc.setAltitude(0);
|
||||
createPresenceLooper(presenceFakeLoc);
|
||||
} else {
|
||||
createFusedLocationClient();
|
||||
}
|
||||
} 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 = () -> {
|
||||
try {
|
||||
sendCoordinateToBackend(fakeLoc);
|
||||
} finally {
|
||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||
}
|
||||
};
|
||||
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() {
|
||||
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
|
||||
|
||||
@ -294,7 +340,7 @@ public class BackgroundLocalizationService extends Service {
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
altitude = location.getAltitude();
|
||||
Log.e(TAG,"TASK" + latitude + " " + longitude);
|
||||
Log.e(TAG, "TASK" + latitude + " " + longitude);
|
||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
|
||||
}
|
||||
@ -307,6 +353,7 @@ public class BackgroundLocalizationService extends Service {
|
||||
|
||||
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
|
||||
if (!MapUtils.checkIfCoordinateIsValid(latitude, longitude)) {
|
||||
coordinatesHistory.add(fakeLoc);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,9 @@ public interface UserService {
|
||||
@GET("api/users/tutors/active")
|
||||
Single <List<User>> getAllActiveTutors();
|
||||
|
||||
|
||||
|
||||
|
||||
@GET("api/users/tutors/offline")
|
||||
Single <List<User>> getAllOfflineTutors();
|
||||
|
||||
@ -60,6 +63,9 @@ public interface UserService {
|
||||
@GET("api/users/{id}")
|
||||
Single <User> getUserById(@Path("id") String userID);
|
||||
|
||||
@GET("api/users/self/{id}")
|
||||
Single <User> getSelf(@Path("id") String userID);
|
||||
|
||||
@PUT("api/users/{id}")
|
||||
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
||||
|
||||
|
@ -20,5 +20,7 @@ public class Const {
|
||||
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 List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
||||
public final static String WMI_SSID_NAME = "wmi";
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
@ -10,12 +14,15 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLongitudeRange;
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
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.PrefUtils.shouldBatteryExclusionBeShown;
|
||||
|
||||
public class MapUtils {
|
||||
|
||||
@ -41,8 +48,8 @@ public class MapUtils {
|
||||
|
||||
// Map Bounds Area
|
||||
public static void setZoom(MapboxMap mapboxMap, Integer zoom) {
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||
}
|
||||
|
||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
||||
@ -73,14 +80,34 @@ public class MapUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean checkIfCoordinateIsValid(Location coordinate){
|
||||
return outsideLatitudeRange.contains(coordinate.getLatitude()) && outsideLongitudeRange.contains(coordinate.getLongitude());
|
||||
public static Boolean checkIfCoordinateIsValid(Location coordinate) {
|
||||
return outsideLatitudeRange.contains(coordinate.getLatitude()) && outsideLongitudeRange.contains(coordinate.getLongitude());
|
||||
}
|
||||
|
||||
public static Boolean checkIfCoordinateIsValid(Double latitude, Double longitude){
|
||||
public static Boolean checkIfCoordinateIsValid(Double latitude, Double longitude) {
|
||||
return Const.buildingLatitudeRange.contains(latitude) && Const.buildingLongitudeRange.contains(longitude);
|
||||
}
|
||||
|
||||
public static void BatteryOptimizationsExceptionCheck(Context context) {
|
||||
if (shouldBatteryExclusionBeShown(getApplicationContext())) {
|
||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), false);
|
||||
|
||||
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
|
||||
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
// Method is used to interpolate the marker animation.
|
||||
|
@ -243,4 +243,13 @@ public class PrefUtils {
|
||||
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);
|
||||
}
|
||||
}
|
@ -4,13 +4,13 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".activity.LoginActivity">
|
||||
|
||||
|
||||
@ -43,10 +43,9 @@
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/email_til"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -60,10 +59,9 @@
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
app:passwordToggleEnabled="true"
|
||||
android:id="@+id/password_til"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -77,7 +75,6 @@
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/email_sign_in_button"
|
||||
style="?android:textAppearanceSmall"
|
||||
@ -87,7 +84,6 @@
|
||||
android:text="@string/action_log_in"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
@ -288,6 +288,8 @@
|
||||
|
||||
<string name="available_now">Dostępny teraz</string>
|
||||
<string name="profile_activity_title">Profil użytkownika</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 \"Bateria\" upewnij się, że opcja optymalizacji jest wyłączona.</string>
|
||||
|
||||
<string name="never_logged_in">Nigdy</string>
|
||||
|
||||
|
@ -456,5 +456,7 @@
|
||||
<string name="user_status_label" translatable="false">Status</string>
|
||||
<string name="available_now">Available now</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_title">Please note</string>
|
||||
<string name="never_logged_in">Never</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user