Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit ec5543d

Browse files
authored
Merge branch 'dev' into authentication_ui
2 parents 5f5d104 + ef25bd8 commit ec5543d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2201
-63
lines changed

app/build.gradle

+12-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ dependencies {
8282
def coroutines_version = "1.7.3"
8383
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
8484
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
85-
def lifecycle_version = "2.6.2"
85+
// - - Coroutine test
86+
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
87+
8688
// - - ViewModel
89+
def lifecycle_version = "2.6.2"
8790
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
8891
// - - LiveData
8992
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
@@ -96,7 +99,15 @@ dependencies {
9699
implementation "com.squareup.okhttp3:okhttp:$logging_version"
97100
implementation "com.squareup.okhttp3:logging-interceptor:$logging_version"
98101

102+
// - - Glide
103+
104+
implementation "com.github.bumptech.glide:glide:4.12.0"
105+
kapt "com.github.bumptech.glide:compiler:4.12.0"
106+
implementation "androidx.activity:activity-ktx:1.8.2"
107+
99108
// - - MockWebServer
100109
def mock_web_server_version = "4.3.1"
101110
testImplementation "com.squareup.okhttp3:mockwebserver:$mock_web_server_version"
111+
112+
testImplementation "org.mockito:mockito-core:5.10.0"
102113
}

app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
56

67
<application
78
android:allowBackup="true"

app/src/main/java/com/fictadvisor/android/data/dto/schedule/DetailedEventResponse.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.fictadvisor.android.data.dto.schedule
33
data class DetailedEventResponse(
44
val url: String,
55
val eventInfo: String,
6-
val disciplineType: TDiscipline,
6+
val eventType: TDiscipline,
77
val disciplineInfo: String,
88
val period: TEventPeriod,
99
val teachers: List<Teacher>

app/src/main/java/com/fictadvisor/android/data/dto/schedule/PatchEventDTO.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ package com.fictadvisor.android.data.dto.schedule
22

33
data class PatchEventDTO(
44
val week: Int,
5+
val name: String,
56
val changeStartDate: Boolean,
67
val changeEndDate: Boolean,
7-
val disciplineType: String? = null,
8+
val eventType: TDiscipline? = null,
89
val url: String,
910
val eventInfo: String,
1011
val disciplineInfo: String,
1112
val period: TEventPeriod,
1213
val teachers: List<String>,
13-
val disciplineId: String
14+
val disciplineId: String,
15+
val startTime: String,
16+
val endTime: String
1417
)

app/src/main/java/com/fictadvisor/android/data/dto/schedule/PostEventDTO.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package com.fictadvisor.android.data.dto.schedule
22

33
data class PostEventDTO (
44
val groupId: String,
5+
val name: String,
56
val teachers: List<String>,
67
val disciplineId: String,
78
val url: String,
89
val eventInfo: String,
9-
val disciplineType: TDiscipline,
10+
val eventType: TDiscipline,
1011
val disciplineInfo: String,
1112
val period: TEventPeriod,
12-
)
13+
val startTime: String,
14+
val endTime: String
15+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class AddContactBody(
4+
val name: ContactType,
5+
val displayName: String,
6+
val link: String
7+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class ChangeAvatarResponse(
4+
val id: String,
5+
val email: String,
6+
val username: String,
7+
val telegramId: Long,
8+
val avatar: String,
9+
val state: UserGroupState
10+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class ChangeInfoBody(
4+
val firstName: String?,
5+
val lastName: String?,
6+
val middleName: String?,
7+
val groupId: String?,
8+
val state: UserGroupState?
9+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class ChangeRoleBody(
4+
val roleId: String
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class ChangeUserBody(
4+
val email: String?,
5+
val username: String?,
6+
val state: UserGroupState?
7+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class Contact(
4+
val link: String,
5+
val id: String,
6+
val name: ContactType,
7+
val displayName: String
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
enum class ContactType {
4+
YOUTUBE,
5+
DISCORD,
6+
TELEGRAM,
7+
INSTAGRAM,
8+
FACEBOOK,
9+
GITHUB,
10+
TWITTER,
11+
MAIL
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class GetContactsResponse(
4+
val contacts: List<Contact>
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class GetSelectiveDisciplinesBySemesterResponse(
4+
val selective: List<UserSelective>
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class GetSelectiveDisciplinesResponse(
4+
val availableSelectiveAmount: Int,
5+
val year: Int,
6+
val semester: Int,
7+
val remainingSelective: List<UserRemainingSelective>
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class GetSelectiveResponse(
4+
val disciplines: List<String>
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class PostSelectiveDisciplinesBody(
4+
val disciplines: List<String>
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class RequestNewGroupBody(
4+
val groupId: String,
5+
val isCaptain: Boolean
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class SimplifiedUser(
4+
val id: String,
5+
val email: String,
6+
val username: String,
7+
val telegramId: Long?,
8+
val avatar: String?,
9+
val state: UserGroupState
10+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class UserDTOResponse(
4+
val id: String,
5+
val firstName: String,
6+
val middleName: String,
7+
val lastName: String,
8+
val state: UserGroupState,
9+
val username: String,
10+
val email: String,
11+
val avatar: String,
12+
val telegramId: Long,
13+
val group: UserGroup
14+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class UserGroup(
4+
val id: String,
5+
val code: String,
6+
val role: UserGroupRole?,
7+
val state: UserGroupState
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
enum class UserGroupRole {
4+
CAPTAIN,
5+
MODERATOR,
6+
STUDENT
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
enum class UserGroupState {
4+
APPROVED,
5+
DECLINED,
6+
PENDING
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class UserRemainingSelective(
4+
val disciplineId: String,
5+
val subjectName: String
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class UserSelective(
4+
val semester: Int,
5+
val year: Int,
6+
val disciplines: List<String>,
7+
val amount: Int
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class VerifyStudentBody(
4+
val state: UserGroupState,
5+
val isCaptain: Boolean
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.fictadvisor.android.data.dto.user
2+
3+
data class VerifyStudentResponse(
4+
val students: List<UserDTOResponse>
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.fictadvisor.android.data.remote
2+
3+
import com.bumptech.glide.annotation.GlideModule
4+
import com.bumptech.glide.module.AppGlideModule
5+
6+
@GlideModule
7+
class GlideModule: AppGlideModule()

app/src/main/java/com/fictadvisor/android/data/remote/RetrofitClient.kt

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.fictadvisor.android.data.remote
33
import com.fictadvisor.android.data.remote.api.AuthApi
44
import com.fictadvisor.android.data.remote.api.GroupApi
55
import com.fictadvisor.android.data.remote.api.ScheduleApi
6+
import com.fictadvisor.android.data.remote.api.UserApi
67
import okhttp3.Interceptor
78
import okhttp3.OkHttpClient
89
import okhttp3.logging.HttpLoggingInterceptor
@@ -73,4 +74,10 @@ object RetrofitClient {
7374
.create(ScheduleApi::class.java)
7475
}
7576

77+
val userApi: UserApi by lazy {
78+
retrofitClient
79+
.build()
80+
.create(UserApi::class.java)
81+
}
82+
7683
}

app/src/main/java/com/fictadvisor/android/data/remote/api/AuthApi.kt

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ package com.fictadvisor.android.data.remote.api
33
import com.fictadvisor.android.data.dto.*
44
import okhttp3.ResponseBody
55
import retrofit2.Response
6-
import retrofit2.http.Body
7-
import retrofit2.http.GET
8-
import retrofit2.http.POST
9-
import retrofit2.http.PUT
10-
import retrofit2.http.Path
11-
import retrofit2.http.Query
6+
import retrofit2.http.*
127

138
interface AuthApi {
149

@@ -37,13 +32,13 @@ interface AuthApi {
3732
suspend fun verifyEmailToken(@Path("token") token: String): Response<AuthLoginResponse>
3833

3934
@PUT("/v2/auth/updatePassword")
40-
suspend fun updatePassword(@Body updatePasswordRequest: UpdatePasswordDTO): Response<AuthLoginResponse>
35+
suspend fun updatePassword(@Header("Authorization") token: String, @Body updatePasswordRequest: UpdatePasswordDTO): Response<AuthLoginResponse>
4136

4237
@POST("/v2/auth/resetPassword/{token}")
4338
suspend fun resetPassword(@Path("token") token: String, @Body resetPasswordRequest: ResetPasswordDTO): Response<AuthLoginResponse>
4439

4540
@GET("/v2/auth/me")
46-
suspend fun getStudent(): Response<OrdinaryStudentResponse>
41+
suspend fun getStudent(@Header("Authorization") token: String): Response<OrdinaryStudentResponse>
4742

4843
@GET("/v2/auth/verifyIsRegistered")
4944
suspend fun verifyIsRegistered(@Query("username") username: String?, @Query("email") email: String?): Response<Boolean>

app/src/main/java/com/fictadvisor/android/data/remote/api/ScheduleApi.kt

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import retrofit2.Response
88
import retrofit2.http.Body
99
import retrofit2.http.DELETE
1010
import retrofit2.http.GET
11+
import retrofit2.http.Header
1112
import retrofit2.http.PATCH
1213
import retrofit2.http.POST
1314
import retrofit2.http.Path
@@ -25,6 +26,7 @@ interface ScheduleApi {
2526

2627
@GET("/v2/schedule/groups/{groupId}/events")
2728
suspend fun getEventsAuthorized(
29+
@Header("Authorization") token: String,
2830
@Path("groupId") groupId: String,
2931
@Query("week") week: Int,
3032
@Query("showOwnSelective") showOwnSelective: Boolean,
@@ -36,24 +38,28 @@ interface ScheduleApi {
3638

3739
@GET("/v2/schedule/events/{eventId}")
3840
suspend fun getEventInfo(
41+
@Header("Authorization") token: String,
3942
@Path("eventId") eventId: String,
4043
@Query("week") week: Any // You can define the type accordingly
4144
): Response<DetailedEventResponse>
4245

4346
@DELETE("/v2/schedule/groups/{groupId}/events/{eventId}")
4447
suspend fun deleteEventById(
48+
@Header("Authorization") token: String,
4549
@Path("groupId") groupId: String,
4650
@Path("eventId") eventId: String
4751
): Response<DetailedEventResponse>
4852

4953
@POST("/v2/schedule/events")
5054
suspend fun addEvent(
55+
@Header("Authorization") token: String,
5156
@Body body: PostEventDTO,
5257
@Query("groupId") groupId: String
5358
): Response<DetailedEventResponse>
5459

5560
@PATCH("/v2/schedule/groups/{groupId}/events/{eventId}")
5661
suspend fun editEvent(
62+
@Header("Authorization") token: String,
5763
@Body body: PatchEventDTO,
5864
@Path("groupId") groupId: String,
5965
@Path("eventId") eventId: String

0 commit comments

Comments
 (0)