Merge branch 'showOnMap' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
5db5d2f8e0
@ -389,11 +389,14 @@ public abstract class BaseActivity
|
||||
if (itemId == R.id.nav_map) {
|
||||
removeFragment(sharingFragment);
|
||||
removeFragment(userListFragment);
|
||||
activeFragment = ActiveFragment.NONE;
|
||||
activeFragment = ActiveFragment.NONE;
|
||||
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
|
||||
} else if (itemId == R.id.nav_profile) {
|
||||
loadUserSettingsFragment();
|
||||
findViewById(R.id.action_search).setVisibility(View.GONE);
|
||||
} else if (itemId == R.id.nav_user_list) {
|
||||
loadUserListFragment();
|
||||
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
|
||||
}
|
||||
selectBottomNavigationBarItem(itemId);
|
||||
}, 300);
|
||||
|
@ -93,7 +93,7 @@ public class MapActivity extends BaseActivity
|
||||
private Coordinate droppedMarkercoordinate;
|
||||
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
|
||||
private HashMap<String, MapMarker> markerHash = new HashMap<>();
|
||||
private HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||
public HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||
private Set<String> previousCoordsIds = new HashSet<>();
|
||||
private ManualLocationUtils manualLocationUtils;
|
||||
// Camera Animation params
|
||||
@ -710,7 +710,7 @@ public class MapActivity extends BaseActivity
|
||||
}));
|
||||
}
|
||||
|
||||
private void filterMarkers(List<User> users) {
|
||||
public void filterMarkers(List<User> users) {
|
||||
restoreMapMarkers();
|
||||
|
||||
Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
@ -9,6 +11,10 @@ import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@ -18,6 +24,8 @@ 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;
|
||||
|
||||
@ -25,7 +33,6 @@ import com.annimon.stream.Stream;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
|
||||
|
||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
||||
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
@ -63,6 +70,7 @@ public class UsersListFragment extends Fragment {
|
||||
@BindView(R.id.txt_empty_notes_view)
|
||||
TextView noNotesView;
|
||||
|
||||
private SearchView searchView;
|
||||
private UserService userService;
|
||||
private TutorTabApi tutorTabService;
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
@ -120,14 +128,12 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
try {
|
||||
menu.findItem(R.id.showOnlineUsersOnly).setChecked(fetchOnlyOnlineUsers);
|
||||
}
|
||||
catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onPrepareOptionsMenu error");
|
||||
}
|
||||
}
|
||||
@ -135,13 +141,13 @@ public class UsersListFragment extends Fragment {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
//item.setChecked(fetchOnlyOnlineUsers);
|
||||
switch (item.getItemId()){
|
||||
switch (item.getItemId()) {
|
||||
case R.id.showOnlineUsersOnly:
|
||||
|
||||
if(item.isChecked()) {
|
||||
if (item.isChecked()) {
|
||||
fetchOnlyOnlineUsers = false;
|
||||
item.setChecked(false);
|
||||
}else{
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
fetchOnlyOnlineUsers = true;
|
||||
}
|
||||
@ -158,7 +164,11 @@ public class UsersListFragment extends Fragment {
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.users_list_menu, menu);
|
||||
menu.getItem(0).setChecked(fetchOnlyOnlineUsers);
|
||||
super.onCreateOptionsMenu(menu,inflater);
|
||||
|
||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
||||
searchView = (SearchView) myActionMenuItem.getActionView();
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
public void searchUser(String textToSearch) {
|
||||
@ -176,6 +186,7 @@ public class UsersListFragment extends Fragment {
|
||||
// User cancelled the dialog
|
||||
});
|
||||
|
||||
|
||||
TextView userName = view.findViewById(R.id.userName);
|
||||
ListView userDutyHours = view.findViewById(R.id.userDutyHours);
|
||||
TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle);
|
||||
@ -184,8 +195,26 @@ public class UsersListFragment extends Fragment {
|
||||
TextView userEmail = view.findViewById(R.id.userEmail);
|
||||
TextView department = view.findViewById(R.id.userDepartment);
|
||||
|
||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||
|
||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||
Drawable image;
|
||||
if (user.isIsOnline()) {
|
||||
image = this.getResources().getDrawable(R.drawable.user_list_online);
|
||||
} else {
|
||||
image = this.getResources().getDrawable(R.drawable.user_list_offline);
|
||||
}
|
||||
|
||||
if (!user.isIsActive()) {
|
||||
image = this.getResources().getDrawable(R.drawable.user_list_off);
|
||||
}
|
||||
|
||||
Spannable span = new SpannableString(" " + userName.getText()); // or set your text manually
|
||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||
ImageSpan imageSpan = new ImageSpan(image);
|
||||
span.setSpan(imageSpan, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
userName.setText(span);
|
||||
|
||||
UsersListFragment usersListFragment = this;
|
||||
disposable.add(
|
||||
tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -193,7 +222,20 @@ public class UsersListFragment extends Fragment {
|
||||
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
||||
@Override
|
||||
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
final AlertDialog alertDialog;
|
||||
if (((MapActivity) getActivity()).markerUserHash.containsValue(user.getId())) {
|
||||
alertDialogBuilderUserInput.setPositiveButton(R.string.show_on_map, (dialog, id) -> {
|
||||
// User cancelled the dialog
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(usersListFragment);
|
||||
fragmentTransaction.commit();
|
||||
List<User> list = new ArrayList<User>();
|
||||
list.add(user);
|
||||
((MapActivity) getActivity()).filterMarkers(list);
|
||||
});
|
||||
}
|
||||
alertDialog = alertDialogBuilderUserInput.create();
|
||||
|
||||
String userNoteText = tutorTabViewModel.getNote();
|
||||
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
|
||||
.map(DutyHourViewModel::getSummary).toList();
|
||||
@ -276,7 +318,7 @@ public class UsersListFragment extends Fragment {
|
||||
|
||||
private void searchTutorInBackend(String searchString) {
|
||||
disposable.add(
|
||||
userService.searchUser(searchString)
|
||||
userService.searchUser(searchString)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||
@ -295,7 +337,7 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
|
||||
public void restoreUsersList(){
|
||||
public void restoreUsersList() {
|
||||
fetchAllTutors();
|
||||
}
|
||||
|
||||
@ -331,10 +373,10 @@ public class UsersListFragment extends Fragment {
|
||||
createSnackbar(message);
|
||||
}
|
||||
|
||||
private void createSnackbar(String msg){
|
||||
private void createSnackbar(String msg) {
|
||||
Snackbar snackbar = Snackbar.make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);
|
||||
View view = snackbar.getView();
|
||||
CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams();
|
||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
||||
params.gravity = Gravity.TOP;
|
||||
view.setLayoutParams(params);
|
||||
snackbar.show();
|
||||
@ -345,9 +387,9 @@ public class UsersListFragment extends Fragment {
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
} else {
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
if(fetchOnlyOnlineUsers)
|
||||
if (fetchOnlyOnlineUsers)
|
||||
noNotesView.setText(R.string.no_online_users);
|
||||
else{
|
||||
else {
|
||||
noNotesView.setText(R.string.no_offline_users);
|
||||
}
|
||||
}
|
||||
|
15
app/src/main/res/drawable/trip_orgin.xml
Normal file
15
app/src/main/res/drawable/trip_orgin.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:pathData="M0 0h24v24H0z" />
|
||||
<path
|
||||
android:fillColor="#FFFF"
|
||||
android:pathData="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z" />
|
||||
<path
|
||||
android:pathData="M0 0h24v24H0z" />
|
||||
</vector>
|
@ -27,17 +27,19 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal"
|
||||
android:drawablePadding="10dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -158,25 +160,25 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="20dp">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="20dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_note"/>
|
||||
<TextView
|
||||
android:id="@+id/userNote"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
android:paddingLeft="10dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_note"/>
|
||||
<TextView
|
||||
android:id="@+id/userNote"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
android:paddingLeft="10dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -265,6 +265,10 @@
|
||||
<string name="network_err">Błąd sieci!</string>
|
||||
<string name="search_null">Brak wyników!</string>
|
||||
<string name="modal_manual_hint">Nadaj nazwę tej lokalizacji.</string>
|
||||
<string name="online">Dostępny</string>
|
||||
<string name="offline">Niedostępny</string>
|
||||
<string name="inactive">Nieaktywny</string>
|
||||
<string name="show_on_map">POKAŻ NA MAPIE</string>
|
||||
|
||||
</resources>
|
||||
|
||||
|
@ -436,5 +436,9 @@
|
||||
<string name="network_err">Network Error !</string>
|
||||
<string name="search_null">Search response is empty!</string>
|
||||
<string name="modal_manual_hint">Insert a name for this localization.</string>
|
||||
<string name="online">Online</string>
|
||||
<string name="offline">Offline</string>
|
||||
<string name="inactive">Inactive</string>
|
||||
<string name="show_on_map">SHOW ON MAP</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user