회원가입, 로그인 페이지 추가
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package kr.co.vividnext.sodalive.settings
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class GetTermsResponse(
|
||||
@SerializedName("title") val title: String,
|
||||
@SerializedName("description") val description: String
|
||||
)
|
@@ -0,0 +1,84 @@
|
||||
package kr.co.vividnext.sodalive.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.webkit.WebSettingsCompat
|
||||
import androidx.webkit.WebViewFeature
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityTermsBinding
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class TermsActivity : BaseActivity<ActivityTermsBinding>(ActivityTermsBinding::inflate) {
|
||||
|
||||
private val viewModel: TermsViewModel by inject()
|
||||
|
||||
private lateinit var loadingDialog: LoadingDialog
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
bindData()
|
||||
|
||||
val terms = intent.getStringExtra(Constants.EXTRA_TERMS) ?: "terms"
|
||||
if (terms == "privacy") {
|
||||
viewModel.getPrivacyPolicy()
|
||||
} else {
|
||||
viewModel.getTermsOfService()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun setupView() {
|
||||
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||
WebSettingsCompat.setForceDark(
|
||||
binding.webView.settings,
|
||||
WebSettingsCompat.FORCE_DARK_ON
|
||||
)
|
||||
}
|
||||
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
|
||||
binding.webView.settings.apply {
|
||||
javaScriptEnabled = false // 자바스크립트 실행 허용
|
||||
javaScriptCanOpenWindowsAutomatically = false // 자바스크립트에서 새창 실 행 허용
|
||||
setSupportMultipleWindows(false) // 새 창 실행 허용
|
||||
loadWithOverviewMode = true // 메타 태그 허용
|
||||
|
||||
useWideViewPort = true // 화면 사이즈 맞추기 허용
|
||||
setSupportZoom(false) // 화면 줌 허용
|
||||
builtInZoomControls = false // 화면 확대 축소 허용 여부
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindData() {
|
||||
viewModel.isLoading.observe(this) {
|
||||
if (it) {
|
||||
loadingDialog.show(screenWidth, "공지사항을 불러오고 있습니다.")
|
||||
} else {
|
||||
loadingDialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let { Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
|
||||
viewModel.titleLiveData.observe(this) {
|
||||
binding.toolbar.tvBack.text = it
|
||||
}
|
||||
|
||||
viewModel.termsLiveData.observe(this) {
|
||||
val viewPort =
|
||||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=0.8\">"
|
||||
val data = viewPort + it
|
||||
binding.webView.loadData(
|
||||
data,
|
||||
"text/html; charset=utf-8",
|
||||
"utf-8"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package kr.co.vividnext.sodalive.settings
|
||||
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import retrofit2.http.GET
|
||||
|
||||
interface TermsApi {
|
||||
@GET("/stplat/terms_of_service")
|
||||
fun getTermsOfService(): Single<ApiResponse<GetTermsResponse>>
|
||||
|
||||
@GET("/stplat/privacy_policy")
|
||||
fun getPrivacyPolicy(): Single<ApiResponse<GetTermsResponse>>
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.settings
|
||||
|
||||
class TermsRepository(private val api: TermsApi) {
|
||||
fun getTermsOfService() = api.getTermsOfService()
|
||||
fun getPrivacyPolicy() = api.getPrivacyPolicy()
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
package kr.co.vividnext.sodalive.settings
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.orhanobut.logger.Logger
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
|
||||
class TermsViewModel(private val repository: TermsRepository) : BaseViewModel() {
|
||||
private val _titleLiveData = MutableLiveData<String>()
|
||||
val titleLiveData: LiveData<String>
|
||||
get() = _titleLiveData
|
||||
|
||||
private val _termsLiveData = MutableLiveData<String>()
|
||||
val termsLiveData: LiveData<String>
|
||||
get() = _termsLiveData
|
||||
|
||||
private val _toastLiveData = MutableLiveData<String?>()
|
||||
val toastLiveData: LiveData<String?>
|
||||
get() = _toastLiveData
|
||||
|
||||
private var _isLoading = MutableLiveData(false)
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
fun getTermsOfService() {
|
||||
_isLoading.value = true
|
||||
|
||||
compositeDisposable.add(
|
||||
repository.getTermsOfService()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
|
||||
if (it.success && it.data != null) {
|
||||
_titleLiveData.postValue(it.data.title)
|
||||
_termsLiveData.postValue(it.data.description)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun getPrivacyPolicy() {
|
||||
_isLoading.value = true
|
||||
|
||||
compositeDisposable.add(
|
||||
repository.getPrivacyPolicy()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
_isLoading.value = false
|
||||
|
||||
if (it.success && it.data != null) {
|
||||
_titleLiveData.postValue(it.data.title)
|
||||
_termsLiveData.postValue(it.data.description)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
} else {
|
||||
_toastLiveData.postValue(
|
||||
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user