Skip to content

Commit

Permalink
Merge branch 'develop' into release/fairer2.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/java/com/depromeet/housekeeper/di/NetworkModule.kt
  • Loading branch information
wjdwns committed Jun 27, 2023
2 parents 6b0bb8d + 18a3a21 commit c84d87a
Show file tree
Hide file tree
Showing 18 changed files with 280 additions and 187 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ dependencies {
implementation Dependencies.glidesvgloader

implementation platform(Dependencies.firebaseBOM)
implementation Dependencies.firebasektx
implementation Dependencies.firebaseAnalytics
implementation Dependencies.firebasedynamiclink
implementation Dependencies.firebasemessaging
implementation Dependencies.firebaseMessagingDirectboot
implementation Dependencies.firebaseConfig

implementation Dependencies.workermanager

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.depromeet.housekeeper

import android.app.Application
import android.content.Intent
import com.depromeet.housekeeper.service.InternetService
import com.depromeet.housekeeper.util.PrefsManager
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/java/com/depromeet/housekeeper/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import okhttp3.*
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

Expand All @@ -25,10 +26,10 @@ import javax.inject.Singleton
class NetworkModule {
private val DEBUG_URL =
"http://fairer-dev-env.eba-yzy7enxi.ap-northeast-2.elasticbeanstalk.com"

private val RELEASE_URL =
"http://fairer-env.eba-w7ubjjfy.ap-northeast-2.elasticbeanstalk.com"
private val BASE_URL: String = if(BuildConfig.DEBUG) DEBUG_URL else RELEASE_URL
private lateinit var RELEASE_URL: String
private val BASE_URL: String by lazy {
if (BuildConfig.DEBUG) DEBUG_URL else RELEASE_URL
}

private val networkInterceptor: Interceptor = Interceptor { chain ->
val request = chain.request()
Expand Down Expand Up @@ -76,7 +77,11 @@ class NetworkModule {

@Singleton
@Provides
fun provideRetrofit(okHttpClientBuilder: OkHttpClient.Builder): Retrofit {
fun provideRetrofit(okHttpClientBuilder: OkHttpClient.Builder, remoteConfigWrapper: RemoteConfigWrapper): Retrofit {
RELEASE_URL = remoteConfigWrapper.fetchAndActivateConfig()
Timber.d("RELEASE_URL = $RELEASE_URL")
Timber.d("BASE_URL = $BASE_URL")

val moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.depromeet.housekeeper.di

import com.depromeet.housekeeper.R
import com.depromeet.housekeeper.util.FIREBASE_SERVER_URL
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class RemoteConfigWrapper @Inject constructor() {
private val remoteConfig: FirebaseRemoteConfig by lazy{
FirebaseRemoteConfig.getInstance().apply {
val configSettings = FirebaseRemoteConfigSettings.Builder()
.build()
setConfigSettingsAsync(configSettings)
setDefaultsAsync(R.xml.remote_config_default) // 먼저 안전하게 default 가져옴(remote config 변경되면 xml 변경해주기를 요망)
}
}

fun fetchAndActivateConfig(): String {
remoteConfig.fetchAndActivate().addOnCompleteListener{ task ->
val updated = task.result
if (task.isSuccessful){
val updated = task.result
Timber.d("Config params updated success: $updated")
} else {
Timber.d("Config params updated failed: $updated")
}
}
return remoteConfig.getString(FIREBASE_SERVER_URL)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ class RuleFragment : BaseFragment<FragmentRuleBinding>(R.layout.fragment_rule) {
}

listenEditorDoneAction {
if (it.length<=16){
viewModel.createRule(it)
hideKeyboard(requireContext(), this)
if (adapter.itemCount < 10) {
if (it.length <= 16) {
viewModel.createRule(it)
hideKeyboard(requireContext(), this)
}
}

}

setOnFocusChangeListener { view, hasFocus ->
Expand All @@ -146,4 +149,4 @@ class RuleFragment : BaseFragment<FragmentRuleBinding>(R.layout.fragment_rule) {
}

}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.depromeet.housekeeper.ui.main

import android.annotation.SuppressLint
import android.app.DatePickerDialog
import android.content.res.Resources
import android.graphics.Canvas
Expand Down Expand Up @@ -48,6 +49,7 @@ import com.depromeet.housekeeper.util.NavigationUtil.navigateSafe
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -127,6 +129,7 @@ class MainFragment : BaseFragment<FragmentMainBinding>(R.layout.fragment_main) {
}
}

@SuppressLint("ClickableViewAccessibility")
private fun setAdapter() {
feedbackAdapter = FeedbackAdapter(emptyList<FeedbackFindOneResponseDto>().toMutableList())
dayOfAdapter = DayOfWeekAdapter(DateUtil.getCurrentWeek(),
Expand Down Expand Up @@ -214,6 +217,7 @@ class MainFragment : BaseFragment<FragmentMainBinding>(R.layout.fragment_main) {
binding.rvGroups.adapter = groupProfileAdapter
}

@SuppressLint("ClickableViewAccessibility")
private fun bindingVm() {
lifecycleScope.launchWhenStarted {
mainViewModel.completeChoreNum.collect {
Expand Down Expand Up @@ -323,14 +327,30 @@ class MainFragment : BaseFragment<FragmentMainBinding>(R.layout.fragment_main) {
}

lifecycleScope.launchWhenResumed {
mainViewModel.rule.collect {
binding.lvRule.rule = it
mainViewModel.rule.collectLatest { rules ->
var index = 0
while (true) {
val rule = rules.getOrNull(index)
if (rule != null) {
binding.lvRule.rule = rule.ruleName
index = (index + 1) % rules.size
}
delay(5000) // 5초 대기
}
}
}

lifecycleScope.launchWhenResumed {
mainViewModel.selectUserId.collect {
mainViewModel.getHouseWorks()
if (it == PrefsManager.memberId) {
houseWorkAdapter?.updateIsMe(true)
Timber.d("memberId!")
} else {
houseWorkAdapter?.updateIsMe(false)
Timber.d("No My memberId!")
}

}
}

Expand Down Expand Up @@ -689,4 +709,4 @@ class MainFragment : BaseFragment<FragmentMainBinding>(R.layout.fragment_main) {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.depromeet.housekeeper.model.request.UrgeModel
import com.depromeet.housekeeper.model.response.FeedbackListModel
import com.depromeet.housekeeper.model.response.HouseWork
import com.depromeet.housekeeper.model.response.HouseWorks
import com.depromeet.housekeeper.model.response.RuleResponse
import com.depromeet.housekeeper.util.DATE_UTIL_TAG
import com.depromeet.housekeeper.util.DateUtil.dateFormat
import com.depromeet.housekeeper.util.DateUtil.fullDateFormat
Expand Down Expand Up @@ -94,8 +95,8 @@ class MainViewModel @Inject constructor(
val selectUserId: StateFlow<Int>
get() = _selectUserId

private val _rule: MutableStateFlow<String> = MutableStateFlow("")
val rule: StateFlow<String>
private val _rule: MutableStateFlow<List<RuleResponse>> = MutableStateFlow(listOf())
val rule: StateFlow<List<RuleResponse>>
get() = _rule

private val _groupName: MutableStateFlow<String> = MutableStateFlow("")
Expand Down Expand Up @@ -318,8 +319,8 @@ class MainViewModel @Inject constructor(
val result = receiveApiResult(it)
if (result != null) {
_rule.value = when {
result.ruleResponseDtos.isNotEmpty() -> result.ruleResponseDtos.random().ruleName
else -> ""
result.ruleResponseDtos.isNotEmpty() -> result.ruleResponseDtos
else -> listOf()
}
}
}
Expand Down Expand Up @@ -420,4 +421,4 @@ class MainViewModel @Inject constructor(
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.depromeet.housekeeper.ui.main.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -20,6 +21,7 @@ class HouseWorkAdapter(
private val feedbackClick: (Int?) -> Unit
) : RecyclerView.Adapter<HouseWorkAdapter.ItemViewHolder>() {
private var doneHouseWorks: MutableList<HouseWork> = mutableListOf()
var isMe : Boolean = true


private fun getTime(houseWork: HouseWork): String {
Expand All @@ -33,6 +35,7 @@ class HouseWorkAdapter(
} ?: return "하루 종일"
}

@SuppressLint("NotifyDataSetChanged")
fun updateDate(remainHouseWork: MutableList<HouseWork>, doneHouseWork: MutableList<HouseWork>) {
list.clear()
list.addAll(remainHouseWork)
Expand Down Expand Up @@ -109,6 +112,7 @@ class HouseWorkAdapter(
}

binding.flHouseWork.setOnClickListener {
if(isMe)
onClick.invoke(houseWork)
}

Expand Down Expand Up @@ -148,4 +152,8 @@ class HouseWorkAdapter(
val totalFeedbackNum = feedbackHouseworkResponse.values.sumOf { it.feedbackNum }
return totalFeedbackNum == 0
}
}

fun updateIsMe(value : Boolean){
isMe = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SettingProfileViewModel @Inject constructor(
/**
* Network Communication
*/
fun getMe() {
private fun getMe() {
viewModelScope.launch {
userRepository.getMe().collectLatest {
val result = receiveApiResult(it)
Expand Down Expand Up @@ -80,4 +80,4 @@ class SettingProfileViewModel @Inject constructor(
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.depromeet.housekeeper.ui.signIn
import androidx.lifecycle.viewModelScope
import com.depromeet.housekeeper.base.BaseViewModel
import com.depromeet.housekeeper.data.repository.UserRepository
import com.depromeet.housekeeper.model.enums.ProfileViewType
import com.depromeet.housekeeper.model.request.UpdateMember
import com.depromeet.housekeeper.model.response.UpdateMemberResponse
import com.depromeet.housekeeper.model.enums.ProfileViewType
import com.depromeet.housekeeper.util.PrefsManager
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -52,6 +52,10 @@ class SignProfileViewModel @Inject constructor(

fun setViewType(viewType: ProfileViewType) {
_viewType.value = viewType
Timber.d("viewType : $viewType")
if (viewType == ProfileViewType.Modify) {
getMe()
}
}

fun setSelectedImage(imgUrl: String) {
Expand Down Expand Up @@ -97,6 +101,16 @@ class SignProfileViewModel @Inject constructor(
}
}

private fun getMe() {
viewModelScope.launch {
userRepository.getMe().collectLatest {
val result = receiveApiResult(it)
if (result != null) {
_selectedImage.value = result.profilePath
}
}
}
}

data class ProfileState(
val url: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const val NETWORK_ERROR = 1001
const val FILTER_INTERNET_CONNECTED = "FILTER_INTERNET_CONNECTED"
const val IS_INTERNET_CONNECTED = "IS_INTERNET_CONNECTED"

/**
* REMOTE CONFIG KEY
*/
const val FIREBASE_SERVER_URL = "server_url"

/**
* NAVIGATION KEY
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.depromeet.housekeeper.R
import com.depromeet.housekeeper.ui.main.adapter.HouseWorkAdapter

class SwipeHelperCallback(private val recyclerViewAdapter: HouseWorkAdapter) :
ItemTouchHelper.Callback() {
Callback() {

// swipe_view 를 swipe 했을 때 <삭제> 화면이 보이도록 고정하기 위한 변수들
private var currentPosition: Int? = null // 현재 선택된 recycler view의 position
Expand All @@ -25,7 +25,9 @@ class SwipeHelperCallback(private val recyclerViewAdapter: HouseWorkAdapter) :
// 드래그 방향 : 위, 아래 인식
// 스와이프 방향 : 왼쪽, 오른쪽 인식
// 설정 안 하고 싶으면 0
return makeMovementFlags(0, LEFT or RIGHT)
return if(recyclerViewAdapter.isMe)
makeMovementFlags(0, LEFT or RIGHT)
else 0
}

// 드래그 일어날 때 동작 (롱터치 후 드래그)
Expand Down Expand Up @@ -164,4 +166,4 @@ class SwipeHelperCallback(private val recyclerViewAdapter: HouseWorkAdapter) :

}

}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/bottom_sheet_edit_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:orientation="vertical">

Expand Down
Loading

0 comments on commit c84d87a

Please sign in to comment.