Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: 토큰 시간 변경 #578

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
android:theme="@style/Theme.Naaga"
android:usesCleartextTraffic="true"
tools:targetApi="33">
<activity
android:name=".presentation.profile.ProfileActivity"
android:exported="false" />

<meta-data
android:name="com.naver.maps.map.CLIENT_ID"
Expand All @@ -40,44 +43,44 @@
</activity>
<activity
android:name=".presentation.beginadventure.BeginAdventureActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.onadventure.OnAdventureActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.adventurehistory.AdventureHistoryActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.upload.UploadActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.rank.RankActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.adventureresult.AdventureResultActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.mypage.MyPageActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.login.LoginActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.setting.SettingActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.adventuredetail.AdventureDetailActivity"
android:screenOrientation="portrait"
android:exported="false" />
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.now.naaga.data.remote.dto

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

@Serializable
data class NicknameDto(
@SerialName("nickname")
val nickname: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.now.naaga.data.remote.retrofit.service

import com.now.naaga.data.remote.dto.NicknameDto
import com.now.naaga.data.remote.dto.PlayerDto
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PATCH

interface ProfileService {
@GET("/profiles/my")
suspend fun getProfile(): Response<PlayerDto>

@PATCH("/profiles/my")
suspend fun modifyNickname(
@Body nicknameDto: NicknameDto,
): Response<NicknameDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.now.naaga.data.repository

import com.now.domain.model.Player
import com.now.domain.repository.ProfileRepository
import com.now.naaga.data.mapper.toDomain
import com.now.naaga.data.remote.dto.NicknameDto
import com.now.naaga.data.remote.retrofit.service.ProfileService
import com.now.naaga.util.extension.getValueOrThrow

class DefaultProfileRepository(
private val profileService: ProfileService,
) : ProfileRepository {
override suspend fun fetchProfile(): Player {
val response = profileService.getProfile().getValueOrThrow()
return response.toDomain()
}

override suspend fun modifyNickname(nickname: String): String {
val nicknameDto = NicknameDto(nickname)
val response = profileService.modifyNickname(nicknameDto).getValueOrThrow()
return response.nickname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import com.now.domain.repository.AdventureRepository
import com.now.domain.repository.AuthRepository
import com.now.domain.repository.LetterRepository
import com.now.domain.repository.PlaceRepository
import com.now.domain.repository.ProfileRepository
import com.now.domain.repository.RankRepository
import com.now.domain.repository.StatisticsRepository
import com.now.naaga.data.local.AuthDataSource
import com.now.naaga.data.remote.retrofit.service.AdventureService
import com.now.naaga.data.remote.retrofit.service.AuthService
import com.now.naaga.data.remote.retrofit.service.LetterService
import com.now.naaga.data.remote.retrofit.service.PlaceService
import com.now.naaga.data.remote.retrofit.service.ProfileService
import com.now.naaga.data.remote.retrofit.service.RankService
import com.now.naaga.data.remote.retrofit.service.StatisticsService
import com.now.naaga.data.repository.DefaultAdventureRepository
import com.now.naaga.data.repository.DefaultAuthRepository
import com.now.naaga.data.repository.DefaultLetterRepository
import com.now.naaga.data.repository.DefaultPlaceRepository
import com.now.naaga.data.repository.DefaultProfileRepository
import com.now.naaga.data.repository.DefaultRankRepository
import com.now.naaga.data.repository.DefaultStatisticsRepository
import dagger.Module
Expand Down Expand Up @@ -55,4 +58,9 @@ class RepositoryModule {
@Provides
fun provideLetterRepository(letterService: LetterService): LetterRepository =
DefaultLetterRepository(letterService)

@Singleton
@Provides
fun provideProfileRepository(profileService: ProfileService): ProfileRepository =
DefaultProfileRepository(profileService)
}
5 changes: 5 additions & 0 deletions android/app/src/main/java/com/now/naaga/di/ServiceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.now.naaga.data.remote.retrofit.service.AdventureService
import com.now.naaga.data.remote.retrofit.service.AuthService
import com.now.naaga.data.remote.retrofit.service.LetterService
import com.now.naaga.data.remote.retrofit.service.PlaceService
import com.now.naaga.data.remote.retrofit.service.ProfileService
import com.now.naaga.data.remote.retrofit.service.RankService
import com.now.naaga.data.remote.retrofit.service.StatisticsService
import dagger.Module
Expand Down Expand Up @@ -61,4 +62,8 @@ class ServiceModule {
@Singleton
@Provides
fun provideLetterService(retrofit: Retrofit): LetterService = retrofit.create(LetterService::class.java)

@Singleton
@Provides
fun provideProfileService(retrofit: Retrofit): ProfileService = retrofit.create(ProfileService::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.now.naaga.databinding.DialogReadLetterBinding
import com.now.naaga.presentation.uimodel.model.LetterUiModel
import com.now.naaga.util.dpToPx
import com.now.naaga.util.getWidthProportionalToDevice
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

class LetterReadDialog(private val content: String) : DialogFragment() {
class LetterReadDialog(private val content: LetterUiModel) : DialogFragment() {
private lateinit var binding: DialogReadLetterBinding

override fun onCreateView(
Expand Down Expand Up @@ -39,10 +42,18 @@ class LetterReadDialog(private val content: String) : DialogFragment() {

private fun setContent() {
binding.letter = content
binding.tvDialogLetterDate.text = getFormattedDate()
}

private fun getFormattedDate(): String {
val serverLocalDateTime = LocalDateTime.parse(content.registerDate, DateTimeFormatter.ISO_DATE_TIME)
val outputFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT_PATTERN)
return serverLocalDateTime.format(outputFormatter)
}

companion object {
private const val WIDTH_RATE = 0.78f
private const val HEIGHT = 430
private const val DATE_FORMAT_PATTERN = "yyyy-MM-dd"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.now.naaga.presentation.mypage
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import com.now.domain.model.Statistics
Expand All @@ -14,6 +15,7 @@ import com.now.naaga.data.throwable.DataThrowable
import com.now.naaga.databinding.ActivityMyPageBinding
import com.now.naaga.presentation.adventurehistory.AdventureHistoryActivity
import com.now.naaga.presentation.mypage.statistics.MyPageStatisticsAdapter
import com.now.naaga.presentation.profile.ProfileActivity
import com.now.naaga.presentation.uimodel.model.StatisticsUiModel
import com.now.naaga.util.extension.showToast
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -23,6 +25,14 @@ class MyPageActivity : AppCompatActivity(), AnalyticsDelegate by DefaultAnalytic
private lateinit var binding: ActivityMyPageBinding
private val viewModel: MyPageViewModel by viewModels()

private val myPageActivityLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
val nickname = it.data?.getStringExtra(NICKNAME_KEY) ?: ""
binding.tvMypageNickname.text = nickname
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMyPageBinding.inflate(layoutInflater)
Expand All @@ -48,10 +58,14 @@ class MyPageActivity : AppCompatActivity(), AnalyticsDelegate by DefaultAnalytic
val intent = AdventureHistoryActivity.getIntent(this)
startActivity(intent)
}
binding.ivMypageProfileModify.setOnClickListener {
val intent = ProfileActivity.getIntent(this)
myPageActivityLauncher.launch(intent)
}
}

private fun fetchData() {
viewModel.fetchRank()
viewModel.fetchProfile()
viewModel.fetchStatistics()
viewModel.fetchPlaces()
}
Expand Down Expand Up @@ -82,8 +96,16 @@ class MyPageActivity : AppCompatActivity(), AnalyticsDelegate by DefaultAnalytic
}

companion object {
private const val NICKNAME_KEY = "nickname"

fun getIntent(context: Context): Intent {
return Intent(context, MyPageActivity::class.java)
}

fun getIntent(context: Context, nickname: String): Intent {
return Intent(context, MyPageActivity::class.java).apply {
putExtra(NICKNAME_KEY, nickname)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.now.domain.model.Place
import com.now.domain.model.Rank
import com.now.domain.model.Player
import com.now.domain.model.Statistics
import com.now.domain.model.type.OrderType
import com.now.domain.model.type.SortType
import com.now.domain.repository.PlaceRepository
import com.now.domain.repository.RankRepository
import com.now.domain.repository.ProfileRepository
import com.now.domain.repository.StatisticsRepository
import com.now.naaga.data.throwable.DataThrowable
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -20,12 +20,12 @@ import javax.inject.Inject

@HiltViewModel
class MyPageViewModel @Inject constructor(
private val rankRepository: RankRepository,
private val profileRepository: ProfileRepository,
private val statisticsRepository: StatisticsRepository,
private val placeRepository: PlaceRepository,
) : ViewModel() {
private val _rank = MutableLiveData<Rank>()
val rank: LiveData<Rank> = _rank
private val _profile = MutableLiveData<Player>()
val profile: LiveData<Player> = _profile

private val _statistics = MutableLiveData<Statistics>()
val statistics: LiveData<Statistics> = _statistics
Expand All @@ -36,12 +36,12 @@ class MyPageViewModel @Inject constructor(
private val _throwable = MutableLiveData<DataThrowable>()
val throwable: LiveData<DataThrowable> = _throwable

fun fetchRank() {
fun fetchProfile() {
viewModelScope.launch {
runCatching {
rankRepository.getMyRank()
}.onSuccess { rank ->
_rank.value = rank
profileRepository.fetchProfile()
}.onSuccess { profile ->
_profile.value = profile
}.onFailure {
setThrowable(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,15 @@ class DefaultNaverMapSettingDelegate() : NaverMapSettingDelegate, DefaultLifecyc
override fun addLetter(letter: LetterPreview, action: (id: Long) -> Unit) {
Marker().apply {
position = LatLng(letter.coordinate.latitude, letter.coordinate.longitude)
icon = selectLetterIcon(letter.isNearBy)
if (letter.isNearBy) {
setOnSingleClickListener {
action(letter.id)
}
icon = OverlayImage.fromResource(R.drawable.ic_letter)
setOnSingleClickListener {
action(letter.id)
}
map = naverMap
letterMarkers.add(this)
}
}

private fun selectLetterIcon(isNearBy: Boolean): OverlayImage {
return if (isNearBy) {
OverlayImage.fromResource(R.drawable.ic_letter)
} else {
OverlayImage.fromResource(R.drawable.ic_letter_preview)
}
}

override fun removeLetters() {
letterMarkers.forEach { letterMarker ->
letterMarker.map = null
Expand Down
Loading
Loading