Skip to content

Commit

Permalink
Merge pull request #196 from hellokitty-coding-club/feat/report
Browse files Browse the repository at this point in the history
  • Loading branch information
KxxHyoRim authored Nov 11, 2023
2 parents ae7c7a8 + 7e4ea77 commit 0c37406
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 34 deletions.
2 changes: 1 addition & 1 deletion common-ui/src/main/res/menu/menu_edit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/edit_profile"
<item android:id="@+id/edit"
android:title="@string/edit"/>
</menu>
2 changes: 1 addition & 1 deletion common-ui/src/main/res/menu/menu_edit_delete.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/edit_profile"
<item android:id="@+id/edit"
android:title="@string/edit"/>
<item android:id="@+id/delete_mission"
android:title="@string/delete" />
Expand Down
12 changes: 12 additions & 0 deletions domain/src/main/java/com/lgtm/domain/usecase/ProfileUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ class ProfileUseCase @Inject constructor(
) {

private lateinit var role: Role
private lateinit var nickname: String
private lateinit var github: String
private lateinit var introduction: String


suspend fun fetchProfileInfo(userId: Int? = null): Result<List<Profile>> {
return try {
val response = profileRepository.getProfileInfo(userId).getOrNull()
?: return Result.failure(Exception("response is null"))

role = response.memberType ?: throw IllegalStateException("memberType is null")
nickname = response.nickname
github = response.githubId
introduction = response.introduction

val profileList = when (response.memberType) {
Role.REVIEWEE -> getRevieweeProfile(response)
Expand All @@ -38,6 +45,10 @@ class ProfileUseCase @Inject constructor(
}
}

fun getNickname() = nickname
fun getGithub() = github
fun getIntroduction() = introduction

private fun commonProfileList(response: ProfileVO) = listOf(
ProfileImage(response.profileImageUrl, response.isMyProfile),
ProfileGlance(
Expand Down Expand Up @@ -66,6 +77,7 @@ class ProfileUseCase @Inject constructor(
*response.memberMissionHistory?.toTypedArray() ?: addEmptyView(),
)
}

private fun getReviewerProfile(response: ProfileVO): List<Profile> {
return commonProfileList(response) + listOf(
ProfileTitleText(ProfileTitleTextType.CAREER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,25 @@ class SplashViewModel @Inject constructor(
private val introRepository: IntroRepository,
private val authRepository: AuthRepository,
) : BaseViewModel() {


private val _minVersion = MutableLiveData<Int>()
val minVersion: LiveData<Int> = _minVersion

private val _latestVersion = MutableLiveData<Int>()
val latestVersion: LiveData<Int> = _latestVersion

private val _isSystemMaintenance = MutableLiveData<Boolean>()
val isSystemMaintenance: LiveData<Boolean> = _isSystemMaintenance


private val _isDataAllSet = MediatorLiveData<Boolean>().apply { value = false }
val isDataAllSet: LiveData<Boolean> = _isDataAllSet

init {
addSourceOnIsDataAllSet()
}

fun getAppVersionInfo() {
viewModelScope.launch(lgtmErrorHandler) {
introRepository.getIntro()
Expand All @@ -42,46 +55,42 @@ class SplashViewModel @Inject constructor(
}
}

private val _isDataAllSet = MediatorLiveData<Boolean>().apply { value = false }
val isDataAllSet: LiveData<Boolean> = _isDataAllSet

init {
addSourceOnIsDataAllSet()
fun checkSystemMaintenance() {
val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 10
}
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
if (task.isSuccessful) {
val isSystemMaintenance = remoteConfig.getBoolean(IS_SYSTEM_MAINTENANCE)
_isSystemMaintenance.value = isSystemMaintenance
Log.d(TAG, "checkSystemMaintenance: $isSystemMaintenance")
} else {
Log.e(TAG, "checkSystemMaintenance: fail")
_isSystemMaintenance.value = false
}
}
}

private fun addSourceOnIsDataAllSet() {
_isDataAllSet.addSource(minVersion) {
if (_isDataAllSet.value == true) return@addSource
fetchIsDataAllSetState()
}
_isDataAllSet.addSource(latestVersion) {
_isDataAllSet.addSource(isSystemMaintenance) {
if (_isDataAllSet.value == true) return@addSource
fetchIsDataAllSetState()
}
}

fun removeSourceOnIsDataAllSet() {
_isDataAllSet.removeSource(minVersion)
_isDataAllSet.removeSource(latestVersion)
}

private fun fetchIsDataAllSetState() {
_isDataAllSet.value = _minVersion.value != null && _isSystemMaintenance.value != null
_isDataAllSet.value = minVersion.value != null && isSystemMaintenance.value != null
}

private val _isSystemMaintenance = MutableLiveData<Boolean>()
val isSystemMaintenance: LiveData<Boolean> = _isSystemMaintenance

fun checkSystemMaintenance() {
val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 10
}
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.fetchAndActivate().addOnCompleteListener {
val isSystemMaintenance = remoteConfig.getBoolean(IS_SYSTEM_MAINTENANCE)
_isSystemMaintenance.postValue(isSystemMaintenance)
}
fun removeSourceOnIsDataAllSet() {
_isDataAllSet.removeSource(minVersion)
_isDataAllSet.removeSource(isSystemMaintenance)
}

fun isAutoLoginAvailable(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_
if (intent.resolveActivity(requireActivity().packageManager) != null)
startActivity(intent)
else copyEmailToClipboard()

}

private fun copyEmailToClipboard() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lgtm.android.mission_detail

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -202,8 +203,8 @@ class MissionDetailActivity :

override fun onMenuItemClick(item: MenuItem): Boolean {
return when (item.itemId) {
id.report, id.edit_profile -> {
Toast.makeText(this, string.service_under_preparation, Toast.LENGTH_SHORT).show()
id.report -> {
onPressCsCenter()
true
}

Expand All @@ -212,10 +213,29 @@ class MissionDetailActivity :
true
}

id.edit_text -> {
Toast.makeText(this, string.service_under_preparation, Toast.LENGTH_SHORT).show()
true
}

else -> false
}
}

private fun onPressCsCenter() {
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
putExtra(Intent.EXTRA_SUBJECT, "[LGTM] 미션 불편사항 신고")
putExtra(Intent.EXTRA_TEXT, missionDetailViewModel.getReportMessage())
}
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(this, "메일을 보낼 수 없습니다", Toast.LENGTH_SHORT).show()
}
}

private fun showDeleteMissionDialog() {
val title = getString(string.delete_mission_title)
val description = getString(string.delete_mission_message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import com.lgtm.android.common_ui.model.mapper.toUiModel
import com.lgtm.android.common_ui.util.NetworkState
import com.lgtm.domain.constants.MissionDetailStatus
import com.lgtm.domain.entity.response.MissionDetailVO
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.usecase.MissionUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class MissionDetailViewModel @Inject constructor(
private val missionUseCase: MissionUseCase
private val missionUseCase: MissionUseCase,
private val authRepository: AuthRepository,
) : BaseViewModel() {

private val _missionDetailUiState: MutableLiveData<MissionDetailUI> = MutableLiveData()
Expand Down Expand Up @@ -119,4 +121,44 @@ class MissionDetailViewModel @Inject constructor(
}
}
}


fun getReportMessage() =
"안녕하세요 고객님, LGTM 서비스 이용에 불편을 드려 죄송합니다. 보내주신 내용은 빠른 시일 내로 운영팀에서 처리하겠습니다.\n" +
"처리 결과는 발신된 이메일 주소로 전달될 예정입니다. 감사합니다.\n\n" +
"[신고 유형을 선택해주세요]\n" +
"1. 성적, 폭력적 또는 혐오스러운 내용\n" +
"2. 욕설 혹은 유해한 내용\n" +
"3. 기타 부적절한 내용\n" +
"4. 기타 서비스 이용 불편사항\n" +
"응답 : \n" +
"\n\n\n" +
"[신고 내용]\n" +
"불편을 겪으신 내용을 적어주세요. 필요시 사진을 첨부해주셔도 좋습니다.\n" +
"응답 : \n" +
"\n\n\n" +
"-------------------------------------------------\n" +
"아래 내용은 운영진에게 전달되는 정보니 수정하지 말아주세요:)\n\n" +
"[신고 정보]\n" +
"1. 신고자 ID : ${getUserId()}\n" +
"2. 미션 제목 : ${getMissionTitle()}\n" +
"3. 미션 본문 : ${getMissionDescription()} \n" +
"4. 미션 URL : ${getMissionUrl()}\n" +
"5. 리뷰어 닉네임 : ${getReviewerNickname()}\n"

private fun getUserId(): Int? {
return authRepository.getMemberId()
}

private fun getMissionTitle(): String {
return missionDetailUiState.value?.missionTitle ?: ""
}

private fun getMissionDescription(): String {
return missionDetailUiState.value?.description ?: ""
}

private fun getReviewerNickname(): String {
return missionDetailUiState.value?.memberProfile?.nickname ?: ""
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lgtm.android.profile

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -137,11 +138,11 @@ class ProfileActivity : BaseActivity<ActivityProfileBinding>(R.layout.activity_p
override fun onMenuItemClick(item: MenuItem): Boolean {
return when (item.itemId) {
id.report -> {
makeToastServiceUnderPreparation()
onClickReport()
true
}

id.edit_profile -> {
id.edit -> {
makeToastServiceUnderPreparation()
true
}
Expand All @@ -150,6 +151,20 @@ class ProfileActivity : BaseActivity<ActivityProfileBinding>(R.layout.activity_p
}
}

private fun onClickReport() {
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
putExtra(Intent.EXTRA_SUBJECT, "[LGTM] 사용자 프로필 신고")
putExtra(Intent.EXTRA_TEXT, profileViewModel.getReportMessage())
}
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(this, "메일을 보낼 수 없습니다", Toast.LENGTH_SHORT).show()
}
}

private fun makeToastServiceUnderPreparation() {
Toast.makeText(this, com.lgtm.android.common_ui.R.string.service_under_preparation, Toast.LENGTH_SHORT).show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import com.lgtm.android.common_ui.base.BaseViewModel
import com.lgtm.domain.profile.Profile
import com.lgtm.domain.profile.profileViewType.ProfileGlance
import com.lgtm.domain.profile.profileViewType.ProfileImage
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.usecase.ProfileUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class ProfileViewModel @Inject constructor(
private val profileUseCase: ProfileUseCase
private val profileUseCase: ProfileUseCase,
private val authRepository: AuthRepository,
) : BaseViewModel() {

private val _profileInfo = MutableLiveData<List<Profile>>()
Expand Down Expand Up @@ -58,4 +60,27 @@ class ProfileViewModel @Inject constructor(
val gitId = (profileInfo.value?.get(1) as ProfileGlance).githubId
return "https://github.com/$gitId"
}

fun getReportMessage() =
"안녕하세요 고객님, LGTM 서비스 이용에 불편을 드려 죄송합니다. 보내주신 내용은 빠른 시일 내로 운영팀에서 처리하겠습니다.\n" +
"처리 결과는 발신된 이메일 주소로 전달될 예정입니다. 감사합니다.\n\n" +
"[신고 유형을 선택해주세요]\n" +
"1. 성적, 폭력적 또는 혐오스러운 내용\n" +
"2. 욕설 혹은 유해한 내용\n" +
"3. 기타 부적절한 내용\n" +
"4. 기타 서비스 이용 불편사항\n" +
"응답 : \n" +
"\n\n\n" +
"[신고 내용]\n" +
"불편을 겪으신 내용을 적어주세요. 필요시 사진을 첨부해주셔도 좋습니다.\n" +
"응답 : \n" +
"\n\n\n" +
"-------------------------------------------------\n" +
"아래 내용은 운영진에게 전달되는 정보니 수정하지 말아주세요:)\n\n" +
"[신고 정보]\n" +
"1. 신고자 ID : ${authRepository.getMemberId()} \n" +
"2. 피신고자 닉네임 : ${profileUseCase.getNickname()}\n" +
"3. 피신고자 Gitub : ${profileUseCase.getGithub()}\n" +
"4. 피신고자 한 줄 소개 : ${profileUseCase.getIntroduction()}\n"
}

0 comments on commit 0c37406

Please sign in to comment.