-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat : 설정화면 fcm 토큰 관련 api 연동 #216
Changes from all commits
0560640
4a0621b
be65584
906f9eb
acf78b9
ab2938b
9b6da55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.dongyang.android.youdongknowme.data.remote.entity | ||
|
||
data class UpdateDepartment( | ||
val token: String, | ||
val department: String, | ||
) | ||
|
||
data class RemoveToken( | ||
val token: String, | ||
) | ||
|
||
data class UpdateTopic( | ||
val token: String, | ||
val topics: List<String>, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.dongyang.android.youdongknowme.data.remote.service | ||
|
||
import com.dongyang.android.youdongknowme.data.remote.entity.RemoveToken | ||
import com.dongyang.android.youdongknowme.data.remote.entity.UpdateDepartment | ||
import com.dongyang.android.youdongknowme.data.remote.entity.UpdateTopic | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface SettingService { | ||
|
||
@POST("department/v1/dmu/updateDepartment") | ||
suspend fun updateDepartment(@Body data: UpdateDepartment) | ||
|
||
@POST("department/v1/dmu/deleteDepartment") | ||
suspend fun deleteDepartment(@Body token: RemoveToken) | ||
|
||
@POST("token/v1/dmu/updateTopic") | ||
suspend fun updateTopic(@Body data: UpdateTopic) | ||
|
||
@POST("token/v1/dmu/deleteTopic") | ||
suspend fun deleteTopic(@Body token: RemoveToken) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,9 +64,6 @@ class DepartActivity : BaseActivity<ActivityDepartBinding, DepartViewModel>(), D | |
private fun getDepart(items: ArrayList<String>) { | ||
return binding.btnDepartComplete.setOnClickListener { | ||
viewModel.setDepartment(items[viewModel.selectDepartPosition.value ?: 0]) | ||
val intent = Intent(this, MainActivity::class.java) | ||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | ||
startActivity(intent) | ||
finish() | ||
Comment on lines
66
to
67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 메인 화면으로 이동하는 부분은 일부러 지우신건가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 이 부분 사용해보셨는지 모르겠는데 불편하기도 하고, 학과가 바꼈는지 확인이 안 되기에 finish처리만 했습니다. |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package com.dongyang.android.youdongknowme.ui.view.keyword | ||
|
||
import android.content.Intent | ||
import androidx.lifecycle.Observer | ||
import com.dongyang.android.youdongknowme.R | ||
import com.dongyang.android.youdongknowme.data.local.entity.KeywordEntity | ||
import com.dongyang.android.youdongknowme.databinding.ActivityKeywordBinding | ||
import com.dongyang.android.youdongknowme.standard.base.BaseActivity | ||
import com.dongyang.android.youdongknowme.ui.view.permission.OnboardingPermissionActivity | ||
import com.google.android.material.chip.Chip | ||
import com.google.android.material.chip.ChipGroup | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
|
@@ -17,7 +15,7 @@ class KeywordActivity : BaseActivity<ActivityKeywordBinding, KeywordViewModel>() | |
override val viewModel: KeywordViewModel by viewModel() | ||
|
||
override fun initStartView() = Unit | ||
|
||
override fun initDataBinding() { | ||
// 효율을 위해 단 한번만 옵저빙하여 이미 구독중인 항목을 선택 처리 | ||
viewModel.localKeywordList.observe(this, object : Observer<List<KeywordEntity>> { | ||
|
@@ -40,14 +38,9 @@ class KeywordActivity : BaseActivity<ActivityKeywordBinding, KeywordViewModel>() | |
viewModel.checkFirstLaunch() | ||
viewModel.getLocalKeywordList() | ||
|
||
// TODO :: 안드로이드 데이터베이스에 유저별 설정한 키워드 저장 및 파이어베이스 키워드 구독 설정 | ||
binding.btnKeywordComplete.setOnClickListener { | ||
viewModel.subscribeCheckedKeyword() | ||
if (viewModel.isFirstLaunch.value == true) { | ||
viewModel.setFirstLaunch(false) | ||
val intent = Intent(this@KeywordActivity, OnboardingPermissionActivity::class.java) | ||
startActivity(intent) | ||
} | ||
Comment on lines
-46
to
-50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
setResult(RESULT_OK) | ||
finish() | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package com.dongyang.android.youdongknowme.ui.view.setting | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.activity.result.ActivityResultLauncher | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import com.dongyang.android.youdongknowme.R | ||
import com.dongyang.android.youdongknowme.databinding.FragmentSettingBinding | ||
import com.dongyang.android.youdongknowme.standard.base.BaseFragment | ||
|
@@ -16,13 +19,22 @@ class SettingFragment : BaseFragment<FragmentSettingBinding, SettingViewModel>() | |
override val layoutResourceId: Int = R.layout.fragment_setting | ||
override val viewModel: SettingViewModel by viewModel() | ||
|
||
private lateinit var resultLauncher: ActivityResultLauncher<Intent> | ||
private var topics: List<String> = emptyList() | ||
|
||
override fun initStartView() { | ||
binding.tvSettingAppVersion.text = getAppVersion() | ||
setResultKeyword() | ||
} | ||
Comment on lines
+24
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 첫 줄 함수 개행으로 컨벤션 확정인가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넴 고고 합시다 |
||
|
||
override fun initDataBinding() { | ||
viewModel.myDepartment.observe(viewLifecycleOwner) { department -> | ||
binding.tvSettingDepartment.text = department | ||
|
||
viewModel.myDepartment.observe(viewLifecycleOwner) { myDepartment -> | ||
binding.tvSettingDepartment.text = myDepartment | ||
} | ||
|
||
viewModel.myTopics.observe(viewLifecycleOwner) { myTopics -> | ||
topics = topics | ||
} | ||
|
||
viewModel.isAccessUniversityAlarm.observe(viewLifecycleOwner) { isChecked -> | ||
|
@@ -35,28 +47,30 @@ class SettingFragment : BaseFragment<FragmentSettingBinding, SettingViewModel>() | |
} | ||
|
||
override fun initAfterBinding() { | ||
|
||
viewModel.checkAccessAlarm() | ||
viewModel.getUserDepartment() | ||
viewModel.getUserTopic() | ||
|
||
binding.switchSettingUniversityAlarm.setOnCheckedChangeListener { compoundButton, _ -> | ||
if (compoundButton.isChecked) { | ||
viewModel.setIsAccessSchoolAlarm(true) | ||
viewModel.updateUserTopic(topics) | ||
} else { | ||
viewModel.setIsAccessSchoolAlarm(false) | ||
viewModel.removeUserTopic() | ||
} | ||
} | ||
|
||
binding.switchSettingDepartmentAlarm.setOnCheckedChangeListener { compoundButton, _ -> | ||
if (compoundButton.isChecked) { | ||
viewModel.setIsAccessDepartAlarm(true) | ||
viewModel.updateUserDepartment() | ||
} else { | ||
viewModel.setIsAccessDepartAlarm(false) | ||
viewModel.removeUserDepartment() | ||
} | ||
} | ||
|
||
binding.btnSettingEditKeyword.setOnClickListener { | ||
val intent = Intent(requireActivity(), KeywordActivity::class.java) | ||
startActivity(intent) | ||
resultLauncher.launch(intent) | ||
} | ||
|
||
binding.btnSettingEditDepartment.setOnClickListener { | ||
|
@@ -92,4 +106,14 @@ class SettingFragment : BaseFragment<FragmentSettingBinding, SettingViewModel>() | |
requireContext().packageManager.getPackageInfo(requireContext().packageName, 0) | ||
return packageManager.versionName | ||
} | ||
|
||
private fun setResultKeyword() { | ||
resultLauncher = | ||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | ||
if (result.resultCode == Activity.RESULT_OK) { | ||
viewModel.getUserTopic() | ||
viewModel.updateUserTopic(topics) | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네트워크 시간 때문에 늘린건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 키워드 때문에 타임 아웃 에러나서 서버 측에서 로직 수정해주시면 다시 10으로 되돌릴 예정입니당