Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
ny2060 committed Apr 23, 2023
2 parents dcd77a1 + 01e8471 commit 9b2d02c
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId "org.sopt.havit"
minSdk 23
targetSdk 31
versionCode 103
versionName "1.0.3"
versionCode 104
versionName "1.0.4"
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
28 changes: 28 additions & 0 deletions app/src/main/java/org/sopt/havit/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import com.google.android.material.bottomnavigation.BottomNavigationView
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.havit.databinding.ActivityMainBinding
import org.sopt.havit.ui.save.SaveFragment
import org.sopt.havit.util.GoogleAnalyticsUtil
import org.sopt.havit.util.GoogleAnalyticsUtil.GNB_ADD_CONTENT
import org.sopt.havit.util.GoogleAnalyticsUtil.GNB_CATEGORY
import org.sopt.havit.util.GoogleAnalyticsUtil.GNB_HOME
import org.sopt.havit.util.GoogleAnalyticsUtil.GNB_MYPAGE

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
private lateinit var navHostFragment: NavHostFragment
private lateinit var binding: ActivityMainBinding
private lateinit var navController: NavController
private lateinit var navView: BottomNavigationView
private var isInitialized: Boolean = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -32,13 +38,35 @@ class MainActivity : AppCompatActivity() {
navHostFragment =
supportFragmentManager.findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment
navController = navHostFragment.navController
// 바텀네비게이션 클릭 시 ga 이벤트 보냄
navController.addOnDestinationChangedListener { _, destination, _ ->
when (destination.id) {
R.id.navigation_home -> {
// 처음 홈 화면 진입 시는 클릭해서 진입한게 아니므로 이벤트 보내지 않음
if (isInitialized) {
GoogleAnalyticsUtil.logClickEvent(GNB_HOME)
} else {
isInitialized = true
}
}
R.id.navigation_category -> {
GoogleAnalyticsUtil.logClickEvent(GNB_CATEGORY)
}
R.id.navigation_my_page -> {
GoogleAnalyticsUtil.logClickEvent(GNB_MYPAGE)
}
else -> {}
}
}
navView.setupWithNavController(navController)
binding.navView.background = null
}

private fun setListeners() {
binding.floatingSave.bringToFront()
binding.floatingSave.setOnClickListener {
// 콘텐츠 추가 플로팅 버튼 클릭 시
GoogleAnalyticsUtil.logClickEvent(GNB_ADD_CONTENT)
SaveFragment("").show(supportFragmentManager, "save")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ class ContentsActivity : BaseBindingActivity<ActivityContentsBinding>(R.layout.a
contentsViewModel.setIsSeen(contentsAdapter.currentList[position].id)
currentHavitView = v
currentHavitPosition = position
GoogleAnalyticsUtil.logClickEventWithContentCheck(
GoogleAnalyticsUtil.CLICK_CONTENT_CHECK,
!(contentsAdapter.currentList[position].isSeen)
)
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.sopt.havit.data.remote.ContentsMoreData
import org.sopt.havit.domain.entity.Contents
import org.sopt.havit.domain.entity.NetworkState
import org.sopt.havit.domain.repository.ContentsRepository
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/sopt/havit/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ import org.sopt.havit.ui.web.WebActivity
import org.sopt.havit.util.PopupSharedPreference
import org.sopt.havit.util.setDragSensitivity
import org.sopt.havit.util.setOnSingleClickListener
import org.sopt.havit.util.GoogleAnalyticsUtil
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_MUST_SEE_CONTENT
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_SEARCH_CONTENT
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_WHOLE_CATEGORY
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_HAVIT_SERVICE_GUIDE
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_SEE_MORE
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_RECOMMENDED_SITE

@AndroidEntryPoint
class HomeFragment : BaseBindingFragment<FragmentHomeBinding>(R.layout.fragment_home) {
Expand Down Expand Up @@ -92,6 +99,8 @@ class HomeFragment : BaseBindingFragment<FragmentHomeBinding>(R.layout.fragment_
recommendRvAdapter.setItemClickListener(object :
HomeRecommendRvAdapter.OnItemClickListener {
override fun onWebClick(v: View, position: Int) {
GoogleAnalyticsUtil.logClickEventWithRecommendedSiteNum(CLICK_RECOMMENDED_SITE, position)

val intent = Intent(v.context, WebActivity::class.java)
homeViewModel.recommendList.value?.get(position)
?.let {
Expand Down Expand Up @@ -229,24 +238,29 @@ class HomeFragment : BaseBindingFragment<FragmentHomeBinding>(R.layout.fragment_
startActivity(intent)
}
binding.clReachContents.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_MUST_SEE_CONTENT)
val intent = Intent(requireActivity(), ContentsSimpleActivity::class.java)
intent.putExtra(CONTENT_TYPE, "unseen")
startActivity(intent)
}
binding.layoutCategory.tvCategoryAll.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_WHOLE_CATEGORY)
val intent = Intent(requireActivity(), HomeCategoryAllActivity::class.java)
startActivity((intent))
}
binding.clSearchClickable.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_SEARCH_CONTENT)
val intent = Intent(requireActivity(), SearchActivity::class.java)
startActivity(intent)
}
binding.tvMoreContents.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_SEE_MORE)
val intent = Intent(requireActivity(), ContentsSimpleActivity::class.java)
intent.putExtra(CONTENT_TYPE, "recent")
startActivity(intent)
}
binding.ivServiceGuide.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_HAVIT_SERVICE_GUIDE)
val intent = Intent(requireActivity(), ServiceGuideActivity::class.java)
startActivity(intent)
}
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/org/sopt/havit/ui/mypage/MyPageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import org.sopt.havit.databinding.FragmentMyPageBinding
import org.sopt.havit.ui.base.BaseBindingFragment
import org.sopt.havit.ui.contents.ContentsActivity
import org.sopt.havit.ui.setting.SettingActivity
import org.sopt.havit.util.GoogleAnalyticsUtil
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_CHECKED_CONTENT
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_MY_CATEGORY
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_MY_CONTENT

