Skip to content

Commit

Permalink
Merge pull request #129 from depromeet/feature/#124-view-collision
Browse files Browse the repository at this point in the history
[FEAT/#124] 대화 주제 사용성 개선
  • Loading branch information
unam98 authored Feb 1, 2024
2 parents ddd35f7 + 6c84779 commit 74f2e37
Show file tree
Hide file tree
Showing 19 changed files with 541 additions and 293 deletions.
13 changes: 6 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"
<uses-permission
android:name="android.permission.POST_NOTIFICATIONS"
android:minSdkVersion="33" />

<application
Expand All @@ -26,6 +27,9 @@
android:theme="@style/Theme.TeumTeum"
android:usesCleartextTraffic="true"
tools:targetApi="tiramisu">
<activity
android:name=".presentation.shaketopic.ShakeTopicActivity"
android:exported="false" />
<service
android:name=".config.TeumMessagingService"
android:enabled="true"
Expand All @@ -34,15 +38,10 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<activity
android:name=".presentation.familiar.FamiliarDialogActivity"
android:exported="false" />
<activity
android:name=".presentation.familiar.topic.TopicActivity"
android:exported="false" />
<activity
android:name=".presentation.familiar.shake.ShakeActivity"
android:exported="false" />
<activity
android:name=".presentation.MainActivity"
android:exported="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ package com.teumteum.teumteum.presentation.familiar
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import com.teumteum.base.BindingActivity
import com.teumteum.domain.entity.Friend
import com.teumteum.teumteum.R
import com.teumteum.teumteum.databinding.ActivityFamiliarDialogBinding
import com.teumteum.teumteum.presentation.MainActivity
import com.teumteum.teumteum.presentation.familiar.introduce.IntroduceActivity
import com.teumteum.teumteum.presentation.familiar.introduce.IntroduceActivity.Companion.EXTRA_FRIENDS
import com.teumteum.teumteum.presentation.familiar.neighbor.NeighborViewModel
import com.teumteum.teumteum.presentation.familiar.shake.ShakeActivity
import com.teumteum.teumteum.presentation.shaketopic.ShakeTopicActivity
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable

Expand Down Expand Up @@ -79,7 +76,7 @@ class FamiliarDialogActivity :
private fun startActivity() {
when (source) {
SOURCE_INTRODUCE -> {
val intent = Intent(this, ShakeActivity::class.java).apply {
val intent = Intent(this, ShakeTopicActivity::class.java).apply {
putExtra(EXTRA_FRIENDS, friends as Serializable)
}
startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.teumteum.teumteum.presentation.familiar.FamiliarDialogActivity
import com.teumteum.teumteum.presentation.familiar.FamiliarDialogActivity.Companion.EXTRA_SOURCE
import com.teumteum.teumteum.presentation.familiar.FamiliarDialogActivity.Companion.SOURCE_INTRODUCE
import com.teumteum.teumteum.presentation.familiar.neighbor.NeighborActivity.Companion.EXTRA_NEIGHBORS_IDS
import com.teumteum.teumteum.presentation.familiar.shake.ShakeActivity
import dagger.hilt.android.AndroidEntryPoint
import java.io.Serializable

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.teumteum.teumteum.presentation.shaketopic

import android.os.Bundle
import androidx.activity.viewModels
import androidx.fragment.app.commit
import com.teumteum.base.BindingActivity
import com.teumteum.domain.entity.Friend
import com.teumteum.teumteum.R
import com.teumteum.teumteum.databinding.ActivityShakeTopicBinding
import com.teumteum.teumteum.presentation.familiar.introduce.IntroduceActivity.Companion.EXTRA_FRIENDS
import com.teumteum.teumteum.presentation.shaketopic.shake.ShakeFragment
import com.teumteum.teumteum.presentation.shaketopic.topic.TopicFragment
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber

@AndroidEntryPoint
class ShakeTopicActivity :
BindingActivity<ActivityShakeTopicBinding>(R.layout.activity_shake_topic) {

private val viewModel by viewModels<ShakeTopicViewModel>()
private var isShakeCompleted = false
private var isApiDataReceived = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initView()
passDataToViewModel()
setUpObserver()
}

private fun initView() {
val initialFragment = ShakeFragment()
supportFragmentManager.commit {
add(R.id.fl_main, initialFragment)
}
}

private fun setUpObserver() {
viewModel.topics.observe(this) { topics ->
if (topics.size >= 2 && !isApiDataReceived) {
onApiDataReceived()
}
}
}
fun onShakeCompleted() {
Timber.d("흔들기 3초 완료")
isShakeCompleted = true
checkAndShowTopicFragment()
}

fun onApiDataReceived() {
Timber.d("데이터 최소 2개 수신 완료")
isApiDataReceived = true
checkAndShowTopicFragment()
}

private fun checkAndShowTopicFragment() {
Timber.d("조건 2개 충족 완료 페이지 이동 실행")
if (isShakeCompleted && isApiDataReceived) {
showTopicFragment()
}
}

private fun showTopicFragment() {
val topicFragment = TopicFragment()
supportFragmentManager.commit {
replace(R.id.fl_main, topicFragment)
addToBackStack(null)
}
}

private fun passDataToViewModel() {
val friends = intent.getSerializableExtra(EXTRA_FRIENDS) as? List<Friend>
viewModel.setFriendsData(friends ?: listOf())
}

companion object {}
}
Loading

0 comments on commit 74f2e37

Please sign in to comment.