Merge branch 'add-beta-student-security' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
f46d9cc60e
@ -126,17 +126,9 @@ public abstract class BaseActivity
|
|||||||
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||||
stopBackgroundLocalizationTask();
|
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))) {
|
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||||
|
|
||||||
@ -165,6 +157,20 @@ public abstract class BaseActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void 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();
|
||||||
|
}
|
||||||
|
|
||||||
protected void checkPermissions() {
|
protected void checkPermissions() {
|
||||||
final List<String> missingPermissions = new ArrayList<String>();
|
final List<String> missingPermissions = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ public class MapActivity extends BaseActivity
|
|||||||
mStatusChecker = () -> {
|
mStatusChecker = () -> {
|
||||||
try {
|
try {
|
||||||
if (shouldFetchNewCoords) {
|
if (shouldFetchNewCoords) {
|
||||||
|
checkIfUsesCanBeTutor();
|
||||||
fetchTopCoords();
|
fetchTopCoords();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -404,6 +405,30 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), resp.getPredefinedCoordinateId());
|
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() {
|
private void fetchTopCoords() {
|
||||||
|
|
||||||
disposable.add(
|
disposable.add(
|
||||||
|
@ -39,6 +39,9 @@ public interface UserService {
|
|||||||
@GET("api/users/tutors/active")
|
@GET("api/users/tutors/active")
|
||||||
Single <List<User>> getAllActiveTutors();
|
Single <List<User>> getAllActiveTutors();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GET("api/users/tutors/offline")
|
@GET("api/users/tutors/offline")
|
||||||
Single <List<User>> getAllOfflineTutors();
|
Single <List<User>> getAllOfflineTutors();
|
||||||
|
|
||||||
@ -60,6 +63,9 @@ public interface UserService {
|
|||||||
@GET("api/users/{id}")
|
@GET("api/users/{id}")
|
||||||
Single <User> getUserById(@Path("id") String userID);
|
Single <User> getUserById(@Path("id") String userID);
|
||||||
|
|
||||||
|
@GET("api/users/self/{id}")
|
||||||
|
Single <User> getSelf(@Path("id") String userID);
|
||||||
|
|
||||||
@PUT("api/users/{id}")
|
@PUT("api/users/{id}")
|
||||||
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user