11package com.example.ivdemo.popup
22
3+ import android.content.ClipboardManager
34import android.content.Context
45import android.text.Editable
56import android.text.TextWatcher
67import android.view.View
78import android.widget.RadioButton
89import android.widget.Toast
10+ import androidx.core.content.ContextCompat
911import androidx.fragment.app.FragmentManager
1012import com.tencent.iot.twcall.databinding.PopupDeviceSettingLayoutBinding
13+ import com.tencent.iotvideo.link.entity.UserEntity
1114import com.tencent.iotvideo.link.util.DeviceSetting
1215import com.tencent.iotvideo.link.util.updateOperate
1316
@@ -16,6 +19,9 @@ class DeviceSettingDialog(private val context: Context) :
1619
1720 private val deviceSetting by lazy { DeviceSetting .getInstance(context) }
1821 private var ipcType: Int = 2
22+ private var wxAppId: String? = null
23+ private var modelId: String? = null
24+ private var openId: String? = null
1925 private val textWatcher = object : TextWatcher {
2026 override fun beforeTextChanged (
2127 s : CharSequence? ,
@@ -57,6 +63,23 @@ class DeviceSettingDialog(private val context: Context) :
5763 rgSelectWay.setOnCheckedChangeListener { group, checkedId ->
5864 ipcType = group.findViewById<RadioButton >(checkedId).tag.toString().toInt()
5965 }
66+ btnPaste.setOnClickListener {
67+ val clipboard =
68+ ContextCompat .getSystemService(context, ClipboardManager ::class .java);
69+ if (clipboard != null && clipboard.hasPrimaryClip()) {
70+ clipboard.primaryClip?.getItemAt(0 )?.text.toString().split(" \n " )
71+ .forEachIndexed { index, s ->
72+ when (index) {
73+ 0 -> binding.etLoginProductId.setText(s)
74+ 1 -> binding.etLoginDeviceName.setText(s)
75+ 2 -> binding.etLoginDeviceKey.setText(s)
76+ 3 -> wxAppId = s
77+ 4 -> modelId = s
78+ 5 -> openId = s
79+ }
80+ }
81+ }
82+ }
6083
6184 btnConfirm.setOnClickListener(View .OnClickListener {
6285 if (! checkDeviceInfo()) {
@@ -83,6 +106,15 @@ class DeviceSettingDialog(private val context: Context) :
83106 deviceSetting.productId = etLoginProductId.text.toString()
84107 deviceSetting.deviceName = etLoginDeviceName.text.toString()
85108 deviceSetting.deviceKey = etLoginDeviceKey.text.toString()
109+ wxAppId?.let {
110+ deviceSetting.appId = it
111+ }
112+ modelId?.let {
113+ deviceSetting.modelId = it
114+ }
115+ openId?.let {
116+ deviceSetting.addOnlyEntity(UserEntity (openId, false ))
117+ }
86118 }
87119 }
88120
0 commit comments