online indicator and show on map button in tutor modal #124

Merged
s411201 merged 1 commits from showOnMap into develop 2019-01-04 14:03:57 +01:00
7 changed files with 118 additions and 48 deletions

View File

@ -390,10 +390,13 @@ public abstract class BaseActivity
removeFragment(sharingFragment); removeFragment(sharingFragment);
removeFragment(userListFragment); removeFragment(userListFragment);
activeFragment = ActiveFragment.NONE; activeFragment = ActiveFragment.NONE;
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
} else if (itemId == R.id.nav_profile) { } else if (itemId == R.id.nav_profile) {
loadUserSettingsFragment(); loadUserSettingsFragment();
findViewById(R.id.action_search).setVisibility(View.GONE);
} else if (itemId == R.id.nav_user_list) { } else if (itemId == R.id.nav_user_list) {
loadUserListFragment(); loadUserListFragment();
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
} }
selectBottomNavigationBarItem(itemId); selectBottomNavigationBarItem(itemId);
}, 300); }, 300);

View File

@ -91,7 +91,7 @@ public class MapActivity extends BaseActivity
private Coordinate droppedMarkercoordinate; private Coordinate droppedMarkercoordinate;
private HashMap<String, Coordinate> coordsMap = new HashMap<>(); private HashMap<String, Coordinate> coordsMap = new HashMap<>();
private HashMap<String, MapMarker> markerHash = 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 Set<String> previousCoordsIds = new HashSet<>();
private ManualLocationUtils manualLocationUtils; private ManualLocationUtils manualLocationUtils;
// Camera Animation params // Camera Animation params
@ -708,7 +708,7 @@ public class MapActivity extends BaseActivity
})); }));
} }
private void filterMarkers(List<User> users) { public void filterMarkers(List<User> users) {
restoreMapMarkers(); restoreMapMarkers();
Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker); Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker);

View File

@ -1,6 +1,8 @@
package com.uam.wmi.findmytutor.activity; package com.uam.wmi.findmytutor.activity;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout; 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.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; 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.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -18,6 +24,8 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -25,7 +33,6 @@ import com.annimon.stream.Stream;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter; import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
import com.uam.wmi.findmytutor.model.DutyHourViewModel; import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import com.uam.wmi.findmytutor.model.TutorTabViewModel; import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import com.uam.wmi.findmytutor.model.User; import com.uam.wmi.findmytutor.model.User;
@ -63,6 +70,7 @@ public class UsersListFragment extends Fragment {
@BindView(R.id.txt_empty_notes_view) @BindView(R.id.txt_empty_notes_view)
TextView noNotesView; TextView noNotesView;
private SearchView searchView;
private UserService userService; private UserService userService;
private TutorTabApi tutorTabService; private TutorTabApi tutorTabService;
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -120,14 +128,12 @@ public class UsersListFragment extends Fragment {
} }
@Override @Override
public void onPrepareOptionsMenu(Menu menu) { public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
try { try {
menu.findItem(R.id.showOnlineUsersOnly).setChecked(fetchOnlyOnlineUsers); menu.findItem(R.id.showOnlineUsersOnly).setChecked(fetchOnlyOnlineUsers);
} } catch (Exception e) {
catch(Exception e) {
Log.e(TAG, "onPrepareOptionsMenu error"); Log.e(TAG, "onPrepareOptionsMenu error");
} }
} }
@ -158,6 +164,10 @@ public class UsersListFragment extends Fragment {
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.users_list_menu, menu); inflater.inflate(R.menu.users_list_menu, menu);
menu.getItem(0).setChecked(fetchOnlyOnlineUsers); menu.getItem(0).setChecked(fetchOnlyOnlineUsers);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) myActionMenuItem.getActionView();
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
} }
@ -176,6 +186,7 @@ public class UsersListFragment extends Fragment {
// User cancelled the dialog // User cancelled the dialog
}); });
TextView userName = view.findViewById(R.id.userName); TextView userName = view.findViewById(R.id.userName);
ListView userDutyHours = view.findViewById(R.id.userDutyHours); ListView userDutyHours = view.findViewById(R.id.userDutyHours);
TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle); TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle);
@ -184,8 +195,26 @@ public class UsersListFragment extends Fragment {
TextView userEmail = view.findViewById(R.id.userEmail); TextView userEmail = view.findViewById(R.id.userEmail);
TextView department = view.findViewById(R.id.userDepartment); 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( disposable.add(
tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId()) tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
@ -193,7 +222,20 @@ public class UsersListFragment extends Fragment {
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() { .subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
@Override @Override
public void onSuccess(TutorTabViewModel tutorTabViewModel) { 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(); String userNoteText = tutorTabViewModel.getNote();
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours()) List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
.map(DutyHourViewModel::getSummary).toList(); .map(DutyHourViewModel::getSummary).toList();

View 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>

View File

@ -27,6 +27,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/userName" android:id="@+id/userName"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -36,6 +37,7 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/lbl_new_note_title" android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal" android:textStyle="normal"
android:drawablePadding="10dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/> app:layout_constraintStart_toStartOf="parent"/>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -265,6 +265,10 @@
<string name="network_err">Błąd sieci!</string> <string name="network_err">Błąd sieci!</string>
<string name="search_null">Brak wyników!</string> <string name="search_null">Brak wyników!</string>
<string name="modal_manual_hint">Nadaj nazwę tej lokalizacji.</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> </resources>

View File

@ -436,5 +436,9 @@
<string name="network_err">Network Error !</string> <string name="network_err">Network Error !</string>
<string name="search_null">Search response is empty!</string> <string name="search_null">Search response is empty!</string>
<string name="modal_manual_hint">Insert a name for this localization.</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> </resources>