From 53a9b1ea2ef49799e29804cfc669affb4cecf3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Sat, 25 Aug 2018 06:50:28 +0200 Subject: [PATCH 01/14] v1 of userService and models --- .idea/caches/build_file_checksums.ser | Bin 537 -> 540 bytes .../findmytutor/model/IsUsingListBool.java | 20 +++ .../wmi/findmytutor/model/PagedResult.java | 87 ++++++++++ .../com/uam/wmi/findmytutor/model/Result.java | 163 +++++++++++++++++ .../wmi/findmytutor/model/StudentIdModel.java | 31 ++++ .../com/uam/wmi/findmytutor/model/User.java | 164 ++++++++++++++++++ .../wmi/findmytutor/service/UserService.java | 75 ++++++++ build.gradle | 2 +- 8 files changed, 541 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/Result.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/User.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 0349eb789b5963e54a80a5c2d6dc8162ad8c714f..f7feae91852b188555d60a2737ba5b7286cc2c32 100644 GIT binary patch delta 90 zcmV-g0Hyz#1e^qrm;`9NfWncSwGt~sI$TwAWpZ;|ZDDe1Wn?ijlePgilTiT|5Yh{i w7N#CD$|K`wyN_am1gFo=%p7WrsSlS7BbW^urV+&2o#hrDvq|8@~Yr# zqD)h0sOjVbjIvtmC9>oqzVOz)`uJPtA7`gj34?~SRZM7cYEf}aUTS_$ehk!{n8_a) Or6;#D3Qc~`s0#o{=PG^x diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java new file mode 100644 index 0000000..e11d6ac --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java @@ -0,0 +1,20 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class IsUsingListBool { + + @SerializedName("isUsing") + @Expose + private Boolean isUsing; + + public Boolean getIsUsing() { + return isUsing; + } + + public void setIsUsing(Boolean isUsing) { + this.isUsing = isUsing; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java new file mode 100644 index 0000000..9e7ad33 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java @@ -0,0 +1,87 @@ +package com.uam.wmi.findmytutor.model; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class PagedResult { + + @SerializedName("results") + @Expose + private List results = null; + @SerializedName("currentPage") + @Expose + private Integer currentPage; + @SerializedName("pageCount") + @Expose + private Integer pageCount; + @SerializedName("pageSize") + @Expose + private Integer pageSize; + @SerializedName("rowCount") + @Expose + private Integer rowCount; + @SerializedName("firstRowOnPage") + @Expose + private Integer firstRowOnPage; + @SerializedName("lastRowOnPage") + @Expose + private Integer lastRowOnPage; + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public Integer getPageCount() { + return pageCount; + } + + public void setPageCount(Integer pageCount) { + this.pageCount = pageCount; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getRowCount() { + return rowCount; + } + + public void setRowCount(Integer rowCount) { + this.rowCount = rowCount; + } + + public Integer getFirstRowOnPage() { + return firstRowOnPage; + } + + public void setFirstRowOnPage(Integer firstRowOnPage) { + this.firstRowOnPage = firstRowOnPage; + } + + public Integer getLastRowOnPage() { + return lastRowOnPage; + } + + public void setLastRowOnPage(Integer lastRowOnPage) { + this.lastRowOnPage = lastRowOnPage; + } + +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java new file mode 100644 index 0000000..6fc4336 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java @@ -0,0 +1,163 @@ +package com.uam.wmi.findmytutor.model; +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Result { + + @SerializedName("id") + @Expose + private String id; + @SerializedName("isOnline") + @Expose + private Boolean isOnline; + @SerializedName("isUsingBlacklist") + @Expose + private Boolean isUsingBlacklist; + @SerializedName("isUsingWhitelist") + @Expose + private Boolean isUsingWhitelist; + @SerializedName("blacklist") + @Expose + private List blacklist = null; + @SerializedName("whitelist") + @Expose + private List whitelist = null; + @SerializedName("ldapLogin") + @Expose + private String ldapLogin; + @SerializedName("title") + @Expose + private String title; + @SerializedName("firstName") + @Expose + private String firstName; + @SerializedName("lastName") + @Expose + private String lastName; + @SerializedName("department") + @Expose + private String department; + @SerializedName("userName") + @Expose + private String userName; + @SerializedName("email") + @Expose + private String email; + @SerializedName("isActive") + @Expose + private Boolean isActive; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Boolean getIsOnline() { + return isOnline; + } + + public void setIsOnline(Boolean isOnline) { + this.isOnline = isOnline; + } + + public Boolean getIsUsingBlacklist() { + return isUsingBlacklist; + } + + public void setIsUsingBlacklist(Boolean isUsingBlacklist) { + this.isUsingBlacklist = isUsingBlacklist; + } + + public Boolean getIsUsingWhitelist() { + return isUsingWhitelist; + } + + public void setIsUsingWhitelist(Boolean isUsingWhitelist) { + this.isUsingWhitelist = isUsingWhitelist; + } + + public List getBlacklist() { + return blacklist; + } + + public void setBlacklist(List blacklist) { + this.blacklist = blacklist; + } + + public List getWhitelist() { + return whitelist; + } + + public void setWhitelist(List whitelist) { + this.whitelist = whitelist; + } + + public String getLdapLogin() { + return ldapLogin; + } + + public void setLdapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java new file mode 100644 index 0000000..518cf24 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java @@ -0,0 +1,31 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class StudentIdModel { + + @SerializedName("studentId") + @Expose + private String studentId; + @SerializedName("ldapLogin") + @Expose + private String ldapLogin; + + public String getStudentId() { + return studentId; + } + + public void setStudentId(String studentId) { + this.studentId = studentId; + } + + public String getLdapLogin() { + return ldapLogin; + } + + public void setLdapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/User.java b/app/src/main/java/com/uam/wmi/findmytutor/model/User.java new file mode 100644 index 0000000..6c37884 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/User.java @@ -0,0 +1,164 @@ +package com.uam.wmi.findmytutor.model; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class User { + + @SerializedName("id") + @Expose + private String id; + @SerializedName("isOnline") + @Expose + private Boolean isOnline; + @SerializedName("isUsingBlacklist") + @Expose + private Boolean isUsingBlacklist; + @SerializedName("isUsingWhitelist") + @Expose + private Boolean isUsingWhitelist; + @SerializedName("blacklist") + @Expose + private List blacklist = null; + @SerializedName("whitelist") + @Expose + private List whitelist = null; + @SerializedName("ldapLogin") + @Expose + private String ldapLogin; + @SerializedName("title") + @Expose + private String title; + @SerializedName("firstName") + @Expose + private String firstName; + @SerializedName("lastName") + @Expose + private String lastName; + @SerializedName("department") + @Expose + private String department; + @SerializedName("userName") + @Expose + private String userName; + @SerializedName("email") + @Expose + private String email; + @SerializedName("isActive") + @Expose + private Boolean isActive; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Boolean getIsOnline() { + return isOnline; + } + + public void setIsOnline(Boolean isOnline) { + this.isOnline = isOnline; + } + + public Boolean getIsUsingBlacklist() { + return isUsingBlacklist; + } + + public void setIsUsingBlacklist(Boolean isUsingBlacklist) { + this.isUsingBlacklist = isUsingBlacklist; + } + + public Boolean getIsUsingWhitelist() { + return isUsingWhitelist; + } + + public void setIsUsingWhitelist(Boolean isUsingWhitelist) { + this.isUsingWhitelist = isUsingWhitelist; + } + + public List getBlacklist() { + return blacklist; + } + + public void setBlacklist(List blacklist) { + this.blacklist = blacklist; + } + + public List getWhitelist() { + return whitelist; + } + + public void setWhitelist(List whitelist) { + this.whitelist = whitelist; + } + + public String getLdapLogin() { + return ldapLogin; + } + + public void setLdapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + +} \ No newline at end of file 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 new file mode 100644 index 0000000..e74aaac --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/UserService.java @@ -0,0 +1,75 @@ +package com.uam.wmi.findmytutor.service; +import com.uam.wmi.findmytutor.model.JwtToken; +import com.uam.wmi.findmytutor.model.PagedResult; +import com.uam.wmi.findmytutor.model.User; +import com.uam.wmi.findmytutor.model.IsUsingListBool; +import com.uam.wmi.findmytutor.model.StudentIdModel; +import java.util.List; + +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.DELETE; +import retrofit2.http.GET; +import retrofit2.http.PUT; +import retrofit2.http.POST; +import retrofit2.http.Path; +import retrofit2.http.Header; + +public interface UserService { + @GET("api/users") + Call> getAllUsers(@Header("Authorization") JwtToken token); + + @POST("api/users") + Call> postAllUsers(@Header("Authorization") JwtToken token); + + @GET("api/users/page/{pageNum}") + Call getPagedUsers(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); + + @GET("/api/users/tutors/page/{pageNum}") + Call getPagedTutors(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); + + @GET("/api/users/students/page/{pageNum}") + Call getPagedStudents(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); + + @GET("api/users/{id}") + Call getUserByID(@Path("id") String userID, @Header("Authorization") JwtToken token); + + @PUT("api/users/{id}") + Call updateUserByID(@Path("id") String userID, @Body User user,@Header("Authorization") JwtToken token); + + @DELETE("api/users/{id}") + Call deleteUserByID(@Path("id") String userID, @Header("Authorization") JwtToken token); + + @GET("api/users/userLogin/{ldapLogin}") + Call getUserLdapLogin(@Path("ldapLogin") String ldapLogin,@Header("Authorization") JwtToken token); + + @PUT("api/users/setActive/{userID}") + Call setUserActive(@Path("userID") String userID,@Header("Authorization") JwtToken token); + + @PUT("api/users/setInActive/{userID}") + Call setUserInActive(@Path("userID") String userID,@Header("Authorization") JwtToken token); + + @GET("api/users/blacklist/{tutorID}") + Call> getTutorBlacklistedByID(@Path("tutorID") String tutorID,@Header("Authorization") JwtToken token); + + @PUT("api/users/blacklist/{tutorID}") + Call setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing,@Header("Authorization") JwtToken token); + + @POST("api/users/blacklist/{tutorID}") + Call> addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + + @DELETE("api/users/blacklist/{tutorID}") + Call> removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + + @GET("api/users/whitelist/{tutorID}") + Call> getTutorwhitelistedByID(@Path("tutorID") String tutorID,@Header("Authorization") JwtToken token); + + @PUT("api/users/whitelist/{tutorID}") + Call setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing,@Header("Authorization") JwtToken token); + + @POST("api/users/whitelist/{tutorID}") + Call> addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + + @DELETE("api/users/whitelist/{tutorID}") + Call> removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); +} diff --git a/build.gradle b/build.gradle index 1a3d812..077cb2f 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong From 5dc11c6fec3843912bcfc02f3f25934a42492792 Mon Sep 17 00:00:00 2001 From: Mieszko Date: Sat, 25 Aug 2018 20:26:17 +0200 Subject: [PATCH 02/14] Add models and coordinates service --- .idea/assetWizardSettings.xml | 14 + app/.gitignore | 65 ++ app/build.gradle | 3 + .../findmytutor/activity/LoginActivity.java | 22 +- .../findmytutor/activity/MainActivity.java | 5 - .../findmytutor/activity/StartupActivity.java | 10 - .../uam/wmi/findmytutor/model/Coordinate.java | 260 +++++++ .../uam/wmi/findmytutor/model/DutyHour.java | 192 +++++ .../model/IsUsingListBoolModel.java | 76 ++ .../uam/wmi/findmytutor/model/LdapUser.java | 288 +++++-- .../model/PagedResultUserResponseModel.java | 206 +++++ .../wmi/findmytutor/model/StudentIdModel.java | 100 +++ .../uam/wmi/findmytutor/model/TutorTab.java | 204 +++++ .../com/uam/wmi/findmytutor/model/User.java | 726 ++++++++++++++++++ .../findmytutor/model/UserResponseModel.java | 393 ++++++++++ .../wmi/findmytutor/service/Coordinates.java | 48 ++ 16 files changed, 2501 insertions(+), 111 deletions(-) create mode 100644 .idea/assetWizardSettings.xml create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/User.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml new file mode 100644 index 0000000..2a9c5e0 --- /dev/null +++ b/.idea/assetWizardSettings.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore index 796b96d..25f9fc7 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,66 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following line if you do not want to check your keystore files in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md /build diff --git a/app/build.gradle b/app/build.gradle index 402e9f8..d0b1d68 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,4 +29,7 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.2' implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + implementation "io.swagger:swagger-annotations:1.5.15" + implementation "org.threeten:threetenbp:1.3.5" + } 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 0823334..d876bcd 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 @@ -3,24 +3,22 @@ package com.uam.wmi.findmytutor.activity; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.TargetApi; +import android.app.LoaderManager.LoaderCallbacks; import android.content.Context; +import android.content.CursorLoader; import android.content.Intent; +import android.content.Loader; import android.content.SharedPreferences; import android.content.pm.PackageManager; -import android.support.annotation.NonNull; -import android.support.design.widget.Snackbar; -import android.support.v7.app.AppCompatActivity; -import android.app.LoaderManager.LoaderCallbacks; - -import android.content.CursorLoader; -import android.content.Loader; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; - import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; +import android.support.annotation.NonNull; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; @@ -32,7 +30,6 @@ import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; -import android.widget.Toast; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.JwtToken; @@ -44,8 +41,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import retrofit2.Call; -import retrofit2.Callback; import retrofit2.Response; import static android.Manifest.permission.READ_CONTACTS; @@ -326,7 +321,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< protected Boolean doInBackground(Void... params) { LdapService service = RetrofitClientInstance.getRetrofitLoginInstance().create(LdapService.class); - LdapUser user = new LdapUser("string",mPassword,"string","string","string","string",mEmail); + LdapUser user = new LdapUser("string",mPassword,"string","pracownik","string","string",mEmail); try { Response loginResponse = service.fakeValidate(user).execute(); @@ -341,7 +336,8 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< } } catch (IOException e) { - Log.e("Login error", "nie udalo sie kurde..."); + Log.d("login failure",e.toString()); + Log.e("Login error", e.toString()); return false; } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index 3341ffc..2eac035 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -3,13 +3,8 @@ package com.uam.wmi.findmytutor.activity; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.util.Log; -import android.view.View; - import com.uam.wmi.findmytutor.R; public class MainActivity extends AppCompatActivity { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index 17ec17b..4c7a441 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -5,17 +5,7 @@ import android.content.Context; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import android.util.Log; -import android.widget.Toast; -import com.uam.wmi.findmytutor.model.JwtToken; -import com.uam.wmi.findmytutor.model.LdapUser; -import com.uam.wmi.findmytutor.network.RetrofitClientInstance; -import com.uam.wmi.findmytutor.service.LdapService; - -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; public class StartupActivity extends AppCompatActivity { private static final int AUTHENTICATION_REQUEST_CODE = 666; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java new file mode 100644 index 0000000..017b640 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java @@ -0,0 +1,260 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.Objects; +import java.util.UUID; + +import io.swagger.annotations.ApiModelProperty; + +/** + * Coordinate + */ + +public class Coordinate { + @SerializedName("coordinateId") + private UUID coordinateId = null; + + @SerializedName("latitude") + private Float latitude = null; + + @SerializedName("longitude") + private Float longitude = null; + + @SerializedName("altitude") + private Float altitude = null; + + @SerializedName("userId") + private String userId = null; + + @SerializedName("approximatedLocation") + private String approximatedLocation = null; + + @SerializedName("displayMode") + private String displayMode = "exact"; + + @SerializedName("timeStamp") + private Long timeStamp = null; + + @SerializedName("label") + private String label = null; + + public Coordinate coordinateId(UUID coordinateId) { + this.coordinateId = coordinateId; + return this; + } + + /** + * Get coordinateId + * @return coordinateId + **/ + @ApiModelProperty(required = true, value = "") + public UUID getCoordinateId() { + return coordinateId; + } + + public void setCoordinateId(UUID coordinateId) { + this.coordinateId = coordinateId; + } + + public Coordinate latitude(Float latitude) { + this.latitude = latitude; + return this; + } + + /** + * Get latitude + * @return latitude + **/ + @ApiModelProperty(required = true, value = "") + public Float getLatitude() { + return latitude; + } + + public void setLatitude(Float latitude) { + this.latitude = latitude; + } + + public Coordinate longitude(Float longitude) { + this.longitude = longitude; + return this; + } + + /** + * Get longitude + * @return longitude + **/ + @ApiModelProperty(required = true, value = "") + public Float getLongitude() { + return longitude; + } + + public void setLongitude(Float longitude) { + this.longitude = longitude; + } + + public Coordinate altitude(Float altitude) { + this.altitude = altitude; + return this; + } + + /** + * Get altitude + * @return altitude + **/ + @ApiModelProperty(required = true, value = "") + public Float getAltitude() { + return altitude; + } + + public void setAltitude(Float altitude) { + this.altitude = altitude; + } + + public Coordinate userId(String userId) { + this.userId = userId; + return this; + } + + /** + * Get userId + * @return userId + **/ + @ApiModelProperty(required = true, value = "") + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Coordinate approximatedLocation(String approximatedLocation) { + this.approximatedLocation = approximatedLocation; + return this; + } + + /** + * Get approximatedLocation + * @return approximatedLocation + **/ + @ApiModelProperty(value = "") + public String getApproximatedLocation() { + return approximatedLocation; + } + + public void setApproximatedLocation(String approximatedLocation) { + this.approximatedLocation = approximatedLocation; + } + + public Coordinate displayMode(String displayMode) { + this.displayMode = displayMode; + return this; + } + + /** + * Get displayMode + * @return displayMode + **/ + @ApiModelProperty(required = true, value = "") + public String getDisplayMode() { + return displayMode; + } + + public void setDisplayMode(String displayMode) { + this.displayMode = displayMode; + } + + public Coordinate timeStamp(Long timeStamp) { + this.timeStamp = timeStamp; + return this; + } + + /** + * Get timeStamp + * @return timeStamp + **/ + @ApiModelProperty(value = "") + public Long getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Long timeStamp) { + this.timeStamp = timeStamp; + } + + public Coordinate label(String label) { + this.label = label; + return this; + } + + /** + * Get label + * @return label + **/ + @ApiModelProperty(value = "") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Coordinate coordinate = (Coordinate) o; + return Objects.equals(this.coordinateId, coordinate.coordinateId) && + Objects.equals(this.latitude, coordinate.latitude) && + Objects.equals(this.longitude, coordinate.longitude) && + Objects.equals(this.altitude, coordinate.altitude) && + Objects.equals(this.userId, coordinate.userId) && + Objects.equals(this.approximatedLocation, coordinate.approximatedLocation) && + Objects.equals(this.displayMode, coordinate.displayMode) && + Objects.equals(this.timeStamp, coordinate.timeStamp) && + Objects.equals(this.label, coordinate.label); + } + + @Override + public int hashCode() { + return Objects.hash(coordinateId, latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Coordinate {\n"); + + sb.append(" coordinateId: ").append(toIndentedString(coordinateId)).append("\n"); + sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n"); + sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n"); + sb.append(" altitude: ").append(toIndentedString(altitude)).append("\n"); + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" approximatedLocation: ").append(toIndentedString(approximatedLocation)).append("\n"); + sb.append(" displayMode: ").append(toIndentedString(displayMode)).append("\n"); + sb.append(" timeStamp: ").append(toIndentedString(timeStamp)).append("\n"); + sb.append(" label: ").append(toIndentedString(label)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java b/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java new file mode 100644 index 0000000..a2d0fe3 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java @@ -0,0 +1,192 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.Objects; +import java.util.UUID; + +import io.swagger.annotations.ApiModelProperty; + +/** + * DutyHour + */ + +public class DutyHour { + @SerializedName("dutyHourId") + private UUID dutyHourId = null; + + @SerializedName("tutorTabId") + private UUID tutorTabId = null; + + @SerializedName("day") + private String day = null; + + @SerializedName("start") + private String start = null; + + @SerializedName("end") + private String end = null; + + @SerializedName("tutorTab") + private TutorTab tutorTab = null; + + public DutyHour dutyHourId(UUID dutyHourId) { + this.dutyHourId = dutyHourId; + return this; + } + + /** + * Get dutyHourId + * @return dutyHourId + **/ + @ApiModelProperty(value = "") + public UUID getDutyHourId() { + return dutyHourId; + } + + public void setDutyHourId(UUID dutyHourId) { + this.dutyHourId = dutyHourId; + } + + public DutyHour tutorTabId(UUID tutorTabId) { + this.tutorTabId = tutorTabId; + return this; + } + + /** + * Get tutorTabId + * @return tutorTabId + **/ + @ApiModelProperty(required = true, value = "") + public UUID getTutorTabId() { + return tutorTabId; + } + + public void setTutorTabId(UUID tutorTabId) { + this.tutorTabId = tutorTabId; + } + + public DutyHour day(String day) { + this.day = day; + return this; + } + + /** + * Get day + * @return day + **/ + @ApiModelProperty(value = "") + public String getDay() { + return day; + } + + public void setDay(String day) { + this.day = day; + } + + public DutyHour start(String start) { + this.start = start; + return this; + } + + /** + * Get start + * @return start + **/ + @ApiModelProperty(value = "") + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + public DutyHour end(String end) { + this.end = end; + return this; + } + + /** + * Get end + * @return end + **/ + @ApiModelProperty(value = "") + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } + + public DutyHour tutorTab(TutorTab tutorTab) { + this.tutorTab = tutorTab; + return this; + } + + /** + * Get tutorTab + * @return tutorTab + **/ + @ApiModelProperty(value = "") + public TutorTab getTutorTab() { + return tutorTab; + } + + public void setTutorTab(TutorTab tutorTab) { + this.tutorTab = tutorTab; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DutyHour dutyHour = (DutyHour) o; + return Objects.equals(this.dutyHourId, dutyHour.dutyHourId) && + Objects.equals(this.tutorTabId, dutyHour.tutorTabId) && + Objects.equals(this.day, dutyHour.day) && + Objects.equals(this.start, dutyHour.start) && + Objects.equals(this.end, dutyHour.end) && + Objects.equals(this.tutorTab, dutyHour.tutorTab); + } + + @Override + public int hashCode() { + return Objects.hash(dutyHourId, tutorTabId, day, start, end, tutorTab); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DutyHour {\n"); + + sb.append(" dutyHourId: ").append(toIndentedString(dutyHourId)).append("\n"); + sb.append(" tutorTabId: ").append(toIndentedString(tutorTabId)).append("\n"); + sb.append(" day: ").append(toIndentedString(day)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).append("\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" tutorTab: ").append(toIndentedString(tutorTab)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java new file mode 100644 index 0000000..511e578 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java @@ -0,0 +1,76 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.Objects; + +import io.swagger.annotations.ApiModelProperty; + +/** + * IsUsingListBoolModel + */ + +public class IsUsingListBoolModel { + @SerializedName("isUsing") + private Boolean isUsing = null; + + public IsUsingListBoolModel isUsing(Boolean isUsing) { + this.isUsing = isUsing; + return this; + } + + /** + * Get isUsing + * @return isUsing + **/ + @ApiModelProperty(value = "") + public Boolean isIsUsing() { + return isUsing; + } + + public void setIsUsing(Boolean isUsing) { + this.isUsing = isUsing; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IsUsingListBoolModel isUsingListBoolModel = (IsUsingListBoolModel) o; + return Objects.equals(this.isUsing, isUsingListBoolModel.isUsing); + } + + @Override + public int hashCode() { + return Objects.hash(isUsing); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IsUsingListBoolModel {\n"); + + sb.append(" isUsing: ").append(toIndentedString(isUsing)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java index 5bf06eb..4704389 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java @@ -1,96 +1,218 @@ package com.uam.wmi.findmytutor.model; -import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import java.util.Objects; + +import io.swagger.annotations.ApiModelProperty; + + +/** + * LdapUser + */ + public class LdapUser { + @SerializedName("login") + private String login = null; - @SerializedName("login") - @Expose - private String login; - @SerializedName("password") - @Expose - private String password; - @SerializedName("department") - @Expose - private String department; - @SerializedName("title") - @Expose - private String title; - @SerializedName("firstName") - @Expose - private String firstName; - @SerializedName("lastName") - @Expose - private String lastName; - @SerializedName("email") - @Expose - private String email; + @SerializedName("password") + private String password = null; - public LdapUser(String login, String password, String department, String title, String firstName, String lastName, String email) { - this.login = login; - this.password = password; - this.department = department; - this.title = title; - this.firstName = firstName; - this.lastName = lastName; - this.email = email; + @SerializedName("department") + private String department = null; + + @SerializedName("title") + private String title = null; + + @SerializedName("firstName") + private String firstName = null; + + @SerializedName("lastName") + private String lastName = null; + + @SerializedName("email") + private String email = null; + + public LdapUser(String string, String mPassword, String string1, String pracownik, String string2, String string3, String mEmail) { + } + + public LdapUser login(String login) { + this.login = login; + return this; + } + + /** + * Get login + * @return login + **/ + @ApiModelProperty(required = true, value = "") + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public LdapUser password(String password) { + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @ApiModelProperty(required = true, value = "") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public LdapUser department(String department) { + this.department = department; + return this; + } + + /** + * Get department + * @return department + **/ + @ApiModelProperty(value = "") + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public LdapUser title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * @return title + **/ + @ApiModelProperty(value = "") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public LdapUser firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @ApiModelProperty(value = "") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public LdapUser lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @ApiModelProperty(value = "") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public LdapUser email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @ApiModelProperty(value = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; } - - public String getLogin() { - return login; + if (o == null || getClass() != o.getClass()) { + return false; } + LdapUser ldapUser = (LdapUser) o; + return Objects.equals(this.login, ldapUser.login) && + Objects.equals(this.password, ldapUser.password) && + Objects.equals(this.department, ldapUser.department) && + Objects.equals(this.title, ldapUser.title) && + Objects.equals(this.firstName, ldapUser.firstName) && + Objects.equals(this.lastName, ldapUser.lastName) && + Objects.equals(this.email, ldapUser.email); + } - public void setLogin(String login) { - this.login = login; + @Override + public int hashCode() { + return Objects.hash(login, password, department, title, firstName, lastName, email); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LdapUser {\n"); + + sb.append(" login: ").append(toIndentedString(login)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" department: ").append(toIndentedString(department)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; } + return o.toString().replace("\n", "\n "); + } - public String getPassword() { - return password; - } +} - public void setPassword(String password) { - this.password = password; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java new file mode 100644 index 0000000..1898ce7 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java @@ -0,0 +1,206 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import io.swagger.annotations.ApiModelProperty; + +/** + * PagedResultUserResponseModel + */ + +public class PagedResultUserResponseModel { + @SerializedName("results") + private List results = null; + + @SerializedName("currentPage") + private Integer currentPage = null; + + @SerializedName("pageCount") + private Integer pageCount = null; + + @SerializedName("pageSize") + private Integer pageSize = null; + + @SerializedName("rowCount") + private Integer rowCount = null; + + @SerializedName("firstRowOnPage") + private Integer firstRowOnPage = null; + + @SerializedName("lastRowOnPage") + private Integer lastRowOnPage = null; + + public PagedResultUserResponseModel results(List results) { + this.results = results; + return this; + } + + public PagedResultUserResponseModel addResultsItem(UserResponseModel resultsItem) { + if (this.results == null) { + this.results = new ArrayList(); + } + this.results.add(resultsItem); + return this; + } + + /** + * Get results + * @return results + **/ + @ApiModelProperty(value = "") + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + public PagedResultUserResponseModel currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + /** + * Get currentPage + * @return currentPage + **/ + @ApiModelProperty(value = "") + public Integer getCurrentPage() { + return currentPage; + } + + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + public PagedResultUserResponseModel pageCount(Integer pageCount) { + this.pageCount = pageCount; + return this; + } + + /** + * Get pageCount + * @return pageCount + **/ + @ApiModelProperty(value = "") + public Integer getPageCount() { + return pageCount; + } + + public void setPageCount(Integer pageCount) { + this.pageCount = pageCount; + } + + public PagedResultUserResponseModel pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Get pageSize + * @return pageSize + **/ + @ApiModelProperty(value = "") + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public PagedResultUserResponseModel rowCount(Integer rowCount) { + this.rowCount = rowCount; + return this; + } + + /** + * Get rowCount + * @return rowCount + **/ + @ApiModelProperty(value = "") + public Integer getRowCount() { + return rowCount; + } + + public void setRowCount(Integer rowCount) { + this.rowCount = rowCount; + } + + /** + * Get firstRowOnPage + * @return firstRowOnPage + **/ + @ApiModelProperty(value = "") + public Integer getFirstRowOnPage() { + return firstRowOnPage; + } + + /** + * Get lastRowOnPage + * @return lastRowOnPage + **/ + @ApiModelProperty(value = "") + public Integer getLastRowOnPage() { + return lastRowOnPage; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PagedResultUserResponseModel pagedResultUserResponseModel = (PagedResultUserResponseModel) o; + return Objects.equals(this.results, pagedResultUserResponseModel.results) && + Objects.equals(this.currentPage, pagedResultUserResponseModel.currentPage) && + Objects.equals(this.pageCount, pagedResultUserResponseModel.pageCount) && + Objects.equals(this.pageSize, pagedResultUserResponseModel.pageSize) && + Objects.equals(this.rowCount, pagedResultUserResponseModel.rowCount) && + Objects.equals(this.firstRowOnPage, pagedResultUserResponseModel.firstRowOnPage) && + Objects.equals(this.lastRowOnPage, pagedResultUserResponseModel.lastRowOnPage); + } + + @Override + public int hashCode() { + return Objects.hash(results, currentPage, pageCount, pageSize, rowCount, firstRowOnPage, lastRowOnPage); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PagedResultUserResponseModel {\n"); + + sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" currentPage: ").append(toIndentedString(currentPage)).append("\n"); + sb.append(" pageCount: ").append(toIndentedString(pageCount)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" rowCount: ").append(toIndentedString(rowCount)).append("\n"); + sb.append(" firstRowOnPage: ").append(toIndentedString(firstRowOnPage)).append("\n"); + sb.append(" lastRowOnPage: ").append(toIndentedString(lastRowOnPage)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java new file mode 100644 index 0000000..33c8880 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java @@ -0,0 +1,100 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.Objects; + +import io.swagger.annotations.ApiModelProperty; + + +/** + * StudentIdModel + */ + +public class StudentIdModel { + @SerializedName("studentId") + private String studentId = null; + + @SerializedName("ldapLogin") + private String ldapLogin = null; + + public StudentIdModel studentId(String studentId) { + this.studentId = studentId; + return this; + } + + /** + * Get studentId + * @return studentId + **/ + @ApiModelProperty(value = "") + public String getStudentId() { + return studentId; + } + + public void setStudentId(String studentId) { + this.studentId = studentId; + } + + public StudentIdModel ldapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + return this; + } + + /** + * Get ldapLogin + * @return ldapLogin + **/ + @ApiModelProperty(value = "") + public String getLdapLogin() { + return ldapLogin; + } + + public void setLdapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StudentIdModel studentIdModel = (StudentIdModel) o; + return Objects.equals(this.studentId, studentIdModel.studentId) && + Objects.equals(this.ldapLogin, studentIdModel.ldapLogin); + } + + @Override + public int hashCode() { + return Objects.hash(studentId, ldapLogin); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class StudentIdModel {\n"); + + sb.append(" studentId: ").append(toIndentedString(studentId)).append("\n"); + sb.append(" ldapLogin: ").append(toIndentedString(ldapLogin)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java b/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java new file mode 100644 index 0000000..96d1332 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java @@ -0,0 +1,204 @@ +package com.uam.wmi.findmytutor.model; + + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +import io.swagger.annotations.ApiModelProperty; + + +/** + * TutorTab + */ + +public class TutorTab { + @SerializedName("tutorTabId") + private UUID tutorTabId = null; + + @SerializedName("userId") + private String userId = null; + + @SerializedName("room") + private String room = null; + + @SerializedName("emailTutorTab") + private String emailTutorTab = null; + + @SerializedName("dutyHours") + private List dutyHours = null; + + @SerializedName("user") + private User user = null; + + public TutorTab tutorTabId(UUID tutorTabId) { + this.tutorTabId = tutorTabId; + return this; + } + + /** + * Get tutorTabId + * @return tutorTabId + **/ + @ApiModelProperty(value = "") + public UUID getTutorTabId() { + return tutorTabId; + } + + public void setTutorTabId(UUID tutorTabId) { + this.tutorTabId = tutorTabId; + } + + public TutorTab userId(String userId) { + this.userId = userId; + return this; + } + + /** + * Get userId + * @return userId + **/ + @ApiModelProperty(required = true, value = "") + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public TutorTab room(String room) { + this.room = room; + return this; + } + + /** + * Get room + * @return room + **/ + @ApiModelProperty(value = "") + public String getRoom() { + return room; + } + + public void setRoom(String room) { + this.room = room; + } + + public TutorTab emailTutorTab(String emailTutorTab) { + this.emailTutorTab = emailTutorTab; + return this; + } + + /** + * Get emailTutorTab + * @return emailTutorTab + **/ + @ApiModelProperty(value = "") + public String getEmailTutorTab() { + return emailTutorTab; + } + + public void setEmailTutorTab(String emailTutorTab) { + this.emailTutorTab = emailTutorTab; + } + + public TutorTab dutyHours(List dutyHours) { + this.dutyHours = dutyHours; + return this; + } + + public TutorTab addDutyHoursItem(DutyHour dutyHoursItem) { + if (this.dutyHours == null) { + this.dutyHours = new ArrayList(); + } + this.dutyHours.add(dutyHoursItem); + return this; + } + + /** + * Get dutyHours + * @return dutyHours + **/ + @ApiModelProperty(value = "") + public List getDutyHours() { + return dutyHours; + } + + public void setDutyHours(List dutyHours) { + this.dutyHours = dutyHours; + } + + public TutorTab user(User user) { + this.user = user; + return this; + } + + /** + * Get user + * @return user + **/ + @ApiModelProperty(value = "") + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TutorTab tutorTab = (TutorTab) o; + return Objects.equals(this.tutorTabId, tutorTab.tutorTabId) && + Objects.equals(this.userId, tutorTab.userId) && + Objects.equals(this.room, tutorTab.room) && + Objects.equals(this.emailTutorTab, tutorTab.emailTutorTab) && + Objects.equals(this.dutyHours, tutorTab.dutyHours) && + Objects.equals(this.user, tutorTab.user); + } + + @Override + public int hashCode() { + return Objects.hash(tutorTabId, userId, room, emailTutorTab, dutyHours, user); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TutorTab {\n"); + + sb.append(" tutorTabId: ").append(toIndentedString(tutorTabId)).append("\n"); + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" room: ").append(toIndentedString(room)).append("\n"); + sb.append(" emailTutorTab: ").append(toIndentedString(emailTutorTab)).append("\n"); + sb.append(" dutyHours: ").append(toIndentedString(dutyHours)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/User.java b/app/src/main/java/com/uam/wmi/findmytutor/model/User.java new file mode 100644 index 0000000..3e7f9cc --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/User.java @@ -0,0 +1,726 @@ +package com.uam.wmi.findmytutor.model; + + +import com.google.gson.annotations.SerializedName; + +import org.threeten.bp.OffsetDateTime; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import io.swagger.annotations.ApiModelProperty; + +/** + * User + */ + +public class User { + @SerializedName("isOnline") + private Boolean isOnline = null; + + @SerializedName("isUsingBlacklist") + private Boolean isUsingBlacklist = null; + + @SerializedName("isUsingWhitelist") + private Boolean isUsingWhitelist = null; + + @SerializedName("blacklist") + private List blacklist = null; + + @SerializedName("whitelist") + private List whitelist = null; + + @SerializedName("department") + private String department = null; + + @SerializedName("ldapLogin") + private String ldapLogin = null; + + @SerializedName("title") + private String title = null; + + @SerializedName("firstName") + private String firstName = null; + + @SerializedName("lastName") + private String lastName = null; + + @SerializedName("isActive") + private Boolean isActive = null; + + @SerializedName("tutorTab") + private TutorTab tutorTab = null; + + @SerializedName("coordinates") + private List coordinates = null; + + @SerializedName("id") + private String id = null; + + @SerializedName("userName") + private String userName = null; + + @SerializedName("normalizedUserName") + private String normalizedUserName = null; + + @SerializedName("email") + private String email = null; + + @SerializedName("normalizedEmail") + private String normalizedEmail = null; + + @SerializedName("emailConfirmed") + private Boolean emailConfirmed = null; + + @SerializedName("passwordHash") + private String passwordHash = null; + + @SerializedName("securityStamp") + private String securityStamp = null; + + @SerializedName("concurrencyStamp") + private String concurrencyStamp = null; + + @SerializedName("phoneNumber") + private String phoneNumber = null; + + @SerializedName("phoneNumberConfirmed") + private Boolean phoneNumberConfirmed = null; + + @SerializedName("twoFactorEnabled") + private Boolean twoFactorEnabled = null; + + @SerializedName("lockoutEnd") + private OffsetDateTime lockoutEnd = null; + + @SerializedName("lockoutEnabled") + private Boolean lockoutEnabled = null; + + @SerializedName("accessFailedCount") + private Integer accessFailedCount = null; + + public User isOnline(Boolean isOnline) { + this.isOnline = isOnline; + return this; + } + + /** + * Get isOnline + * @return isOnline + **/ + @ApiModelProperty(value = "") + public Boolean isIsOnline() { + return isOnline; + } + + public void setIsOnline(Boolean isOnline) { + this.isOnline = isOnline; + } + + public User isUsingBlacklist(Boolean isUsingBlacklist) { + this.isUsingBlacklist = isUsingBlacklist; + return this; + } + + /** + * Get isUsingBlacklist + * @return isUsingBlacklist + **/ + @ApiModelProperty(value = "") + public Boolean isIsUsingBlacklist() { + return isUsingBlacklist; + } + + public void setIsUsingBlacklist(Boolean isUsingBlacklist) { + this.isUsingBlacklist = isUsingBlacklist; + } + + public User isUsingWhitelist(Boolean isUsingWhitelist) { + this.isUsingWhitelist = isUsingWhitelist; + return this; + } + + /** + * Get isUsingWhitelist + * @return isUsingWhitelist + **/ + @ApiModelProperty(value = "") + public Boolean isIsUsingWhitelist() { + return isUsingWhitelist; + } + + public void setIsUsingWhitelist(Boolean isUsingWhitelist) { + this.isUsingWhitelist = isUsingWhitelist; + } + + public User blacklist(List blacklist) { + this.blacklist = blacklist; + return this; + } + + public User addBlacklistItem(String blacklistItem) { + if (this.blacklist == null) { + this.blacklist = new ArrayList(); + } + this.blacklist.add(blacklistItem); + return this; + } + + /** + * Get blacklist + * @return blacklist + **/ + @ApiModelProperty(value = "") + public List getBlacklist() { + return blacklist; + } + + public void setBlacklist(List blacklist) { + this.blacklist = blacklist; + } + + public User whitelist(List whitelist) { + this.whitelist = whitelist; + return this; + } + + public User addWhitelistItem(String whitelistItem) { + if (this.whitelist == null) { + this.whitelist = new ArrayList(); + } + this.whitelist.add(whitelistItem); + return this; + } + + /** + * Get whitelist + * @return whitelist + **/ + @ApiModelProperty(value = "") + public List getWhitelist() { + return whitelist; + } + + public void setWhitelist(List whitelist) { + this.whitelist = whitelist; + } + + public User department(String department) { + this.department = department; + return this; + } + + /** + * Get department + * @return department + **/ + @ApiModelProperty(required = true, value = "") + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public User ldapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + return this; + } + + /** + * Get ldapLogin + * @return ldapLogin + **/ + @ApiModelProperty(required = true, value = "") + public String getLdapLogin() { + return ldapLogin; + } + + public void setLdapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + } + + public User title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * @return title + **/ + @ApiModelProperty(required = true, value = "") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @ApiModelProperty(required = true, value = "") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @ApiModelProperty(required = true, value = "") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User isActive(Boolean isActive) { + this.isActive = isActive; + return this; + } + + /** + * Get isActive + * @return isActive + **/ + @ApiModelProperty(required = true, value = "") + public Boolean isIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public User tutorTab(TutorTab tutorTab) { + this.tutorTab = tutorTab; + return this; + } + + /** + * Get tutorTab + * @return tutorTab + **/ + @ApiModelProperty(value = "") + public TutorTab getTutorTab() { + return tutorTab; + } + + public void setTutorTab(TutorTab tutorTab) { + this.tutorTab = tutorTab; + } + + public User coordinates(List coordinates) { + this.coordinates = coordinates; + return this; + } + + public User addCoordinatesItem(Coordinate coordinatesItem) { + if (this.coordinates == null) { + this.coordinates = new ArrayList(); + } + this.coordinates.add(coordinatesItem); + return this; + } + + /** + * Get coordinates + * @return coordinates + **/ + @ApiModelProperty(value = "") + public List getCoordinates() { + return coordinates; + } + + public void setCoordinates(List coordinates) { + this.coordinates = coordinates; + } + + public User id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public User userName(String userName) { + this.userName = userName; + return this; + } + + /** + * Get userName + * @return userName + **/ + @ApiModelProperty(value = "") + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public User normalizedUserName(String normalizedUserName) { + this.normalizedUserName = normalizedUserName; + return this; + } + + /** + * Get normalizedUserName + * @return normalizedUserName + **/ + @ApiModelProperty(value = "") + public String getNormalizedUserName() { + return normalizedUserName; + } + + public void setNormalizedUserName(String normalizedUserName) { + this.normalizedUserName = normalizedUserName; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @ApiModelProperty(value = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User normalizedEmail(String normalizedEmail) { + this.normalizedEmail = normalizedEmail; + return this; + } + + /** + * Get normalizedEmail + * @return normalizedEmail + **/ + @ApiModelProperty(value = "") + public String getNormalizedEmail() { + return normalizedEmail; + } + + public void setNormalizedEmail(String normalizedEmail) { + this.normalizedEmail = normalizedEmail; + } + + public User emailConfirmed(Boolean emailConfirmed) { + this.emailConfirmed = emailConfirmed; + return this; + } + + /** + * Get emailConfirmed + * @return emailConfirmed + **/ + @ApiModelProperty(value = "") + public Boolean isEmailConfirmed() { + return emailConfirmed; + } + + public void setEmailConfirmed(Boolean emailConfirmed) { + this.emailConfirmed = emailConfirmed; + } + + public User passwordHash(String passwordHash) { + this.passwordHash = passwordHash; + return this; + } + + /** + * Get passwordHash + * @return passwordHash + **/ + @ApiModelProperty(value = "") + public String getPasswordHash() { + return passwordHash; + } + + public void setPasswordHash(String passwordHash) { + this.passwordHash = passwordHash; + } + + public User securityStamp(String securityStamp) { + this.securityStamp = securityStamp; + return this; + } + + /** + * Get securityStamp + * @return securityStamp + **/ + @ApiModelProperty(value = "") + public String getSecurityStamp() { + return securityStamp; + } + + public void setSecurityStamp(String securityStamp) { + this.securityStamp = securityStamp; + } + + public User concurrencyStamp(String concurrencyStamp) { + this.concurrencyStamp = concurrencyStamp; + return this; + } + + /** + * Get concurrencyStamp + * @return concurrencyStamp + **/ + @ApiModelProperty(value = "") + public String getConcurrencyStamp() { + return concurrencyStamp; + } + + public void setConcurrencyStamp(String concurrencyStamp) { + this.concurrencyStamp = concurrencyStamp; + } + + public User phoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + /** + * Get phoneNumber + * @return phoneNumber + **/ + @ApiModelProperty(value = "") + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public User phoneNumberConfirmed(Boolean phoneNumberConfirmed) { + this.phoneNumberConfirmed = phoneNumberConfirmed; + return this; + } + + /** + * Get phoneNumberConfirmed + * @return phoneNumberConfirmed + **/ + @ApiModelProperty(value = "") + public Boolean isPhoneNumberConfirmed() { + return phoneNumberConfirmed; + } + + public void setPhoneNumberConfirmed(Boolean phoneNumberConfirmed) { + this.phoneNumberConfirmed = phoneNumberConfirmed; + } + + public User twoFactorEnabled(Boolean twoFactorEnabled) { + this.twoFactorEnabled = twoFactorEnabled; + return this; + } + + /** + * Get twoFactorEnabled + * @return twoFactorEnabled + **/ + @ApiModelProperty(value = "") + public Boolean isTwoFactorEnabled() { + return twoFactorEnabled; + } + + public void setTwoFactorEnabled(Boolean twoFactorEnabled) { + this.twoFactorEnabled = twoFactorEnabled; + } + + public User lockoutEnd(OffsetDateTime lockoutEnd) { + this.lockoutEnd = lockoutEnd; + return this; + } + + /** + * Get lockoutEnd + * @return lockoutEnd + **/ + @ApiModelProperty(value = "") + public OffsetDateTime getLockoutEnd() { + return lockoutEnd; + } + + public void setLockoutEnd(OffsetDateTime lockoutEnd) { + this.lockoutEnd = lockoutEnd; + } + + public User lockoutEnabled(Boolean lockoutEnabled) { + this.lockoutEnabled = lockoutEnabled; + return this; + } + + /** + * Get lockoutEnabled + * @return lockoutEnabled + **/ + @ApiModelProperty(value = "") + public Boolean isLockoutEnabled() { + return lockoutEnabled; + } + + public void setLockoutEnabled(Boolean lockoutEnabled) { + this.lockoutEnabled = lockoutEnabled; + } + + public User accessFailedCount(Integer accessFailedCount) { + this.accessFailedCount = accessFailedCount; + return this; + } + + /** + * Get accessFailedCount + * @return accessFailedCount + **/ + @ApiModelProperty(value = "") + public Integer getAccessFailedCount() { + return accessFailedCount; + } + + public void setAccessFailedCount(Integer accessFailedCount) { + this.accessFailedCount = accessFailedCount; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.isOnline, user.isOnline) && + Objects.equals(this.isUsingBlacklist, user.isUsingBlacklist) && + Objects.equals(this.isUsingWhitelist, user.isUsingWhitelist) && + Objects.equals(this.blacklist, user.blacklist) && + Objects.equals(this.whitelist, user.whitelist) && + Objects.equals(this.department, user.department) && + Objects.equals(this.ldapLogin, user.ldapLogin) && + Objects.equals(this.title, user.title) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.isActive, user.isActive) && + Objects.equals(this.tutorTab, user.tutorTab) && + Objects.equals(this.coordinates, user.coordinates) && + Objects.equals(this.id, user.id) && + Objects.equals(this.userName, user.userName) && + Objects.equals(this.normalizedUserName, user.normalizedUserName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.normalizedEmail, user.normalizedEmail) && + Objects.equals(this.emailConfirmed, user.emailConfirmed) && + Objects.equals(this.passwordHash, user.passwordHash) && + Objects.equals(this.securityStamp, user.securityStamp) && + Objects.equals(this.concurrencyStamp, user.concurrencyStamp) && + Objects.equals(this.phoneNumber, user.phoneNumber) && + Objects.equals(this.phoneNumberConfirmed, user.phoneNumberConfirmed) && + Objects.equals(this.twoFactorEnabled, user.twoFactorEnabled) && + Objects.equals(this.lockoutEnd, user.lockoutEnd) && + Objects.equals(this.lockoutEnabled, user.lockoutEnabled) && + Objects.equals(this.accessFailedCount, user.accessFailedCount); + } + + @Override + public int hashCode() { + return Objects.hash(isOnline, isUsingBlacklist, isUsingWhitelist, blacklist, whitelist, department, ldapLogin, title, firstName, lastName, isActive, tutorTab, coordinates, id, userName, normalizedUserName, email, normalizedEmail, emailConfirmed, passwordHash, securityStamp, concurrencyStamp, phoneNumber, phoneNumberConfirmed, twoFactorEnabled, lockoutEnd, lockoutEnabled, accessFailedCount); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" isOnline: ").append(toIndentedString(isOnline)).append("\n"); + sb.append(" isUsingBlacklist: ").append(toIndentedString(isUsingBlacklist)).append("\n"); + sb.append(" isUsingWhitelist: ").append(toIndentedString(isUsingWhitelist)).append("\n"); + sb.append(" blacklist: ").append(toIndentedString(blacklist)).append("\n"); + sb.append(" whitelist: ").append(toIndentedString(whitelist)).append("\n"); + sb.append(" department: ").append(toIndentedString(department)).append("\n"); + sb.append(" ldapLogin: ").append(toIndentedString(ldapLogin)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" isActive: ").append(toIndentedString(isActive)).append("\n"); + sb.append(" tutorTab: ").append(toIndentedString(tutorTab)).append("\n"); + sb.append(" coordinates: ").append(toIndentedString(coordinates)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" userName: ").append(toIndentedString(userName)).append("\n"); + sb.append(" normalizedUserName: ").append(toIndentedString(normalizedUserName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" normalizedEmail: ").append(toIndentedString(normalizedEmail)).append("\n"); + sb.append(" emailConfirmed: ").append(toIndentedString(emailConfirmed)).append("\n"); + sb.append(" passwordHash: ").append(toIndentedString(passwordHash)).append("\n"); + sb.append(" securityStamp: ").append(toIndentedString(securityStamp)).append("\n"); + sb.append(" concurrencyStamp: ").append(toIndentedString(concurrencyStamp)).append("\n"); + sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n"); + sb.append(" phoneNumberConfirmed: ").append(toIndentedString(phoneNumberConfirmed)).append("\n"); + sb.append(" twoFactorEnabled: ").append(toIndentedString(twoFactorEnabled)).append("\n"); + sb.append(" lockoutEnd: ").append(toIndentedString(lockoutEnd)).append("\n"); + sb.append(" lockoutEnabled: ").append(toIndentedString(lockoutEnabled)).append("\n"); + sb.append(" accessFailedCount: ").append(toIndentedString(accessFailedCount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java new file mode 100644 index 0000000..cef0da8 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java @@ -0,0 +1,393 @@ +package com.uam.wmi.findmytutor.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.Objects; +import java.util.List; +import java.util.ArrayList; +import io.swagger.annotations.ApiModelProperty; + + +/** + * UserResponseModel + */ + +public class UserResponseModel { + @SerializedName("id") + private String id = null; + + @SerializedName("isOnline") + private Boolean isOnline = null; + + @SerializedName("isUsingBlacklist") + private Boolean isUsingBlacklist = null; + + @SerializedName("isUsingWhitelist") + private Boolean isUsingWhitelist = null; + + @SerializedName("blacklist") + private List blacklist = null; + + @SerializedName("whitelist") + private List whitelist = null; + + @SerializedName("ldapLogin") + private String ldapLogin = null; + + @SerializedName("title") + private String title = null; + + @SerializedName("firstName") + private String firstName = null; + + @SerializedName("lastName") + private String lastName = null; + + @SerializedName("department") + private String department = null; + + @SerializedName("userName") + private String userName = null; + + @SerializedName("email") + private String email = null; + + @SerializedName("isActive") + private Boolean isActive = null; + + public UserResponseModel id(String id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @ApiModelProperty(value = "") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public UserResponseModel isOnline(Boolean isOnline) { + this.isOnline = isOnline; + return this; + } + + /** + * Get isOnline + * @return isOnline + **/ + @ApiModelProperty(value = "") + public Boolean isIsOnline() { + return isOnline; + } + + public void setIsOnline(Boolean isOnline) { + this.isOnline = isOnline; + } + + public UserResponseModel isUsingBlacklist(Boolean isUsingBlacklist) { + this.isUsingBlacklist = isUsingBlacklist; + return this; + } + + /** + * Get isUsingBlacklist + * @return isUsingBlacklist + **/ + @ApiModelProperty(value = "") + public Boolean isIsUsingBlacklist() { + return isUsingBlacklist; + } + + public void setIsUsingBlacklist(Boolean isUsingBlacklist) { + this.isUsingBlacklist = isUsingBlacklist; + } + + public UserResponseModel isUsingWhitelist(Boolean isUsingWhitelist) { + this.isUsingWhitelist = isUsingWhitelist; + return this; + } + + /** + * Get isUsingWhitelist + * @return isUsingWhitelist + **/ + @ApiModelProperty(value = "") + public Boolean isIsUsingWhitelist() { + return isUsingWhitelist; + } + + public void setIsUsingWhitelist(Boolean isUsingWhitelist) { + this.isUsingWhitelist = isUsingWhitelist; + } + + public UserResponseModel blacklist(List blacklist) { + this.blacklist = blacklist; + return this; + } + + public UserResponseModel addBlacklistItem(String blacklistItem) { + if (this.blacklist == null) { + this.blacklist = new ArrayList(); + } + this.blacklist.add(blacklistItem); + return this; + } + + /** + * Get blacklist + * @return blacklist + **/ + @ApiModelProperty(value = "") + public List getBlacklist() { + return blacklist; + } + + public void setBlacklist(List blacklist) { + this.blacklist = blacklist; + } + + public UserResponseModel whitelist(List whitelist) { + this.whitelist = whitelist; + return this; + } + + public UserResponseModel addWhitelistItem(String whitelistItem) { + if (this.whitelist == null) { + this.whitelist = new ArrayList(); + } + this.whitelist.add(whitelistItem); + return this; + } + + /** + * Get whitelist + * @return whitelist + **/ + @ApiModelProperty(value = "") + public List getWhitelist() { + return whitelist; + } + + public void setWhitelist(List whitelist) { + this.whitelist = whitelist; + } + + public UserResponseModel ldapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + return this; + } + + /** + * Get ldapLogin + * @return ldapLogin + **/ + @ApiModelProperty(value = "") + public String getLdapLogin() { + return ldapLogin; + } + + public void setLdapLogin(String ldapLogin) { + this.ldapLogin = ldapLogin; + } + + public UserResponseModel title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * @return title + **/ + @ApiModelProperty(value = "") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public UserResponseModel firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + @ApiModelProperty(value = "") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public UserResponseModel lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + @ApiModelProperty(value = "") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public UserResponseModel department(String department) { + this.department = department; + return this; + } + + /** + * Get department + * @return department + **/ + @ApiModelProperty(value = "") + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public UserResponseModel userName(String userName) { + this.userName = userName; + return this; + } + + /** + * Get userName + * @return userName + **/ + @ApiModelProperty(value = "") + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public UserResponseModel email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + @ApiModelProperty(value = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public UserResponseModel isActive(Boolean isActive) { + this.isActive = isActive; + return this; + } + + /** + * Get isActive + * @return isActive + **/ + @ApiModelProperty(value = "") + public Boolean isIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserResponseModel userResponseModel = (UserResponseModel) o; + return Objects.equals(this.id, userResponseModel.id) && + Objects.equals(this.isOnline, userResponseModel.isOnline) && + Objects.equals(this.isUsingBlacklist, userResponseModel.isUsingBlacklist) && + Objects.equals(this.isUsingWhitelist, userResponseModel.isUsingWhitelist) && + Objects.equals(this.blacklist, userResponseModel.blacklist) && + Objects.equals(this.whitelist, userResponseModel.whitelist) && + Objects.equals(this.ldapLogin, userResponseModel.ldapLogin) && + Objects.equals(this.title, userResponseModel.title) && + Objects.equals(this.firstName, userResponseModel.firstName) && + Objects.equals(this.lastName, userResponseModel.lastName) && + Objects.equals(this.department, userResponseModel.department) && + Objects.equals(this.userName, userResponseModel.userName) && + Objects.equals(this.email, userResponseModel.email) && + Objects.equals(this.isActive, userResponseModel.isActive); + } + + @Override + public int hashCode() { + return Objects.hash(id, isOnline, isUsingBlacklist, isUsingWhitelist, blacklist, whitelist, ldapLogin, title, firstName, lastName, department, userName, email, isActive); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserResponseModel {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" isOnline: ").append(toIndentedString(isOnline)).append("\n"); + sb.append(" isUsingBlacklist: ").append(toIndentedString(isUsingBlacklist)).append("\n"); + sb.append(" isUsingWhitelist: ").append(toIndentedString(isUsingWhitelist)).append("\n"); + sb.append(" blacklist: ").append(toIndentedString(blacklist)).append("\n"); + sb.append(" whitelist: ").append(toIndentedString(whitelist)).append("\n"); + sb.append(" ldapLogin: ").append(toIndentedString(ldapLogin)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" department: ").append(toIndentedString(department)).append("\n"); + sb.append(" userName: ").append(toIndentedString(userName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" isActive: ").append(toIndentedString(isActive)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java new file mode 100644 index 0000000..46a4236 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java @@ -0,0 +1,48 @@ +package com.uam.wmi.findmytutor.service; + +import com.uam.wmi.findmytutor.model.Coordinate; +import com.uam.wmi.findmytutor.model.JwtToken; + +import java.util.List; + +import okhttp3.ResponseBody; +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.DELETE; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Path; + +public interface Coordinates { + + @GET("api/coordinates") + Call> getAllCoordinates(@Header("Authorization") JwtToken token); + + @GET("api/coordinates/{id}") + Call getCoordinatesById(@Path("id") String id, @Header("Authorization") JwtToken token); + + @GET("api/coordinates/user/{userId}") + Call> getCoordinatesByUserId(@Path("userId") String userId , @Header("Authorization") JwtToken token); + + @GET("api/coordinates/userTop/{userId}") + Call> getTopCoordinatesByUserId(@Path("userId") String userId , @Header("Authorization") JwtToken token); + + @GET("api/coordinates/top") + Call> getTopCoordinates(@Header("Authorization") JwtToken token); + + @GET("api/coordinates/top/online") + Call> getOnlineCoordinates(@Header("Authorization") JwtToken token); + + @POST("api/coordinates") + Call postCoordinate(@Body Coordinate coordinate, @Header("Authorization") JwtToken token); + + @PUT("api/coordinates/{id}") + Call putCoordinatesById(@Path("id") String id, @Header("Authorization") JwtToken token); + + @DELETE("api/coordinates/{id}") + Call deleteCoordinatesById(@Path("id") String id, @Header("Authorization") JwtToken token); + +} + From ceeb62bcecd4d77a3ed28621c33997ad56d918f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Sat, 25 Aug 2018 22:48:37 +0200 Subject: [PATCH 03/14] updated gitignore and removed .idea cache from tracked files --- .gitignore | 71 +++++++++++++++++++++++--- .idea/caches/build_file_checksums.ser | Bin 540 -> 0 bytes 2 files changed, 63 insertions(+), 8 deletions(-) delete mode 100644 .idea/caches/build_file_checksums.ser diff --git a/.gitignore b/.gitignore index 5edb4ee..3c117df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,65 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ *.iml -.gradle -/local.properties -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -.DS_Store -/build -/captures +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following line if you do not want to check your keystore files in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later .externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md \ No newline at end of file diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser deleted file mode 100644 index f7feae91852b188555d60a2737ba5b7286cc2c32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 540 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}uGBYr_F>vMNC#JY1CYR(Fc`|U8WE7{mc1 z7N?e!Wagz8!!#B$)G@Gu)Xuw^u+Qc`d!BBBo>aKg;e{m(+Rj!np~b01#WA^wMOmpS zhDI?^T``EjEJ!UX$xJOSg`0Clw&!L)!zPxO4V*LH{BWu(Vc Date: Sun, 26 Aug 2018 13:09:43 +0200 Subject: [PATCH 04/14] Add JWT authorization --- app/build.gradle | 5 ++ .../findmytutor/activity/LoginActivity.java | 2 +- .../findmytutor/activity/MainActivity.java | 35 +++++++- .../network/RetrofitClientInstance.java | 90 ++++++++----------- .../wmi/findmytutor/service/Coordinates.java | 2 +- 5 files changed, 75 insertions(+), 59 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d0b1d68..b82179e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,10 @@ apply plugin: 'com.android.application' android { compileSdkVersion 27 + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } defaultConfig { applicationId "com.uam.wmi.findmytutor" minSdkVersion 19 @@ -31,5 +35,6 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation "io.swagger:swagger-annotations:1.5.15" implementation "org.threeten:threetenbp:1.3.5" + implementation "com.squareup.okhttp3:logging-interceptor:3.10.0" } 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 d876bcd..50b3848 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 @@ -319,7 +319,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< @Override protected Boolean doInBackground(Void... params) { - LdapService service = RetrofitClientInstance.getRetrofitLoginInstance().create(LdapService.class); + LdapService service = RetrofitClientInstance.createService(LdapService.class); LdapUser user = new LdapUser("string",mPassword,"string","pracownik","string","string",mEmail); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index 2eac035..6c8011b 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -5,7 +5,19 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; +import android.widget.Toast; + import com.uam.wmi.findmytutor.R; +import com.uam.wmi.findmytutor.model.Coordinate; +import com.uam.wmi.findmytutor.network.RetrofitClientInstance; +import com.uam.wmi.findmytutor.service.Coordinates; + +import java.util.List; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + public class MainActivity extends AppCompatActivity { @@ -14,8 +26,27 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); - String text = sharedPref.getString("test",null); - Log.e("Mainactivity", text); + final String authToken = sharedPref.getString("authToken",null); + + Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken); + + Call> call = service.getTopCoordinates(authToken); + + + call.enqueue(new Callback>() { + @Override + public void onResponse(Call> call, Response> response) { + Log.e("MainActivity", "rsp: " + response.body()); + } + + @Override + public void onFailure(Call> call, Throwable t) { + Toast.makeText(MainActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show(); + } + }); + + + } } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java b/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java index d537f97..77db473 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java @@ -1,71 +1,51 @@ package com.uam.wmi.findmytutor.network; -import java.util.concurrent.TimeUnit; - import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class RetrofitClientInstance { - private static Retrofit retrofit; + private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/"; + private static Retrofit.Builder builder + = new Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(GsonConverterFactory.create()); - public static Retrofit getRetrofitLoginInstance() { - if (retrofit == null) { - retrofit = new retrofit2.Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create()) - .build(); + private static Retrofit retrofit = builder.build(); + + private static OkHttpClient.Builder httpClient + = new OkHttpClient.Builder(); + + private static HttpLoggingInterceptor logging + = new HttpLoggingInterceptor() + .setLevel(HttpLoggingInterceptor.Level.BASIC); + + public static S createService(Class serviceClass) { + if (!httpClient.interceptors().contains(logging)) { + httpClient.addInterceptor(logging); + builder.client(httpClient.build()); + retrofit = builder.build(); } - return retrofit; + return retrofit.create(serviceClass); } - public static Retrofit getRetrofitInstance() { - if (retrofit == null) { - retrofit = new retrofit2.Retrofit.Builder() - .baseUrl(BASE_URL) - .client(provideOkHttpClient()) - .addConverterFactory(GsonConverterFactory.create()) - .build(); + public static S createService(Class serviceClass, final String token) { + if (token != null) { + httpClient.interceptors().clear(); + httpClient.addInterceptor(chain -> { + Request original = chain.request(); + Request.Builder builder1 = original.newBuilder() + .header("Authorization", "Bearer " + token); + Request request = builder1.build(); + return chain.proceed(request); + }); + builder.client(httpClient.build()); + retrofit = builder.build(); } - return retrofit; + return retrofit.create(serviceClass); } - - private static OkHttpClient provideOkHttpClient() { - OkHttpClient.Builder okhttpClientBuilder = new OkHttpClient.Builder(); - okhttpClientBuilder.connectTimeout(30, TimeUnit.SECONDS); - okhttpClientBuilder.readTimeout(30, TimeUnit.SECONDS); - okhttpClientBuilder.writeTimeout(30, TimeUnit.SECONDS); - return okhttpClientBuilder.build(); - } - -// -// private OkHttpClient provideokHttpClient() { -// OkHttpClient.Builder okhttpClientBuilder = new OkHttpClient.Builder(); -// okhttpClientBuilder.connectTimeout(30, TimeUnit.SECONDS); -// okhttpClientBuilder.readTimeout(30, TimeUnit.SECONDS); -// okhttpClientBuilder.writeTimeout(30, TimeUnit.SECONDS); -// -// okhttpClientBuilder.addInterceptor(new NetworkConnectionInterceptor() { -// @Override -// public boolean isInternetAvailable() { -// return this.isInternetAvailable(); -// } -// -// @Override -// public void onInternetUnavailable() { -// if (mInternetConnectionListener != null) { -// mInternetConnectionListener.onInternetUnavailable(); -// } -// } -// -// @Override -// public void onCacheUnavailable() { -// if (mInternetConnectionListener != null) { -// mInternetConnectionListener.onCacheUnavailable(); -// } -// } -// }); -// } } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java index 46a4236..f4d6960 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java @@ -30,7 +30,7 @@ public interface Coordinates { Call> getTopCoordinatesByUserId(@Path("userId") String userId , @Header("Authorization") JwtToken token); @GET("api/coordinates/top") - Call> getTopCoordinates(@Header("Authorization") JwtToken token); + Call> getTopCoordinates(@Header("Authorization") String auth); @GET("api/coordinates/top/online") Call> getOnlineCoordinates(@Header("Authorization") JwtToken token); From 5eea1133b974969c11e85059500a34120c6d776d Mon Sep 17 00:00:00 2001 From: Mieszko Date: Sun, 26 Aug 2018 13:11:20 +0200 Subject: [PATCH 05/14] Refactor of service --- .../java/com/uam/wmi/findmytutor/activity/MainActivity.java | 2 +- .../main/java/com/uam/wmi/findmytutor/service/Coordinates.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index 6c8011b..1032282 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -30,7 +30,7 @@ public class MainActivity extends AppCompatActivity { Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken); - Call> call = service.getTopCoordinates(authToken); + Call> call = service.getTopCoordinates(); call.enqueue(new Callback>() { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java index f4d6960..48f84a5 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java @@ -30,7 +30,7 @@ public interface Coordinates { Call> getTopCoordinatesByUserId(@Path("userId") String userId , @Header("Authorization") JwtToken token); @GET("api/coordinates/top") - Call> getTopCoordinates(@Header("Authorization") String auth); + Call> getTopCoordinates(); @GET("api/coordinates/top/online") Call> getOnlineCoordinates(@Header("Authorization") JwtToken token); From 68eec30ecded7fed4c840fa451dfd76eb14466ff Mon Sep 17 00:00:00 2001 From: Mieszko Date: Sun, 26 Aug 2018 13:17:43 +0200 Subject: [PATCH 06/14] Remove unnecessary headers from service --- .../wmi/findmytutor/service/Coordinates.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java index 48f84a5..088cd3c 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java @@ -1,7 +1,6 @@ package com.uam.wmi.findmytutor.service; import com.uam.wmi.findmytutor.model.Coordinate; -import com.uam.wmi.findmytutor.model.JwtToken; import java.util.List; @@ -10,7 +9,6 @@ import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; -import retrofit2.http.Header; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; @@ -18,31 +16,31 @@ import retrofit2.http.Path; public interface Coordinates { @GET("api/coordinates") - Call> getAllCoordinates(@Header("Authorization") JwtToken token); + Call> getAllCoordinates(); @GET("api/coordinates/{id}") - Call getCoordinatesById(@Path("id") String id, @Header("Authorization") JwtToken token); + Call getCoordinatesById(@Path("id") String id); @GET("api/coordinates/user/{userId}") - Call> getCoordinatesByUserId(@Path("userId") String userId , @Header("Authorization") JwtToken token); + Call> getCoordinatesByUserId(@Path("userId") String userId); @GET("api/coordinates/userTop/{userId}") - Call> getTopCoordinatesByUserId(@Path("userId") String userId , @Header("Authorization") JwtToken token); + Call> getTopCoordinatesByUserId(@Path("userId") String userId); @GET("api/coordinates/top") Call> getTopCoordinates(); @GET("api/coordinates/top/online") - Call> getOnlineCoordinates(@Header("Authorization") JwtToken token); + Call> getOnlineCoordinates(); @POST("api/coordinates") - Call postCoordinate(@Body Coordinate coordinate, @Header("Authorization") JwtToken token); + Call postCoordinate(@Body Coordinate coordinate); @PUT("api/coordinates/{id}") - Call putCoordinatesById(@Path("id") String id, @Header("Authorization") JwtToken token); + Call putCoordinatesById(@Path("id") String id); @DELETE("api/coordinates/{id}") - Call deleteCoordinatesById(@Path("id") String id, @Header("Authorization") JwtToken token); + Call deleteCoordinatesById(@Path("id") String id); } From 4510b887ccca13cd6f14e0c439ae02160cc4bf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Sun, 26 Aug 2018 16:19:04 +0200 Subject: [PATCH 07/14] fixed response type for post methods --- .gitignore | 6 ++++-- .idea/caches/build_file_checksums.ser | Bin 0 -> 540 bytes .idea/misc.xml | 2 +- .../uam/wmi/findmytutor/service/UserService.java | 8 +++++--- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .idea/caches/build_file_checksums.ser diff --git a/.gitignore b/.gitignore index 3c117df..0c1fdca 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,9 @@ captures/ .idea/dictionaries .idea/libraries .idea/caches - +.idea/vcs.xml +.idea/workspace.xml +.idea/modules.xml # Keystore files # Uncomment the following line if you do not want to check your keystore files in. #*.jks @@ -62,4 +64,4 @@ fastlane/report.xml fastlane/Preview.html fastlane/screenshots fastlane/test_output -fastlane/readme.md \ No newline at end of file +fastlane/readme.md diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000000000000000000000000000000000000..065fdfe34a95bb8b03dcca74561cfff4cc6a7a85 GIT binary patch literal 540 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}Q#7BMhIJFWRF{)3GpI3_o-C@VF^ z&?p9~D+Upm1*t_PnW@F4aC5H6_T21e*u?U(fpf;2A5L{83_K_47&`?vLw{r566LUaOgkfsH+?5_iXBZyT^R;EYec5hV!XSvp4WE0NSM5ny>bJ=@ L&G^|_fusrms{FdJ literal 0 HcmV?d00001 diff --git a/.idea/misc.xml b/.idea/misc.xml index c0f68ed..99202cc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + 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 e74aaac..8aad341 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 @@ -6,6 +6,7 @@ import com.uam.wmi.findmytutor.model.IsUsingListBool; import com.uam.wmi.findmytutor.model.StudentIdModel; import java.util.List; +import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; @@ -15,12 +16,13 @@ import retrofit2.http.POST; import retrofit2.http.Path; import retrofit2.http.Header; + public interface UserService { @GET("api/users") Call> getAllUsers(@Header("Authorization") JwtToken token); @POST("api/users") - Call> postAllUsers(@Header("Authorization") JwtToken token); + Call createUser(@Body User user,@Header("Authorization") JwtToken token); @GET("api/users/page/{pageNum}") Call getPagedUsers(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); @@ -56,7 +58,7 @@ public interface UserService { Call setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing,@Header("Authorization") JwtToken token); @POST("api/users/blacklist/{tutorID}") - Call> addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + Call addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); @DELETE("api/users/blacklist/{tutorID}") Call> removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); @@ -68,7 +70,7 @@ public interface UserService { Call setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing,@Header("Authorization") JwtToken token); @POST("api/users/whitelist/{tutorID}") - Call> addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + Call addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); @DELETE("api/users/whitelist/{tutorID}") Call> removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); From 6dcad78524870b012f49f34bb308244aa1238d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Sun, 26 Aug 2018 16:30:19 +0200 Subject: [PATCH 08/14] removed token from arg list --- .../wmi/findmytutor/service/UserService.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) 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 8aad341..0dc77a0 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 @@ -22,7 +22,7 @@ public interface UserService { Call> getAllUsers(@Header("Authorization") JwtToken token); @POST("api/users") - Call createUser(@Body User user,@Header("Authorization") JwtToken token); + Call createUser(@Body User user); @GET("api/users/page/{pageNum}") Call getPagedUsers(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); @@ -37,41 +37,41 @@ public interface UserService { Call getUserByID(@Path("id") String userID, @Header("Authorization") JwtToken token); @PUT("api/users/{id}") - Call updateUserByID(@Path("id") String userID, @Body User user,@Header("Authorization") JwtToken token); + Call updateUserByID(@Path("id") String userID, @Body User user); @DELETE("api/users/{id}") Call deleteUserByID(@Path("id") String userID, @Header("Authorization") JwtToken token); @GET("api/users/userLogin/{ldapLogin}") - Call getUserLdapLogin(@Path("ldapLogin") String ldapLogin,@Header("Authorization") JwtToken token); + Call getUserLdapLogin(@Path("ldapLogin") String ldapLogin); @PUT("api/users/setActive/{userID}") - Call setUserActive(@Path("userID") String userID,@Header("Authorization") JwtToken token); + Call setUserActive(@Path("userID") String userID); @PUT("api/users/setInActive/{userID}") - Call setUserInActive(@Path("userID") String userID,@Header("Authorization") JwtToken token); + Call setUserInActive(@Path("userID") String userID); @GET("api/users/blacklist/{tutorID}") - Call> getTutorBlacklistedByID(@Path("tutorID") String tutorID,@Header("Authorization") JwtToken token); + Call> getTutorBlacklistedByID(@Path("tutorID") String tutorID); @PUT("api/users/blacklist/{tutorID}") - Call setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing,@Header("Authorization") JwtToken token); + Call setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); @POST("api/users/blacklist/{tutorID}") - Call addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + Call addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); @DELETE("api/users/blacklist/{tutorID}") - Call> removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + Call> removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); @GET("api/users/whitelist/{tutorID}") - Call> getTutorwhitelistedByID(@Path("tutorID") String tutorID,@Header("Authorization") JwtToken token); + Call> getTutorwhitelistedByID(@Path("tutorID") String tutorID); @PUT("api/users/whitelist/{tutorID}") - Call setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing,@Header("Authorization") JwtToken token); + Call setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); @POST("api/users/whitelist/{tutorID}") - Call addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + Call addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); @DELETE("api/users/whitelist/{tutorID}") - Call> removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student,@Header("Authorization") JwtToken token); + Call> removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); } From 9c17221e65887256a187db2123ff4b99a1639a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Sun, 26 Aug 2018 16:32:01 +0200 Subject: [PATCH 09/14] removed token from arg list v2 --- .../com/uam/wmi/findmytutor/service/UserService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 0dc77a0..0df22c1 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,28 +19,28 @@ import retrofit2.http.Header; public interface UserService { @GET("api/users") - Call> getAllUsers(@Header("Authorization") JwtToken token); + Call> getAllUsers(); @POST("api/users") Call createUser(@Body User user); @GET("api/users/page/{pageNum}") - Call getPagedUsers(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); + Call getPagedUsers(@Path("pageNum") String pageNum ); @GET("/api/users/tutors/page/{pageNum}") - Call getPagedTutors(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); + Call getPagedTutors(@Path("pageNum") String pageNum); @GET("/api/users/students/page/{pageNum}") - Call getPagedStudents(@Path("pageNum") String pageNum, @Header("Authorization") JwtToken token); + Call getPagedStudents(@Path("pageNum") String pageNum); @GET("api/users/{id}") - Call getUserByID(@Path("id") String userID, @Header("Authorization") JwtToken token); + Call getUserByID(@Path("id") String userID); @PUT("api/users/{id}") Call updateUserByID(@Path("id") String userID, @Body User user); @DELETE("api/users/{id}") - Call deleteUserByID(@Path("id") String userID, @Header("Authorization") JwtToken token); + Call deleteUserByID(@Path("id") String userID); @GET("api/users/userLogin/{ldapLogin}") Call getUserLdapLogin(@Path("ldapLogin") String ldapLogin); From c97f892eaba217191cb03f90b21ec005257ac1be Mon Sep 17 00:00:00 2001 From: Mieszko Date: Sun, 26 Aug 2018 19:38:55 +0200 Subject: [PATCH 10/14] Fix login --- .idea/caches/build_file_checksums.ser | Bin 540 -> 0 bytes app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 3 + .../findmytutor/activity/LoginActivity.java | 14 ++- .../findmytutor/activity/MainActivity.java | 91 +++++++++++++++++- .../uam/wmi/findmytutor/model/LdapUser.java | 9 +- app/src/main/res/layout/activity_main.xml | 14 ++- app/src/main/res/values/strings.xml | 1 + 8 files changed, 121 insertions(+), 13 deletions(-) delete mode 100644 .idea/caches/build_file_checksums.ser diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser deleted file mode 100644 index 065fdfe34a95bb8b03dcca74561cfff4cc6a7a85..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 540 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}Q#7BMhIJFWRF{)3GpI3_o-C@VF^ z&?p9~D+Upm1*t_PnW@F4aC5H6_T21e*u?U(fpf;2A5L{83_K_47&`?vLw{r566LUaOgkfsH+?5_iXBZyT^R;EYec5hV!XSvp4WE0NSM5ny>bJ=@ L&G^|_fusrms{FdJ diff --git a/app/build.gradle b/app/build.gradle index b82179e..f739be0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,5 +36,5 @@ dependencies { implementation "io.swagger:swagger-annotations:1.5.15" implementation "org.threeten:threetenbp:1.3.5" implementation "com.squareup.okhttp3:logging-interceptor:3.10.0" - + implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.4.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index da59066..0192f05 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,9 @@ + + + loginResponse = service.fakeValidate(user).execute(); + Log.e("Login", "jwt token: " + loginResponse.body()); if (loginResponse.isSuccessful()) { String authToken = loginResponse.body().getToken(); Log.e("Login", "jwt token: " + authToken); @@ -335,12 +337,14 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< return true; } - } catch (IOException e) { - Log.d("login failure",e.toString()); - Log.e("Login error", e.toString()); + } catch (Exception e) { + Log.e("Login error", "nie udalo sie kurde..."); return false; } + + + //To jest async i nie da sie zwrocic :( // Call call = service.fakeValidate(user); // diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index 1032282..8558086 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -7,6 +7,8 @@ import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.Toast; +import com.mapbox.mapboxsdk.Mapbox; +import com.mapbox.mapboxsdk.maps.MapView; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.Coordinate; import com.uam.wmi.findmytutor.network.RetrofitClientInstance; @@ -20,33 +22,120 @@ import retrofit2.Response; public class MainActivity extends AppCompatActivity { + private MapView mapView; + + public List getCoordinates() { + return this.coordinates; + } + + public void setCoordinates(List coordinates) { + this.coordinates = coordinates; + } + + public List coordinates; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + Mapbox.getInstance(this, getString(R.string.access_token)); + setContentView(R.layout.activity_main); + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + + setContentView(R.layout.activity_main); SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); final String authToken = sharedPref.getString("authToken",null); Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken); - Call> call = service.getTopCoordinates(); + Call> call = service.getOnlineCoordinates(); call.enqueue(new Callback>() { @Override public void onResponse(Call> call, Response> response) { Log.e("MainActivity", "rsp: " + response.body()); + + setCoordinates(response.body()); + + + /* mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(MapboxMap mapboxMap,List response) { + + // Add the custom icon marker to the map + for(Coordinate coord: response.body()){ + mapboxMap.addMarker(new MarkerOptions() + .position(new LatLng(coord.getLatitude(), coord.getLongitude())) + + } + + } + });*/ } @Override public void onFailure(Call> call, Throwable t) { Toast.makeText(MainActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show(); } + + + + }); + + } + + @Override + public void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + + } + + @Override + public void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + public void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + } + diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java index 4704389..22a640b 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java @@ -33,7 +33,14 @@ public class LdapUser { @SerializedName("email") private String email = null; - public LdapUser(String string, String mPassword, String string1, String pracownik, String string2, String string3, String mEmail) { + public LdapUser(String login, String password, String department, String title, String firstName, String lastName, String email) { + this.login = login; + this.password = password; + this.department = department; + this.title = title; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; } public LdapUser login(String login) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 7fcef54..cbad62f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -2,6 +2,7 @@ @@ -23,10 +24,13 @@ android:layout_margin="@dimen/fab_margin" app:srcCompat="@android:drawable/ic_dialog_email" /> - + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3730eb0..5da9a7c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,4 +17,5 @@ completions." MainActivity + pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew From 56b472887c1aa9388663378dba3deb18ba7bff10 Mon Sep 17 00:00:00 2001 From: Domagalski Date: Sun, 26 Aug 2018 22:28:59 +0200 Subject: [PATCH 11/14] Code clean up, removed nasty code, 2 classes that we won't need for now, Logout button added, Polish translation added --- .idea/misc.xml | 2 +- .../findmytutor/activity/LoginActivity.java | 53 ++----------------- .../findmytutor/activity/MainActivity.java | 30 +++++++---- .../network/NetworkConnectionInterceptor.java | 32 ----------- .../uam/wmi/findmytutor/service/Session.java | 4 -- app/src/main/res/layout/activity_main.xml | 5 +- app/src/main/res/values-pl/strings.xml | 10 ++++ app/src/main/res/values/strings.xml | 10 ++-- 8 files changed, 43 insertions(+), 103 deletions(-) delete mode 100644 app/src/main/java/com/uam/wmi/findmytutor/network/NetworkConnectionInterceptor.java delete mode 100644 app/src/main/java/com/uam/wmi/findmytutor/service/Session.java create mode 100644 app/src/main/res/values-pl/strings.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 99202cc..c0f68ed 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + 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 53f10f5..42f7042 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 @@ -294,7 +294,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< private interface ProfileQuery { String[] PROJECTION = { ContactsContract.CommonDataKinds.Email.ADDRESS, - ContactsContract.CommonDataKinds.Email.IS_PRIMARY, + ContactsContract.CommonDataKinds.Email.IS_PRIMARY, }; int ADDRESS = 0; @@ -338,49 +338,10 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< } } catch (Exception e) { - Log.e("Login error", "nie udalo sie kurde..."); + Log.e("Login error", "Something went wrong while logging in..."); return false; } - - - - //To jest async i nie da sie zwrocic :( -// Call call = service.fakeValidate(user); -// -// call.enqueue(new Callback() { -// @Override -// public void onResponse(Call call, Response response) { -// Log.e("jwt", response.body().getToken()); -// } -// -// @Override -// public void onFailure(Call call, Throwable t) { -// Toast.makeText(LoginActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show(); -// return false; -// } -// }); - - - - // TODO: attempt authentication against a network service. - -// try { -// // Simulate network access. -// Thread.sleep(2000); -// } catch (InterruptedException e) { -// return false; -// } -// -// for (String credential : DUMMY_CREDENTIALS) { -// String[] pieces = credential.split(":"); -// if (pieces[0].equals(mEmail)) { -// // Account exists, return true if the password matches. -// return pieces[1].equals(mPassword); -// } -// } - - // TODO: register the new account here. return false; } @@ -390,17 +351,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< showProgress(false); if (success) { - - // TODO: Ustawiam localstora kluczyk jakis - SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); - SharedPreferences.Editor editor = sharedPref.edit(); - editor.putString("test", "jakieś gówno"); - editor.commit(); - Log.e("okurwa", "eealslasla"); - // TODO: Ma zwracac 666 i cos jeszcze, do tego wpisywac jwt to shared prefs... kurwa Intent data = new Intent(); - String txt = "siema eee"; + String txt = "test text to Startup compo"; data.setData(Uri.parse(txt)); setResult(RESULT_OK, data); finish(); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index 8558086..b379007 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -1,10 +1,14 @@ package com.uam.wmi.findmytutor.activity; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.util.Log; +import android.view.View; +import android.widget.Button; import android.widget.Toast; import com.mapbox.mapboxsdk.Mapbox; @@ -37,15 +41,28 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Mapbox.getInstance(this, getString(R.string.access_token)); setContentView(R.layout.activity_main); + final FloatingActionButton button = findViewById(R.id.logoutButton); + button.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View view) { + SharedPreferences preferences =getSharedPreferences("fmtPrefs",Context.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.clear().commit(); + + Intent i = getBaseContext().getPackageManager() + .getLaunchIntentForPackage( getBaseContext().getPackageName() ); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(i); + finish(); + } + }); + mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); - - setContentView(R.layout.activity_main); - SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); + final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); final String authToken = sharedPref.getString("authToken",null); Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken); @@ -85,11 +102,6 @@ public class MainActivity extends AppCompatActivity { }); - - - - - } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/network/NetworkConnectionInterceptor.java b/app/src/main/java/com/uam/wmi/findmytutor/network/NetworkConnectionInterceptor.java deleted file mode 100644 index f5732e3..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/network/NetworkConnectionInterceptor.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.uam.wmi.findmytutor.network; - -import java.io.IOException; - -import okhttp3.Interceptor; -import okhttp3.Request; -import okhttp3.Response; - -public abstract class NetworkConnectionInterceptor implements Interceptor { - - public abstract boolean isInternetAvailable(); - - public abstract void onInternetUnavailable(); - - public abstract void onCacheUnavailable(); - - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - if (!isInternetAvailable()) { - onInternetUnavailable(); - request = request.newBuilder().header("Cache-Control", - "public, only-if-cached, max-stale=" + 60 * 60 * 24).build(); - Response response = chain.proceed(request); - if (response.cacheResponse() == null) { - onCacheUnavailable(); - } - return response; - } - return chain.proceed(request); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/Session.java b/app/src/main/java/com/uam/wmi/findmytutor/service/Session.java deleted file mode 100644 index 20a6a58..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/Session.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.uam.wmi.findmytutor.service; - -public interface Session { -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cbad62f..2c0768b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -17,12 +17,13 @@ + app:backgroundTint="@android:color/holo_red_dark" + app:srcCompat="@android:drawable/ic_lock_power_off" /> + + Zaloguj + Hasło (opcjonalne) + Zaloguj + Nieprawidłowe hasło + Hasło jest zbyt krótkie + Nieprawidłowy mail + To pole jest wymagane + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5da9a7c..b10a931 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,11 +1,11 @@ - FindMyTutor + FindMyTutor Sign in - StartUp Activity + StartUp Activity - Email + Email Password (optional) Sign in or register Sign in @@ -16,6 +16,6 @@ "Contacts permissions are needed for providing email completions." - MainActivity - pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew + MainActivity + pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew From e36eb8bf0dfe628481ee430de1170259fbd751f3 Mon Sep 17 00:00:00 2001 From: Mieszko Date: Thu, 30 Aug 2018 10:04:37 +0200 Subject: [PATCH 12/14] Change login and whole API handling to rxjava --- app/build.gradle | 16 ++- app/src/main/AndroidManifest.xml | 3 +- .../findmytutor/activity/LoginActivity.java | 57 ++++++----- .../findmytutor/activity/MainActivity.java | 51 +--------- .../wmi/findmytutor/model/BaseResponse.java | 9 ++ .../uam/wmi/findmytutor/model/Coordinate.java | 2 +- .../uam/wmi/findmytutor/model/DutyHour.java | 2 +- .../findmytutor/model/IsUsingListBool.java | 2 +- .../model/IsUsingListBoolModel.java | 2 +- .../uam/wmi/findmytutor/model/LdapUser.java | 2 +- .../com/uam/wmi/findmytutor/model/Model.java | 16 +++ .../wmi/findmytutor/model/PagedResult.java | 11 ++- .../model/PagedResultUserResponseModel.java | 2 +- .../com/uam/wmi/findmytutor/model/Result.java | 5 +- .../wmi/findmytutor/model/StudentIdModel.java | 2 +- .../uam/wmi/findmytutor/model/TutorTab.java | 2 +- .../com/uam/wmi/findmytutor/model/User.java | 2 +- .../findmytutor/model/UserResponseModel.java | 2 +- .../wmi/findmytutor/network/ApiClient.java | 75 ++++++++++++++ .../network/RetrofitClientInstance.java | 51 ---------- ...oordinates.java => CoordinateService.java} | 2 +- .../wmi/findmytutor/service/LdapService.java | 10 +- .../wmi/findmytutor/service/UserService.java | 56 +++++------ .../utils/MyDividerItemDecoration.java | 98 +++++++++++++++++++ .../uam/wmi/findmytutor/utils/PrefUtils.java | 27 +++++ .../utils/RecyclerTouchListener.java | 54 ++++++++++ app/src/main/res/layout/tutor_list_row.xml | 42 ++++++++ app/src/main/res/values/array.xml | 43 ++++++++ app/src/main/res/values/colors.xml | 4 + app/src/main/res/values/dimens.xml | 14 +++ app/src/main/res/values/strings.xml | 7 ++ 31 files changed, 491 insertions(+), 180 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/BaseResponse.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/model/Model.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java delete mode 100644 app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java rename app/src/main/java/com/uam/wmi/findmytutor/service/{Coordinates.java => CoordinateService.java} (97%) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java create mode 100644 app/src/main/res/layout/tutor_list_row.xml create mode 100644 app/src/main/res/values/array.xml diff --git a/app/build.gradle b/app/build.gradle index f739be0..a333d4f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,11 +30,19 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - implementation 'com.google.code.gson:gson:2.8.2' - implementation 'com.squareup.retrofit2:retrofit:2.3.0' - implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.squareup.retrofit2:retrofit:2.4.0' + implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation "io.swagger:swagger-annotations:1.5.15" implementation "org.threeten:threetenbp:1.3.5" - implementation "com.squareup.okhttp3:logging-interceptor:3.10.0" implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.4.0' + implementation 'io.reactivex.rxjava2:rxjava:2.2.0' + implementation 'com.android.support:recyclerview-v7:27.1.1' + implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' + implementation "com.jakewharton:butterknife:8.8.1" + annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1" + implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0" + implementation "com.squareup.okhttp3:okhttp:3.11.0" + implementation "com.squareup.okhttp3:okhttp-urlconnection:3.10.0" + implementation "com.squareup.okhttp3:logging-interceptor:3.11.0" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0192f05..55a5adf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,7 +8,8 @@ - + + () { + @Override + public void onSuccess(JwtToken jwtToken) { + PrefUtils.storeApiKey(getApplicationContext(), jwtToken.getToken()); + onPostExecute(true); + } - Log.e("Login", "jwt token: " + user); + @Override + public void onError(Throwable e) { + Log.e("LoginError", "onError: " + e.getMessage()); + } + })); + return true; - try { - Response loginResponse = service.fakeValidate(user).execute(); - Log.e("Login", "jwt token: " + loginResponse.body()); - if (loginResponse.isSuccessful()) { - String authToken = loginResponse.body().getToken(); - Log.e("Login", "jwt token: " + authToken); - - SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); - sharedPref.edit().putString("authToken", authToken).putBoolean("loggedIn", true).apply(); - - return true; - } - - } catch (Exception e) { - Log.e("Login error", "Something went wrong while logging in..."); - return false; - } - - return false; } @Override @@ -361,6 +365,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< mPasswordView.setError(getString(R.string.error_incorrect_password)); mPasswordView.requestFocus(); } + } @Override diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index b379007..e2c9158 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -6,24 +6,17 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; -import android.util.Log; import android.view.View; -import android.widget.Button; -import android.widget.Toast; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.maps.MapView; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.Coordinate; -import com.uam.wmi.findmytutor.network.RetrofitClientInstance; -import com.uam.wmi.findmytutor.service.Coordinates; +import com.uam.wmi.findmytutor.network.ApiClient; +import com.uam.wmi.findmytutor.service.CoordinateService; import java.util.List; -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; - public class MainActivity extends AppCompatActivity { private MapView mapView; @@ -62,46 +55,10 @@ public class MainActivity extends AppCompatActivity { mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); - final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); - final String authToken = sharedPref.getString("authToken",null); - - Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken); - - Call> call = service.getOnlineCoordinates(); + CoordinateService service = ApiClient.getClient(getApplicationContext()) + .create(CoordinateService.class); - call.enqueue(new Callback>() { - @Override - public void onResponse(Call> call, Response> response) { - Log.e("MainActivity", "rsp: " + response.body()); - - setCoordinates(response.body()); - - - /* mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(MapboxMap mapboxMap,List response) { - - // Add the custom icon marker to the map - for(Coordinate coord: response.body()){ - mapboxMap.addMarker(new MarkerOptions() - .position(new LatLng(coord.getLatitude(), coord.getLongitude())) - - } - - } - });*/ - } - - @Override - public void onFailure(Call> call, Throwable t) { - Toast.makeText(MainActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show(); - } - - - - - }); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/BaseResponse.java b/app/src/main/java/com/uam/wmi/findmytutor/model/BaseResponse.java new file mode 100644 index 0000000..21b73c1 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/BaseResponse.java @@ -0,0 +1,9 @@ +package com.uam.wmi.findmytutor.model; + +public class BaseResponse { + String error; + + public String getError() { + return error; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java index 017b640..95e9b59 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java @@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty; * Coordinate */ -public class Coordinate { +public class Coordinate extends BaseResponse{ @SerializedName("coordinateId") private UUID coordinateId = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java b/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java index a2d0fe3..46cbdb3 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/DutyHour.java @@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty; * DutyHour */ -public class DutyHour { +public class DutyHour extends BaseResponse { @SerializedName("dutyHourId") private UUID dutyHourId = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java index e11d6ac..36e0345 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBool.java @@ -3,7 +3,7 @@ package com.uam.wmi.findmytutor.model; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -public class IsUsingListBool { +public class IsUsingListBool extends BaseResponse{ @SerializedName("isUsing") @Expose diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java index 511e578..fd29619 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/IsUsingListBoolModel.java @@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty; * IsUsingListBoolModel */ -public class IsUsingListBoolModel { +public class IsUsingListBoolModel extends BaseResponse { @SerializedName("isUsing") private Boolean isUsing = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java index 22a640b..b57c702 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/LdapUser.java @@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty; * LdapUser */ -public class LdapUser { +public class LdapUser extends BaseResponse{ @SerializedName("login") private String login = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java new file mode 100644 index 0000000..3b5ee47 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Model.java @@ -0,0 +1,16 @@ +package com.uam.wmi.findmytutor.model; + + +import com.google.gson.annotations.SerializedName; + +public class Model +{ + @SerializedName("data") + private PagedResult data; + + public PagedResult getData () + { + return data; + } + +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java index 9e7ad33..db05386 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResult.java @@ -1,14 +1,15 @@ package com.uam.wmi.findmytutor.model; -import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -public class PagedResult { +import java.util.List; + +public class PagedResult { @SerializedName("results") @Expose - private List results = null; + private List results = null; @SerializedName("currentPage") @Expose private Integer currentPage; @@ -28,11 +29,11 @@ public class PagedResult { @Expose private Integer lastRowOnPage; - public List getResults() { + public List getResults() { return results; } - public void setResults(List results) { + public void setResults(List results) { this.results = results; } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java index 1898ce7..0e16bb2 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/PagedResultUserResponseModel.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; * PagedResultUserResponseModel */ -public class PagedResultUserResponseModel { +public class PagedResultUserResponseModel extends BaseResponse { @SerializedName("results") private List results = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java index 6fc4336..1e4f111 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Result.java @@ -1,9 +1,10 @@ package com.uam.wmi.findmytutor.model; -import java.util.List; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -public class Result { +import java.util.List; + +public class Result extends BaseResponse { @SerializedName("id") @Expose diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java index 33c8880..3eea407 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/StudentIdModel.java @@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty; * StudentIdModel */ -public class StudentIdModel { +public class StudentIdModel extends BaseResponse{ @SerializedName("studentId") private String studentId = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java b/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java index 96d1332..62916f1 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/TutorTab.java @@ -15,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; * TutorTab */ -public class TutorTab { +public class TutorTab extends BaseResponse{ @SerializedName("tutorTabId") private UUID tutorTabId = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/User.java b/app/src/main/java/com/uam/wmi/findmytutor/model/User.java index 3e7f9cc..f16add4 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/User.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/User.java @@ -15,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; * User */ -public class User { +public class User extends BaseResponse{ @SerializedName("isOnline") private Boolean isOnline = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java b/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java index cef0da8..c927500 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/model/UserResponseModel.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; * UserResponseModel */ -public class UserResponseModel { +public class UserResponseModel extends BaseResponse{ @SerializedName("id") private String id = null; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java b/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java new file mode 100644 index 0000000..008a6cc --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java @@ -0,0 +1,75 @@ +package com.uam.wmi.findmytutor.network; + +import android.content.Context; +import android.text.TextUtils; + +import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; +import com.uam.wmi.findmytutor.utils.PrefUtils; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import okhttp3.Interceptor; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.logging.HttpLoggingInterceptor; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + + +public class ApiClient { + private static Retrofit retrofit = null; + private static int REQUEST_TIMEOUT = 60; + private static OkHttpClient okHttpClient; + private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/"; + + public static Retrofit getClient(Context context) { + + if (okHttpClient == null) + initOkHttp(context); + + if (retrofit == null) { + retrofit = new Retrofit.Builder() + .baseUrl(BASE_URL) + .client(okHttpClient) + .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) + .addConverterFactory(GsonConverterFactory.create()) + .build(); + } + return retrofit; + } + + private static void initOkHttp(final Context context) { + OkHttpClient.Builder httpClient = new OkHttpClient().newBuilder() + .connectTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS) + .readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS) + .writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS); + + HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); + interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); + + httpClient.addInterceptor(interceptor); + + httpClient.addInterceptor(new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + Request original = chain.request(); + Request.Builder requestBuilder = original.newBuilder() + .addHeader("Accept", "application/json") + .addHeader("Content-Type", "application/json"); + + // Adding Authorization token (API Key) + // Requests will be denied without API key + if (!TextUtils.isEmpty(PrefUtils.getApiKey(context))) { + requestBuilder.addHeader("Authorization", PrefUtils.getApiKey(context)); + } + + Request request = requestBuilder.build(); + return chain.proceed(request); + } + }); + + okHttpClient = httpClient.build(); + } + }; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java b/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java deleted file mode 100644 index 77db473..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/network/RetrofitClientInstance.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.uam.wmi.findmytutor.network; - -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.logging.HttpLoggingInterceptor; -import retrofit2.Retrofit; -import retrofit2.converter.gson.GsonConverterFactory; - -public class RetrofitClientInstance { - - private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/"; - - private static Retrofit.Builder builder - = new Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create()); - - private static Retrofit retrofit = builder.build(); - - private static OkHttpClient.Builder httpClient - = new OkHttpClient.Builder(); - - private static HttpLoggingInterceptor logging - = new HttpLoggingInterceptor() - .setLevel(HttpLoggingInterceptor.Level.BASIC); - - public static S createService(Class serviceClass) { - if (!httpClient.interceptors().contains(logging)) { - httpClient.addInterceptor(logging); - builder.client(httpClient.build()); - retrofit = builder.build(); - } - return retrofit.create(serviceClass); - } - - public static S createService(Class serviceClass, final String token) { - if (token != null) { - httpClient.interceptors().clear(); - httpClient.addInterceptor(chain -> { - Request original = chain.request(); - Request.Builder builder1 = original.newBuilder() - .header("Authorization", "Bearer " + token); - Request request = builder1.build(); - return chain.proceed(request); - }); - builder.client(httpClient.build()); - retrofit = builder.build(); - } - return retrofit.create(serviceClass); - } -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java b/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java similarity index 97% rename from app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java rename to app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java index 088cd3c..877bec2 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/Coordinates.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java @@ -13,7 +13,7 @@ import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; -public interface Coordinates { +public interface CoordinateService { @GET("api/coordinates") Call> getAllCoordinates(); diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/LdapService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/LdapService.java index 3583d2a..bb262f5 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/service/LdapService.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/service/LdapService.java @@ -3,7 +3,7 @@ package com.uam.wmi.findmytutor.service; import com.uam.wmi.findmytutor.model.JwtToken; import com.uam.wmi.findmytutor.model.LdapUser; -import retrofit2.Call; +import io.reactivex.Single; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.POST; @@ -12,15 +12,15 @@ import retrofit2.http.Path; public interface LdapService { @POST("api/ldap/fakeValidate") - Call fakeValidate(@Body LdapUser user); + Single fakeValidate(@Body LdapUser user); @POST("api/ldap/validate") - Call validate(@Body LdapUser user); + Single validate(@Body LdapUser user); @GET("api/ldap/getUserData/{login}") - Call getUserDataByLogin(@Path("login") String userLogin); + Single getUserDataByLogin(@Path("login") String userLogin); @GET("api/ldap/getUserData/email/{email}") - Call getUserDataByMail(@Path("email") String userMail); + Single getUserDataByMail(@Path("email") String userMail); } 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 0df22c1..a0dbea3 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 @@ -1,77 +1,77 @@ package com.uam.wmi.findmytutor.service; -import com.uam.wmi.findmytutor.model.JwtToken; -import com.uam.wmi.findmytutor.model.PagedResult; -import com.uam.wmi.findmytutor.model.User; + import com.uam.wmi.findmytutor.model.IsUsingListBool; +import com.uam.wmi.findmytutor.model.PagedResult; import com.uam.wmi.findmytutor.model.StudentIdModel; +import com.uam.wmi.findmytutor.model.User; + import java.util.List; -import okhttp3.ResponseBody; -import retrofit2.Call; +import io.reactivex.Completable; +import io.reactivex.Single; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; -import retrofit2.http.PUT; import retrofit2.http.POST; +import retrofit2.http.PUT; import retrofit2.http.Path; -import retrofit2.http.Header; public interface UserService { @GET("api/users") - Call> getAllUsers(); + Single > getAllUsers(); @POST("api/users") - Call createUser(@Body User user); + Completable createUser(@Body User user); @GET("api/users/page/{pageNum}") - Call getPagedUsers(@Path("pageNum") String pageNum ); + Single getPagedUsers(@Path("pageNum") String pageNum ); - @GET("/api/users/tutors/page/{pageNum}") - Call getPagedTutors(@Path("pageNum") String pageNum); + @GET("api/users/tutors/page/{pageNum}") + Single getPagedTutors(@Path("pageNum") String pageNum); - @GET("/api/users/students/page/{pageNum}") - Call getPagedStudents(@Path("pageNum") String pageNum); + @GET("api/users/students/page/{pageNum}") + Single getPagedStudents(@Path("pageNum") String pageNum); @GET("api/users/{id}") - Call getUserByID(@Path("id") String userID); + Single getUserByID(@Path("id") String userID); @PUT("api/users/{id}") - Call updateUserByID(@Path("id") String userID, @Body User user); + Completable updateUserByID(@Path("id") String userID, @Body User user); @DELETE("api/users/{id}") - Call deleteUserByID(@Path("id") String userID); + Completable deleteUserByID(@Path("id") String userID); @GET("api/users/userLogin/{ldapLogin}") - Call getUserLdapLogin(@Path("ldapLogin") String ldapLogin); + Single getUserLdapLogin(@Path("ldapLogin") String ldapLogin); @PUT("api/users/setActive/{userID}") - Call setUserActive(@Path("userID") String userID); + Completable setUserActive(@Path("userID") String userID); @PUT("api/users/setInActive/{userID}") - Call setUserInActive(@Path("userID") String userID); + Completable setUserInActive(@Path("userID") String userID); @GET("api/users/blacklist/{tutorID}") - Call> getTutorBlacklistedByID(@Path("tutorID") String tutorID); + Single> getTutorBlacklistedByID(@Path("tutorID") String tutorID); @PUT("api/users/blacklist/{tutorID}") - Call setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); + Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); @POST("api/users/blacklist/{tutorID}") - Call addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); + Completable addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); @DELETE("api/users/blacklist/{tutorID}") - Call> removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); + Completable removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student); @GET("api/users/whitelist/{tutorID}") - Call> getTutorwhitelistedByID(@Path("tutorID") String tutorID); + Single> getTutorwhitelistedByID(@Path("tutorID") String tutorID); @PUT("api/users/whitelist/{tutorID}") - Call setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); + Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing); @POST("api/users/whitelist/{tutorID}") - Call addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); + Completable addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); @DELETE("api/users/whitelist/{tutorID}") - Call> removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); + Completable removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student); } diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java new file mode 100644 index 0000000..96a4d62 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java @@ -0,0 +1,98 @@ +package com.uam.wmi.findmytutor.utils; + +import android.content.Context; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.util.TypedValue; +import android.view.View; + +public class MyDividerItemDecoration extends RecyclerView.ItemDecoration { + + private static final int[] ATTRS = new int[]{ + android.R.attr.listDivider + }; + + public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; + public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; + + private Drawable mDivider; + private int mOrientation; + private Context context; + private int margin; + + public MyDividerItemDecoration(Context context, int orientation, int margin) { + this.context = context; + this.margin = margin; + final TypedArray a = context.obtainStyledAttributes(ATTRS); + mDivider = a.getDrawable(0); + a.recycle(); + setOrientation(orientation); + } + + public void setOrientation(int orientation) { + if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) { + throw new IllegalArgumentException("invalid orientation"); + } + mOrientation = orientation; + } + + @Override + public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { + if (mOrientation == VERTICAL_LIST) { + drawVertical(c, parent); + } else { + drawHorizontal(c, parent); + } + } + + public void drawVertical(Canvas c, RecyclerView parent) { + final int left = parent.getPaddingLeft(); + final int right = parent.getWidth() - parent.getPaddingRight(); + + final int childCount = parent.getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = parent.getChildAt(i); + final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child + .getLayoutParams(); + final int top = child.getBottom() + params.bottomMargin; + final int bottom = top + mDivider.getIntrinsicHeight(); + mDivider.setBounds(left + dpToPx(margin), top, right - dpToPx(margin), bottom); + mDivider.draw(c); + } + } + + public void drawHorizontal(Canvas c, RecyclerView parent) { + final int top = parent.getPaddingTop(); + final int bottom = parent.getHeight() - parent.getPaddingBottom(); + + final int childCount = parent.getChildCount(); + for (int i = 0; i < childCount; i++) { + final View child = parent.getChildAt(i); + final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child + .getLayoutParams(); + final int left = child.getRight() + params.rightMargin; + final int right = left + mDivider.getIntrinsicHeight(); + mDivider.setBounds(left, top + dpToPx(margin), right, bottom - dpToPx(margin)); + mDivider.draw(c); + } + } + + @Override + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + if (mOrientation == VERTICAL_LIST) { + outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); + } else { + outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); + } + } + + private int dpToPx(int dp) { + Resources r = context.getResources(); + return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics())); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java new file mode 100644 index 0000000..8613c34 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java @@ -0,0 +1,27 @@ +package com.uam.wmi.findmytutor.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +public class PrefUtils { + /** + * Storing API Key in shared preferences to + * add it in header part of every retrofit request + */ + public PrefUtils() { + } + + private static SharedPreferences getSharedPreferences(Context context) { + return context.getSharedPreferences("APP_PREF", Context.MODE_PRIVATE); + } + + public static void storeApiKey(Context context, String apiKey) { + SharedPreferences.Editor editor = getSharedPreferences(context).edit(); + editor.putString("API_KEY", apiKey); + editor.commit(); + } + + public static String getApiKey(Context context) { + return getSharedPreferences(context).getString("API_KEY", null); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java new file mode 100644 index 0000000..28aef5d --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java @@ -0,0 +1,54 @@ +package com.uam.wmi.findmytutor.utils; + +import android.content.Context; +import android.support.v7.widget.RecyclerView; +import android.view.GestureDetector; +import android.view.MotionEvent; +import android.view.View; + +public class RecyclerTouchListener implements RecyclerView.OnItemTouchListener { + + private ClickListener clicklistener; + private GestureDetector gestureDetector; + + public RecyclerTouchListener(Context context, final RecyclerView recycleView, final ClickListener clicklistener) { + + this.clicklistener = clicklistener; + gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { + @Override + public boolean onSingleTapUp(MotionEvent e) { + return true; + } + + @Override + public void onLongPress(MotionEvent e) { + View child = recycleView.findChildViewUnder(e.getX(), e.getY()); + if (child != null && clicklistener != null) { + clicklistener.onLongClick(child, recycleView.getChildAdapterPosition(child)); + } + } + }); + } + + @Override + public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { + View child = rv.findChildViewUnder(e.getX(), e.getY()); + if (child != null && clicklistener != null && gestureDetector.onTouchEvent(e)) { + clicklistener.onClick(child, rv.getChildAdapterPosition(child)); + } + return false; + } + + @Override + public void onTouchEvent(RecyclerView rv, MotionEvent e) { + } + + @Override + public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { + } + + public interface ClickListener { + void onClick(View view, int position); + void onLongClick(View view, int position); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/tutor_list_row.xml b/app/src/main/res/layout/tutor_list_row.xml new file mode 100644 index 0000000..8ec9c3d --- /dev/null +++ b/app/src/main/res/layout/tutor_list_row.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml new file mode 100644 index 0000000..aadfc8e --- /dev/null +++ b/app/src/main/res/values/array.xml @@ -0,0 +1,43 @@ + + + + #e84e40 + #ec407a + #ab47bc + #7e57c2 + #5c6bc0 + #738ffe + #29b6f6 + #26c6da + #26a69a + #2baf2b + #9ccc65 + #d4e157 + #ffee58 + #ffa726 + #ff7043 + #8d6e63 + #bdbdbd + #78909c + + + #e51c23 + #e91e63 + #9c27b0 + #673ab7 + #3f51b5 + #5677fc + #03a9f4 + #00bcd4 + #009688 + #259b24 + #8bc34a + #cddc39 + #ffeb3b + #ff9800 + #ff5722 + #795548 + #9e9e9e + #607d8b + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3ab3e9c..4e15c2e 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,4 +3,8 @@ #3F51B5 #303F9F #FF4081 + #999 + #89c3c3c3 + #858585 + #232323 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 812cb7b..93fc64f 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,4 +3,18 @@ 16dp 16dp 16dp + + + + 16dp + 10dp + 26sp + 120dp + 20sp + 10dp + 20sp + 10dp + 40sp + 14sp + 13sp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b10a931..52d1d21 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,6 +3,13 @@ Sign in StartUp Activity + + Settings + Notes + No notes found! + New Note + Enter your note! + Email From 790721193493a91ba5502638f1ba669da0d52455 Mon Sep 17 00:00:00 2001 From: Domagalski Date: Tue, 4 Sep 2018 00:01:35 +0200 Subject: [PATCH 13/14] bottom navi with 3 fragments, moved mapbox to map fragment and integraded with bottom navbar --- .../findmytutor/activity/MainActivity.java | 113 ++++++++++-------- .../wmi/findmytutor/activity/MapFragment.java | 98 +++++++++++++++ .../activity/NotificationFragment.java | 31 +++++ .../findmytutor/activity/ProfileFragment.java | 31 +++++ app/src/main/res/color/nav_item_colors.xml | 6 + .../drawable-hdpi/outline_map_white_24dp.png | Bin 0 -> 370 bytes .../outline_notifications_white_24dp.png | Bin 0 -> 349 bytes .../outline_person_white_24dp.png | Bin 0 -> 403 bytes app/src/main/res/layout/activity_main.xml | 74 ++++++++---- app/src/main/res/layout/fragment_map.xml | 21 ++++ .../main/res/layout/fragment_notification.xml | 14 +++ app/src/main/res/layout/fragment_profile.xml | 14 +++ app/src/main/res/menu/nav_items.xml | 17 +++ app/src/main/res/values/colors.xml | 5 + app/src/main/res/values/strings.xml | 5 + 15 files changed, 357 insertions(+), 72 deletions(-) create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java create mode 100644 app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java create mode 100644 app/src/main/res/color/nav_item_colors.xml create mode 100644 app/src/main/res/drawable-hdpi/outline_map_white_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/outline_notifications_white_24dp.png create mode 100644 app/src/main/res/drawable-hdpi/outline_person_white_24dp.png create mode 100644 app/src/main/res/layout/fragment_map.xml create mode 100644 app/src/main/res/layout/fragment_notification.xml create mode 100644 app/src/main/res/layout/fragment_profile.xml create mode 100644 app/src/main/res/menu/nav_items.xml diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java index e2c9158..a443ed2 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java @@ -1,12 +1,18 @@ package com.uam.wmi.findmytutor.activity; +import android.app.Fragment; +import android.app.FragmentTransaction; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.BottomNavigationView; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; +import android.view.MenuItem; import android.view.View; +import android.widget.FrameLayout; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.maps.MapView; @@ -19,6 +25,16 @@ import java.util.List; public class MainActivity extends AppCompatActivity { + + private BottomNavigationView mMainNav; + private FrameLayout mMainFrame; + + private MapFragment mapFragment; + private NotificationFragment notificationFragment; + private ProfileFragment profileFragment; + + + private MapView mapView; public List getCoordinates() { @@ -36,11 +52,49 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); Mapbox.getInstance(this, getString(R.string.access_token)); setContentView(R.layout.activity_main); + + + mMainFrame = (FrameLayout) findViewById(R.id.main_frame); + mMainNav = (BottomNavigationView) findViewById(R.id.main_nav); + + mapFragment = new MapFragment(); + notificationFragment = new NotificationFragment(); + profileFragment = new ProfileFragment(); + + // Default frag here + setFragment(mapFragment); + mMainNav.setSelectedItemId(R.id.nav_map); + + mMainNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + + switch (item.getItemId()) { + case R.id.nav_map: + mMainNav.setItemBackgroundResource(R.color.colorPrimary); + setFragment(mapFragment); + return true; + case R.id.nav_notif: + mMainNav.setItemBackgroundResource(R.color.colorAccent); + setFragment(notificationFragment); + return true; + case R.id.nav_profile: + mMainNav.setItemBackgroundResource(R.color.colorPrimaryDark); + setFragment(profileFragment); + return true; + default: + return false; + } + } + }); + + + // Logout button final FloatingActionButton button = findViewById(R.id.logoutButton); button.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { - SharedPreferences preferences =getSharedPreferences("fmtPrefs",Context.MODE_PRIVATE); + SharedPreferences preferences = getSharedPreferences("fmtPrefs",Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear().commit(); @@ -52,59 +106,16 @@ public class MainActivity extends AppCompatActivity { } }); - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - - CoordinateService service = ApiClient.getClient(getApplicationContext()) - .create(CoordinateService.class); +// CoordinateService service = ApiClient.getClient(getApplicationContext()) +// .create(CoordinateService.class); } - - @Override - public void onStart() { - super.onStart(); - mapView.onStart(); + private void setFragment(Fragment fragment) { + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.main_frame, fragment); + fragmentTransaction.commit(); + } } - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - public void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - -} - diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java new file mode 100644 index 0000000..d8c1e36 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java @@ -0,0 +1,98 @@ +package com.uam.wmi.findmytutor.activity; + + +import android.os.Bundle; +import android.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.mapbox.mapboxsdk.maps.MapView; +import com.uam.wmi.findmytutor.R; +import com.uam.wmi.findmytutor.network.ApiClient; +import com.uam.wmi.findmytutor.service.CoordinateService; + +import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; + +/** + * A simple {@link Fragment} subclass. + */ +public class MapFragment extends Fragment { + private MapView mapView; + + + public MapFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_map, container, false); + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + mapView = (MapView) view.findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + CoordinateService service = ApiClient.getClient(getApplicationContext()) + .create(CoordinateService.class); + } + + @Override + public void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + + } + + @Override + public void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + public void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + mapView.onDestroy(); + } + +// @Override +// public void onDestroy() { +// super.onDestroy(); +// mapView.onDestroy(); +// } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + + +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java new file mode 100644 index 0000000..431777b --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java @@ -0,0 +1,31 @@ +package com.uam.wmi.findmytutor.activity; + + +import android.os.Bundle; +import android.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.uam.wmi.findmytutor.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class NotificationFragment extends Fragment { + + + public NotificationFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_notification, container, false); + } + +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java new file mode 100644 index 0000000..d994bfd --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java @@ -0,0 +1,31 @@ +package com.uam.wmi.findmytutor.activity; + + +import android.os.Bundle; +import android.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.uam.wmi.findmytutor.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class ProfileFragment extends Fragment { + + + public ProfileFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_profile, container, false); + } + +} diff --git a/app/src/main/res/color/nav_item_colors.xml b/app/src/main/res/color/nav_item_colors.xml new file mode 100644 index 0000000..721a035 --- /dev/null +++ b/app/src/main/res/color/nav_item_colors.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/outline_map_white_24dp.png b/app/src/main/res/drawable-hdpi/outline_map_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..579a6e79b96d79a58bc94fc373313724d48510c3 GIT binary patch literal 370 zcmV-&0ge8NP)41DG0oZbSTkx?oLy6xYRa}})sUtdbIr~kvfVMRV|?5BbufO{^yArk_lkO2 zWQJ{?dt|dwIo9Lt@y(O`r(bGQ>z=iSCaeco;ksHN>-0?9z0|QvSFJKQ*iUl64^)=9Hw*=AyzZLPtFDMcSJ+aMHEoR!~m1I>eX9mL4;kV|u1rB;E!~+`* z3%2Qj^ly4wO}24WxvVxVUOW;&(CDU0>)wtx}Vdo08|hb-*q znCZ59o;%=zD#>2kWttYj>AZo^cV86oy-47e)%xpeiL**%duE48`2t@ZFh2M@*h*Ja zCZ67IX0LRBTGuVtFJUvx8h6!d^EB;rz+<27GbYD!lue#`Vw)MgdRP?I0hA<@f@Zd| QUH||907*qoM6N<$f=foI)&Kwi literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/outline_notifications_white_24dp.png b/app/src/main/res/drawable-hdpi/outline_notifications_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..17da39ca5b8bcb213627004ea4373f50c67af1ba GIT binary patch literal 349 zcmV-j0iyniP)VrBWl!G`Vf z@7_yve*lj2X+fz(g&t$Z^r)x^oMCXTBJc*-L`7hM@-7n(e<%p*-@$1&fm zGUG(qFd!XV==V5c?u9PfG-$9xmsjR?6=iHN#bz8()dH#R>`GBQV{N6NjXf!f5w@iiY+@rt@rl)y zf;u);6h>h8#{y-b43q(qXn-Vs9}7Sdy^l)@yALGDsQAGD#SpWh^2QxzKU+wB3&cR} v40vl)kQRX?`G3>@w?Me*zvNJg+))4k1O-*KiT5jU00000NkvXXu0mjfq)?6- literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/outline_person_white_24dp.png b/app/src/main/res/drawable-hdpi/outline_person_white_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..54eef90a5ef8209c203fc56961ee68c918a10f43 GIT binary patch literal 403 zcmV;E0c`$>P)eXhQ&$832V23Q@#{NCOQ3uu&jEVWZ4U z$*_IH&*)_Cw*P_L2k_wW@Wi`7AV8854SMuwP$DUQB20}DN{y%y7Jo2D3+2>ePW*t) zB(|6%%@EZlkA+2^Hfl&(Oi@O4iHRtpbWvq7MH98{NViZeF~v73?nvXPFEK?Qm2jj9 zRNude3XZhk-$WHum*}s7x~PhnVwoYTLyia*IXb8zDKWRfQdIw3JbhCS*Gm}I~``($JmWNF}4gRD%0 zd9In(6$|1GD}3Peg3TsNqJ#t+*gWI(&Z@Y>qRrTVJ9bIP1jN|kmH}gJEOEmLV>c{{ x2Sm7J>{Q(FhB}lfaDaLhHy8>EW+(^*0zZGCZ9%o{C}IEr002ovPDHLkV1krCqbmRa literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 2c0768b..b1e333b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -7,31 +7,63 @@ android:layout_height="match_parent" tools:context=".activity.MainActivity"> - + android:layout_height="wrap_content"> - + + + + + + + + - + - + + + + + + + + + + + + + + + - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml new file mode 100644 index 0000000..88bfe2e --- /dev/null +++ b/app/src/main/res/layout/fragment_map.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notification.xml b/app/src/main/res/layout/fragment_notification.xml new file mode 100644 index 0000000..2cd9409 --- /dev/null +++ b/app/src/main/res/layout/fragment_notification.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile.xml b/app/src/main/res/layout/fragment_profile.xml new file mode 100644 index 0000000..f98dfe6 --- /dev/null +++ b/app/src/main/res/layout/fragment_profile.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/nav_items.xml b/app/src/main/res/menu/nav_items.xml new file mode 100644 index 0000000..8b00a9f --- /dev/null +++ b/app/src/main/res/menu/nav_items.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4e15c2e..2361e98 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -7,4 +7,9 @@ #89c3c3c3 #858585 #232323 + + + #ffffff + #80ffffff + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52d1d21..6464e50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,6 +3,11 @@ Sign in StartUp Activity + + Map + Notification + Profile + Settings Notes From 3bd289424a8d655dce2bb41d05a04bc839818699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jedy=C5=84ski?= Date: Tue, 4 Sep 2018 00:34:02 +0200 Subject: [PATCH 14/14] added simple switch to login layout and passed it's vale down to fake validate endpoint --- .../findmytutor/activity/LoginActivity.java | 21 +++++++++++++++---- app/src/main/res/layout/activity_login.xml | 6 ++++++ 2 files changed, 23 insertions(+), 4 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 f23e4e4..b06432c 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 @@ -27,7 +27,9 @@ import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; +import android.widget.Switch; import android.widget.TextView; +import android.widget.ToggleButton; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.JwtToken; @@ -73,6 +75,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< private EditText mPasswordView; private View mProgressView; private View mLoginFormView; + private boolean loginOption; @Override protected void onCreate(Bundle savedInstanceState) { @@ -94,6 +97,14 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< } }); + Switch tutorLogin = (Switch) findViewById(R.id.tutor_login_switch); + tutorLogin.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + loginOption = tutorLogin.isChecked(); + } + }); + Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button); mEmailSignInButton.setOnClickListener(new OnClickListener() { @@ -198,7 +209,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< // Show a progress spinner, and kick off a background task to // perform the user login attempt. showProgress(true); - mAuthTask = new UserLoginTask(email, password); + mAuthTask = new UserLoginTask(email, password,loginOption); mAuthTask.execute((Void) null); } } @@ -311,14 +322,16 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< private final String mEmail; private final String mPassword; + private boolean isTutor; private LdapService ldapService; private CompositeDisposable disposable = new CompositeDisposable(); private Boolean isAuthorizate; // Constructor - UserLoginTask(String email, String password) { + UserLoginTask(String email, String password, Boolean loginOption) { mEmail = email; mPassword = password; + isTutor=loginOption; this.ldapService = ApiClient.getClient(getApplicationContext()) .create(LdapService.class); this.isAuthorizate = false; @@ -326,8 +339,8 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks< @Override protected Boolean doInBackground(Void... params) { - LdapUser user = new LdapUser("string",mPassword,"string","tutor","string","string",mEmail); - + LdapUser user = new LdapUser("string",mPassword,"string",(isTutor)?"tutor":"student","string","string",mEmail); + Log.d("LoginRole","Login role is : " + user.getTitle()); disposable.add( ldapService .fakeValidate(user) diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 6784ef7..c2c77b7 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -64,6 +64,12 @@ + +