Skip to content

Commit

Permalink
Merge pull request #857 from TeamHavit/release
Browse files Browse the repository at this point in the history
[RELEASE] v1.0.6 배포완료
  • Loading branch information
KxxHyoRim authored May 8, 2023
2 parents 69672a5 + b773cb8 commit d6ee80b
Show file tree
Hide file tree
Showing 18 changed files with 271 additions and 57 deletions.
1 change: 1 addition & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id 'androidx.navigation.safeargs.kotlin'
id 'com.google.gms.google-services'
id 'kotlin-android-extensions'
id 'com.google.firebase.crashlytics'
}

Properties properties = new Properties()
Expand All @@ -19,8 +20,8 @@ android {
applicationId "org.sopt.havit"
minSdk 23
targetSdk 31
versionCode 105
versionName "1.0.5"
versionCode 106
versionName "1.0.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "HAVIT_BASE_URL_DEV", properties["HAVIT_BASE_URL_DEV"])
buildConfigField("String", "HAVIT_BASE_URL_PROD", properties["HAVIT_BASE_URL_PROD"])
Expand Down Expand Up @@ -136,10 +137,11 @@ dependencies {
* bom 이외의 sdk에 버전 지정을 하지 않게 주의
* */

implementation platform('com.google.firebase:firebase-bom:29.0.2')
implementation platform('com.google.firebase:firebase-bom:31.5.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.google.firebase:firebase-messaging-ktx:23.0.0'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'

// Jsoup
implementation 'org.jsoup:jsoup:1.13.1'
Expand All @@ -154,4 +156,12 @@ dependencies {
// 스켈레톤 shimmer
implementation "com.facebook.shimmer:shimmer:0.5.0"

// google play core
implementation 'com.google.android.play:app-update:2.0.1'
implementation 'com.google.android.play:app-update-ktx:2.0.1'

// google play service
implementation 'com.google.android.gms:play-services-base:18.0.1'
implementation 'com.google.android.gms:play-services-tasks:18.0.1'

}
10 changes: 10 additions & 0 deletions app/src/main/java/org/sopt/havit/domain/entity/VersionState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.havit.domain.entity

/** VersionState가 Unkown인 경우
* 1. debug build로 실행할 경우 (Prod로 실행해주세요)
* 2. Play Store지원을 하지 않는 Emulator를 사용하고 있는 경우
* */
enum class VersionState {
Latest, Update, Unknown

}
75 changes: 67 additions & 8 deletions app/src/main/java/org/sopt/havit/ui/setting/SettingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import com.kakao.sdk.user.UserApiClient
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.havit.BuildConfig
import org.sopt.havit.R
import org.sopt.havit.databinding.ActivitySettingBinding
import org.sopt.havit.domain.entity.VersionState
import org.sopt.havit.ui.base.BaseBindingActivity
import org.sopt.havit.ui.home.ServiceGuideActivity
import org.sopt.havit.ui.setting.viewmodel.SettingViewModel
import org.sopt.havit.ui.sign.SplashWithSignActivity
import org.sopt.havit.util.*
import org.sopt.havit.util.CANNOT_SEND_MAIL_TYPE
import org.sopt.havit.util.DialogUtil
import org.sopt.havit.util.ERROR_OCCUR_TYPE
import org.sopt.havit.util.HavitSharedPreference
import org.sopt.havit.util.ToastUtil
import org.sopt.havit.util.setOnSingleClickListener
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -27,20 +33,75 @@ class SettingActivity : BaseBindingActivity<ActivitySettingBinding>(R.layout.act
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.vmSetting = settingViewModel
setVersion()
setClickListener()
getLatestVersion()
observeIsLatest()
onClickUpdate()
}

override fun onResume() {
super.onResume()
setData()
}

private fun setVersion() {
val version = BuildConfig.VERSION_NAME // build.gradle->defaultConfig에 있는 version_name
settingViewModel.setVersion(version)
private fun getLatestVersion() {
settingViewModel.getLatestVersion()
}

private fun onClickUpdate() {
binding.tvVersionStatus.setOnSingleClickListener {
if (settingViewModel.versionState.value == VersionState.Update) {
linkToPlayStore()
}
}
}

private fun linkToPlayStore() {
try {
val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse("market://details?id=$packageName")
setPackage("com.android.vending")
}
startActivity(intent)
} catch (e: Exception) {
ToastUtil(this).makeToast(ERROR_OCCUR_TYPE)
}
}


private fun setVersionLatestState() {
with(binding.tvVersionStatus) {
setText(R.string.latest_version)
setTextColor(ContextCompat.getColor(this@SettingActivity, R.color.gray_3))
}
}

private fun setVersionUpdateState() {
with(binding.tvVersionStatus) {
setText(R.string.update)
setTextColor(ContextCompat.getColor(this@SettingActivity, R.color.havit_purple))
}
}

private fun setVersionUnknownState() {
with(binding.tvVersionStatus) {
setText(R.string.dash)
setTextColor(ContextCompat.getColor(this@SettingActivity, R.color.gray_3))
}
}

private fun observeIsLatest() {
settingViewModel.versionState.observe(this) { versionState ->
versionState ?: return@observe
when (versionState) {
VersionState.Latest -> setVersionLatestState()
VersionState.Update -> setVersionUpdateState()
VersionState.Unknown -> setVersionUnknownState()
}
}
}


private fun setClickListener() {
// 뒤로가기
binding.ivBack.setOnSingleClickListener { finish() }
Expand Down Expand Up @@ -132,7 +193,5 @@ class SettingActivity : BaseBindingActivity<ActivitySettingBinding>(R.layout.act

companion object {
const val nickname = "nickname"
const val NOTICE_URL =
"https://skitter-sloth-be4.notion.site/What-is-Havit-3db94fcc0cdc4a38bddd87f790e0ac96"
}
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
package org.sopt.havit.ui.setting.viewmodel

import android.app.Application
import android.content.ContentValues.TAG
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.install.model.UpdateAvailability
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import org.sopt.havit.BuildConfig
import org.sopt.havit.data.RetrofitObject
import org.sopt.havit.data.remote.NewNicknameRequest
import org.sopt.havit.data.remote.UserResponse
import org.sopt.havit.domain.entity.Notice
import org.sopt.havit.domain.entity.VersionState
import org.sopt.havit.domain.repository.AuthRepository
import javax.inject.Inject

@HiltViewModel
class SettingViewModel @Inject constructor(
private val authRepository: AuthRepository
) : ViewModel() {
// private val token = MySharedPreference.getXAuthToken(context)

private val authRepository: AuthRepository,
application: Application
) : AndroidViewModel(application) {
private val token = authRepository.getAccessToken()

private val _user = MutableLiveData<UserResponse.UserData>()
val user: LiveData<UserResponse.UserData> = _user
private val _version = MutableLiveData<String>()
val version: LiveData<String> = _version
private val _isLatest = MutableLiveData<Boolean>()
val isLatest: LiveData<Boolean> = _isLatest
val currentVersion: String = BuildConfig.VERSION_NAME
private val _versionState = MutableLiveData(VersionState.Unknown)
val versionState: LiveData<VersionState> = _versionState

// 환경설정_내정보수정
private val _nickname = MutableLiveData<String>()
val nickname: LiveData<String> = _nickname

// version 정보 가져옴
fun setVersion(appVersion: String) {
_version.postValue(appVersion)
Log.d("TOKEN", "setting token : $token")
if (appVersion == "1.0")
_isLatest.postValue(true)
else
_isLatest.postValue(false)
fun getLatestVersion() {
val context = getApplication<Application>().applicationContext
val appUpdateManager = AppUpdateManagerFactory.create(context)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
_versionState.postValue(VersionState.Update)
} else {
_versionState.postValue(VersionState.Latest)
}
}.addOnFailureListener { exception ->
_versionState.postValue(VersionState.Unknown)
Log.e(TAG, "error getting update info(Play Store가 설치된 앱에서 사용해주세요)", exception)
}
}

// user data 가져옴
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ class AddCategoryViewModel @Inject constructor(

fun isCategoryNameAlreadyExist(currentTitle: String): Boolean {
val list = existingCategoryList.value?.toList() ?: throw IllegalStateException()
return list.stream().anyMatch { anotherString: String? ->
currentTitle.equals(anotherString, ignoreCase = true)
}
return list.any { it.equals(currentTitle, ignoreCase = false) }
}

/** Category Title */
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/org/sopt/havit/ui/sign/AddNickNameFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ class AddNickNameFragment :

private fun setTextWatcher() {
binding.etNickname.addTextChangedListener {
signUpViewModel.setNickName(binding.etNickname.text.toString())
val hasSpace = binding.etNickname.text?.toString()?.contains("\\s".toRegex()) ?: false
if (hasSpace) { // 닉네임에 띄어쓰기 포함
signUpViewModel.nickNameStatus.value = NickNameTextStatus.HAS_SPACING
} else if (binding.etNickname.text?.toString()?.isEmpty() == true) { // 닉네임이 공백일 때
signUpViewModel.nickNameStatus.value = NickNameTextStatus.EMPTY
} else { // 정상 닉네임 입력할 때
signUpViewModel.nickNameStatus.value = NickNameTextStatus.FILLED
}
binding.etNickname.setSelection(binding.etNickname.length())
}
}

private fun setListener() {
binding.btnNicknameNext.setOnClickListener {
signUpViewModel.setNickName(binding.etNickname.text.toString())
signUpViewModel.setMoveToNextOrBack(true)
}
binding.ivNicknameDeleteText.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.sopt.havit.ui.sign

enum class NickNameTextStatus {
EMPTY, HAS_SPACING, FILLED
}
6 changes: 5 additions & 1 deletion app/src/main/java/org/sopt/havit/ui/sign/SignUpViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.util.Log
import android.view.View
import androidx.lifecycle.*
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import org.sopt.havit.R
import org.sopt.havit.domain.entity.NetworkState
Expand All @@ -23,6 +24,8 @@ class SignUpViewModel @Inject constructor(

var nickName = MutableLiveData(authRepository.getUserNickName())

val nickNameStatus = MutableStateFlow(NickNameTextStatus.EMPTY)

private var _fcmToken = MutableLiveData<String>()

private var _accessToken = MutableLiveData<String>()
Expand Down Expand Up @@ -122,9 +125,10 @@ class SignUpViewModel @Inject constructor(

fun setClearNickName() {
nickName.value = ""
nickNameStatus.value = NickNameTextStatus.EMPTY
}

fun setMoveToNextOrBack(move: Boolean) {
_isMoveToNextOrBack.value = Event(move)
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/havit/util/BindingAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.sopt.havit.util.DpToPxUtil.px
fun ImageView.loadImage(url: String?) {
Glide.with(context)
.load(url)
.placeholder(R.drawable.img_contents_dummy)
.placeholder(R.drawable.img_contents_dummy_3)
.into(this)
}

Expand Down
14 changes: 3 additions & 11 deletions app/src/main/java/org/sopt/havit/util/DialogOkUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,12 @@ class DialogOkUtil(private val dialogMode: Int, private val doAfterConfirm: () -
}

private fun clickListener() {
binding.ivClose.setOnSingleClickListener {
dismiss()
doAfterConfirm()
}
binding.btnConfirm.setOnSinglePostClickListener {
dismiss()
doAfterConfirm()
}
binding.ivClose.setOnSingleClickListener { dismiss() }
binding.btnConfirm.setOnSinglePostClickListener { dismiss() }
}

override fun onDestroyView() {
if (dialogMode == UNREGISTER) {
doAfterConfirm()
}
doAfterConfirm()
super.onDestroyView()
_binding = null
}
Expand Down
Loading

0 comments on commit d6ee80b

Please sign in to comment.