-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add profile page + dark/light theme + general refactor
Signed-off-by: Stefano Cappa <[email protected]>
- Loading branch information
Showing
24 changed files
with
911 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
app/src/main/java/eu/homeanthill/api/model/LoginAppResponse.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package eu.homeanthill.api.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class GitHub( | ||
@SerializedName("id") val id: Number, | ||
@SerializedName("login") val login: String, | ||
@SerializedName("name") val name: String, | ||
@SerializedName("email") val email: String, | ||
@SerializedName("avatarURL") val avatarURL: String | ||
) | ||
|
||
data class Profile( | ||
@SerializedName("id") val id: String, | ||
@SerializedName("createdAt") val createdAt: String, | ||
@SerializedName("modifiedAt") val modifiedAt: String, | ||
@SerializedName("github") val github: GitHub, | ||
@SerializedName("fcmToken") var fcmToken: String?, | ||
) | ||
|
||
data class ProfileAPITokenResponse( | ||
@SerializedName("apiToken") val apiToken: String, | ||
) |
12 changes: 0 additions & 12 deletions
12
app/src/main/java/eu/homeanthill/api/requests/LoginAppServices.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
app/src/main/java/eu/homeanthill/api/requests/ProfileServices.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package eu.homeanthill.api.requests | ||
|
||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Headers | ||
import retrofit2.http.POST | ||
|
||
import eu.homeanthill.api.model.Profile | ||
import eu.homeanthill.api.model.ProfileAPITokenResponse | ||
import retrofit2.http.Path | ||
|
||
interface ProfileServices { | ||
@Headers("Accept: application/json") | ||
@GET("profile") | ||
suspend fun getProfile(): Response<Profile> | ||
|
||
@Headers("Accept: application/json") | ||
@POST("profile/{id}/tokens") | ||
suspend fun postRegenApiToken(@Path("id") id: String): Response<ProfileAPITokenResponse> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/eu/homeanthill/repository/ProfileRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package eu.homeanthill.repository | ||
|
||
import eu.homeanthill.api.model.ProfileAPITokenResponse | ||
import java.io.IOException | ||
|
||
import eu.homeanthill.api.model.Profile | ||
import eu.homeanthill.api.requests.ProfileServices | ||
|
||
class ProfileRepository(private val profileService: ProfileServices) { | ||
suspend fun repoGetProfile(): Profile { | ||
val result = profileService.getProfile() | ||
if (result.isSuccessful) { | ||
return result.body()!! | ||
} else { | ||
throw Exception(IOException("Error repoGetProfile")) | ||
} | ||
} | ||
|
||
suspend fun repoPostRegenAPIToken(id: String): ProfileAPITokenResponse { | ||
val result = profileService.postRegenApiToken(id) | ||
if (result.isSuccessful) { | ||
return result.body()!! | ||
} else { | ||
throw Exception(IOException("Error repoPostRegenAPIToken")) | ||
} | ||
} | ||
} |
Oops, something went wrong.