Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/#111
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoncheong authored Aug 31, 2023
2 parents aed8c3b + 3693ce0 commit 50f4d88
Show file tree
Hide file tree
Showing 29 changed files with 365 additions and 64 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
android:name=".presentation.setting.DeleteAccountActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".presentation.home.EndingActivity"
android:exported="false"
android:screenOrientation="portrait" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun initView() {
setLoadingView()
setLoadingView(true)
val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_main)
if (currentFragment == null) {
changeFragment(HomeFragment())
Expand All @@ -48,17 +48,22 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun setBottomNav() {
binding.bnvMain.run() {
binding.bnvMain.run {
setOnItemSelectedListener {
changeFragment(
when (it.itemId) {
R.id.menu_home -> {
setLoadingView()
setLoadingView(true)
HomeFragment()
}

R.id.menu_setting -> SettingFragment()
else -> ListFragment()
R.id.menu_setting -> {
setLoadingView(false)
SettingFragment()
}
else -> {
setLoadingView(false)
ListFragment()
}
}
)
true
Expand All @@ -72,8 +77,12 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
.commit()
}

private fun setLoadingView() {
binding.clLoading.visibility = View.VISIBLE
private fun setLoadingView(boolean: Boolean) {
if (boolean) {
binding.clLoading.visibility = View.VISIBLE
} else {
binding.clLoading.visibility = View.GONE
}
}

fun getLoadingView(): View = binding.clLoading
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.sopt.umbba_android.presentation.home

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityEndingBinding
import com.sopt.umbba_android.presentation.setting.ManageAccountActivity
import com.sopt.umbba_android.util.binding.BindingActivity

class EndingActivity : BindingActivity<ActivityEndingBinding>(R.layout.activity_ending) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setBtnClickListener()
}

private fun setBtnClickListener() {
with(binding) {
ivClose.setOnClickListener {
setResult(RESULT_OK)
finish()
}
btnSurvey.setOnClickListener {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse(getString(R.string.ending_survey_uri))
)
)
}
btnDeleteAccount.setOnClickListener {
startActivity(Intent(this@EndingActivity, ManageAccountActivity::class.java))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.sopt.umbba_android.presentation.home

import android.app.Activity.RESULT_OK
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.viewModels
import coil.load
import com.sopt.umbba_android.R
Expand All @@ -20,15 +24,23 @@ import com.sopt.umbba_android.util.setOnSingleClickListener

class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home) {
private val viewModel: HomeViewModel by viewModels { ViewModelFactory(requireActivity()) }

private val startForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK) {
viewModel.setStateCloseEnding()
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.vm = viewModel
observeData()
}


private fun setClickEvent(responseCaseDto: HomeCaseResponseDto.HomeCaseData) {
binding.btnAnswer.setOnSingleClickListener {
viewModel.getResponseCase()
when (responseCaseDto.responseCase) {
1 -> startActivity(Intent(requireActivity(), QuestionAnswerActivity::class.java))
2 -> showInviteDialog(
Expand All @@ -44,6 +56,10 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
private fun observeData() {
viewModel.homeData.observe(viewLifecycleOwner) {
setBackground(it.section)
if (it.index == 8 && viewModel.isShowedEndingPage()) {
viewModel.setStateObserveIndex()
startForResult.launch(Intent(requireActivity(), EndingActivity::class.java))
}
}
viewModel.responseCaseData.observe(viewLifecycleOwner) {
setClickEvent(it)
Expand Down Expand Up @@ -83,6 +99,9 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home

override fun onResume() {
super.onResume()
if (viewModel.isObserveIndex.value == false) {
viewModel.getHomeData()
}
viewModel.getResponseCase()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,30 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo

private var _responseCaseData = MutableLiveData<HomeCaseResponseDto.HomeCaseData>()
val responseCaseData: LiveData<HomeCaseResponseDto.HomeCaseData> = _responseCaseData

private var _homeData = MutableLiveData<HomeResponseDto.HomeData>()
val homeData: LiveData<HomeResponseDto.HomeData> = _homeData

private var _isCloseEnding = MutableLiveData(false)
val isCloseEnding: LiveData<Boolean> = _isCloseEnding

private var _isObserveIndex = MutableLiveData(false)
val isObserveIndex: LiveData<Boolean> = _isObserveIndex

private var _topicTitle = MutableLiveData<String>()
val topicTitle: LiveData<String> = _topicTitle

private fun getHomeData() {
fun getHomeData() {
viewModelScope.launch {
homeRepositoryImpl.getHomeData()
.onSuccess { response ->
Timber.d("getHomeData 성공")
_homeData.value = response.data
_topicTitle.value = "#${response.data.index} ${response.data.topic}"
_topicTitle.value = if (response.data.index != 8) {
"#${response.data.index} ${response.data.topic}"
} else {
"#${(response.data.index) - 1} ${response.data.topic}"
}
}.onFailure { error ->
Timber.e("getHomeData 실패 " + error.message)
}
Expand All @@ -48,4 +59,16 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo
}
}
}

fun setStateCloseEnding() {
_isCloseEnding.value = true
}

fun setStateObserveIndex() {
_isObserveIndex.value = true
}

fun isShowedEndingPage(): Boolean {
return (_isCloseEnding.value == false && _isObserveIndex.value == false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ class AnswerActivity : BindingActivity<ActivityAnswerBinding>(R.layout.activity_
binding.clickListener = this
binding.vm = viewModel
setIntentResponse()
setClickBtnSave()
}

override fun onClick(view: View?) {
when (view?.id) {
R.id.iv_qna_back -> showBackDialog()
R.id.iv_check -> {
setCheckStatus()
}
}
}

private fun setCheckStatus() {
if (!viewModel.answer.value.isNullOrBlank()) {
showConfirmDialog()
private fun setClickBtnSave() {
with(binding) {
viewModel.answer.observe(this@AnswerActivity) {
btnSave.isEnabled = !it.isNullOrBlank()
}
btnSave.setOnClickListener {
showConfirmDialog()
}
}
}

Expand Down
Binary file added app/src/main/res/drawable/bg_ending.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions app/src/main/res/drawable/bg_ending_gradient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="rectangle">
<solid
android:color="@color/umbba_white"/>
</shape>
</item>
<item
android:height="208dp">
<shape
android:shape="rectangle">
<gradient
android:type="linear"
android:angle="270"
android:startColor="@color/ending_gradient_start" />
</shape>
</item>
</layer-list>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/shape_g800_dot_stroke_rect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/grey_800"
android:dashGap="5dp"
android:dashWidth="5dp"/>
</shape>
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_agree_privacy_use.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/app_description"
android:textAppearance="@style/AndroidBody2_2Regular12"
android:textColor="@color/primary_500"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
21 changes: 17 additions & 4 deletions app/src/main/res/layout/activity_answer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:titleText ="@{vm.section}"
app:visibleCheck="@{true}" />
app:titleText="@{vm.section}" />

<TextView
android:id="@+id/tv_topic"
Expand All @@ -55,8 +54,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="19dp"
android:text="@{vm.question}"
android:gravity="center"
android:text="@{vm.question}"
android:textColor="@color/umbba_black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -92,8 +91,8 @@
android:layout_height="wrap_content"
android:gravity="left"
android:hint="@string/answer_edittext_hint"
android:minHeight="172dp"
android:maxLength="100"
android:minHeight="172dp"
android:text="@={vm.answer}"
android:textAppearance="@style/AndroidBody1_2Regular16"
android:textColorHint="@color/grey_800"
Expand All @@ -104,5 +103,19 @@

</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_save"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="24dp"
android:background="@drawable/sel_btn_next"
android:enabled="false"
android:stateListAnimator="@null"
android:text="저장하기"
android:textAppearance="@style/AndroidBody1_1SemiBold16"
android:textColor="@color/umbba_white"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_communication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_start"
style="@style/AndroidBody3Bold16"
style="@style/AndroidBody1_1SemiBold16"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="24dp"
android:background="@drawable/shape_gradient_btn_r50_rect"
android:background="@drawable/shape_pri500_btn_stroke_r50_rect"
android:enabled="true"
android:stateListAnimator="@null"
android:text="@string/answer_phone"
android:textColor="@color/umbba_white"
android:textColor="@color/primary_500"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Loading

0 comments on commit 50f4d88

Please sign in to comment.