diff --git a/.idea/misc.xml b/.idea/misc.xml index 75f1658..b0c7b20 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,10 +1,5 @@ - - - - - - + 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 3209b11..5be8ec4 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 @@ -20,19 +20,16 @@ import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.FrameLayout; import android.widget.Toast; -import com.mapbox.mapboxsdk.Mapbox; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.service.BackgroundLocalizationService; import com.uam.wmi.findmytutor.utils.ActiveFragment; import com.uam.wmi.findmytutor.utils.FeedbackUtils; -import com.uam.wmi.findmytutor.utils.MapUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.RxSearchObservable; @@ -49,8 +46,8 @@ import io.reactivex.functions.Function; import io.reactivex.schedulers.Schedulers; -import static com.uam.wmi.findmytutor.utils.Consts.deafultMapZoom; -import static com.uam.wmi.findmytutor.utils.Consts.searchMapZoom; +import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom; +import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom; import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus; @@ -77,6 +74,7 @@ public abstract class BaseActivity private Fragment userListFragment; private ActiveFragment activeFragment = ActiveFragment.NONE; + private Fragment activeBottomMenu = null; private SearchView searchView; @SuppressLint("CheckResult") @@ -275,7 +273,7 @@ public abstract class BaseActivity searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> { if (!hasFocus && activeFragment.equals(ActiveFragment.NONE)) { restoreMapMarkers(); - adjustMapToSearch(deafultMapZoom); + adjustMapToSearch(defaultMapZoom); } if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){ @@ -351,7 +349,7 @@ public abstract class BaseActivity } else if (itemId == R.id.nav_user_list) { loadUserListFragment(); } - + selectBottomNavigationBarItem(itemId); }, 300); return true; @@ -363,6 +361,7 @@ public abstract class BaseActivity FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.activity_content, sharingFragment); ft.commit(); + } private void loadUserListFragment() { @@ -372,8 +371,8 @@ public abstract class BaseActivity FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.activity_content, userListFragment); ft.commit(); - } + } private void updateNavigationBarState() { int actionId = getNavigationMenuItemId(); @@ -385,9 +384,6 @@ public abstract class BaseActivity item.setChecked(true); } - - abstract int getNavigationMenuItemId(); - abstract int getContentViewId(); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java index 2cf6954..7734dd1 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java @@ -21,7 +21,6 @@ import com.auth0.android.jwt.JWT; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.JwtToken; -import com.uam.wmi.findmytutor.model.LdapUser; import com.uam.wmi.findmytutor.model.User; import com.uam.wmi.findmytutor.model.ValidateUser; import com.uam.wmi.findmytutor.network.ApiClient; @@ -149,11 +148,8 @@ public class LoginActivity extends AppCompatActivity { private void loginProcess(String email, String password) { ValidateUser user = new ValidateUser(email, password); - LdapUser fuser = new LdapUser(email, password, "wmi", "tutor", "henryk", "zdzblo", email); - -// disposable.add(ldapService.validate(user) - disposable.add(ldapService.fakeValidate(fuser) + disposable.add(ldapService.validate(user) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::handleResponse, this::handleError)); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java index f285b1f..17843df 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -52,12 +52,13 @@ import com.uam.wmi.findmytutor.service.CoordinateService; import com.uam.wmi.findmytutor.service.PredefinedStatusesService; import com.uam.wmi.findmytutor.service.UserService; import com.uam.wmi.findmytutor.utils.ApproximatedLocalization; +import com.uam.wmi.findmytutor.utils.InfoHelperUtils; import com.uam.wmi.findmytutor.utils.ManualLocationUtils; import com.uam.wmi.findmytutor.utils.MapMarker; +import com.uam.wmi.findmytutor.utils.MapUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.RestApiHelper; import com.uam.wmi.findmytutor.utils.SharingLevel; -import com.uam.wmi.findmytutor.utils.MapUtils; import java.util.ArrayList; import java.util.HashMap; @@ -72,6 +73,8 @@ import io.reactivex.schedulers.Schedulers; import okhttp3.ResponseBody; import timber.log.Timber; +import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; + public class MapActivity extends BaseActivity implements PermissionsListener, OnMapReadyCallback { @@ -103,6 +106,7 @@ public class MapActivity extends BaseActivity private String myId; private boolean isTutor; private ApproximatedLocalization approximatedLocalization; + private boolean shouldFetchNewCoords = true; @Override protected void onCreate(Bundle savedInstanceState) { @@ -118,7 +122,9 @@ public class MapActivity extends BaseActivity mStatusChecker = () -> { try { - fetchTopCoords(); + if (shouldFetchNewCoords) { + fetchTopCoords(); + } } finally { mHandler.postDelayed(mStatusChecker, mInterval); } @@ -348,7 +354,6 @@ public class MapActivity extends BaseActivity }); }); - alertDialog.show(); } @@ -394,7 +399,7 @@ public class MapActivity extends BaseActivity public void onSuccess(List coordsList) { if (tmpLocalMarker != null && coordsList.isEmpty()) { - Timber.e("200 empty []"); + Log.e("MapActivity", "200 empty []"); mapboxMap.clear(); } @@ -444,7 +449,7 @@ public class MapActivity extends BaseActivity } LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude()); -// TODO fix flickiering markers + ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position", new MapUtils.LatLngEvaluator(), marker.getPosition(), @@ -597,6 +602,7 @@ public class MapActivity extends BaseActivity public void onResume() { super.onResume(); mapView.onResume(); + shouldFetchNewCoords = true; } @Override @@ -609,12 +615,14 @@ public class MapActivity extends BaseActivity protected void onStop() { super.onStop(); mapView.onStop(); + shouldFetchNewCoords = false; } @Override public void onPause() { super.onPause(); mapView.onPause(); + shouldFetchNewCoords = false; } @Override @@ -745,4 +753,6 @@ public class MapActivity extends BaseActivity popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, location[0] + anchorView.getWidth(), location[1] + anchorView.getHeight()); } + + } \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java index 4430e89..c9cfa82 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/UsersListFragment.java @@ -15,6 +15,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; +import android.widget.Toast; import com.annimon.stream.Stream; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; @@ -27,6 +28,7 @@ import com.uam.wmi.findmytutor.model.User; import com.uam.wmi.findmytutor.network.ApiClient; import com.uam.wmi.findmytutor.service.TutorTabApi; import com.uam.wmi.findmytutor.service.UserService; +import com.uam.wmi.findmytutor.utils.InfoHelperUtils; import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration; import com.uam.wmi.findmytutor.utils.RecyclerTouchListener; import com.uam.wmi.findmytutor.utils.RestApiHelper; @@ -76,12 +78,19 @@ public class UsersListFragment extends Fragment { mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered); View view = inflater.inflate(R.layout.users_list, container, false); view.setBackgroundColor(getResources().getColor(android.R.color.white)); + return view; } public void onViewCreated(View view, Bundle savedInstanceState) { ButterKnife.bind(this, view); + // TODO: Merge with code from home + InfoHelperUtils infoHelperUtils = new InfoHelperUtils(); + view.findViewById(R.id.userListInfoImageButton).setOnClickListener(v -> + infoHelperUtils.infoDialogUserList(getActivity(), v) + ); + userService = ApiClient.getClient(getApplicationContext()) .create(UserService.class); @@ -151,11 +160,11 @@ public class UsersListFragment extends Fragment { List dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours()) .map(DutyHourViewModel::getSummary).toList(); - if(dutyHoursList.isEmpty()){ + if (dutyHoursList.isEmpty()) { dutyHoursList.add(getString(R.string.lack_duty_hours)); } - if(tutorTabViewModel.getNote().isEmpty()){ + if (tutorTabViewModel.getNote().isEmpty()) { userNoteText = getString(R.string.lack_note); } @@ -225,7 +234,7 @@ public class UsersListFragment extends Fragment { private int sortByUserName(User t1, User t2) { - return plCollator.compare(t1.getLastName(),t2.getLastName()); + return plCollator.compare(t1.getLastName(), t2.getLastName()); } private void showError(Throwable e) { @@ -234,7 +243,7 @@ public class UsersListFragment extends Fragment { if (e instanceof HttpException) { ResponseBody responseBody = ((HttpException) e).response().errorBody(); message = RestApiHelper.getErrorMessage(responseBody); - }else{ + } else { message = "Network Error !"; } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java index 9fc2acf..4d598ff 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java @@ -3,7 +3,9 @@ package com.uam.wmi.findmytutor.model; import android.util.Range; import com.google.gson.annotations.SerializedName; +import com.uam.wmi.findmytutor.utils.Const; +import java.util.List; import java.util.Objects; import java.util.UUID; @@ -14,8 +16,9 @@ import io.swagger.annotations.ApiModelProperty; */ public class Coordinate extends BaseResponse { - Range latitudeRange = Range.create(52.46598, 52.467545); - Range longtitudeRange = Range.create(16.926099, 16.927794); + private Range latitudeRange = Const.latitudeRange; + private Range longtitudeRange = Const.longitudeRange; + private List allowedApproximatedLocations = Const.validApproximatedLocations; @SerializedName("coordinateId") private UUID coordinateId = null; @@ -47,7 +50,7 @@ public class Coordinate extends BaseResponse { public Coordinate (Double latitude, Double longitude, Double altitude, String approximatedLocation, String label, String userId, String displayMode) { if (!latitudeRange.contains(latitude)) throw new IllegalArgumentException("Inappropriate latitude value" + latitude); if (!longtitudeRange.contains(longitude)) throw new IllegalArgumentException("Inappropriate longitude value" + longitude); - //if (approximatedLocation == null) throw new IllegalArgumentException("Inappropriate approximatedLocation"); + if (!allowedApproximatedLocations.contains(approximatedLocation)) throw new IllegalArgumentException("Inappropriate approximatedLocation"); this.latitude = latitude; this.longitude = longitude; 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 810661c..715473e 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 @@ -16,13 +16,13 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.os.HandlerThread; import android.os.IBinder; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v4.app.NotificationCompat; import android.util.Log; +import com.annimon.stream.Stream; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; @@ -31,25 +31,28 @@ 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.MapUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.RestApiHelper; import com.uam.wmi.findmytutor.utils.SharingLevel; -import com.uam.wmi.findmytutor.utils.MapUtils; + +import org.apache.commons.collections4.queue.CircularFifoQueue; import java.util.ArrayList; import java.util.List; import java.util.TimerTask; +import java.util.concurrent.atomic.AtomicReference; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.observers.DisposableSingleObserver; import io.reactivex.schedulers.Schedulers; import okhttp3.ResponseBody; -import timber.log.Timber; -import static com.uam.wmi.findmytutor.utils.Consts.presenceApproximatedName; -import static com.uam.wmi.findmytutor.utils.Consts.presenceLatitude; -import static com.uam.wmi.findmytutor.utils.Consts.presenceLongitude; +import static com.uam.wmi.findmytutor.utils.Const.defaultBackgroundLocationInterval; +import static com.uam.wmi.findmytutor.utils.Const.presenceApproximatedName; +import static com.uam.wmi.findmytutor.utils.Const.presenceLatitude; +import static com.uam.wmi.findmytutor.utils.Const.presenceLongitude; import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus; public class BackgroundLocalizationService extends Service { @@ -57,21 +60,20 @@ public class BackgroundLocalizationService extends Service { private static final String TAG = "MyLocationService"; private static final int LOCATION_INTERVAL = 1000; private static final float LOCATION_DISTANCE = 5f; - public static String str_receiver = "background.location.broadcast"; - private static long notify_interval = 10000; - Location mLastLocation; - Boolean stopService = false; - Intent intent; - ArrayList providers = new ArrayList(); - LocationListener[] mLocationListeners; - + private static long notify_interval = defaultBackgroundLocationInterval; + private static long notify_interval_inside_building = defaultBackgroundLocationInterval; + private static long notify_interval_outside_building = 360000; + private static int coordinatesHistoryLength = 10; + private Location mLastLocation; + private Boolean stopService = false; + private ArrayList providers = new ArrayList(); + private LocationListener[] mLocationListeners; + private CircularFifoQueue coordinatesHistory = new CircularFifoQueue(coordinatesHistoryLength); private LocationManager mLocationManager = null; private Handler mHandler = new Handler(); - private HandlerThread mHandlerThread = null; private Runnable mStatusChecker; private FusedLocationProviderClient mFusedLocationClient; - public BackgroundLocalizationService() { providers.add(LocationManager.GPS_PROVIDER); providers.add(LocationManager.NETWORK_PROVIDER); @@ -82,7 +84,6 @@ public class BackgroundLocalizationService extends Service { new LocationListener(LocationManager.NETWORK_PROVIDER), new LocationListener(LocationManager.PASSIVE_PROVIDER) }; - } @Override @@ -146,27 +147,39 @@ public class BackgroundLocalizationService extends Service { } if (!stopService) { - - mStatusChecker = () -> { try { fn_getlocation(); + changeBackgroundMode(); } finally { mHandler.postDelayed(mStatusChecker, notify_interval); } }; AsyncTask.execute(mStatusChecker); - } + } + private void changeBackgroundMode() { + if (coordinatesHistory.size() > 4) { + Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory) + .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); + Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory). + map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1); + + if (shouldExtendTimeInterval) { + notify_interval = notify_interval_outside_building; + } else if (shouldAbbreviateTimeInterval) { + notify_interval = notify_interval_inside_building; + } + } } @RequiresApi(api = Build.VERSION_CODES.O) private void startMyOwnForeground() { - String NOTIFICATION_CHANNEL_ID = "com.example.simpleapp"; + String NOTIFICATION_CHANNEL_ID = "com.example.fmt"; String channelName = "My Background Service"; NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE); chan.setLightColor(Color.BLUE); @@ -198,29 +211,35 @@ public class BackgroundLocalizationService extends Service { List providers1 = mLocationManager.getProviders(true); Location bestLocation = null; - - - for (String provider : providers1) { - Location location = mLocationManager.getLastKnownLocation(provider); - - if (location == null) { - continue; - } - if (bestLocation == null || location.getAccuracy() < bestLocation.getAccuracy()) { - bestLocation = location; - } - - } - - Log.e("Best localization:", String.valueOf(bestLocation)); + AtomicReference triggerAnotherLocationListener = new AtomicReference<>(false); mFusedLocationClient.getLastLocation().addOnSuccessListener( location -> { if (location != null) { mLastLocation = location; + coordinatesHistory.add(location); fn_update(location); } + + triggerAnotherLocationListener.set(true); }); + + if (triggerAnotherLocationListener.get()) { + for (String provider : providers1) { + Location location = mLocationManager.getLastKnownLocation(provider); + + if (location == null) { + continue; + } + if (bestLocation == null || location.getAccuracy() < bestLocation.getAccuracy()) { + bestLocation = location; + } + } + + coordinatesHistory.add(bestLocation); + Log.e("Best localization:", String.valueOf(bestLocation)); + } + } private void fn_update(Location location) { @@ -241,7 +260,6 @@ public class BackgroundLocalizationService extends Service { return; } mLocationManager.removeUpdates(listener); - Log.i(TAG, "Removed"); } catch (Exception ex) { Log.i(TAG, "fail to remove location listener, ignore", ex); @@ -257,14 +275,7 @@ public class BackgroundLocalizationService extends Service { mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE); } } - - private class TimerTaskToGetLocation extends TimerTask { - @Override - public void run() { - mHandler.post(BackgroundLocalizationService.this::fn_getlocation); - } - } - + private class LocationListener implements android.location.LocationListener { public LocationListener(String provider) { @@ -344,9 +355,6 @@ public class BackgroundLocalizationService extends Service { locationLevel ); - Log.e(TAG, String.valueOf(coordinate)); - - disposable.add( coordinateService .postCoordinate(coordinate) @@ -362,17 +370,11 @@ public class BackgroundLocalizationService extends Service { @SuppressLint("LongLogTag") @Override public void onError(Throwable e) { - Log.e("CoordinateService onError", e.getMessage()); - - if (e instanceof HttpException) { - ResponseBody responseBody = ((HttpException) e).response().errorBody(); - Log.e("CoordinateService onError", RestApiHelper.getErrorMessage(responseBody)); - } } })); } catch (IllegalArgumentException e) { - Log.e(TAG,e.toString()); + Log.e(TAG, e.toString()); } return null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/FeedbackService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/FeedbackService.java index 6461a19..c5b318b 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/FeedbackService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/FeedbackService.java @@ -10,7 +10,7 @@ import retrofit2.http.POST; public interface FeedbackService { @POST("api/Feedback") - Observable postFeedback(@Body Feedback feedback); + Observable> postFeedback(@Body Feedback feedback); @GET("api/Feedback") Observable getFeedback(); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/ApproximatedLocalization.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/ApproximatedLocalization.java index 4a42bf3..83f26fc 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/ApproximatedLocalization.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/ApproximatedLocalization.java @@ -48,7 +48,7 @@ public class ApproximatedLocalization { return Objects.requireNonNull(Objects.requireNonNull(feature.getStringProperty("name"))); } - return null; + return Const.presenceApproximatedName; } public List getMiddlePointOfBuildingPart(String buildingPart) { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java new file mode 100644 index 0000000..fa92616 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java @@ -0,0 +1,18 @@ +package com.uam.wmi.findmytutor.utils; + +import android.util.Range; + +import java.util.Arrays; +import java.util.List; + +public class Const { + public final static Integer defaultBackgroundLocationInterval = 15000; + public final static Integer defaultMapZoom = 17; + public final static Integer searchMapZoom = 13; + public final static Double presenceLatitude = 52.466365; + public final static Double presenceLongitude = 16.926792; + public final static String presenceApproximatedName = "Unknown"; + public final static Range latitudeRange = Range.create(52.466092, 52.467529); + public final static Range longitudeRange = Range.create(16.926159, 16.927759); + public final static List validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown"); +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/Consts.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/Consts.java deleted file mode 100644 index f866a7f..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/Consts.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.uam.wmi.findmytutor.utils; - -import android.util.Range; - -public class Consts { - public final static Integer deafultMapZoom = 17; - public final static Integer searchMapZoom = 13; - public final static Double presenceLatitude = 52.466365; - public final static Double presenceLongitude = 16.926792; - public final static String presenceApproximatedName = "Unknown"; - public final static Range latitudeRange = Range.create(52.466709, 52.467007); - public final static Range longtitudeRange = Range.create(16.926159, 16.926976); -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/FeedbackUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/FeedbackUtils.java index 17021d3..26f2031 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/FeedbackUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/FeedbackUtils.java @@ -82,10 +82,9 @@ public class FeedbackUtils { try { appVersion = activityContext.getPackageManager().getPackageInfo(activityContext.getPackageName(), 0).versionName; if( !mode ){ - body = PrefUtils.getUserFirstName(activityContext) + " " + PrefUtils.getUserLastName(activityContext) + "\n" + body; userFeedback = new Feedback(mode, header, - PrefUtils.getUserId(activityContext), + PrefUtils.getUserFirstName(activityContext) + " " + PrefUtils.getUserLastName(activityContext) + " | " + PrefUtils.getUserId(activityContext), "Android "+ Build.VERSION.RELEASE, appVersion, Build.MODEL, @@ -113,8 +112,10 @@ public class FeedbackUtils { .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::handleResponse, this::handleError)); } - private void handleResponse( Void resp) { + private void handleResponse( Response resp) { Toast.makeText(activityContext, activityContext.getString(R.string.modal_feedback_thankyou), Toast.LENGTH_SHORT).show(); + Log.d("FEEDBACK toast","gdzie jest mój tost"); + } private void handleError(Throwable error) { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java new file mode 100644 index 0000000..0ccf9dd --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/InfoHelperUtils.java @@ -0,0 +1,28 @@ +package com.uam.wmi.findmytutor.utils; + +import android.app.Activity; +import android.content.Context; +import android.support.v7.app.AlertDialog; +import android.view.LayoutInflater; +import android.view.View; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.PopupWindow; +import android.widget.Toast; + + +import com.uam.wmi.findmytutor.R; + +import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; + +public class InfoHelperUtils { + + + public static void infoDialogUserList(Activity activity, View anchorView ) { + + View popupView = LayoutInflater.from(activity).inflate(R.layout.feedback_modal, null); + final PopupWindow popupWindow = new PopupWindow(popupView, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); + popupWindow.showAsDropDown(popupView); + Toast.makeText(getApplicationContext(), anchorView.getId() + "", Toast.LENGTH_SHORT).show(); + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java index 6de0208..abb59f4 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/ManualLocationUtils.java @@ -44,8 +44,6 @@ public class ManualLocationUtils { activityContext = context; } - - private void handleError(Throwable error) { if (error instanceof HttpException) { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/MapUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/MapUtils.java index c75b338..b63cf5f 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/MapUtils.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/MapUtils.java @@ -2,30 +2,20 @@ package com.uam.wmi.findmytutor.utils; import android.animation.TypeEvaluator; import android.content.Context; -import android.graphics.Color; import android.location.Location; -import android.view.Gravity; -import android.view.View; -import android.widget.FrameLayout; -import android.content.res.AssetManager; -import com.mapbox.mapboxsdk.annotations.Polygon; -import com.mapbox.mapboxsdk.annotations.PolygonOptions; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; 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 com.uam.wmi.findmytutor.model.Coordinate; import java.io.IOException; import java.io.InputStream; -import static com.uam.wmi.findmytutor.utils.Consts.latitudeRange; -import static com.uam.wmi.findmytutor.utils.Consts.longtitudeRange; +import static com.uam.wmi.findmytutor.utils.Const.latitudeRange; +import static com.uam.wmi.findmytutor.utils.Const.longitudeRange; public class MapUtils { @@ -85,7 +75,7 @@ public class MapUtils { } public static Boolean checkIfCoordinateIsValid(Location coordinate){ - return (!latitudeRange.contains(coordinate.getLatitude()) && !longtitudeRange.contains(coordinate.getLongitude())); + return latitudeRange.contains(coordinate.getLatitude()) && longitudeRange.contains(coordinate.getLongitude()); } // Function for marker animation diff --git a/app/src/main/res/layout/users_list.xml b/app/src/main/res/layout/users_list.xml index 397f01e..e87d8be 100644 --- a/app/src/main/res/layout/users_list.xml +++ b/app/src/main/res/layout/users_list.xml @@ -1,15 +1,22 @@ - + + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 3a53422..02ee2e0 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -175,6 +175,44 @@ lokalizacja dokładna (udostępniana z GPS telefonu) lokalizacja przybliżona lokalizacja manualna (wybrana ręcznie) + + Na mapie wyświetlane są markery reprezentujące profesorów udostępniających w tej chwili swoją lokalizację. + + + W tym panelu możesz dodać użytkowników do swojej czarnej listy. Użytkownicy z czarnej listy nie będą widzieć żadnych danych które udostępniasz - lokalizacji, twojego statusu online, czy informacji o obecności. + Jedyną informacją która wciąż będzie udostępniana wszystkim jest notka w Twoim profilu. + Za pomocą powyższego przycisku możesz włączyć lub wyłączyć używanie czarnej listy. Czarna lista nie może być aktywna jednocześnie z białą listą. + + + W tym panelu możesz dodać użytkowników do swojej białej listy. Użytkownicy SPOZA listy nie będą widzieć żadnych danych które udostępniasz - lokalizacji, twojego statusu online, czy informacji o obecności. + Jedyną informacją która wciąż będzie udostępniana wszystkim jest notka w Twoim profilu. + Za pomocą powyższego przycisku możesz włączyć lub wyłączyć używanie białej listy. Biała lista nie może być aktywna jednocześnie z czarną listą. + + + W tej zakładce możesz edytować swój profil widoczny dla wszystkich użytkowników. + Jeśli zakładka jest pusta lub zawiera nieaktualne dane, możesz je ręcznie uaktualnić. + W każdej chwili możesz przywrócić dane ze strony WMI za pomocą przycisku (jeśli są dostępne na stronie). + Dodatkowo możesz uzupełnić notkę, aby przekazać jakąś informację widoczną dla wszystkich studentów: np. “dzisiejszy dyżur odwołany” itp. + + + W tej zakładce możesz włączyć/wyłączyć udostępnianie swojej lokalizacji oraz ją skonfigurować. + Niektóre zmiany mogą nie być widoczne od razu! Odświeżanie informacji zajmuje do 2 minut. + Udostępniać możesz na jednym z 4 poziomów: + - dokładny - lokalizacja wyświetlana na mapie na podstawie GPS + - przybliżony - przybliżona lokalizacja wyświetlana na podstawie GPS + - manualny - udostępnianie z ręcznie wybranego punktu na mapie + - tylko obecność - udostępnianie jedynie informacji o pojawieniu się na wydziale (aktywny na liście), bez udostępniania lokalizacji + Każdy poziom z wyjątkiem manualnie wybranej lokalizacji automatycznie zaczyna udostępniać po wejściu na wydział i przestaje udostępniać po jego opuszczeniu. Wystarczy włączyć udostępnianie, a lokalizacja nie będzie udostępniana tylko przy obecności na wydziale. + Udostępnianie w dowolnym momencie można wyłączyć za pomocą przełącznika. + Dodatkowo, do Twojej lokalizacji możesz dodać status opisowy (będzie on widoczny dla użytkowników po kliknięciu w marker). + Zarówno manualne lokalizacje jak i statusy możesz dodać do listy, które potem możesz wybrać w wygodny sposób. + + + W tym panelu znajduje się listę profesorów. Ich status symbolizowany jest przez kolorowe kropki: + GREEN dot - użytkownik jest obecnie online + RED dot - użytkownik jest obecnie offline + BLACK dot - użytkownik jest nieaktywny (nie udostępnił żadnych danych o lokalizacji od conajmniej tygodnia). + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d61cfc0..fb32743 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -251,4 +251,42 @@ manual localization (manually picked) + + There are markers on the map which represent tutors sharing their location at the very moment. + + + In this panel you can add users to your blacklist. Users from the blacklist can’t see any data that you share - localization, online status, or information about presence. + The only thing which remains public is the note in your profile. + With the switch you can turn on/off usage of the blacklist. Blacklist and whitelist cannot be active at the same time. + + + In this panel you can add users to your whitelist. Users OUT OF the whitelist can’t see any data that you share - localization, online status, or information about presence. + The only thing which remains public is the note in your profile. + With the switch you can turn on/off usage of the whitelist. Blacklist and whitelist cannot be active at the same time. + + + In this tab you can edit you profile visible for all the users. + If the tab is empty or contains outdated information, you can update them manually. + Any time you can restore data from the WMI website with the button (if the data is available). + Additionally, you can fill your note, to share a message visible for all the users: for example “today’s duty hours are cancelled” etc. + + + In this tab you can turn on/off sharing your localization and configure it. + Some of the changes may not happen immediately! Refreshing information takes up to 2 minutes. + You can share your localization on one of the 4 levels: + - exact - localization displayed on a map, based on GPS + - approximated - approximated localization based on GPS + - manual - sharing from manually picked point + - presence only - sharing only information whether you are present on the faculty or not, without sharing your localization + Each level, except from manual, will be automatically turned on when entering, and turn off when leaving the faculty. You only need to make sure that sharing is on, and the localization will be shared only when on the faculty. + Sharing can be turned off at any time with the switch. + Additionally, you can add descriptive status to your localization (visible for users after clicking on a marker). + Both manual localizations and statuses can be added to a list, and then used them in a convenient way. + + + This panel contains the list of tutors. Their status is represented by colorful dots: + GREEN dot - user is currently online + RED dot - user is currently offline + BLACK dot - user is inactive (didn’t share any localization data since 7 days) +