Add appropriate search functionality #116

Merged
s416204 merged 1 commits from user-search-query-approach into develop 2019-01-03 21:33:46 +01:00
6 changed files with 25 additions and 33 deletions
Showing only changes of commit af1e1a53b4 - Show all commits

View File

@ -220,17 +220,12 @@ public abstract class BaseActivity
} }
public void handleBackgroundTaskLifeCycle() { public void handleBackgroundTaskLifeCycle() {
Log.e("Localization", String.valueOf(PrefUtils.isEnableSharingLocalization(getApplicationContext())));
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor; Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor;
Log.e("Localization", String.valueOf(shouldServiceRun));
if (shouldServiceRun) { if (shouldServiceRun) {
startBackgroundLocalizationTask(); startBackgroundLocalizationTask();
Log.e("Localization", "JEstem i odpalam");
} else { } else {
stopBackgroundLocalizationTask(); stopBackgroundLocalizationTask();
Log.e("Localization", "JEstem i nie odpalam");
} }
} }
@ -304,11 +299,10 @@ public abstract class BaseActivity
} }
}); });
RxSearchObservable.fromView(searchView) RxSearchObservable.fromView(searchView)
.skip(0) .skip(0)
.map(String::toLowerCase) .map(String::toLowerCase)
.filter(t -> !t.isEmpty())
.debounce(250, TimeUnit.MILLISECONDS) .debounce(250, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())

View File

