Merge branch 'approximated-localizations' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
18900340ee
@ -135,6 +135,7 @@ public abstract class BaseActivity
|
||||
userListFragment = new UsersListFragment();
|
||||
|
||||
isTutor = PrefUtils.getIsTutor(getApplicationContext());
|
||||
|
||||
if (!isTutor) {
|
||||
navigationView.findViewById(R.id.nav_profile).setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -72,12 +73,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||
return false;
|
||||
});
|
||||
|
||||
Switch tutorLogin = findViewById(R.id.tutor_login_switch);
|
||||
|
||||
tutorLogin.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
PrefUtils.storeIsTutor(getApplicationContext(), isChecked);
|
||||
});
|
||||
|
||||
Button mEmailSignInButton = findViewById(R.id.email_sign_in_button);
|
||||
mEmailSignInButton.setOnClickListener(view -> attemptLogin());
|
||||
|
||||
@ -158,17 +153,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
private void loginProcess(String email, String password) {
|
||||
Log.e("LOGIN", String.valueOf(PrefUtils.getIsTutor(getApplicationContext())));
|
||||
ValidateUser user = new ValidateUser(email, password);
|
||||
|
||||
//Fake validate
|
||||
LdapUser user = new LdapUser(email, password, "admin", (PrefUtils.getIsTutor(getApplicationContext())) ? "Tutor" : "Student", "Imię", "Nazwisko", email);
|
||||
|
||||
// ValidateUser user = new ValidateUser(email, password);
|
||||
|
||||
// LDAP logging
|
||||
// disposable.add(ldapService.validate(user)
|
||||
|
||||
disposable.add(ldapService.fakeValidate(user)
|
||||
disposable.add(ldapService.validate(user)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
@ -192,13 +179,20 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
String token = jwtToken.getToken();
|
||||
JWT jwt = new JWT(token);
|
||||
Claim role = jwt.getClaim("nameid");
|
||||
Claim userId = jwt.getClaim("nameid");
|
||||
Claim role = jwt.getClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
|
||||
if(Objects.requireNonNull(role.asString()).equals("Student")){
|
||||
PrefUtils.storeIsTutor(getApplicationContext(), false);
|
||||
}
|
||||
|
||||
Log.e("LOGOWANIE",role.asString());
|
||||
|
||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), true);
|
||||
PrefUtils.storeApiKey(getApplicationContext(), token);
|
||||
PrefUtils.storeUserId(getApplicationContext(), role.asString());
|
||||
PrefUtils.storeUserId(getApplicationContext(), userId.asString());
|
||||
|
||||
getUserProfile(role.asString());
|
||||
getUserProfile(userId.asString());
|
||||
|
||||
Intent data = new Intent();
|
||||
String txt = "Main Activity";
|
||||
|
@ -134,7 +134,7 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static String getLocale(Context context) {
|
||||
return getSharedPreferences(context).getString("LOCALE", "pl");
|
||||
return getSharedPreferences(context).getString("LOCALE", "en");
|
||||
}
|
||||
|
||||
public static Boolean isBackgroundLocationServiceRunning(Context context) {
|
||||
|
@ -3,14 +3,6 @@ package com.uam.wmi.findmytutor.utils;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.content.Context;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
@ -19,8 +11,6 @@ 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.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -38,11 +28,9 @@ public class mapUtils {
|
||||
.add(WMI_BOUNDS.getNorthEast())
|
||||
.add(WMI_BOUNDS.getSouthEast())
|
||||
.add(WMI_BOUNDS.getSouthWest())
|
||||
.alpha(0.1f)
|
||||
.fillColor(Color.YELLOW);
|
||||
.alpha(0.0f);
|
||||
// For adding and removing
|
||||
private static Polygon polygon;
|
||||
private static View crosshair;
|
||||
|
||||
// Map Bounds Area
|
||||
public static void setMapBoundsArea(Context context, MapboxMap mapboxMap, MapView mapView, Boolean check) {
|
||||
@ -50,28 +38,22 @@ public class mapUtils {
|
||||
if (check) {
|
||||
// Set bounds to WMI
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(WMI_BOUNDS);
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, 17, 0, 0,4000);
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, 17, 0, 0, 4000);
|
||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||
|
||||
// Visualise bounds area
|
||||
// showBoundsArea
|
||||
polygon = mapboxMap.addPolygon(boundsArea);
|
||||
// showCrosshair
|
||||
crosshair = new View(context);
|
||||
crosshair.setLayoutParams(new FrameLayout.LayoutParams(15, 15, Gravity.CENTER));
|
||||
crosshair.setBackgroundColor(Color.GREEN);
|
||||
mapView.addView(crosshair);
|
||||
} else {
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(null);
|
||||
mapboxMap.setMinZoomPreference(2);
|
||||
mapboxMap.removePolygon(polygon);
|
||||
mapView.removeView(crosshair);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration){
|
||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
||||
CameraPosition position = new CameraPosition.Builder()
|
||||
.target(new LatLng(lat, lon)) // Sets the new camera position
|
||||
.zoom(zoomParam) // Sets the zoom
|
||||
@ -83,22 +65,6 @@ public class mapUtils {
|
||||
.newCameraPosition(position), duration);
|
||||
}
|
||||
|
||||
// Function for marker animation
|
||||
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
// Method is used to interpolate the marker animation.
|
||||
|
||||
private LatLng latLng = new LatLng();
|
||||
|
||||
@Override
|
||||
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
|
||||
latLng.setLatitude(startValue.getLatitude()
|
||||
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
|
||||
latLng.setLongitude(startValue.getLongitude()
|
||||
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
|
||||
return latLng;
|
||||
}
|
||||
}
|
||||
|
||||
// read file to JSON
|
||||
public static String loadJsonFromAsset(Context context, String filename) {
|
||||
// Using this method to load in GeoJSON files from the assets folder.
|
||||
@ -116,4 +82,20 @@ public class mapUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// Function for marker animation
|
||||
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
// Method is used to interpolate the marker animation.
|
||||
|
||||
private LatLng latLng = new LatLng();
|
||||
|
||||
@Override
|
||||
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
|
||||
latLng.setLatitude(startValue.getLatitude()
|
||||
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
|
||||
latLng.setLongitude(startValue.getLongitude()
|
||||
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
|
||||
return latLng;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,11 +72,6 @@
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/tutor_login_switch"
|
||||
android:layout_width="192dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Login as Tutor" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/email_sign_in_button"
|
||||
|
Loading…
Reference in New Issue
Block a user