Merge branch 'change-user-list' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
c188ce38a8
@ -10,7 +10,7 @@ android {
|
||||
applicationId "com.uam.wmi.findmytutor"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 27
|
||||
versionCode 52
|
||||
versionCode 53
|
||||
versionName "1.0.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
@ -80,9 +80,9 @@ public abstract class BaseActivity
|
||||
private SharingFragment sharingFragment;
|
||||
|
||||
private Fragment userListFragment;
|
||||
private ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||
public ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||
private Fragment activeBottomMenu = null;
|
||||
private SearchView searchView;
|
||||
public SearchView searchView;
|
||||
public MenuItem infoMenuItem;
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
@ -45,12 +45,10 @@ import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
|
||||
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.EnableSharingDialog;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
||||
import com.uam.wmi.findmytutor.utils.ManualLocationUtils;
|
||||
import com.uam.wmi.findmytutor.utils.MapMarker;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
@ -76,12 +74,12 @@ import static com.uam.wmi.findmytutor.utils.Const.mapRefreshInterval;
|
||||
public class MapActivity extends BaseActivity
|
||||
implements PermissionsListener, OnMapReadyCallback {
|
||||
|
||||
public HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||
private String tag = getClass().getName();
|
||||
private PermissionsManager permissionsManager;
|
||||
private LocationComponent locationComponent;
|
||||
private CoordinateService coordinateService;
|
||||
private UserService userService;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private int mInterval = mapRefreshInterval;
|
||||
private Handler mHandler = new Handler();
|
||||
@ -94,7 +92,6 @@ public class MapActivity extends BaseActivity
|
||||
private Coordinate droppedMarkercoordinate;
|
||||
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
|
||||
private HashMap<String, MapMarker> markerHash = new HashMap<>();
|
||||
public HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||
private Set<String> previousCoordsIds = new HashSet<>();
|
||||
private ManualLocationUtils manualLocationUtils;
|
||||
// Camera Animation params
|
||||
@ -204,13 +201,25 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||
|
||||
if(cordStatus.equals("")){
|
||||
if (cordStatus.equals("")) {
|
||||
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), getString(R.string.lack_of_status)));
|
||||
}else{
|
||||
} else {
|
||||
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), cordStatus));
|
||||
}
|
||||
|
||||
sharingLevelView.setText(String.format("%s: %s", getResources().getString(R.string.settings_location_level), sharingLevel));
|
||||
String sharingLevelToRender = sharingLevel;
|
||||
|
||||
if (PrefUtils.getLocale(getApplicationContext()).equals("pl")) {
|
||||
if (sharingLevel.equals(SharingLevel.MANUAL.toString())) {
|
||||
sharingLevelToRender = getString(R.string.manual_mode);
|
||||
} else if (sharingLevel.equals(SharingLevel.EXACT.toString())) {
|
||||
sharingLevelToRender = getString(R.string.exact_mode);
|
||||
} else if (sharingLevel.equals(SharingLevel.APPROXIMATED.toString())) {
|
||||
sharingLevelToRender = getString(R.string.approx_mode);
|
||||
}
|
||||
}
|
||||
|
||||
sharingLevelView.setText(String.format("%s: %s", getResources().getString(R.string.settings_location_level), sharingLevelToRender));
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
alertDialog.show();
|
||||
@ -238,6 +247,7 @@ public class MapActivity extends BaseActivity
|
||||
mapboxMap.addOnMapClickListener(e -> {
|
||||
removeLocationButton.setVisibility(View.GONE);
|
||||
selectLocationButton.setVisibility(View.GONE);
|
||||
restoreMapMarkers();
|
||||
});
|
||||
}
|
||||
|
||||
@ -595,47 +605,6 @@ public class MapActivity extends BaseActivity
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
mHandler.removeCallbacks(mStatusChecker);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
@ -678,11 +647,13 @@ public class MapActivity extends BaseActivity
|
||||
@Override
|
||||
public void searchUser(String textToSearch) {
|
||||
getUserFromApi(textToSearch);
|
||||
|
||||
Log.e("LOCALE",LocaleUtils.getCurrentLocale());
|
||||
}
|
||||
|
||||
private void getUserFromApi(String userNameToSearch) {
|
||||
disposable.add(
|
||||
userService.getAllTutors()
|
||||
userService.getAllOnlineTutors()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(tutors -> Stream.of(tutors).filter(t ->
|
||||
@ -690,6 +661,7 @@ public class MapActivity extends BaseActivity
|
||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||
@Override
|
||||
public void onSuccess(List<User> users) {
|
||||
Log.e("USERS", String.valueOf(users));
|
||||
filterMarkers(users);
|
||||
}
|
||||
|
||||
@ -721,7 +693,7 @@ public class MapActivity extends BaseActivity
|
||||
}
|
||||
|
||||
public void restoreMapMarkers() {
|
||||
|
||||
try {
|
||||
for (Marker marker : mapboxMap.getMarkers()) {
|
||||
MapMarker markerMap = markerHash.get(markerUserHash.get(marker.getId()));
|
||||
|
||||
@ -730,10 +702,56 @@ public class MapActivity extends BaseActivity
|
||||
}
|
||||
|
||||
mapboxMap.getMarkerViewManager().update();
|
||||
} catch (Exception e) {
|
||||
Log.e("MAP", String.valueOf(e));
|
||||
}
|
||||
}
|
||||
|
||||
public void adjustMapToSearch(Integer zoom) {
|
||||
MapUtils.setZoom(mapboxMap, zoom);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
mHandler.removeCallbacks(mStatusChecker);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.TimePickerDialog;
|
||||
@ -11,11 +12,13 @@ import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class TimePickerFragment extends DialogFragment
|
||||
implements TimePickerDialog.OnTimeSetListener {
|
||||
private TextView textView;
|
||||
private String field;
|
||||
private DutyHourViewModel duty;
|
||||
@SuppressLint("ValidFragment")
|
||||
public TimePickerFragment(TextView view, DutyHourViewModel duty, String field){
|
||||
this.textView = view;
|
||||
this.duty=duty;
|
||||
|
@ -24,8 +24,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -39,6 +37,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.ActiveFragment;
|
||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||
@ -225,13 +224,16 @@ public class UsersListFragment extends Fragment {
|
||||
if (((MapActivity) getActivity()).markerUserHash.containsValue(user.getId())) {
|
||||
alertDialogBuilderUserInput.setPositiveButton(R.string.show_on_map, (dialog, id) -> {
|
||||
// User cancelled the dialog
|
||||
((MapActivity) getActivity()).activeFragment = ActiveFragment.NONE;
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(usersListFragment);
|
||||
fragmentTransaction.commit();
|
||||
List<User> list = new ArrayList<User>();
|
||||
((MapActivity) getActivity()).searchUser(user.getFirstName());
|
||||
|
||||
/* List<User> list = new ArrayList<User>();
|
||||
list.add(user);
|
||||
((MapActivity) getActivity()).filterMarkers(list);
|
||||
((MapActivity) getActivity()).updateNavigationBarState();
|
||||
((MapActivity) getActivity()).updateNavigationBarState();*/
|
||||
});
|
||||
}
|
||||
alertDialog = alertDialogBuilderUserInput.create();
|
||||
@ -273,27 +275,10 @@ public class UsersListFragment extends Fragment {
|
||||
disposable.add(
|
||||
(fetchOnlyOnlineUsers ?
|
||||
userService.getAllActiveTutors() :
|
||||
userService.getAllOfflineTutors())
|
||||
userService.getAllTutors())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(tutors -> {
|
||||
List<User> tutorsList = new ArrayList<>(tutors);
|
||||
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
|
||||
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
|
||||
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
|
||||
List<User> notActiveTutors = Stream.of(tutorsList)
|
||||
.filterNot(User::isIsActive).toList();
|
||||
|
||||
Collections.sort(onlineTutors, this::sortByUserName);
|
||||
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
|
||||
Collections.sort(notActiveTutors, this::sortByUserName);
|
||||
|
||||
List<User> sortedUserList = new ArrayList<>(onlineTutors);
|
||||
sortedUserList.addAll(activeNotOnlineTutors);
|
||||
sortedUserList.addAll(notActiveTutors);
|
||||
|
||||
return sortedUserList;
|
||||
})
|
||||
.map(this::mapUsersToSortedList)
|
||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||
@Override
|
||||
public void onSuccess(List<User> users) {
|
||||
@ -310,6 +295,24 @@ public class UsersListFragment extends Fragment {
|
||||
}));
|
||||
}
|
||||
|
||||
private List<User> mapUsersToSortedList(List<User> tutors) {
|
||||
List<User> tutorsList = new ArrayList<>(tutors);
|
||||
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
|
||||
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
|
||||
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
|
||||
List<User> notActiveTutors = Stream.of(tutorsList)
|
||||
.filterNot(User::isIsActive).toList();
|
||||
|
||||
Collections.sort(onlineTutors, this::sortByUserName);
|
||||
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
|
||||
Collections.sort(notActiveTutors, this::sortByUserName);
|
||||
|
||||
List<User> sortedUserList = new ArrayList<>(onlineTutors);
|
||||
sortedUserList.addAll(activeNotOnlineTutors);
|
||||
sortedUserList.addAll(notActiveTutors);
|
||||
|
||||
return sortedUserList;
|
||||
}
|
||||
|
||||
private void searchTutorInBackend(String searchString) {
|
||||
disposable.add(
|
||||
|
@ -1,16 +1,13 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
|
||||
import android.support.v7.widget.SearchView;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.subjects.PublishSubject;
|
||||
|
||||
|
||||
public class RxSearchObservable {
|
||||
|
||||
private RxSearchObservable() {
|
||||
// no instance
|
||||
}
|
||||
|
||||
public static Observable<String> fromView(SearchView searchView) {
|
||||
@ -30,13 +27,8 @@ public class RxSearchObservable {
|
||||
subject.onNext(text);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return subject;
|
||||
}
|
||||
}
|
||||
|
@ -441,6 +441,9 @@
|
||||
"For example, position the FAB to one side of stream of a cards so the FAB won’t interfere "
|
||||
"when a user tries to pick up one of cards.\n\n"
|
||||
</string>
|
||||
<string name="manual_mode">manualny</string>
|
||||
<string name="exact_mode">dokładny</string>
|
||||
<string name="approx_mode">przybliżony</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user