@ -229,7 +229,7 @@ public class UsersListFragment extends Fragment {
private void fetchAllTutors() { private void fetchAllTutors() {
disposable.add( disposable.add(
(fetchOnlyOnlineUsers ? (fetchOnlyOnlineUsers ?
userService.getAllOnlineTutors() : userService.getAllActiveTutors() :
userService.getAllOfflineTutors()) userService.getAllOfflineTutors())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@ -313,12 +313,7 @@ public class UsersListFragment extends Fragment {
message = getString(R.string.network_err); message = getString(R.string.network_err);
} }
Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); createSnackbar(message);
View view = snackbar.getView();
CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams();
params.gravity = Gravity.TOP;
view.setLayoutParams(params);
snackbar.show();
} }
private void showSearchError(Throwable e) { private void showSearchError(Throwable e) {
@ -332,23 +327,18 @@ public class UsersListFragment extends Fragment {
message = getString(R.string.search_null); message = getString(R.string.search_null);
} }
/* Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG) createSnackbar(message);
.show(); }
*/
private void createSnackbar(String msg){
Snackbar snackbar = Snackbar.make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);
Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG);
View view = snackbar.getView(); View view = snackbar.getView();
CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams(); CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams();
params.gravity = Gravity.TOP; params.gravity = Gravity.TOP;
view.setLayoutParams(params); view.setLayoutParams(params);
snackbar.show(); snackbar.show();
} }
private void toggleEmptyNotes() { private void toggleEmptyNotes() {
if (tutorsList.size() > 0) { if (tutorsList.size() > 0) {
noNotesView.setVisibility(View.GONE); noNotesView.setVisibility(View.GONE);

View File

@ -19,6 +19,7 @@ import retrofit2.http.HTTP;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.PUT; import retrofit2.http.PUT;
import retrofit2.http.Path; import retrofit2.http.Path;
import retrofit2.http.Query;
public interface UserService { public interface UserService {
@ -34,11 +35,14 @@ public interface UserService {
@GET("api/users/tutors/online") @GET("api/users/tutors/online")
Single <List<User>> getAllOnlineTutors(); Single <List<User>> getAllOnlineTutors();
@GET("api/users/tutors/active")
Single <List<User>> getAllActiveTutors();
@GET("api/users/tutors/offline") @GET("api/users/tutors/offline")
Single <List<User>> getAllOfflineTutors(); Single <List<User>> getAllOfflineTutors();
@GET("api/users/tutors/search/{searchString}") @GET("api/users/tutors/search")
Single <List<User>> searchUser(@Path("searchString") String searchString ); Single <List<User>> searchUser(@Query(value = "searchString", encoded = true) String searchString);
@POST("api/users") @POST("api/users")
Completable createUser(@Body User user); Completable createUser(@Body User user);

View File

@ -72,4 +72,6 @@
android:text="@string/info_icon_userlist_summary" android:text="@string/info_icon_userlist_summary"
android:textColor="@color/half_black"/> android:textColor="@color/half_black"/>
</LinearLayout> </LinearLayout>

View File

@ -253,9 +253,10 @@
<string name="scrap_tutor_tab">Pobierz dane z WMI</string> <string name="scrap_tutor_tab">Pobierz dane z WMI</string>
<string name="scrap_tutor_msg">Dane zostały zaktualizwane!</string> <string name="scrap_tutor_msg">Dane zostały zaktualizwane!</string>
<string name="no_online_users">Brak użytkowników online.</string> <!--(ENG) Checkbox online users list -->
<string name="no_online_users">Brak aktywnych użytkowników.</string>
<string name="no_offline_users">Brak użytkowników offline.</string> <string name="no_offline_users">Brak użytkowników offline.</string>
<string name="only_online_users">Tylko użytkownicy online</string> <string name="only_online_users">Tylko aktywni użytkownicy</string>
<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>

View File

@ -260,7 +260,6 @@
<string name="map_info_text_marker_exact">exact localization (from mobile GPS)</string> <string name="map_info_text_marker_exact">exact localization (from mobile GPS)</string>
<string name="map_info_text_marker_approximated">approximated localization</string> <string name="map_info_text_marker_approximated">approximated localization</string>
<string name="map_info_text_marker_manual">manual localization (manually picked)</string> <string name="map_info_text_marker_manual">manual localization (manually picked)</string>
<string name="map_info_text_p4">You can search for any tutor on the map by entering his name and surname in the search field.</string>
<!--(ENG) Blacklist info helper--> <!--(ENG) Blacklist info helper-->
<string name="info_icon_blacklist_p1">In this panel you can add users to your blacklist. Users from the blacklist cant see any data that you share - localization, online status, or information about presence.</string> <string name="info_icon_blacklist_p1">In this panel you can add users to your blacklist. Users from the blacklist cant see any data that you share - localization, online status, or information about presence.</string>
@ -298,9 +297,7 @@
<string name="info_icon_userlist_tab_level_status_offline">- user is currently offline</string> <string name="info_icon_userlist_tab_level_status_offline">- user is currently offline</string>
<string name="info_icon_userlist_tab_level_status_inactive">- user is inactive </string> <string name="info_icon_userlist_tab_level_status_inactive">- user is inactive </string>
<string name="info_icon_userlist_tab_level_status_inactive_tip">(didnt share any localization data since 7 days)</string> <string name="info_icon_userlist_tab_level_status_inactive_tip">(didnt share any localization data since 7 days)</string>
<string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.</string> <string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.\n\nYou can search for any tutor on the map by entering his name and surname in the search field.\n\nBy default, only active users are shown. You can change that in menu (three dots icon).\n\nYou can also search for a tutor directly, by entering name and surname of person that you look for.</string>
<string name="info_icon_userlist_tab_p3">By default, only active users are shown. You can change that in menu (three dots icon).</string>
<string name="info_icon_userlist_tab_p4">You can also search for a tutor directly, by entering name and surname of person that you look for.</string>
<!--(ENG) Blacklist --> <!--(ENG) Blacklist -->
<string name="title_activity_black_list">Blacklist</string> <string name="title_activity_black_list">Blacklist</string>
@ -335,9 +332,13 @@
<string name="off">OFF</string> <string name="off">OFF</string>
<string name="scrap_tutor_tab">Scrap!</string> <string name="scrap_tutor_tab">Scrap!</string>
<string name="scrap_tutor_msg">Data updated!</string> <string name="scrap_tutor_msg">Data updated!</string>
<string name="no_online_users">Currently, there are no\nonline users.</string>
<!--(ENG) Checkbox online users list -->
<string name="no_online_users">Currently, there are no\nactive users.</string>
<string name="no_offline_users">Currently, there are no\noffline users.</string> <string name="no_offline_users">Currently, there are no\noffline users.</string>
<string name="only_online_users">Only online users</string> <string name="only_online_users">Only active users</string>
<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>