|
@@ -12,6 +12,7 @@ import android.util.Log
|
|
import android.view.MenuItem
|
|
import android.view.MenuItem
|
|
import android.view.MotionEvent
|
|
import android.view.MotionEvent
|
|
import android.view.View
|
|
import android.view.View
|
|
|
|
+import android.view.View.GONE
|
|
import android.view.View.VISIBLE
|
|
import android.view.View.VISIBLE
|
|
import android.view.WindowManager
|
|
import android.view.WindowManager
|
|
import android.view.inputmethod.InputMethodManager
|
|
import android.view.inputmethod.InputMethodManager
|
|
@@ -25,6 +26,7 @@ import androidx.core.content.ContextCompat
|
|
import androidx.core.view.get
|
|
import androidx.core.view.get
|
|
import androidx.lifecycle.LifecycleObserver
|
|
import androidx.lifecycle.LifecycleObserver
|
|
import androidx.navigation.findNavController
|
|
import androidx.navigation.findNavController
|
|
|
|
+import androidx.navigation.fragment.findNavController
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
@@ -88,6 +90,7 @@ class SettingActivity : BaseActivity<BackstageActivitySettingBinding, SettingVie
|
|
private var backPressedTime: Long = 0
|
|
private var backPressedTime: Long = 0
|
|
var devOnOffDialog: DevOnOffDialog? = null
|
|
var devOnOffDialog: DevOnOffDialog? = null
|
|
var connectionServerDialog: ConnectionServerDialog? = null
|
|
var connectionServerDialog: ConnectionServerDialog? = null
|
|
|
|
+ var outServerDialog: DevOnOffDialog? = null
|
|
var updateAppDialog: UpdateAppDialog? = null
|
|
var updateAppDialog: UpdateAppDialog? = null
|
|
var apkInfoBean: ApkInfoBean? = null//更新信息
|
|
var apkInfoBean: ApkInfoBean? = null//更新信息
|
|
var windSpeed = 0
|
|
var windSpeed = 0
|
|
@@ -144,6 +147,19 @@ class SettingActivity : BaseActivity<BackstageActivitySettingBinding, SettingVie
|
|
homeReturnToUpperLevel.setOnClickListener(this@SettingActivity)
|
|
homeReturnToUpperLevel.setOnClickListener(this@SettingActivity)
|
|
ivDevOnAndOff.setOnClickListener(this@SettingActivity)
|
|
ivDevOnAndOff.setOnClickListener(this@SettingActivity)
|
|
btnConnectionServer.setOnClickListener(this@SettingActivity)
|
|
btnConnectionServer.setOnClickListener(this@SettingActivity)
|
|
|
|
+ LongClickUtils.setLongClick(Handler(), llOutSystem, 3000, object : View.OnLongClickListener {
|
|
|
|
+ override fun onLongClick(p0: View?): Boolean {
|
|
|
|
+ if (SpUtils.getString(
|
|
|
|
+ MMKVName.CONNECT_STATE, ConnectStateEnum.DISCONNECTED.name
|
|
|
|
+ )==ConnectStateEnum.CONNECTED.name){
|
|
|
|
+ btnOutServer.visibility=VISIBLE
|
|
|
|
+ }else{
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ btnOutServer.setOnClickListener(this@SettingActivity)
|
|
btnUpdateApp.setOnClickListener(this@SettingActivity)
|
|
btnUpdateApp.setOnClickListener(this@SettingActivity)
|
|
//设置连接状态
|
|
//设置连接状态
|
|
connectState(
|
|
connectState(
|
|
@@ -225,9 +241,16 @@ class SettingActivity : BaseActivity<BackstageActivitySettingBinding, SettingVie
|
|
observeLiveData(mViewModel.isM3Success, ::closeDialog)
|
|
observeLiveData(mViewModel.isM3Success, ::closeDialog)
|
|
observeLiveData(mViewModel.connectState, ::connectState)
|
|
observeLiveData(mViewModel.connectState, ::connectState)
|
|
observeLiveData(mViewModel.apkInfo, ::updateApp)
|
|
observeLiveData(mViewModel.apkInfo, ::updateApp)
|
|
|
|
+ observeLiveData(mViewModel.connectOut, ::connectOut)
|
|
|
|
+
|
|
lifecycle.addObserver(this)
|
|
lifecycle.addObserver(this)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ private fun connectOut(b: Boolean) {
|
|
|
|
+ if (b){
|
|
|
|
+ mBinding.btnOutServer.visibility = GONE
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
private fun updateApp(apkInfoBean: ApkInfoBean) {
|
|
private fun updateApp(apkInfoBean: ApkInfoBean) {
|
|
this.apkInfoBean = apkInfoBean
|
|
this.apkInfoBean = apkInfoBean
|
|
@@ -315,6 +338,10 @@ class SettingActivity : BaseActivity<BackstageActivitySettingBinding, SettingVie
|
|
showConnectionServer()
|
|
showConnectionServer()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ R.id.btn_out_server -> {
|
|
|
|
+ showOutServer()
|
|
|
|
+ }
|
|
|
|
+
|
|
R.id.btn_update_app -> {
|
|
R.id.btn_update_app -> {
|
|
if (mBinding.tvUpdateHint.visibility != VISIBLE) {
|
|
if (mBinding.tvUpdateHint.visibility != VISIBLE) {
|
|
ToastUtil.switchToastStyleToInfo(UiUtil.getStringRes(R.string.backstage_latest_version))
|
|
ToastUtil.switchToastStyleToInfo(UiUtil.getStringRes(R.string.backstage_latest_version))
|
|
@@ -326,7 +353,25 @@ class SettingActivity : BaseActivity<BackstageActivitySettingBinding, SettingVie
|
|
else -> {}
|
|
else -> {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ private fun showOutServer() {
|
|
|
|
+ if (outServerDialog == null) {
|
|
|
|
+ outServerDialog = DevOnOffDialog(this@SettingActivity)
|
|
|
|
+ outServerDialog?.setListener(object : DialogClickListener {
|
|
|
|
+ override fun onClickListener(type: Int, text: String?) {
|
|
|
|
+ when (type) {
|
|
|
|
+ outServerDialog?.type1 -> {
|
|
|
|
+ // 脱离系统
|
|
|
|
+ mViewModel.initOutSystem()
|
|
|
|
+ outServerDialog?.dismiss()
|
|
|
|
+ }
|
|
|
|
+ else -> {}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ outServerDialog?.setContent(R.string.out_system_msg,R.string.backstage_confirm)
|
|
|
|
+ outServerDialog?.show()
|
|
|
|
+ }
|
|
private fun showUpdateApp() {
|
|
private fun showUpdateApp() {
|
|
if (updateAppDialog == null) {
|
|
if (updateAppDialog == null) {
|
|
updateAppDialog = UpdateAppDialog(this@SettingActivity)
|
|
updateAppDialog = UpdateAppDialog(this@SettingActivity)
|
|
@@ -424,6 +469,7 @@ class SettingActivity : BaseActivity<BackstageActivitySettingBinding, SettingVie
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ devOnOffDialog?.setContent(R.string.backstage_open_dev_tips,R.string.backstage_start_dev)
|
|
devOnOffDialog?.show()
|
|
devOnOffDialog?.show()
|
|
}
|
|
}
|
|
|
|
|