@AndroidEntryPoint
class MyPageFragment : BaseBindingFragment<FragmentMyPageBinding>(R.layout.fragment_my_page) {
Expand Down Expand Up @@ -42,6 +46,7 @@ class MyPageFragment : BaseBindingFragment<FragmentMyPageBinding>(R.layout.fragm

private fun setListeners() {
binding.clCategoryNum.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_MY_CATEGORY)
startActivity(
Intent(
requireContext(),
Expand All @@ -50,6 +55,7 @@ class MyPageFragment : BaseBindingFragment<FragmentMyPageBinding>(R.layout.fragm
)
}
binding.clSavedContents.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_MY_CONTENT)
startActivity(
Intent(requireContext(), ContentsActivity::class.java).apply {
putExtra("categoryId", ALL_CONTENTS_ID)
Expand All @@ -58,6 +64,7 @@ class MyPageFragment : BaseBindingFragment<FragmentMyPageBinding>(R.layout.fragm
)
}
binding.clSeenContents.setOnClickListener {
GoogleAnalyticsUtil.logClickEvent(CLICK_CHECKED_CONTENT)
startActivity(
Intent(requireContext(), ContentsActivity::class.java).apply {
putExtra("categoryId", SEEN_CONTENTS_ID)
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/sopt/havit/ui/search/SearchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.sopt.havit.ui.base.BaseBindingActivity
import org.sopt.havit.ui.contents.more.ContentsMoreFragment
import org.sopt.havit.ui.web.WebActivity
import org.sopt.havit.util.DialogUtil
import org.sopt.havit.util.GoogleAnalyticsUtil
import org.sopt.havit.util.KeyBoardUtil
import java.io.Serializable

Expand Down Expand Up @@ -118,6 +119,10 @@ class SearchActivity : BaseBindingActivity<ActivitySearchBinding>(R.layout.activ
) {
searchContentsAdapter.searchContents[pos].isSeen = !(data.isSeen)
searchViewModel.setIsSeen(data.id)
GoogleAnalyticsUtil.logClickEventWithContentCheck(
GoogleAnalyticsUtil.CLICK_CONTENT_CHECK,
data.isSeen
)
if (v.tag == "seen") {
Glide.with(v.context)
.load(R.drawable.ic_contents_unread)
Expand Down
21 changes: 12 additions & 9 deletions app/src/main/java/org/sopt/havit/ui/search/SearchViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.sopt.havit.domain.entity.Contents
import org.sopt.havit.domain.entity.NetworkState
import org.sopt.havit.domain.repository.ContentsRepository
import org.sopt.havit.domain.usecase.SearchUseCase
import org.sopt.havit.util.GoogleAnalyticsUtil
import javax.inject.Inject

@HiltViewModel
Expand All @@ -23,21 +24,19 @@ class SearchViewModel @Inject constructor(
private val _searchResult = MutableLiveData<List<Contents>>()
var searchResult: LiveData<List<Contents>> = _searchResult

var searchResultSize = MutableLiveData(0)

private var _searchReload = MutableLiveData<Boolean>(false)
private var _searchReload = MutableLiveData(false)
var searchReload: LiveData<Boolean> = _searchReload

fun setReload() {
_searchReload.value = !(_searchReload.value)!!
}

var searchTv = MutableLiveData(false)
private var isSeenCheck = MutableLiveData(false)

private var _isRead = MutableLiveData<Boolean>()
var isRead: LiveData<Boolean> = _isRead

var isServerNetwork = MutableLiveData<NetworkState>()

fun getSearchContents(keyWord: String) {
viewModelScope.launch {
searchUseCase.getSearchContents(keyWord).collect {
Expand All @@ -59,10 +58,14 @@ class SearchViewModel @Inject constructor(

fun setIsSeen(contentsId: Int) {
viewModelScope.launch(Dispatchers.IO) {
try {
val response = contentsRepository.isSeen(contentsId)
isSeenCheck.postValue(response.success)
} catch (e: Exception) {
kotlin.runCatching {
contentsRepository.isSeen(contentsId)

}.onSuccess {
isServerNetwork.postValue(NetworkState.SUCCESS)
isSeenCheck.postValue(it.success)
}.onFailure {
isServerNetwork.postValue(NetworkState.FAIL)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import org.sopt.havit.ui.base.BaseBindingFragment
import org.sopt.havit.ui.category.CategoryAddActivity
import org.sopt.havit.ui.share.AddCategoryViewModel
import org.sopt.havit.ui.share.add_category.IconAdapter.Companion.clickedPosition
import org.sopt.havit.util.ADD_CATEGORY_TYPE
import org.sopt.havit.util.ToastUtil
import org.sopt.havit.util.setOnSingleClickListener
import org.sopt.havit.util.setOnSinglePostClickListener
import org.sopt.havit.util.*
import org.sopt.havit.util.GoogleAnalyticsUtil.SELECT_ICON

@AndroidEntryPoint
class ChooseIconFragment :
Expand All @@ -35,6 +33,7 @@ class ChooseIconFragment :
initNetworkErrorViewClickListener()
toolbarClickListener()
observeNetworkStatus()
setScreenEventLogging()
}

private fun toolbarClickListener() {
Expand Down Expand Up @@ -66,9 +65,16 @@ class ChooseIconFragment :
private fun initNormalViewClickNext() {
binding.btnNext.setOnSinglePostClickListener {
viewModel.addCategory()
setClickEventLogging()
}
}

private fun setClickEventLogging() {
val iconIdx = requireNotNull(viewModel.selectedIconPosition.value)
GoogleAnalyticsUtil.logClickEventOnAddCategory(iconNum = iconIdx)
}


private fun observeNetworkStatus() {
viewModel.addCategoryViewState.observe(viewLifecycleOwner) {
when (it) {
Expand All @@ -95,4 +101,8 @@ class ChooseIconFragment :
categoryName = viewModel.categoryTitle.value ?: throw IllegalStateException()
)
}

private fun setScreenEventLogging() {
GoogleAnalyticsUtil.logScreenEvent(SELECT_ICON)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.sopt.havit.databinding.FragmentEnterCategoryTitleBinding
import org.sopt.havit.domain.model.NetworkStatus
import org.sopt.havit.ui.base.BaseBindingFragment
import org.sopt.havit.ui.share.AddCategoryViewModel
import org.sopt.havit.util.GoogleAnalyticsUtil
import org.sopt.havit.util.GoogleAnalyticsUtil.ADD_CATEGORY
import org.sopt.havit.util.KeyBoardUtil
import org.sopt.havit.util.KeyBoardUtil.setUpAsSoftKeyboard
import org.sopt.havit.util.setOnSingleClickListener
Expand All @@ -34,6 +36,7 @@ class EnterCategoryTitleFragment :
setKeyBoardState()
toolbarClickListener()
setUpAsSoftKeyboard(view) // 다음버튼 위/아래 움직이게
setScreenEventLogging()
}

private fun getExistingCategoryList() {
Expand Down Expand Up @@ -87,4 +90,8 @@ class EnterCategoryTitleFragment :
KeyBoardUtil.openKeyBoard(requireContext(), binding.etCategoryTitle)
else KeyBoardUtil.hideKeyBoard(requireActivity())
}

private fun setScreenEventLogging() {
GoogleAnalyticsUtil.logScreenEvent(ADD_CATEGORY)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.sopt.havit.domain.model.NetworkStatus
import org.sopt.havit.ui.base.BaseBindingFragment
import org.sopt.havit.ui.share.ShareViewModel
import org.sopt.havit.util.*
import org.sopt.havit.util.GoogleAnalyticsUtil.CLICK_COMPLETE_SAVE_CONTENT
import org.sopt.havit.util.GoogleAnalyticsUtil.CONTENT_CUSTOM
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -30,6 +32,7 @@ class ContentsSummeryFragment :
initListener()
toolbarClickListener()
onClickRefreshButtonOnNetworkError()
setScreenEventLogging()
}

private fun initListener() {
Expand Down Expand Up @@ -74,6 +77,7 @@ class ContentsSummeryFragment :

private fun saveContents() {
viewModel.saveContents()
setClickEventLogging()
}

private fun toolbarClickListener() {
Expand All @@ -99,5 +103,13 @@ class ContentsSummeryFragment :
}
}

private fun setScreenEventLogging() {
GoogleAnalyticsUtil.logScreenEvent(CONTENT_CUSTOM)
}

private fun setClickEventLogging() {
GoogleAnalyticsUtil.logClickEvent(CLICK_COMPLETE_SAVE_CONTENT)
}

private fun setCustomToast() = ToastUtil(requireContext()).makeToast(ADD_CONTENT_TYPE)
}
Loading

0 comments on commit 9b2d02c

Please sign in to comment.