From 9059cbd01d41da42e6c18eafa2580c11d9d83ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Wed, 2 Jan 2019 17:42:10 +0100 Subject: [PATCH 1/9] Fix online icon --- .../main/java/com/uam/wmi/findmytutor/utils/Const.java | 2 +- app/src/main/res/layout/tutor_list_row.xml | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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 index f5103c7..48fd35f 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java @@ -6,7 +6,7 @@ import java.util.Arrays; import java.util.List; public class Const { - public final static String BASE_URL = "https://s416084.projektstudencki.pl/develop/"; + public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/"; public final static Integer onlineBackgroundLocationInterval = 7000; public final static Integer offlineBackgroundLocationInterval = 36000; public final static Integer defaultMapZoom = 17; diff --git a/app/src/main/res/layout/tutor_list_row.xml b/app/src/main/res/layout/tutor_list_row.xml index f35e962..b93a6ad 100644 --- a/app/src/main/res/layout/tutor_list_row.xml +++ b/app/src/main/res/layout/tutor_list_row.xml @@ -1,6 +1,6 @@ From 44e392c027e1e1ed8f5a5663bae4b62f528368b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Wed, 2 Jan 2019 18:23:03 +0100 Subject: [PATCH 2/9] Add search on backend --- .../findmytutor/activity/BaseActivity.java | 7 +- .../activity/UsersListFragment.java | 70 ++++++++++++++++--- .../wmi/findmytutor/service/UserService.java | 3 + .../findmytutor/utils/RxSearchObservable.java | 3 + app/src/main/res/menu/menu_main.xml | 2 + app/src/main/res/values-pl/strings.xml | 3 + app/src/main/res/values/strings.xml | 2 + 7 files changed, 81 insertions(+), 9 deletions(-) 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 c7935ba..bed01f5 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 @@ -285,7 +285,6 @@ public abstract class BaseActivity getMenuInflater().inflate(R.menu.menu_main, menu); infoMenuItem = menu.findItem(R.id.action_info); - MenuItem myActionMenuItem = menu.findItem(R.id.action_search); searchView = (SearchView) myActionMenuItem.getActionView(); @@ -295,11 +294,17 @@ public abstract class BaseActivity adjustMapToSearch(defaultMapZoom); } + if (!hasFocus && activeFragment.equals(ActiveFragment.USER_LIST)) { + ((UsersListFragment) userListFragment).restoreUsersList(); + } + if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){ adjustMapToSearch(searchMapZoom); } }); + + RxSearchObservable.fromView(searchView) .skip(0) .map(String::toLowerCase) 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 89fadf0..9b89791 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 @@ -10,6 +10,7 @@ import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -160,11 +161,7 @@ public class UsersListFragment extends Fragment { } public void searchUser(String textToSearch) { - - tutorsFiltered.clear(); - tutorsFiltered.addAll(Stream.of(tutorsList).filter(t -> - t.toSearchAbleString().toLowerCase().contains(textToSearch.toLowerCase())).toList()); - mAdapter.notifyDataSetChanged(); + searchTutorInBackend(textToSearch); } private void showNoteDialog(final User user) { @@ -276,6 +273,31 @@ public class UsersListFragment extends Fragment { } + private void searchTutorInBackend(String searchString) { + disposable.add( + userService.searchUser(searchString) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeWith(new DisposableSingleObserver>() { + @Override + public void onSuccess(List users) { + tutorsFiltered.clear(); + tutorsFiltered.addAll(users); + mAdapter.notifyDataSetChanged(); + } + + @Override + public void onError(Throwable e) { + showSearchError(e); + } + })); + } + + + public void restoreUsersList(){ + fetchAllTutors(); + } + private int sortByUserName(User t1, User t2) { return plCollator.compare(t1.getLastName(), t2.getLastName()); } @@ -288,13 +310,45 @@ public class UsersListFragment extends Fragment { ResponseBody responseBody = ((HttpException) e).response().errorBody(); message = RestApiHelper.getErrorMessage(responseBody); } else { - message = "Network Error !"; + message = getString(R.string.network_err); } - Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG) - .show(); + Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); + 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) { + String message; + Log.e(TAG, String.valueOf(e)); + + if (e instanceof HttpException) { + ResponseBody responseBody = ((HttpException) e).response().errorBody(); + message = RestApiHelper.getErrorMessage(responseBody); + } else { + message = getString(R.string.search_null); + } + + /* Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG) + .show(); +*/ + + + + Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); + View view = snackbar.getView(); + CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams(); + params.gravity = Gravity.TOP; + view.setLayoutParams(params); + snackbar.show(); + + + } + + private void toggleEmptyNotes() { if (tutorsList.size() > 0) { noNotesView.setVisibility(View.GONE); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java index 8915cfa..1399068 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java @@ -37,6 +37,9 @@ public interface UserService { @GET("api/users/tutors/offline") Single > getAllOfflineTutors(); + @GET("api/users/tutors/search/{searchString}") + Single > searchUser(@Path("searchString") String searchString ); + @POST("api/users") Completable createUser(@Body User user); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/RxSearchObservable.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/RxSearchObservable.java index 33d4aee..5d0d5b4 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/RxSearchObservable.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/RxSearchObservable.java @@ -21,6 +21,7 @@ public class RxSearchObservable { @Override public boolean onQueryTextSubmit(String s) { subject.onNext(s); + searchView.clearFocus(); return false; } @@ -31,6 +32,8 @@ public class RxSearchObservable { } + + }); diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 96cd955..985b8dd 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -6,6 +6,8 @@ android:id="@+id/action_search" android:icon="@drawable/ic_menu_search" app:showAsAction="always" + android:focusable="true" + android:focusableInTouchMode="true" app:actionViewClass="android.support.v7.widget.SearchView" android:title="@string/search"/> Brak użytkowników offline. Tylko użytkownicy online + Błąd sieci! + Brak wyników! + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f42f4d..9e420ed 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -423,5 +423,7 @@ Currently, there are no\nonline users. Currently, there are no\noffline users. Only online users + Network Error ! + Search response is empty! From b32393906735381025c1f2330127df04d3f56a25 Mon Sep 17 00:00:00 2001 From: Maciej Wanat Date: Wed, 2 Jan 2019 19:16:04 +0100 Subject: [PATCH 3/9] Text fixes --- app/src/main/res/values/strings.xml | 103 +++------------------------- 1 file changed, 9 insertions(+), 94 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9e420ed..cc7f5bc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -260,6 +260,7 @@ exact localization (from mobile GPS) approximated localization manual localization (manually picked) + You can search for any tutor on the map by entering his name and surname in the search field. 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. @@ -297,103 +298,17 @@ - user is currently offline - user is inactive (didn’t share any localization data since 7 days) - BlackList - User index - Add user to Blacklist - - "Material is the metaphor.\n\n" - - "A material metaphor is the unifying theory of a rationalized space and a system of motion." - "The material is grounded in tactile reality, inspired by the study of paper and ink, yet " - "technologically advanced and open to imagination and magic.\n" - "Surfaces and edges of the material provide visual cues that are grounded in reality. The " - "use of familiar tactile attributes helps users quickly understand affordances. Yet the " - "flexibility of the material creates new affordances that supercede those in the physical " - "world, without breaking the rules of physics.\n" - "The fundamentals of light, surface, and movement are key to conveying how objects move, " - "interact, and exist in space and in relation to each other. Realistic lighting shows " - "seams, divides space, and indicates moving parts.\n\n" - - "Bold, graphic, intentional.\n\n" - - "The foundational elements of print based design typography, grids, space, scale, color, " - "and use of imagery guide visual treatments. These elements do far more than please the " - "eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge " - "imagery, large scale typography, and intentional white space create a bold and graphic " - "interface that immerse the user in the experience.\n" - "An emphasis on user actions makes core functionality immediately apparent and provides " - "waypoints for the user.\n\n" - - "Motion provides meaning.\n\n" - - "Motion respects and reinforces the user as the prime mover. Primary user actions are " - "inflection points that initiate motion, transforming the whole design.\n" - "All action takes place in a single environment. Objects are presented to the user without " - "breaking the continuity of experience even as they transform and reorganize.\n" - "Motion is meaningful and appropriate, serving to focus attention and maintain continuity. " - "Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n" - - "3D world.\n\n" - - "The material environment is a 3D space, which means all objects have x, y, and z " - "dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the " - "positive z-axis extending towards the viewer. Every sheet of material occupies a single " - "position along the z-axis and has a standard 1dp thickness.\n" - "On the web, the z-axis is used for layering and not for perspective. The 3D world is " - "emulated by manipulating the y-axis.\n\n" - - "Light and shadow.\n\n" - - "Within the material environment, virtual lights illuminate the scene. Key lights create " - "directional shadows, while ambient light creates soft shadows from all angles.\n" - "Shadows in the material environment are cast by these two light sources. In Android " - "development, shadows occur when light sources are blocked by sheets of material at " - "various positions along the z-axis. On the web, shadows are depicted by manipulating the " - "y-axis only. The following example shows the card with a height of 6dp.\n\n" - - "Resting elevation.\n\n" - - "All material objects, regardless of size, have a resting elevation, or default elevation " - "that does not change. If an object changes elevation, it should return to its resting " - "elevation as soon as possible.\n\n" - - "Component elevations.\n\n" - - "The resting elevation for a component type is consistent across apps (e.g., FAB elevation " - "does not vary from 6dp in one app to 16dp in another app).\n" - "Components may have different resting elevations across platforms, depending on the depth " - "of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n" - - "Responsive elevation and dynamic elevation offsets.\n\n" - - "Some component types have responsive elevation, meaning they change elevation in response " - "to user input (e.g., normal, focused, and pressed) or system events. These elevation " - "changes are consistently implemented using dynamic elevation offsets.\n" - "Dynamic elevation offsets are the goal elevation that a component moves towards, relative " - "to the component’s resting state. They ensure that elevation changes are consistent " - "across actions and component types. For example, all components that lift on press have " - "the same elevation change relative to their resting elevation.\n" - "Once the input event is completed or cancelled, the component will return to its resting " - "elevation.\n\n" - - "Avoiding elevation interference.\n\n" - - "Components with responsive elevations may encounter other components as they move between " - "their resting elevations and dynamic elevation offsets. Because material cannot pass " - "through other material, components avoid interfering with one another any number of ways, " - "whether on a per component basis or using the entire app layout.\n" - "On a component level, components can move or be removed before they cause interference. " - "For example, a floating action button (FAB) can disappear or move off screen before a " - "user picks up a card, or it can move if a snackbar appears.\n" - "On the layout level, design your app layout to minimize opportunities for interference. " - "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" - - Add After clicking on a name, the tutor tab will pop up, containing details about selected tutor. + By default, only active users are shown. You can change that in menu (three dots icon). + You can also search for a tutor directly, by entering name and surname of person that you look for. + + + Blacklist + User index + Add user to blacklist + Add Yes - App issues reporting From 88f263217ae9b0cf0ec3965385f2a8bf1e4c5eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 17:39:34 +0100 Subject: [PATCH 4/9] Use fused and change loc mode --- .idea/misc.xml | 2 +- .../BackgroundLocalizationService.java | 120 ++++++++++++++---- .../com/uam/wmi/findmytutor/utils/Const.java | 4 +- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index dc44dda..b0c7b20 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -29,7 +29,7 @@ - + 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 1323d62..c72a3ce 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 @@ -11,11 +11,13 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.location.Location; +import android.location.LocationListener; import android.location.LocationManager; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.IBinder; +import android.os.Looper; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v4.app.NotificationCompat; @@ -23,12 +25,17 @@ import android.util.Log; import com.annimon.stream.Stream; import com.google.android.gms.location.FusedLocationProviderClient; +import com.google.android.gms.location.LocationCallback; +import com.google.android.gms.location.LocationRequest; +import com.google.android.gms.location.LocationResult; import com.google.android.gms.location.LocationServices; + import com.mapbox.geojson.Point; 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.Const; import com.uam.wmi.findmytutor.utils.MapUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.SharingLevel; @@ -54,7 +61,8 @@ import static java.lang.String.valueOf; public class BackgroundLocalizationService extends Service { private static final String TAG = "MyLocationService"; - private static long notify_interval = onlineBackgroundLocationInterval; + private static long notify_interval; + private Boolean highAccuracyMode; private static long notify_interval_inside_building = onlineBackgroundLocationInterval; private static long notify_interval_outside_building = offlineBackgroundLocationInterval; private static int coordinatesHistoryLength = 5; @@ -66,6 +74,11 @@ public class BackgroundLocalizationService extends Service { private Runnable mStatusChecker; private FusedLocationProviderClient mFusedLocationClient; private Location fakeLoc = null; + private LocationRequest mLocationRequest; + private Location mCurrentLocation; + private LocationCallback mLocationCallback; + private Looper myLooper; + private LocationListener mLocationListener; public BackgroundLocalizationService() { providers.add(LocationManager.GPS_PROVIDER); @@ -90,7 +103,9 @@ public class BackgroundLocalizationService extends Service { if (intent != null) { stopService = intent.getBooleanExtra("request_stop", false); + notify_interval = intent.getLongExtra("notify_interval", onlineBackgroundLocationInterval); } + if (stopService) { storeBackgroundLocationStatus(getApplication(), false); stopForeground(true); @@ -101,6 +116,21 @@ public class BackgroundLocalizationService extends Service { return START_STICKY; } + private void createLocationCallback() { + mLocationCallback = new LocationCallback() { + @Override + public void onLocationResult(LocationResult locationResult) { + super.onLocationResult(locationResult); + if (locationResult != null) { + mCurrentLocation = locationResult.getLastLocation(); + sendCoordinateToBackend(mCurrentLocation); + coordinatesHistory.add(mCurrentLocation); + changeBackgroundMode(); + } + } + }; + } + @Override public void onCreate() { Log.e(TAG, "onCreate"); @@ -114,30 +144,40 @@ public class BackgroundLocalizationService extends Service { startForeground(1001, notification); } + createFusedLocationClient(); + } + + private void createFusedLocationClient(){ + Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval)); + myLooper = Looper.myLooper(); + + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + return; + } + + mLocationRequest = new LocationRequest(); + + if(saveMode != 0){ + mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); + }else{ + mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); + } + + mLocationRequest.setFastestInterval(notify_interval); + mLocationRequest.setInterval(notify_interval); + + createLocationCallback(); if (!stopService) { - mStatusChecker = () -> { - try { - if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { - sendCoordinateToBackend(fakeLoc); - } else { - mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); - getLocalizationFromListeners(); - changeBackgroundMode(); - } - } finally { - mFusedLocationClient = null; - destroyLocationListeners(); - mHandler.postDelayed(mStatusChecker, notify_interval); - } - }; - - AsyncTask.execute(mStatusChecker); + mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); + mFusedLocationClient.requestLocationUpdates(mLocationRequest, + mLocationCallback, myLooper); } } private void changeBackgroundMode() { if (coordinatesHistory.size() > 4) { + Long prevInterval = notify_interval; Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory) .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); @@ -150,6 +190,11 @@ public class BackgroundLocalizationService extends Service { notify_interval = notify_interval_inside_building; } + Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval)); + + if(changedMode != 0){ + updateListeners(); + } } } @@ -192,9 +237,7 @@ public class BackgroundLocalizationService extends Service { coordinatesHistory.add(location); sendCoordinateToBackend(location); } - }); - } private void sendCoordinateToBackend(Location location) { @@ -211,7 +254,41 @@ public class BackgroundLocalizationService extends Service { } private void destroyLocationListeners() { + if (mFusedLocationClient != null) { + mFusedLocationClient.removeLocationUpdates(mLocationCallback); + mFusedLocationClient = null; + mLocationCallback = null; + mLocationRequest = null; + } + } + private void updateListeners() { + if (mFusedLocationClient != null) { + mFusedLocationClient.removeLocationUpdates(mLocationCallback) + .addOnCompleteListener(task -> { + restartService(); + mFusedLocationClient = null; + mLocationCallback = null; + mLocationRequest = null; + }); + } + } + + private void restartService(){ + + Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); + stopIntent.putExtra("request_stop", true); + + stopService(stopIntent); + + Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); + startIntent.putExtra("notify_interval", notify_interval); + + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { + startForegroundService(startIntent); + } else { + startService(startIntent); + } } @@ -277,7 +354,6 @@ public class BackgroundLocalizationService extends Service { .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(new DisposableCompletableObserver() { - @Override public void onComplete() { Log.e(TAG, "CoordinateSuccess"); @@ -285,9 +361,7 @@ public class BackgroundLocalizationService extends Service { @Override public void onError(Throwable e) { - Log.e(TAG, "onErr" + valueOf(e)); - } })); } catch (IllegalArgumentException e) { 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 index 48fd35f..21d043b 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java @@ -7,8 +7,8 @@ import java.util.List; public class Const { public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/"; - public final static Integer onlineBackgroundLocationInterval = 7000; - public final static Integer offlineBackgroundLocationInterval = 36000; + public final static Integer onlineBackgroundLocationInterval = 7000; + public final static Integer offlineBackgroundLocationInterval = 14000; public final static Integer defaultMapZoom = 17; public final static Integer searchMapZoom = 13; public final static Double presenceLatitude = 52.466365; From ea0d6e1e96cc1274a5b721594d343df4ea18cdee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 19:34:55 +0100 Subject: [PATCH 5/9] Add save battery mode --- .../findmytutor/activity/BaseActivity.java | 3 +- .../wmi/findmytutor/activity/MapActivity.java | 2 +- .../findmytutor/activity/SharingFragment.java | 2 + .../BackgroundLocalizationService.java | 95 +++++++++---------- .../com/uam/wmi/findmytutor/utils/Const.java | 4 +- app/src/main/res/layout/location_modal.xml | 4 +- app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 54 insertions(+), 58 deletions(-) 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 bed01f5..36f212a 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 @@ -53,6 +53,7 @@ import io.reactivex.schedulers.Schedulers; import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom; +import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval; import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom; import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus; @@ -200,7 +201,6 @@ public abstract class BaseActivity public void stopBackgroundLocalizationTask() { Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); stopIntent.putExtra("request_stop", true); - Log.e("Localization", "JEstem w stop BG"); stopService(stopIntent); @@ -210,6 +210,7 @@ public abstract class BaseActivity checkPermissions(); Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); + startIntent.putExtra("notify_interval", onlineBackgroundLocationInterval); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { startForegroundService(startIntent); 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 b1e9a32..e0d4309 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 @@ -333,7 +333,7 @@ public class MapActivity extends BaseActivity final AlertDialog alertDialog = alertDialogBuilderUserInput.create(); - EditText modalUserInput = view.findViewById(R.id.feedback_input); + EditText modalUserInput = view.findViewById(R.id.manual_input); alertDialog.setOnShowListener(dialogInterface -> { Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java index 1eee441..5755ab7 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java @@ -153,6 +153,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere /** Sharing level list **/ locationMode.setOnPreferenceChangeListener((preference, newValue) -> { + ((MapActivity) getActivity()).stopBackgroundLocalizationTask(); + ((MapActivity) getActivity()).startBackgroundLocalizationTask(); PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue))); 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 c72a3ce..827c589 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 @@ -29,13 +29,11 @@ import com.google.android.gms.location.LocationCallback; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationResult; import com.google.android.gms.location.LocationServices; - import com.mapbox.geojson.Point; 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.Const; import com.uam.wmi.findmytutor.utils.MapUtils; import com.uam.wmi.findmytutor.utils.PrefUtils; import com.uam.wmi.findmytutor.utils.SharingLevel; @@ -61,11 +59,11 @@ import static java.lang.String.valueOf; public class BackgroundLocalizationService extends Service { private static final String TAG = "MyLocationService"; - private static long notify_interval; - private Boolean highAccuracyMode; - private static long notify_interval_inside_building = onlineBackgroundLocationInterval; - private static long notify_interval_outside_building = offlineBackgroundLocationInterval; + private static Integer notify_interval = onlineBackgroundLocationInterval; + private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval; + private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval; private static int coordinatesHistoryLength = 5; + private Boolean highAccuracyMode; private Location mLastLocation; private Boolean stopService = false; private ArrayList providers = new ArrayList(); @@ -77,7 +75,6 @@ public class BackgroundLocalizationService extends Service { private LocationRequest mLocationRequest; private Location mCurrentLocation; private LocationCallback mLocationCallback; - private Looper myLooper; private LocationListener mLocationListener; public BackgroundLocalizationService() { @@ -103,7 +100,7 @@ public class BackgroundLocalizationService extends Service { if (intent != null) { stopService = intent.getBooleanExtra("request_stop", false); - notify_interval = intent.getLongExtra("notify_interval", onlineBackgroundLocationInterval); + notify_interval = intent.getIntExtra("notify_interval", onlineBackgroundLocationInterval); } if (stopService) { @@ -124,8 +121,7 @@ public class BackgroundLocalizationService extends Service { if (locationResult != null) { mCurrentLocation = locationResult.getLastLocation(); sendCoordinateToBackend(mCurrentLocation); - coordinatesHistory.add(mCurrentLocation); - changeBackgroundMode(); + changeBackgroundMode(); } } }; @@ -144,12 +140,24 @@ public class BackgroundLocalizationService extends Service { startForeground(1001, notification); } - createFusedLocationClient(); + if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { + createFusedLocationClient(); + }else if (!stopService && + PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { + mStatusChecker = () -> { + try { + sendCoordinateToBackend(fakeLoc); + } finally { + mHandler.postDelayed(mStatusChecker, notify_interval); + } + }; + + AsyncTask.execute(mStatusChecker); + } } - private void createFusedLocationClient(){ + private void createFusedLocationClient() { Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval)); - myLooper = Looper.myLooper(); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return; @@ -157,9 +165,9 @@ public class BackgroundLocalizationService extends Service { mLocationRequest = new LocationRequest(); - if(saveMode != 0){ + if (saveMode != 0) { mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); - }else{ + } else { mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); } @@ -171,13 +179,13 @@ public class BackgroundLocalizationService extends Service { if (!stopService) { mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this); mFusedLocationClient.requestLocationUpdates(mLocationRequest, - mLocationCallback, myLooper); + mLocationCallback, Looper.getMainLooper()); } } private void changeBackgroundMode() { if (coordinatesHistory.size() > 4) { - Long prevInterval = notify_interval; + Integer prevInterval = notify_interval; Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory) .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); @@ -191,8 +199,7 @@ public class BackgroundLocalizationService extends Service { } Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval)); - - if(changedMode != 0){ + if (changedMode != 0) { updateListeners(); } } @@ -218,28 +225,6 @@ public class BackgroundLocalizationService extends Service { startForeground(2, notification); } - private void getLocalizationFromListeners() { - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - // TODO: Consider calling - // ActivityCompat#requestPermissions - // here to request the missing permissions, and then overriding - // public void onRequestPermissionsResult(int requestCode, String[] permissions, - // int[] grantResults) - // to handle the case where the user grants the permission. See the documentation - // for ActivityCompat#requestPermissions for more details. - return; - } - - mFusedLocationClient.getLastLocation().addOnSuccessListener( - location -> { - if (location != null) { - mLastLocation = location; - coordinatesHistory.add(location); - sendCoordinateToBackend(location); - } - }); - } - private void sendCoordinateToBackend(Location location) { new Task(location).execute(); } @@ -274,21 +259,21 @@ public class BackgroundLocalizationService extends Service { } } - private void restartService(){ + private void restartService() { - Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); - stopIntent.putExtra("request_stop", true); + Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); + stopIntent.putExtra("request_stop", true); - stopService(stopIntent); + stopService(stopIntent); - Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); - startIntent.putExtra("notify_interval", notify_interval); + Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class); + startIntent.putExtra("notify_interval", notify_interval); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { - startForegroundService(startIntent); - } else { - startService(startIntent); - } + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { + startForegroundService(startIntent); + } else { + startService(startIntent); + } } @@ -337,6 +322,12 @@ public class BackgroundLocalizationService extends Service { approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext()); } + Location fakeLoc = new Location(""); + + fakeLoc.setLatitude(latitude); + fakeLoc.setLongitude(longitude); + coordinatesHistory.add(fakeLoc); + try { Coordinate coordinate = new Coordinate( latitude, 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 index 21d043b..0590a2f 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/Const.java @@ -7,8 +7,8 @@ import java.util.List; public class Const { public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/"; - public final static Integer onlineBackgroundLocationInterval = 7000; - public final static Integer offlineBackgroundLocationInterval = 14000; + public final static Integer onlineBackgroundLocationInterval = 7000; + public final static Integer offlineBackgroundLocationInterval = 360000; public final static Integer defaultMapZoom = 17; public final static Integer searchMapZoom = 13; public final static Double presenceLatitude = 52.466365; diff --git a/app/src/main/res/layout/location_modal.xml b/app/src/main/res/layout/location_modal.xml index 51949bd..a4af220 100644 --- a/app/src/main/res/layout/location_modal.xml +++ b/app/src/main/res/layout/location_modal.xml @@ -24,14 +24,14 @@ android:textStyle="normal" /> Błąd sieci! Brak wyników! + Nadaj nazwę tej lokalizacji. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cc7f5bc..6860e0d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -340,5 +340,6 @@ Only online users Network Error ! Search response is empty! + Insert a name for this localization. From 8bcecbbed52b88af0100513d562b83dd488a2b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 19:50:11 +0100 Subject: [PATCH 6/9] Change online trigger --- .../wmi/findmytutor/service/BackgroundLocalizationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 827c589..d8ca855 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 @@ -190,7 +190,7 @@ public class BackgroundLocalizationService extends Service { .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory). - map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1); + map(MapUtils::checkIfCoordinateIsValid).toList().size() > 0; if (shouldExtendTimeInterval) { notify_interval = notify_interval_outside_building; From b81e28cd61f4ab060f968776afd93ff8fc327367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 19:51:48 +0100 Subject: [PATCH 7/9] Fix online logic --- .../wmi/findmytutor/service/BackgroundLocalizationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d8ca855..86f4fbd 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 @@ -190,7 +190,7 @@ public class BackgroundLocalizationService extends Service { .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory). - map(MapUtils::checkIfCoordinateIsValid).toList().size() > 0; + filter(MapUtils::checkIfCoordinateIsValid).toList().size() > 0; if (shouldExtendTimeInterval) { notify_interval = notify_interval_outside_building; From 8e94d86968cc22c8d1d0c22989e27da225d9f85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 20:03:46 +0100 Subject: [PATCH 8/9] Fix corner case --- .../BackgroundLocalizationService.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) 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 86f4fbd..c05680c 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 @@ -142,7 +142,7 @@ public class BackgroundLocalizationService extends Service { if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { createFusedLocationClient(); - }else if (!stopService && + } else if (!stopService && PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) { mStatusChecker = () -> { try { @@ -184,25 +184,26 @@ public class BackgroundLocalizationService extends Service { } private void changeBackgroundMode() { - if (coordinatesHistory.size() > 4) { - Integer prevInterval = notify_interval; - Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory) - .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); + Integer prevInterval = notify_interval; + Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory) + .map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size(); - Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory). - filter(MapUtils::checkIfCoordinateIsValid).toList().size() > 0; + Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory). + map(MapUtils::checkIfCoordinateIsValid).filter(x -> x).toList().size() > 0; - if (shouldExtendTimeInterval) { - notify_interval = notify_interval_outside_building; - } else if (shouldAbbreviateTimeInterval) { - notify_interval = notify_interval_inside_building; - } - - Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval)); - if (changedMode != 0) { - updateListeners(); - } + if (shouldAbbreviateTimeInterval) { + notify_interval = notify_interval_inside_building; } + + if (coordinatesHistory.size() > 4 && shouldExtendTimeInterval) { + notify_interval = notify_interval_outside_building; + } + + Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval)); + if (changedMode != 0) { + updateListeners(); + } + } @RequiresApi(api = Build.VERSION_CODES.O) From af1e1a53b4ffd960047d9b5dafb53b7ae9cafb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Thu, 3 Jan 2019 21:32:28 +0100 Subject: [PATCH 9/9] Add proper search --- .../findmytutor/activity/BaseActivity.java | 8 +------ .../activity/UsersListFragment.java | 22 +++++-------------- .../wmi/findmytutor/service/UserService.java | 8 +++++-- .../main/res/layout/info_popup_userlist.xml | 2 ++ app/src/main/res/values-pl/strings.xml | 5 +++-- app/src/main/res/values/strings.xml | 13 ++++++----- 6 files changed, 25 insertions(+), 33 deletions(-) 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 36f212a..18d1955 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 @@ -220,17 +220,12 @@ public abstract class BaseActivity } public void handleBackgroundTaskLifeCycle() { - Log.e("Localization", String.valueOf(PrefUtils.isEnableSharingLocalization(getApplicationContext()))); Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor; - Log.e("Localization", String.valueOf(shouldServiceRun)); if (shouldServiceRun) { startBackgroundLocalizationTask(); - Log.e("Localization", "JEstem i odpalam"); - } else { stopBackgroundLocalizationTask(); - Log.e("Localization", "JEstem i nie odpalam"); } } @@ -304,11 +299,10 @@ public abstract class BaseActivity } }); - - RxSearchObservable.fromView(searchView) .skip(0) .map(String::toLowerCase) + .filter(t -> !t.isEmpty()) .debounce(250, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) 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 9b89791..eb15075 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 @@ -229,7 +229,7 @@ public class UsersListFragment extends Fragment { private void fetchAllTutors() { disposable.add( (fetchOnlyOnlineUsers ? - userService.getAllOnlineTutors() : + userService.getAllActiveTutors() : userService.getAllOfflineTutors()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -313,12 +313,7 @@ public class UsersListFragment extends Fragment { message = getString(R.string.network_err); } - Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); - View view = snackbar.getView(); - CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams(); - params.gravity = Gravity.TOP; - view.setLayoutParams(params); - snackbar.show(); + createSnackbar(message); } private void showSearchError(Throwable e) { @@ -332,23 +327,18 @@ public class UsersListFragment extends Fragment { message = getString(R.string.search_null); } - /* Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG) - .show(); -*/ + createSnackbar(message); + } - - - Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG); + 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(); params.gravity = Gravity.TOP; view.setLayoutParams(params); snackbar.show(); - - } - private void toggleEmptyNotes() { if (tutorsList.size() > 0) { noNotesView.setVisibility(View.GONE); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java index 1399068..a393017 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java @@ -19,6 +19,7 @@ import retrofit2.http.HTTP; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; +import retrofit2.http.Query; public interface UserService { @@ -34,11 +35,14 @@ public interface UserService { @GET("api/users/tutors/online") Single > getAllOnlineTutors(); + @GET("api/users/tutors/active") + Single > getAllActiveTutors(); + @GET("api/users/tutors/offline") Single > getAllOfflineTutors(); - @GET("api/users/tutors/search/{searchString}") - Single > searchUser(@Path("searchString") String searchString ); + @GET("api/users/tutors/search") + Single > searchUser(@Query(value = "searchString", encoded = true) String searchString); @POST("api/users") Completable createUser(@Body User user); diff --git a/app/src/main/res/layout/info_popup_userlist.xml b/app/src/main/res/layout/info_popup_userlist.xml index afd1c17..19761d7 100644 --- a/app/src/main/res/layout/info_popup_userlist.xml +++ b/app/src/main/res/layout/info_popup_userlist.xml @@ -72,4 +72,6 @@ android:text="@string/info_icon_userlist_summary" android:textColor="@color/half_black"/> + + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 77ef3d5..e3fa57b 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -253,9 +253,10 @@ Pobierz dane z WMI Dane zostały zaktualizwane! - Brak użytkowników online. + + Brak aktywnych użytkowników. Brak użytkowników offline. - Tylko użytkownicy online + Tylko aktywni użytkownicy Błąd sieci! Brak wyników! diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6860e0d..f9e86bc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -260,7 +260,6 @@ exact localization (from mobile GPS) approximated localization manual localization (manually picked) - You can search for any tutor on the map by entering his name and surname in the search field. 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. @@ -298,9 +297,7 @@ - user is currently offline - user is inactive (didn’t share any localization data since 7 days) - After clicking on a name, the tutor tab will pop up, containing details about selected tutor. - By default, only active users are shown. You can change that in menu (three dots icon). - You can also search for a tutor directly, by entering name and surname of person that you look for. + 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. Blacklist @@ -335,9 +332,13 @@ OFF Scrap! Data updated! - Currently, there are no\nonline users. + + + Currently, there are no\nactive users. Currently, there are no\noffline users. - Only online users + Only active users + + Network Error ! Search response is empty! Insert a name for this localization.