|
@@ -1,22 +1,28 @@
|
|
|
package com.develop.setting.ui
|
|
|
|
|
|
+import android.content.ComponentName
|
|
|
+import android.content.Context
|
|
|
+import android.content.Intent
|
|
|
+import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
+import android.provider.Settings
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
+import android.widget.Toast
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.azhon.appupdate.listener.OnDownloadListener
|
|
|
import com.blankj.utilcode.util.AppUtils
|
|
|
import com.develop.base.ext.getSN
|
|
|
import com.develop.base.ext.updateText
|
|
|
import com.develop.base.util.GlobalToast
|
|
|
-import com.develop.common.food_sdk.GlobalDevEvent
|
|
|
-import com.develop.common.router.Screens
|
|
|
-import com.develop.common.ui.CommonBVMActivity
|
|
|
-import com.develop.common.utils.UpdateUtil
|
|
|
import com.develop.common.dialog.CancelConfirmDialog
|
|
|
import com.develop.common.dialog.CommonDialog
|
|
|
import com.develop.common.dialog.RecipeUpdateDialog
|
|
|
+import com.develop.common.food_sdk.GlobalDevEvent
|
|
|
+import com.develop.common.router.Screens
|
|
|
+import com.develop.common.ui.CommonBVMActivity
|
|
|
import com.develop.common.utils.AppVersionUtil
|
|
|
+import com.develop.common.utils.UpdateUtil
|
|
|
import com.develop.setting.databinding.ActivityAboutBinding
|
|
|
import com.develop.setting.ui.viewmodel.AboutViewModel
|
|
|
import com.kuyuntech.cofarcooking.device.sdk.constant.core.DevStatus
|
|
@@ -25,6 +31,7 @@ import com.kuyuntech.cofarcooking.device.sdk.util.core.CofarSDK
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import java.io.File
|
|
|
|
|
|
+
|
|
|
@Route(path = Screens.Setting.ABOUT)
|
|
|
class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>() {
|
|
|
override fun createViewBinding(inflater: LayoutInflater): ActivityAboutBinding {
|
|
@@ -37,7 +44,11 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
|
|
|
|
|
|
private var updateApkUrl = ""
|
|
|
|
|
|
- private var weightAlignCount = 0;
|
|
|
+ private var weightAlignCount = 0
|
|
|
+
|
|
|
+ private var adbCount = 0
|
|
|
+
|
|
|
+ private var testCount = 0
|
|
|
|
|
|
private val cancelConfirmDialog by lazy {
|
|
|
CancelConfirmDialog()
|
|
@@ -66,6 +77,14 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
|
|
|
|
|
|
binding.devSn.text = getSN()
|
|
|
|
|
|
+ CofarSDK.devInfo().let {
|
|
|
+ binding.tvMcuVersion.text = (it.manufacturer.toString() + "M" + it.haradware.toString() + "H" + it.software.toString()) + "S" + it.protocol + "P" + it.devType + "D"
|
|
|
+ }
|
|
|
+
|
|
|
+ binding.tvFirmware.text = Build.DISPLAY
|
|
|
+
|
|
|
+ binding.model.text = getSN().substring(4,8)
|
|
|
+
|
|
|
recipeUpdateDialog.onDialogClickListener =
|
|
|
object : RecipeUpdateDialog.OnDialogClickListener {
|
|
|
override fun onConfirm() {
|
|
@@ -171,6 +190,41 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
|
|
|
cancelConfirmDialog.showDialog(supportFragmentManager, "cancelConfirmDialog")
|
|
|
}
|
|
|
|
|
|
+ binding.tvAppVersion.setOnClickListener{
|
|
|
+ adbCount++
|
|
|
+ if (adbCount >= 7) {
|
|
|
+ adbCount = 0
|
|
|
+ if(isAdbDebuggingEnabled(this)){
|
|
|
+ Toast.makeText(this, "adb disable", Toast.LENGTH_SHORT).show()
|
|
|
+ toggleAdbDebugging(this,false)
|
|
|
+ }else{
|
|
|
+ Toast.makeText(this, "adb enable", Toast.LENGTH_SHORT).show()
|
|
|
+ toggleAdbDebugging(this,true)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ binding.devSn.setOnClickListener{
|
|
|
+ testCount++
|
|
|
+ if (testCount >= 7) {
|
|
|
+ testCount = 0
|
|
|
+ // 创建启动目标活动的Intent
|
|
|
+ val intent = Intent()
|
|
|
+ intent.component = ComponentName(
|
|
|
+ "com.zavier.androidrk3326functiontest",
|
|
|
+ "com.zavier.androidrk3326functiontest.MainFunctionActivity"
|
|
|
+ )
|
|
|
+
|
|
|
+ // 启动目标活动
|
|
|
+ startActivity(intent)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
binding.tvAppName.text = AppUtils.getAppName()
|
|
|
binding.tvAppVersion.text = "v${AppUtils.getAppVersionName()}"
|
|
|
|
|
@@ -185,6 +239,39 @@ class AboutActivity : CommonBVMActivity<ActivityAboutBinding, AboutViewModel>()
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ fun toggleAdbDebugging(context: Context, enable: Boolean) {
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
+ Settings.Secure.putInt(
|
|
|
+ context.contentResolver,
|
|
|
+ Settings.Global.ADB_ENABLED,
|
|
|
+ if (enable) 1 else 0
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ Settings.Secure.putInt(
|
|
|
+ context.contentResolver,
|
|
|
+ Settings.Secure.ADB_ENABLED,
|
|
|
+ if (enable) 1 else 0
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun isAdbDebuggingEnabled(context: Context): Boolean {
|
|
|
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
+ Settings.Secure.getInt(
|
|
|
+ context.contentResolver,
|
|
|
+ Settings.Global.ADB_ENABLED,
|
|
|
+ 0
|
|
|
+ ) != 0
|
|
|
+ } else {
|
|
|
+ Settings.Secure.getInt(
|
|
|
+ context.contentResolver,
|
|
|
+ Settings.Secure.ADB_ENABLED,
|
|
|
+ 0
|
|
|
+ ) != 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
viewModel.getDevInfo()
|