From b8eedc565c2f1ff17cb979f03572bf38d2c223fc Mon Sep 17 00:00:00 2001 From: "marcin.jedynski" Date: Wed, 21 Nov 2018 04:59:50 +0100 Subject: [PATCH 1/3] hiden tutor portion of drawer if student logged in --- .../java/com/uam/wmi/findmytutor/activity/BaseActivity.java | 1 + .../java/com/uam/wmi/findmytutor/activity/SharingFragment.java | 2 ++ .../main/java/com/uam/wmi/findmytutor/utils/SharingLevel.java | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) 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 610b1ea..17ac628 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 @@ -138,6 +138,7 @@ public abstract class BaseActivity if (!isTutor) { navigationView.findViewById(R.id.nav_profile).setVisibility(View.GONE); + drawerNavigationView.getMenu().setGroupVisible(R.id.drawer_group_tutor, false); } } 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 38bff8d..9bfc6a5 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 @@ -45,6 +45,8 @@ public class SharingFragment extends PreferenceFragment { locationLevelMapping.put(0, SharingLevel.PRESENCE.toString()); locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString()); locationLevelMapping.put(2, SharingLevel.EXACT.toString()); + locationLevelMapping.put(3, SharingLevel.MANUAL.toString()); + addPreferencesFromResource(R.layout.pref_sharing); Preference manualStatus = findPreference("key_manual_status"); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingLevel.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingLevel.java index 055651b..9b0a027 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingLevel.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/SharingLevel.java @@ -3,7 +3,8 @@ package com.uam.wmi.findmytutor.utils; public enum SharingLevel { PRESENCE("presence"), APPROXIMATED("approximated"), - EXACT("exact"); + EXACT("exact"), + MANUAL("manuak"); private final String text; From fce151be6fd5336f709459e01967e55e02566aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Wed, 21 Nov 2018 08:11:48 +0100 Subject: [PATCH 2/3] Change endpoint for users --- .../java/com/uam/wmi/findmytutor/activity/BaseActivity.java | 2 -- .../java/com/uam/wmi/findmytutor/activity/MapActivity.java | 2 +- .../com/uam/wmi/findmytutor/activity/UsersListFragment.java | 3 +-- .../main/java/com/uam/wmi/findmytutor/service/UserService.java | 3 +++ 4 files changed, 5 insertions(+), 5 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 610b1ea..ad2c2a4 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 @@ -275,14 +275,12 @@ public abstract class BaseActivity RxSearchObservable.fromView(searchView) .map(String::toLowerCase) - .filter(t -> !t.trim().isEmpty()) .debounce(300, TimeUnit.MILLISECONDS) .distinctUntilChanged() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::executeSearch); - return true; } 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 14a4d43..b35dd5a 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 @@ -582,7 +582,7 @@ public class MapActivity extends BaseActivity private void getUserFromApi(String userNameToSearch) { disposable.add( - userService.apiUsersGet() + userService.getAllTutors() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(tutors -> Stream.of(tutors).filter(t -> 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 c2c8e53..433ed70 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 @@ -9,7 +9,6 @@ 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.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -170,7 +169,7 @@ public class UsersListFragment extends Fragment { private void fetchAllTutors() { disposable.add( - userService.apiUsersGet() + userService.getAllTutors() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(tutors -> { 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 aca16a4..75671ed 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 @@ -27,6 +27,9 @@ public interface UserService { @GET("api/users") Single > apiUsersGet(); + @GET("api/users/tutors") + Single > getAllTutors(); + @POST("api/users") Completable createUser(@Body User user); From b75e3e5ae3f0aba9da897da093d4596149a16d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mieszko=20Wrzeszczy=C5=84ski?= Date: Wed, 21 Nov 2018 08:37:23 +0100 Subject: [PATCH 3/3] Improve logging --- .../com/uam/wmi/findmytutor/activity/LoginActivity.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java index 301c6fa..912598a 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java @@ -182,12 +182,10 @@ public class LoginActivity extends AppCompatActivity { Claim userId = jwt.getClaim("nameid"); Claim role = jwt.getClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role"); - if(Objects.requireNonNull(role.asString()).equals("Student")){ - PrefUtils.storeIsTutor(getApplicationContext(), false); + if(!Objects.requireNonNull(role.asString()).equals("Student")){ + PrefUtils.storeIsTutor(getApplicationContext(), true); } - - Log.e("LOGOWANIE",role.asString()); - + PrefUtils.storeIsLoggedIn(getApplicationContext(), true); PrefUtils.storeApiKey(getApplicationContext(), token); PrefUtils.storeUserId(getApplicationContext(), userId.asString());