Skip to content

Commit

Permalink
[Feature/#899] 4기 업보 청산 (#900)
Browse files Browse the repository at this point in the history
* feature #875: delete main description at ACTIVE and INACTIVE

* feature #899: fix anonymous image error

* feature #899: feat getUserGeneration

* feature #899: generateBaselineProfile

* feature #899: apply spotlessApply
  • Loading branch information
chattymin authored Oct 9, 2024
1 parent 50da3b5 commit 2564aca
Show file tree
Hide file tree
Showing 23 changed files with 2,080 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ class DefaultHomeRepository @Inject constructor(
}
}

override suspend fun getMainDescription(): Result<HomeSection> {
return runCatching {
homeService.getMainDescription().toEntity()
}
}

override suspend fun getAppService(): Result<List<AppService>> {
return runCatching {
homeService.getAppService().map { it.toEntity() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ interface HomeService {
@GET("user/main")
suspend fun getMainView(): HomeResponse

@GET("description/main")
suspend fun getMainDescription(): DescriptionViewResponse

@GET("user/app-service")
suspend fun getAppService(): List<AppServiceResponse>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import org.sopt.official.domain.entity.home.SoptUser

interface HomeRepository {
suspend fun getMainView(): Result<SoptUser>
suspend fun getMainDescription(): Result<HomeSection>
suspend fun getAppService(): Result<List<AppService>>
suspend fun getHotPost(): Result<HotPostEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class HomeActivity : AppCompatActivity() {
}

private fun initUserStatus() {
viewModel.initMainDescription(args?.userStatus ?: UserStatus.UNAUTHENTICATED)
viewModel.registerPushToken(args?.userStatus ?: UserStatus.UNAUTHENTICATED)
binding.subtitle.isVisible = args?.userStatus == UserStatus.UNAUTHENTICATED
}

private fun initToolbar() {
Expand Down Expand Up @@ -381,8 +381,8 @@ class HomeActivity : AppCompatActivity() {
}

data class StartArgs(
val userStatus: UserStatus,
val deepLinkType: DeepLinkType? = null,
val userStatus: UserStatus,
val deepLinkType: DeepLinkType? = null,
) : Serializable

companion object {
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/org/sopt/official/feature/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,6 @@ class HomeViewModel @Inject constructor(
}
}

fun initMainDescription(userStatus: UserStatus) {
viewModelScope.launch {
if (userStatus != UserStatus.UNAUTHENTICATED) {
homeRepository.getMainDescription().onSuccess {
_description.value = it
}
}
}
}

fun registerPushToken(userStatus: UserStatus) {
if (userStatus == UserStatus.UNAUTHENTICATED) return
viewModelScope.launch {
Expand Down
975 changes: 956 additions & 19 deletions app/src/release/generated/baselineProfiles/baseline-prof.txt

Large diffs are not rendered by default.

975 changes: 956 additions & 19 deletions app/src/release/generated/baselineProfiles/startup-prof.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ package org.sopt.official.data.mypage.local

import android.content.SharedPreferences
import androidx.core.content.edit
import javax.inject.Inject
import org.sopt.official.domain.soptamp.constant.Soptamp
import javax.inject.Inject

class SoptampDataStore @Inject constructor(
@Soptamp private val dataStore: SharedPreferences
@Soptamp private val dataStore: SharedPreferences,
) {
var userId: Int
get() = dataStore.getInt("user_id", -1)
set(value) = dataStore.edit { putInt("user_id", value) }

var generation: Int
get() = dataStore.getInt("generation", -1)
set(value) = dataStore.edit { putInt("generation", value) }

var profileMessage: String
get() = dataStore.getString("profile_message", "") ?: "String"
set(value) = dataStore.edit { putString("profile_message", value) }
Expand All @@ -50,6 +54,7 @@ class SoptampDataStore @Inject constructor(

fun clear() {
userId = -1
generation = -1
profileMessage = ""
nickname = ""
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.data.mypage.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class UserGenerationResponse(
@SerialName("currentGeneration")
val currentGeneration: Int,
@SerialName("status")
val status: String,
) {
fun toDomain() = currentGeneration
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
*/
package org.sopt.official.data.mypage.remote

import javax.inject.Inject
import org.sopt.official.data.mypage.model.request.UpdateNicknameRequest
import org.sopt.official.data.mypage.model.request.UpdateProfileMessageRequest
import org.sopt.official.data.mypage.model.response.UserGenerationResponse
import org.sopt.official.data.mypage.model.response.UserResponse
import org.sopt.official.data.mypage.remote.api.SoptampUserService
import org.sopt.official.data.mypage.source.UserDataSource
import javax.inject.Inject

internal class RemoteUserDataSource @Inject constructor(
private val soptampUserService: SoptampUserService
private val soptampUserService: SoptampUserService,
) : UserDataSource {

override suspend fun checkNickname(nickname: String) {
Expand All @@ -50,4 +51,8 @@ internal class RemoteUserDataSource @Inject constructor(
override suspend fun getUserInfo(): UserResponse {
return soptampUserService.getUserInformation()
}

override suspend fun getUserGeneration(): UserGenerationResponse {
return soptampUserService.getGeneration()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package org.sopt.official.data.mypage.remote.api
import org.sopt.official.data.mypage.model.request.UpdateNicknameRequest
import org.sopt.official.data.mypage.model.request.UpdateProfileMessageRequest
import org.sopt.official.data.mypage.model.response.UpdateProfileMessageResponse
import org.sopt.official.data.mypage.model.response.UserGenerationResponse
import org.sopt.official.data.mypage.model.response.UserResponse
import retrofit2.http.Body
import retrofit2.http.GET
Expand All @@ -41,6 +42,9 @@ interface SoptampUserService {
@GET("user/soptamp")
suspend fun getUserInformation(): UserResponse

@GET("user/generation")
suspend fun getGeneration(): UserGenerationResponse

// 닉네임 변경
@PATCH("user/nickname")
suspend fun updateNickname(@Body nickname: UpdateNicknameRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
*/
package org.sopt.official.data.mypage.repository

import javax.inject.Inject
import org.sopt.official.data.mypage.local.SoptampDataStore
import org.sopt.official.data.mypage.source.UserDataSource
import org.sopt.official.data.poke.source.local.PokeLocalDataSource
import org.sopt.official.domain.mypage.repository.UserRepository
import javax.inject.Inject

class UserRepositoryImpl @Inject constructor(
private val remote: UserDataSource,
Expand All @@ -52,6 +52,12 @@ class UserRepositoryImpl @Inject constructor(
soptampLocal.profileMessage = it.profileMessage
}

override suspend fun getUserGeneration(): Result<Int> = runCatching {
remote.getUserGeneration().toDomain()
}.onSuccess {
soptampLocal.generation = it
}

override suspend fun updateProfileMessage(profileMessage: String) = runCatching {
remote.updateProfileMessage(profileMessage)
}.onSuccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
*/
package org.sopt.official.data.mypage.source

import org.sopt.official.data.mypage.model.response.UserGenerationResponse
import org.sopt.official.data.mypage.model.response.UserResponse

interface UserDataSource {
suspend fun checkNickname(nickname: String)
suspend fun updateNickname(new: String)
suspend fun updateProfileMessage(new: String)
suspend fun getUserInfo(): UserResponse
suspend fun getUserGeneration(): UserGenerationResponse
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.domain.fortune.usecase

import org.sopt.official.domain.fortune.model.TodayFortuneCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface UserRepository {
suspend fun checkNickname(nickname: String): Result<Unit>
suspend fun logout(): Result<Unit>
suspend fun getUserInfo(): Result<SoptampUser>
suspend fun getUserGeneration(): Result<Int>
suspend fun updateProfileMessage(profileMessage: String): Result<Unit>
suspend fun updateNickname(nickname: String): Result<Unit>
fun updateLocalUserInfo(profileMessage: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ object FakeUserRepository : UserRepository {

override suspend fun logout(): Result<Unit> = runCatching {}
override suspend fun getUserInfo(): Result<SoptampUser> = runCatching { fakeUser }
override suspend fun getUserGeneration(): Result<Int> = runCatching { 1 }

override suspend fun updateProfileMessage(profileMessage: String): Result<Unit> = runCatching {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.feature.fortune.feature.fortuneAmulet

import androidx.compose.ui.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.feature.fortune.feature.fortuneAmulet

import androidx.compose.ui.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import androidx.lifecycle.lifecycleScope
import coil.load
import coil.transform.CircleCropTransformation
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable
import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -60,6 +58,8 @@ import org.sopt.official.feature.poke.user.PokeUserListClickListener
import org.sopt.official.feature.poke.util.addOnAnimationEndListener
import org.sopt.official.feature.poke.util.setRelationStrokeColor
import org.sopt.official.feature.poke.util.showPokeToast
import java.io.Serializable
import javax.inject.Inject

@AndroidEntryPoint
class PokeMainActivity : AppCompatActivity() {
Expand Down Expand Up @@ -273,6 +273,8 @@ class PokeMainActivity : AppCompatActivity() {
with(binding) {
layoutSomeonePokeMe.setVisible(true)
imgUserProfileSomeonePokeMe.setOnClickListener {
if (pokeMeItem.isAnonymous) return@setOnClickListener

tracker.track(
type = EventType.CLICK,
name = "memberprofile",
Expand Down Expand Up @@ -334,6 +336,8 @@ class PokeMainActivity : AppCompatActivity() {
private fun initPokeFriendView(pokeFriendItem: PokeUser) {
with(binding) {
imgUserProfilePokeMyFriend.setOnClickListener {
if (pokeFriendItem.isAnonymous) return@setOnClickListener

tracker.track(
type = EventType.CLICK,
name = "memberprofile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class PokeNotificationAdapter(
onBind(currentList[position])

itemView.findViewById<ImageView>(R.id.img_user_profile).setOnClickListener {
if (currentList[position].isAnonymous) return@setOnClickListener
clickListener.onClickProfileImage(currentList[position].playgroundId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ class PokeUserListAdapter(

override fun onBindViewHolder(holder: PokeUserViewHolder, position: Int) {
holder.apply {
onBind(currentList[holder.adapterPosition])
onBind(currentList[position])
itemView.findViewById<ImageView>(R.id.imageView_profile).setOnClickListener {
clickListener.onClickProfileImage(currentList[holder.adapterPosition].playgroundId)
if (currentList[position].isAnonymous) return@setOnClickListener
clickListener.onClickProfileImage(currentList[position].playgroundId)
}
itemView.findViewById<ImageButton>(R.id.imageButton_poke).setOnClickListener {
if (currentList[holder.adapterPosition].isAlreadyPoke) return@setOnClickListener
clickListener.onClickPokeButton(currentList[holder.adapterPosition])
if (currentList[position].isAlreadyPoke) return@setOnClickListener
clickListener.onClickPokeButton(currentList[position])
}
}
}
Expand Down
Loading

0 comments on commit 2564aca

Please sign in to comment.