扫码附件设备,链接设备动画
@@ -25,6 +25,9 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.DefenseApplication">
|
android:theme="@style/Theme.DefenseApplication">
|
||||||
|
<activity
|
||||||
|
android:name=".home.ConnectDeviceActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".liveVideo.AddLinkedUserActivity"
|
android:name=".liveVideo.AddLinkedUserActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
@@ -54,13 +57,7 @@
|
|||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".liveVideo.SettingsActivity"
|
android:name=".liveVideo.SettingsActivity"
|
||||||
android:exported="true">
|
android:exported="false" />
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".liveVideo.LiveVideoActivity"
|
android:name=".liveVideo.LiveVideoActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
@@ -84,7 +81,13 @@
|
|||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".home.HomeActivity"
|
android:name=".home.HomeActivity"
|
||||||
android:exported="false" />
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".login.RegisterSuccessActivity"
|
android:name=".login.RegisterSuccessActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|||||||
@@ -10,14 +10,33 @@ import com.example.defenseapplication.R
|
|||||||
|
|
||||||
data class Device(
|
data class Device(
|
||||||
val name: String,
|
val name: String,
|
||||||
val icon: String
|
val icon: String // 暂时保留,不再实际使用静态图片
|
||||||
)
|
)
|
||||||
class AddDeviceAdapter(private val devices: List<Device>, private val onItemClick: (Device) -> Unit) :
|
|
||||||
RecyclerView.Adapter<AddDeviceAdapter.ViewHolder>() {
|
class AddDeviceAdapter(
|
||||||
|
private val devices: List<Device>,
|
||||||
|
private val onItemClick: (Device) -> Unit
|
||||||
|
) : RecyclerView.Adapter<AddDeviceAdapter.ViewHolder>() {
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
val ivIcon: ImageView = itemView.findViewById(R.id.ivDeviceIcon2)
|
val ivIcon: ImageView = itemView.findViewById(R.id.ivDeviceIcon2)
|
||||||
val tvName: TextView = itemView.findViewById(R.id.tvDeviceName2) // ID 要和布局中一致
|
val tvName: TextView = itemView.findViewById(R.id.tvDeviceName2)
|
||||||
|
|
||||||
|
// 启动帧动画
|
||||||
|
fun startAnimation() {
|
||||||
|
val drawable = ivIcon.drawable
|
||||||
|
if (drawable is android.graphics.drawable.AnimationDrawable && !drawable.isRunning) {
|
||||||
|
drawable.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止帧动画
|
||||||
|
fun stopAnimation() {
|
||||||
|
val drawable = ivIcon.drawable
|
||||||
|
if (drawable is android.graphics.drawable.AnimationDrawable && drawable.isRunning) {
|
||||||
|
drawable.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
@@ -28,13 +47,17 @@ class AddDeviceAdapter(private val devices: List<Device>, private val onItemClic
|
|||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val device = devices[position]
|
val device = devices[position]
|
||||||
holder.tvName.text = device.name
|
holder.tvName.text = device.name
|
||||||
// 根据 icon 字符串加载对应图片(假设 icon 是本地 drawable 的名称)
|
holder.ivIcon.setImageResource(R.drawable.img)
|
||||||
val resId = holder.itemView.context.resources.getIdentifier(device.icon, "drawable", holder.itemView.context.packageName)
|
|
||||||
if (resId != 0) holder.ivIcon.setImageResource(resId) else holder.ivIcon.setImageResource(R.drawable.img)
|
|
||||||
|
|
||||||
// 设置点击事件
|
// 点击事件
|
||||||
holder.itemView.setOnClickListener { onItemClick(device) }
|
holder.itemView.setOnClickListener { onItemClick(device) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
|
super.onViewRecycled(holder)
|
||||||
|
// 视图被回收时停止动画,节省资源
|
||||||
|
holder.stopAnimation()
|
||||||
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = devices.size
|
override fun getItemCount(): Int = devices.size
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@ package com.example.defenseapplication.home
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -12,10 +14,12 @@ import com.example.defenseapplication.adapter.Device
|
|||||||
import com.example.defenseapplication.databinding.AddDeviceActivityBinding
|
import com.example.defenseapplication.databinding.AddDeviceActivityBinding
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
|
||||||
|
//添加设备页面
|
||||||
class AddDeviceActivity : AppCompatActivity() {
|
class AddDeviceActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: AddDeviceActivityBinding
|
private lateinit var binding: AddDeviceActivityBinding
|
||||||
|
private lateinit var adapter: AddDeviceAdapter
|
||||||
|
private val mainHandler = Handler(Looper.getMainLooper())
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = AddDeviceActivityBinding.inflate(layoutInflater)
|
binding = AddDeviceActivityBinding.inflate(layoutInflater)
|
||||||
@@ -28,7 +32,31 @@ class AddDeviceActivity : AppCompatActivity() {
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
setupDeviceList()
|
// 开始播放扫描动画,动画结束后再显示设备列表
|
||||||
|
startScanAnimationThenShowList()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startScanAnimationThenShowList() {
|
||||||
|
// 显示动画层
|
||||||
|
binding.animationContainer.visibility = View.VISIBLE
|
||||||
|
binding.rvDevices.visibility = View.GONE
|
||||||
|
|
||||||
|
// 设置帧动画并启动
|
||||||
|
binding.ivScanAnimation.setImageResource(R.drawable.device_frame_animation)
|
||||||
|
val scanDrawable = binding.ivScanAnimation.drawable
|
||||||
|
if (scanDrawable is android.graphics.drawable.AnimationDrawable) {
|
||||||
|
scanDrawable.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟扫描过程
|
||||||
|
mainHandler.postDelayed({
|
||||||
|
// 停止动画
|
||||||
|
(binding.ivScanAnimation.drawable as? android.graphics.drawable.AnimationDrawable)?.stop()
|
||||||
|
// 隐藏动画层,显示列表
|
||||||
|
binding.animationContainer.visibility = View.GONE
|
||||||
|
binding.rvDevices.visibility = View.VISIBLE
|
||||||
|
setupDeviceList() // 加载设备列表
|
||||||
|
}, 3000) // 动画播放时长,可根据实际帧动画总时长调整
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDeviceList() {
|
private fun setupDeviceList() {
|
||||||
@@ -38,20 +66,38 @@ class AddDeviceActivity : AppCompatActivity() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (devices.isEmpty()) {
|
if (devices.isEmpty()) {
|
||||||
binding.emptyState.visibility = View.VISIBLE
|
|
||||||
binding.rvDevices.visibility = View.GONE
|
binding.rvDevices.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
binding.emptyState.visibility = View.GONE
|
|
||||||
binding.rvDevices.visibility = View.VISIBLE
|
binding.rvDevices.visibility = View.VISIBLE
|
||||||
|
|
||||||
binding.rvDevices.layoutManager = GridLayoutManager(this, 2)
|
binding.rvDevices.layoutManager = GridLayoutManager(this, 2)
|
||||||
// 传入点击回调
|
adapter = AddDeviceAdapter(devices) { device ->
|
||||||
binding.rvDevices.adapter = AddDeviceAdapter(devices) { device ->
|
|
||||||
// 跳转到 AddFamilyActivity(选择Wi-Fi页面)
|
|
||||||
val intent = Intent(this, AddFamilyActivity::class.java)
|
val intent = Intent(this, AddFamilyActivity::class.java)
|
||||||
intent.putExtra("device_name", device.name)
|
intent.putExtra("device_name", device.name)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
binding.rvDevices.adapter = adapter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
// 停止所有可见 item 的动画
|
||||||
|
for (i in 0 until binding.rvDevices.childCount) {
|
||||||
|
val child = binding.rvDevices.getChildAt(i)
|
||||||
|
val holder = binding.rvDevices.getChildViewHolder(child) as? AddDeviceAdapter.ViewHolder
|
||||||
|
holder?.stopAnimation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
// 重新启动所有可见 item 的动画
|
||||||
|
for (i in 0 until binding.rvDevices.childCount) {
|
||||||
|
val child = binding.rvDevices.getChildAt(i)
|
||||||
|
val holder = binding.rvDevices.getChildViewHolder(child) as? AddDeviceAdapter.ViewHolder
|
||||||
|
holder?.startAnimation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ import com.example.defenseapplication.databinding.AddFamilyActivityBinding
|
|||||||
import com.example.defenseapplication.databinding.DialogWifiListBinding
|
import com.example.defenseapplication.databinding.DialogWifiListBinding
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
|
||||||
|
//选择wifi页面
|
||||||
class AddFamilyActivity : AppCompatActivity() {
|
class AddFamilyActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: AddFamilyActivityBinding
|
private lateinit var binding: AddFamilyActivityBinding
|
||||||
@@ -67,7 +68,7 @@ class AddFamilyActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.btnConfirm.setOnClickListener {
|
binding.btnConfirm.setOnClickListener {
|
||||||
val intent=Intent(this, SetNameActivity::class.java)
|
val intent=Intent(this, ConnectDeviceActivity::class.java)
|
||||||
startActivity( intent)
|
startActivity( intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package com.example.defenseapplication.home
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.graphics.drawable.AnimationDrawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.example.defenseapplication.R
|
||||||
|
import com.example.defenseapplication.databinding.AddDeviceActivityBinding
|
||||||
|
import com.example.defenseapplication.databinding.ConnectDeviceActivityBinding
|
||||||
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
|
||||||
|
class ConnectDeviceActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var binding: ConnectDeviceActivityBinding
|
||||||
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
// 每一帧对应的步骤文字和提示
|
||||||
|
private val steps = listOf(
|
||||||
|
StepData("请保持手机蓝牙开启并将手机尽量靠近设备", "向设备传输信息","设备连接网络"),
|
||||||
|
StepData("请保持手机蓝牙开启并将手机尽量靠近设备", "设备连接网络请将设备尽量靠近路由器",""),
|
||||||
|
StepData("请将设备尽量靠近路由器", "","")
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ConnectDeviceActivityBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
ImmersionBar.with(this)
|
||||||
|
.statusBarDarkFont(true)
|
||||||
|
.titleBar(binding.topBar)
|
||||||
|
.init()
|
||||||
|
binding.ivBack.setOnClickListener {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
startFrameAnimation()
|
||||||
|
}
|
||||||
|
private fun startFrameAnimation() {
|
||||||
|
// 设置动画资源
|
||||||
|
binding.ivAnimation.setImageResource(R.drawable.device_wifi_animation)
|
||||||
|
val animDrawable = binding.ivAnimation.drawable as AnimationDrawable
|
||||||
|
|
||||||
|
// 监听每一帧的切换(AnimationDrawable 没有直接的回调,通过 Handler 定时更新文字)
|
||||||
|
var frameIndex = 0
|
||||||
|
val totalFrames = steps.size
|
||||||
|
|
||||||
|
// 先显示第一帧对应的文字
|
||||||
|
updateTextForFrame(0)
|
||||||
|
|
||||||
|
// 开始动画
|
||||||
|
animDrawable.start()
|
||||||
|
|
||||||
|
// 每隔对应帧的时长来更新文字(必须与动画中每帧 duration 一致)
|
||||||
|
val frameDurations = listOf(1500L, 1500L, 1500L) // 与 xml 中的 duration 对应
|
||||||
|
val runnable = object : Runnable {
|
||||||
|
override fun run() {
|
||||||
|
frameIndex++
|
||||||
|
if (frameIndex < totalFrames) {
|
||||||
|
updateTextForFrame(frameIndex)
|
||||||
|
handler.postDelayed(this, frameDurations[frameIndex])
|
||||||
|
} else {
|
||||||
|
// 动画播放完毕,进行下一步操作(比如跳转或显示设备列表)
|
||||||
|
onAnimationComplete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 第一帧文字已经显示,所以延迟第一帧时长后再切换到第二帧
|
||||||
|
handler.postDelayed(runnable, frameDurations[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateTextForFrame(index: Int) {
|
||||||
|
val step = steps[index]
|
||||||
|
binding.tvStepText.text = step.text
|
||||||
|
binding.tvHint.text = step.hint
|
||||||
|
binding.tvDeviceName.text = step.deviceName
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onAnimationComplete() {
|
||||||
|
// 动画结束后的逻辑,显示“扫描完成”并跳转
|
||||||
|
// 隐藏原来的动画相关视图
|
||||||
|
binding.ivAnimation.visibility = View.GONE
|
||||||
|
binding.tvStepText.visibility = View.GONE
|
||||||
|
binding.tvHint.visibility = View.GONE
|
||||||
|
binding.tvDeviceName.visibility = View.GONE
|
||||||
|
// 显示图片 + 文字的布局
|
||||||
|
val successLayout = binding.successLayout
|
||||||
|
successLayout.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
// 跳转到下一个界面或关闭当前页面
|
||||||
|
// 使用 Handler 延迟跳转
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
startActivity(Intent(this, SetNameActivity::class.java))
|
||||||
|
finish()
|
||||||
|
}, 1000) // 1秒后跳转
|
||||||
|
}
|
||||||
|
|
||||||
|
data class StepData(val text: String, val hint: String, val deviceName: String)
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
handler.removeCallbacksAndMessages(null)
|
||||||
|
(binding.ivAnimation.drawable as? AnimationDrawable)?.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import com.example.defenseapplication.R
|
import com.example.defenseapplication.R
|
||||||
import com.example.defenseapplication.databinding.HomeActivityBinding
|
import com.example.defenseapplication.databinding.HomeActivityBinding
|
||||||
import com.example.defenseapplication.databinding.HomeMenuFragmentBinding
|
import com.example.defenseapplication.databinding.HomeMenuFragmentBinding
|
||||||
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
|
||||||
class HomeActivity : AppCompatActivity() {
|
class HomeActivity : AppCompatActivity() {
|
||||||
// ViewBinding 核心对象
|
// ViewBinding 核心对象
|
||||||
@@ -23,7 +24,6 @@ class HomeActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
// 初始化 ViewBinding
|
// 初始化 ViewBinding
|
||||||
binding = HomeActivityBinding.inflate(layoutInflater)
|
binding = HomeActivityBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.example.defenseapplication.adapter.FamilyAdapter
|
|||||||
import com.example.defenseapplication.databinding.HomeMenuFragmentBinding
|
import com.example.defenseapplication.databinding.HomeMenuFragmentBinding
|
||||||
import com.example.defenseapplication.view.DefenseDialogs
|
import com.example.defenseapplication.view.DefenseDialogs
|
||||||
import com.example.defenseapplication.view.showDefenseDialog
|
import com.example.defenseapplication.view.showDefenseDialog
|
||||||
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
|
||||||
class HomeMenuFragment : Fragment() {
|
class HomeMenuFragment : Fragment() {
|
||||||
// ViewBinding
|
// ViewBinding
|
||||||
@@ -63,6 +64,10 @@ class HomeMenuFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
_binding = HomeMenuFragmentBinding.inflate(inflater, container, false)
|
_binding = HomeMenuFragmentBinding.inflate(inflater, container, false)
|
||||||
|
ImmersionBar.with(this)
|
||||||
|
.statusBarDarkFont(true)
|
||||||
|
.titleBar(binding.main)
|
||||||
|
.init()
|
||||||
initView()
|
initView()
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import com.example.defenseapplication.adapter.MessageListAdapter
|
|||||||
import com.example.defenseapplication.adapter.MessageListItem
|
import com.example.defenseapplication.adapter.MessageListItem
|
||||||
import com.example.defenseapplication.databinding.MessageActivityBinding
|
import com.example.defenseapplication.databinding.MessageActivityBinding
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
//消息通知页面
|
||||||
class MessageActivity : AppCompatActivity() {
|
class MessageActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: MessageActivityBinding
|
private lateinit var binding: MessageActivityBinding
|
||||||
private val messageAdapter by lazy { MessageListAdapter() }
|
private val messageAdapter by lazy { MessageListAdapter() }
|
||||||
|
|||||||
@@ -24,13 +24,11 @@ class PersonalFragment : Fragment() {
|
|||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
|
_binding = PersonalFragmentBinding.inflate(inflater, container, false)
|
||||||
ImmersionBar.with(this)
|
ImmersionBar.with(this)
|
||||||
.statusBarDarkFont(true)
|
.statusBarDarkFont(true)
|
||||||
.titleBar(binding.headerLayout)
|
.titleBar(binding.headerLayout)
|
||||||
.init()
|
.init()
|
||||||
|
|
||||||
_binding = PersonalFragmentBinding.inflate(inflater, container, false)
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(R.drawable.img)
|
.load(R.drawable.img)
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.google.zxing.*
|
|||||||
import com.google.zxing.common.HybridBinarizer
|
import com.google.zxing.common.HybridBinarizer
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
//扫一扫页面
|
||||||
class ScanActivity : AppCompatActivity(), SurfaceHolder.Callback {
|
class ScanActivity : AppCompatActivity(), SurfaceHolder.Callback {
|
||||||
|
|
||||||
private lateinit var binding: ScanActivityBinding
|
private lateinit var binding: ScanActivityBinding
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import android.os.Bundle
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.defenseapplication.databinding.SetNameActivityBinding
|
import com.example.defenseapplication.databinding.SetNameActivityBinding
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
//设置名字页面
|
||||||
class SetNameActivity : AppCompatActivity() {
|
class SetNameActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: SetNameActivityBinding
|
private lateinit var binding: SetNameActivityBinding
|
||||||
|
|||||||
BIN
app/src/main/res/drawable/connected_successfully.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/main/res/drawable/device1.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
app/src/main/res/drawable/device2.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
app/src/main/res/drawable/device3.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
7
app/src/main/res/drawable/device_frame_animation.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:oneshot="false">
|
||||||
|
<item android:drawable="@drawable/device1" android:duration="200" />
|
||||||
|
<item android:drawable="@drawable/device2" android:duration="200" />
|
||||||
|
<item android:drawable="@drawable/device3" android:duration="200" />
|
||||||
|
</animation-list>
|
||||||
16
app/src/main/res/drawable/device_wifi_animation.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:oneshot="false">
|
||||||
|
<item android:drawable="@drawable/img_add_dev_aini_1" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_add_dev_aini_2" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_add_dev_aini_3" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_add_dev_aini_2" android:duration="500"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_phone1" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_phone2" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_phone3" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_phone1" android:duration="500"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_wifi1" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_wifi2" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_wifi3" android:duration="200"/>
|
||||||
|
<item android:drawable="@drawable/img_connect_anim_wifi1" android:duration="500"/>
|
||||||
|
</animation-list>
|
||||||
BIN
app/src/main/res/drawable/img_add_dev_aini_1.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
app/src/main/res/drawable/img_add_dev_aini_2.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
app/src/main/res/drawable/img_add_dev_aini_3.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
app/src/main/res/drawable/img_connect_anim_phone1.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
app/src/main/res/drawable/img_connect_anim_phone2.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
app/src/main/res/drawable/img_connect_anim_phone3.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
app/src/main/res/drawable/img_connect_anim_wifi1.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
app/src/main/res/drawable/img_connect_anim_wifi2.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
app/src/main/res/drawable/img_connect_anim_wifi3.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
@@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/white"
|
android:background="@color/message_bg"
|
||||||
tools:context=".home.AddDeviceActivity">
|
tools:context=".home.AddDeviceActivity">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@@ -77,18 +77,19 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp">
|
android:layout_marginTop="16dp">
|
||||||
|
<!--动画层 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/emptyState"
|
android:id="@+id/animationContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:visibility="visible"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivEmpty"
|
android:id="@+id/ivScanAnimation"
|
||||||
android:layout_width="150dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="150dp"
|
android:layout_height="260dp"
|
||||||
android:src="@drawable/add_d" />
|
android:src="@drawable/add_d" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -100,7 +101,7 @@
|
|||||||
android:textColor="@color/gray"
|
android:textColor="@color/gray"
|
||||||
android:textSize="14dp" />
|
android:textSize="14dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<!-- 初始隐藏 -->
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rvDevices"
|
android:id="@+id/rvDevices"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -131,6 +131,7 @@
|
|||||||
android:id="@+id/btnConfirm"
|
android:id="@+id/btnConfirm"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginBottom="40dp"
|
||||||
android:background="@drawable/rounded_blue_bg"
|
android:background="@drawable/rounded_blue_bg"
|
||||||
android:text="@string/next_step"
|
android:text="@string/next_step"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
|||||||
100
app/src/main/res/layout/connect_device_activity.xml
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/white"
|
||||||
|
tools:context=".home.ConnectDeviceActivity">
|
||||||
|
|
||||||
|
<!-- 标题栏 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/topBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingHorizontal="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivBack"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/back" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/connect_device"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_below="@id/topBar">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivAnimation"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="333dp"
|
||||||
|
android:layout_marginTop="48dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvStepText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:textSize="14dp"
|
||||||
|
android:textColor="@color/gray" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvHint"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:textSize="14dp"
|
||||||
|
android:textColor="@color/gray"
|
||||||
|
android:gravity="center" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvDeviceName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:textSize="14dp"
|
||||||
|
android:textColor="@color/gray"
|
||||||
|
android:gravity="center" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:gravity="center"
|
||||||
|
android:id="@+id/successLayout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/successImage"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:src="@drawable/connected_successfully" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:id="@+id/successText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="连接成功"
|
||||||
|
android:textSize="16dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout >
|
||||||
@@ -75,7 +75,8 @@
|
|||||||
<android.widget.Button
|
<android.widget.Button
|
||||||
android:id="@+id/btnConfirm"
|
android:id="@+id/btnConfirm"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginBottom="40dp"
|
||||||
android:background="@drawable/rounded_blue_bg"
|
android:background="@drawable/rounded_blue_bg"
|
||||||
android:text="@string/complete"
|
android:text="@string/complete"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
|||||||
@@ -234,6 +234,7 @@
|
|||||||
<string name="connecting">连接中...</string>
|
<string name="connecting">连接中...</string>
|
||||||
<string name="wifi_connection_failed">WiFi连接失败</string>
|
<string name="wifi_connection_failed">WiFi连接失败</string>
|
||||||
<string name="wifi_connection_success">WiFi连接成功</string>
|
<string name="wifi_connection_success">WiFi连接成功</string>
|
||||||
|
<string name="connect_device">连接设备</string>
|
||||||
|
|
||||||
<!-- Dialog -->
|
<!-- Dialog -->
|
||||||
<string name="tip">提示</string>
|
<string name="tip">提示</string>
|
||||||
|
|||||||
@@ -207,6 +207,7 @@
|
|||||||
<string name="connecting">Connecting...</string>
|
<string name="connecting">Connecting...</string>
|
||||||
<string name="wifi_connection_failed">WiFi Connection failed</string>
|
<string name="wifi_connection_failed">WiFi Connection failed</string>
|
||||||
<string name="wifi_connection_success">WiFi Connected successfully</string>
|
<string name="wifi_connection_success">WiFi Connected successfully</string>
|
||||||
|
<string name="connect_device">Connect Device</string>
|
||||||
|
|
||||||
<!-- Dialog -->
|
<!-- Dialog -->
|
||||||
<string name="tip">Tip</string>
|
<string name="tip">Tip</string>
|
||||||
|
|||||||