|
@@ -8,6 +8,7 @@ import android.widget.ImageView
|
|
|
import android.widget.RelativeLayout
|
|
|
import android.widget.ToggleButton
|
|
|
import androidx.appcompat.widget.Toolbar
|
|
|
+import androidx.core.view.isVisible
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
import com.google.android.material.appbar.CollapsingToolbarLayout
|
|
|
import com.sikey.veryfit.R
|
|
@@ -24,8 +25,10 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
|
|
|
var TAG = RejectStrangerActivity::class.java.simpleName
|
|
|
var mLytRejectHistory: RelativeLayout? = null
|
|
|
+ var mLytAutoAnswer: RelativeLayout? = null
|
|
|
|
|
|
var mTbtn: ToggleButton? = null
|
|
|
+ var mTbtn_auto_answer: ToggleButton? = null
|
|
|
|
|
|
private var mToolbar: Toolbar? = null
|
|
|
private var mBackView: ImageView? = null
|
|
@@ -55,7 +58,7 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
|
|
|
val appBarLayout = findViewById<CollapsingToolbarLayout>(R.id.collapsingToolbar)
|
|
|
if (appBarLayout != null) {
|
|
|
- appBarLayout.title = getString(R.string.reject_stranger)
|
|
|
+ appBarLayout.title = getString(R.string.call_settings)
|
|
|
appBarLayout.setExpandedTitleTextColor(resources.getColorStateList(R.color.dark))
|
|
|
appBarLayout.setCollapsedTitleTextColor(resources.getColor(R.color.dark))
|
|
|
}
|
|
@@ -69,12 +72,42 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
|
|
|
if (!buttonView.isPressed) return@OnCheckedChangeListener
|
|
|
|
|
|
- if (isChecked)
|
|
|
- setWhiteListStatus(1)
|
|
|
- else
|
|
|
- setWhiteListStatus(0)
|
|
|
+ if (isChecked) {
|
|
|
+
|
|
|
+ if (DataManager.instance.currentChildInfo?.device?.model.equals("W303B", ignoreCase = true)) {
|
|
|
+ mLytAutoAnswer?.isVisible = true
|
|
|
+ } else {
|
|
|
+ mLytAutoAnswer?.isVisible = false
|
|
|
+ }
|
|
|
+ if (mTbtn_auto_answer?.isChecked == true)
|
|
|
+ setWhiteListStatus(1, 1)
|
|
|
+ else
|
|
|
+ setWhiteListStatus(1, 0)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ mTbtn_auto_answer?.isChecked = false
|
|
|
+ mLytAutoAnswer?.isVisible = false
|
|
|
+ setWhiteListStatus(0, 0)
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
+ mLytAutoAnswer = findViewById(R.id.lyt_auto_answer)
|
|
|
+ mTbtn_auto_answer = findViewById(R.id.tbtn_auto_anwer)
|
|
|
+ mTbtn_auto_answer?.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+ if (!buttonView.isPressed) return@OnCheckedChangeListener
|
|
|
+ if (isChecked) {
|
|
|
+ if (mTbtn?.isChecked == true)
|
|
|
+ setWhiteListStatus(1, 1)
|
|
|
+ else
|
|
|
+ setWhiteListStatus(0, 0)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (mTbtn?.isChecked == true)
|
|
|
+ setWhiteListStatus(1, 0)
|
|
|
+ else
|
|
|
+ setWhiteListStatus(0, 0)
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
mLytRejectHistory?.setOnClickListener {
|
|
|
startActivity(
|
|
@@ -102,7 +135,8 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
}
|
|
|
if (this.code == "200") {
|
|
|
val status = (this.mData as BlockUnknownCallRepo).status.toggle
|
|
|
- refreshUI(status)
|
|
|
+ val autoAnswer = (this.mData as BlockUnknownCallRepo).status.autoAnswer
|
|
|
+ refreshUI(status, autoAnswer)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -110,7 +144,7 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private fun setWhiteListStatus(open: Int) {
|
|
|
+ private fun setWhiteListStatus(open: Int, autoAnswer: Int) {
|
|
|
|
|
|
/* if (open == 1) {
|
|
|
if (VersionMatch.isBLY() || VersionMatch.isBERE()) {
|
|
@@ -126,7 +160,7 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
HttpServiceExecutor.execute(
|
|
|
(RetrofitFactory.retrofit(WatchSettingService::class.java) as WatchSettingService).setBlockUnknownCall(
|
|
|
DataManager.instance.currentChildInfo?.childId ?: "",
|
|
|
- BlockUnknownCall(if (open == 1) 1 else -1)
|
|
|
+ BlockUnknownCall(if (open == 1) 1 else -1, if (autoAnswer == 1) 1 else -1)
|
|
|
).flowable
|
|
|
).apply {
|
|
|
hideProgressDialog()
|
|
@@ -139,9 +173,15 @@ class RejectStrangerActivity : BaseNoActionBarActivity() {
|
|
|
showProgressDialog()
|
|
|
}
|
|
|
|
|
|
- private fun refreshUI(status: Int) {
|
|
|
+ private fun refreshUI(status: Int, autoAnswer: Int) {
|
|
|
|
|
|
mTbtn?.isChecked = status == 1
|
|
|
+ mTbtn_auto_answer?.isChecked = autoAnswer == 1
|
|
|
+ if (DataManager.instance.currentChildInfo?.device?.model.equals("W303B", ignoreCase = true)) {
|
|
|
+ mLytAutoAnswer?.isVisible = mTbtn!!.isChecked
|
|
|
+ } else {
|
|
|
+ mLytAutoAnswer?.isVisible = false
|
|
|
+ }
|
|
|
/* if (status == 1) {
|
|
|
if (VersionMatch.isBLY() || VersionMatch.isBERE()) {
|
|
|
mLytRejectHistory?.visibility = View.GONE
|