diff --git a/app/build.gradle b/app/build.gradle index e7598f61..ec1111c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -124,10 +124,11 @@ dependencies { // Kakaologin implementation 'com.kakao.sdk:v2-user:2.11.0' implementation 'com.kakao.sdk:v2-share:2.11.0' + implementation "com.kakao.sdk:v2-link:2.4.2" // EncryptedSharedPreferences implementation "androidx.security:security-crypto:1.0.0" // Splash - implementation 'androidx.core:core-splashscreen:1.0.0' + implementation "androidx.core:core-splashscreen:1.0.0" } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aedc739c..3ba685c1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,11 @@ + xmlns:tools="http://schemas.android.com/tools" + package="com.sopt.umbba_android"> + + + + @@ -79,6 +84,15 @@ android:name=".presentation.MainActivity" android:exported="true" android:screenOrientation="portrait"> + + + + + + + + , @SerialName("parentchild_relation") diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/home/HomeFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/home/HomeFragment.kt index 8d1bbb6c..8a05d1a9 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/home/HomeFragment.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/home/HomeFragment.kt @@ -1,18 +1,13 @@ package com.sopt.umbba_android.presentation.home -import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle import android.util.Log import android.view.View -import android.widget.Toast import androidx.fragment.app.viewModels import coil.load -import com.google.android.gms.tasks.OnCompleteListener -import com.google.firebase.messaging.FirebaseMessaging import com.sopt.umbba_android.R import com.sopt.umbba_android.data.model.response.HomeCaseResponseDto -import com.sopt.umbba_android.data.model.response.HomeResponseDto import com.sopt.umbba_android.databinding.FragmentHomeBinding import com.sopt.umbba_android.presentation.home.viewmodel.HomeViewModel import com.sopt.umbba_android.presentation.qna.NoOpponentDialogFragment @@ -29,9 +24,10 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } private fun setClickEvent(responseCaseDto: HomeCaseResponseDto.HomeCaseData) { binding.btnAnswer.setOnClickListener { + viewModel.getResponseCase() when (responseCaseDto.responseCase) { 1 -> startActivity(Intent(requireActivity(), QuestionAnswerActivity::class.java)) - 2 -> showInviteDialog(responseCaseDto.inviteCode.toString()) + 2 -> showInviteDialog(responseCaseDto.inviteUserName.toString(), responseCaseDto.inviteCode.toString()) 3 -> showNoOpponentDialog() } } @@ -46,8 +42,8 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } } - private fun showInviteDialog(inviteCode: String) { - InviteCodeDialogFragment(inviteCode).show( + private fun showInviteDialog(inviteUserName: String, inviteCode: String) { + InviteCodeDialogFragment(inviteUserName, inviteCode).show( requireActivity().supportFragmentManager, "InviteCodeDialogFragment" ) @@ -71,4 +67,9 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } ) } + + override fun onResume() { + super.onResume() + viewModel.getResponseCase() + } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/home/InviteCodeDialogFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/home/InviteCodeDialogFragment.kt index 83b4eb2c..85a11781 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/home/InviteCodeDialogFragment.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/home/InviteCodeDialogFragment.kt @@ -7,6 +7,7 @@ import android.content.Context.CLIPBOARD_SERVICE import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -14,10 +15,16 @@ import android.view.WindowManager import android.widget.Toast import androidx.core.content.ContextCompat.getSystemService import androidx.fragment.app.DialogFragment +import com.google.android.material.snackbar.Snackbar +import com.kakao.sdk.share.ShareClient +import com.kakao.sdk.template.model.Button +import com.kakao.sdk.template.model.Content +import com.kakao.sdk.template.model.FeedTemplate +import com.kakao.sdk.template.model.Link import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.FragmentInviteCodeDialogBinding -class InviteCodeDialogFragment(private val inviteCode: String) : DialogFragment() { +class InviteCodeDialogFragment(private val inviteUserName: String, private val inviteCode: String) : DialogFragment() { private var _binding: FragmentInviteCodeDialogBinding? = null private val binding get() = requireNotNull(_binding) { "InviteCodeDialogFragment is null" } @@ -36,6 +43,7 @@ class InviteCodeDialogFragment(private val inviteCode: String) : DialogFragment( closeDialog() setBackgroundDesign() setInviteCodeText(inviteCode) + sendInviteCodeWithKakao(inviteUserName, inviteCode) } private fun closeDialog() { @@ -62,6 +70,47 @@ class InviteCodeDialogFragment(private val inviteCode: String) : DialogFragment( } } + private fun sendInviteCodeWithKakao(inviteUserName: String, inviteCode: String) { + binding.btnSendInvitation.setOnClickListener { + val defaultFeed = FeedTemplate( + content = Content( + title = "${inviteUserName}으로부터 초대가 왔어요. \\n초대 코드 : $inviteCode", + description = "과거로 떠나 함께 추억을 나누고, \\n공감대를 형성해보세요.", + imageUrl = "https://github.com/Team-Umbba/Umbba-iOS/assets/75068759/64ba7265-9148-4f06-8235-de5f4030e92f", + link = Link( + webUrl = "https://developers.kakao.com", + mobileWebUrl = "https://developers.kakao.com" + ) + ), + buttons = listOf( + Button( + "초대 받기", + Link( + androidExecutionParams = mapOf("key1" to "value1", "key2" to "value2"), + iosExecutionParams = mapOf("key1" to "value1", "key2" to "value2") + ) + ) + ) + ) + + if (ShareClient.instance.isKakaoTalkSharingAvailable(requireContext())) { + ShareClient.instance.shareDefault(requireContext(), defaultFeed) { sharingResult, error -> + if (error != null) { + Log.e("yeonjin", "카카오톡 공유 실패", error) + } else if (sharingResult != null) { + Log.e("yeonjin", "카카오톡 공유 성공 ${sharingResult.intent}") + startActivity(sharingResult.intent) + + Log.w("yeonjin", "Warning Msg: ${sharingResult.warningMsg}") + Log.w("yeonjin", "Argument Msg: ${sharingResult.argumentMsg}") + } + } + } else { + Snackbar.make(binding.root, "카카오톡을 설치해주세요.", Snackbar.LENGTH_SHORT).show() + } + } + } + override fun onResume() { super.onResume() dialog?.window?.setLayout( diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/home/viewmodel/HomeViewModel.kt b/app/src/main/java/com/sopt/umbba_android/presentation/home/viewmodel/HomeViewModel.kt index c8c79869..561eca91 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/home/viewmodel/HomeViewModel.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/home/viewmodel/HomeViewModel.kt @@ -24,7 +24,7 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo private var _topicTitle = MutableLiveData() val topicTitle:LiveData = _topicTitle - private fun getHomeData() { + fun getHomeData() { viewModelScope.launch { homeRepositoryImpl.getHomeData() .onSuccess { response -> @@ -37,7 +37,7 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo } } - private fun getResponseCase() { + fun getResponseCase() { viewModelScope.launch { homeRepositoryImpl.getResponseCase() .onSuccess { response -> diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/login/LoginActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/login/LoginActivity.kt index 4dcb206c..5403a477 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/login/LoginActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/login/LoginActivity.kt @@ -90,7 +90,7 @@ class LoginActivity : BindingActivity(R.layout.activity_lo // 자동로그인 private fun setAutoLogin() { - //토큰이 저장되어 있다면 + //액세스 토큰이 저장되어 있다면 Log.e("yeonjin", "setAutoLogin") Log.e("yeonjin", "sharedPreference : ${SharedPreferences.getString(USER_TOKEN)}") if (!SharedPreferences.getString(USER_TOKEN).isNullOrBlank()) { @@ -99,7 +99,13 @@ class LoginActivity : BindingActivity(R.layout.activity_lo Log.e("yeonjin", "viewmodel gettokenresult") viewModel.getTokenResult.observe(this) { response -> setUserInfo(response.accessToken) - goAgreePrivacyUseActivity() + if (SharedPreferences.getOnboardingBoolean(DID_USER_CLEAR_ONBOARD) + && SharedPreferences.getInviteCodeBoolean(DID_USER_CLEAR_INVITE_CODE) + ) { + goMainActivity() + } else { + goAgreePrivacyUseActivity() + } } } } diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/splash/SplashActivity.kt b/app/src/main/java/com/sopt/umbba_android/presentation/splash/SplashActivity.kt index 6e3a69f0..db3656bd 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/splash/SplashActivity.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/splash/SplashActivity.kt @@ -40,7 +40,7 @@ class SplashActivity : BindingActivity(R.layout.activity_ private fun loadSplashScreen() { lifecycleScope.launch { - delay(1500L) + delay(1400L) goLoginActivity() } }