Skip to content

Commit c9fa09e

Browse files
committed
增加激活类型
1 parent 583e8da commit c9fa09e

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

app/src/main/java/com/example/ivdemo/TweCallActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,11 @@ class TweCallActivity : BaseIPCActivity<ActivityTweCallBinding>(), IvVoipCallbac
293293
showToast("twecall初始化成功")
294294
val activeDeviceInfo = VideoNativeInterface.getInstance().voipActiveDeviceInfoV2
295295
if (activeDeviceInfo == null || activeDeviceInfo.expireTime < System.currentTimeMillis() / 1000) {
296+
val selectActiveType =
297+
intent.getIntExtra("activeType", VoipActivateType.VOIP_ACT_IPC)
298+
Log.i(TAG, "激活类型:$selectActiveType")
296299
val activateRes = VideoNativeInterface.getInstance()
297-
.activateVoipLicenseV2(VoipActivateType.VOIP_ACT_IPC)
300+
.activateVoipLicenseV2(selectActiveType)
298301
if (activateRes == 0) {
299302
showToast("检查设备过期,激活结果成功,resCode:$activateRes")
300303
} else {

app/src/main/java/com/example/ivdemo/TweCallLoginActivity.kt

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ package com.example.ivdemo
22

33
import android.content.Intent
44
import android.os.Bundle
5+
import android.view.View
6+
import android.widget.AdapterView
7+
import android.widget.AdapterView.OnItemSelectedListener
8+
import android.widget.ArrayAdapter
59
import android.widget.RadioButton
610
import android.widget.Toast
711
import androidx.appcompat.app.AppCompatActivity
812
import com.tencent.iot.twcall.R
913
import com.example.ivdemo.popup.QualitySettingDialog
1014
import com.example.ivdemo.popup.WxSettingDialog
1115
import com.tencent.iot.twcall.databinding.ActivityTweCallLoginBinding
16+
import com.tencent.iot.video.device.annotations.VoipActivateType
1217
import com.tencent.iotvideo.link.util.DeviceSetting
1318
import com.tencent.iotvideo.link.util.updateOperate
1419

@@ -17,7 +22,14 @@ class TweCallLoginActivity : AppCompatActivity() {
1722
private val binding by lazy { ActivityTweCallLoginBinding.inflate(layoutInflater) }
1823
private val deviceSetting by lazy { DeviceSetting.getInstance(this) }
1924
private var miniProgramVersion: Int = 0
20-
25+
private val activeType = listOf(
26+
VoipActivateType.VOIP_ACT_TEST to "测试激活码",
27+
VoipActivateType.VOIP_ACT_IPC to "家庭安防场景",
28+
VoipActivateType.VOIP_ACT_WEARABLE to "可穿戴设备",
29+
VoipActivateType.VOIP_ACT_LIFE to "生活娱乐场景",
30+
VoipActivateType.VOIP_ACT_OTHER to "对讲和其他场景"
31+
)
32+
private var selectActiveType = VoipActivateType.VOIP_ACT_IPC
2133
override fun onCreate(savedInstanceState: Bundle?) {
2234
super.onCreate(savedInstanceState)
2335
setContentView(binding.root)
@@ -33,6 +45,28 @@ class TweCallLoginActivity : AppCompatActivity() {
3345
else -> 0
3446
}
3547
}
48+
49+
50+
spSelectActiveType.adapter = ArrayAdapter(
51+
this@TweCallLoginActivity,
52+
android.R.layout.simple_spinner_item,
53+
activeType.map { it.second }
54+
)
55+
spSelectActiveType.setSelection(1)
56+
spSelectActiveType.onItemSelectedListener = object : OnItemSelectedListener {
57+
override fun onItemSelected(
58+
parent: AdapterView<*>?,
59+
view: View?,
60+
position: Int,
61+
id: Long
62+
) {
63+
selectActiveType = activeType.get(position).first
64+
}
65+
66+
override fun onNothingSelected(parent: AdapterView<*>?) {
67+
}
68+
}
69+
3670
// Set button click listeners
3771
if (deviceSetting.appId.isEmpty() || deviceSetting.modelId.isEmpty()) {
3872
btnLoginTweCall.updateOperate(false)
@@ -88,6 +122,7 @@ class TweCallLoginActivity : AppCompatActivity() {
88122
intent.putExtra("deviceName", deviceSetting.deviceName)
89123
intent.putExtra("deviceKey", deviceSetting.deviceKey)
90124
intent.putExtra("miniProgramVersion", miniProgramVersion)
125+
intent.putExtra("activeType", selectActiveType)
91126
startActivity(intent)
92127
}
93128
}

app/src/main/res/layout/activity_twe_call_login.xml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,44 @@
6767
android:text="@string/text_experience_version" />
6868
</RadioGroup>
6969

70+
<androidx.constraintlayout.widget.ConstraintLayout
71+
android:id="@+id/ll_select_active_type"
72+
android:layout_width="wrap_content"
73+
android:layout_height="wrap_content"
74+
android:orientation="vertical"
75+
android:paddingHorizontal="32dp"
76+
app:layout_constraintEnd_toEndOf="parent"
77+
app:layout_constraintStart_toStartOf="parent"
78+
app:layout_constraintTop_toBottomOf="@+id/rg_select_version">
79+
80+
<TextView
81+
android:id="@+id/textView2"
82+
android:layout_width="wrap_content"
83+
android:layout_height="wrap_content"
84+
android:text="@string/text_active_type"
85+
app:layout_constraintStart_toStartOf="parent"
86+
app:layout_constraintTop_toTopOf="parent" />
87+
88+
<TextView
89+
android:id="@+id/textView"
90+
android:layout_width="wrap_content"
91+
android:layout_height="wrap_content"
92+
android:text="@string/text_active_type_tip"
93+
android:textSize="6sp"
94+
app:layout_constraintBottom_toBottomOf="@+id/textView2"
95+
app:layout_constraintStart_toEndOf="@+id/textView2" />
96+
97+
<Spinner
98+
android:id="@+id/sp_select_active_type"
99+
android:layout_width="wrap_content"
100+
android:layout_height="40dp"
101+
android:textAlignment="center"
102+
android:textSize="12sp"
103+
app:layout_constraintEnd_toEndOf="parent"
104+
app:layout_constraintStart_toStartOf="parent"
105+
app:layout_constraintTop_toBottomOf="@+id/textView2" />
106+
</androidx.constraintlayout.widget.ConstraintLayout>
107+
70108
<Button
71109
android:id="@+id/btn_wx_setting"
72110
android:layout_width="match_parent"
@@ -78,7 +116,7 @@
78116
android:text="@string/twe_call_wx_setting"
79117
android:textColor="@color/blue_0052D9"
80118
android:textSize="20sp"
81-
app:layout_constraintTop_toBottomOf="@+id/rg_select_version"
119+
app:layout_constraintTop_toBottomOf="@+id/ll_select_active_type"
82120
tools:layout_editor_absoluteX="80dp" />
83121

84122
<Button

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
<string name="text_p2p_info">P2P信息:%s</string>
6161
<string name="text_exit_ota">OTA退出升级</string>
6262
<string name="text_select_version">请选择下面通信的小程序版本</string>
63+
<string name="text_active_type">请选择激活类型</string>
64+
<string name="text_active_type_tip">注:若出现过期情况,请按照控制台\n选择激活类型</string>
6365
<string name="text_formal_version">正式版</string>
6466
<string name="text_develop_version">开发版</string>
6567
<string name="text_experience_version">体验版</string>
@@ -96,4 +98,7 @@
9698
<string name="title_log">Log</string>
9799
<string name="text_soft_encode">软编码</string>
98100
<string name="text_hard_encode">硬编码</string>
101+
<string name="text_active_code">测试激活码</string>
102+
<string name="text_room_ipc">家庭安防场景</string>
103+
<string name="text_wearable">可穿戴设备</string>
99104
</resources>

0 commit comments

Comments
 (0)