feat(app): 重构应用为发盘机app,界面布局优化、移除无用代码

- 将应用名称从 SmartPlateCabinet 更改为 SmartTakePlate
- 更新初始化页面背景图片为 bg_collect_page3
- 替换 View 组件为 Space 组件以优化布局权重分配
- 调整取盘按钮尺寸和文字大小提升用户体验
- 简化人脸识别登录页面布局结构
- 更新应用图标资源为 logo_launcher
- 移除未使用的权限声明和活动注册
- 优化人脸识别相关 API 接口调用
- 调整时间显示逻辑仅保留时间部分
- 移除扫描枪事件监听相关功能代码
- 重构人脸识别数据更新逻辑
- 移除余额不足对话框相关代码
This commit is contained in:
2026-03-27 15:48:04 +08:00
parent 86c3c07e42
commit 7d2bf08023
51 changed files with 1413 additions and 3255 deletions
@@ -28,10 +28,10 @@ object DateTimeUtils {
}
/**
* 获取带时间的完整中文格式(示例:2025年6月11日 星期三 14:30
* 获取带时间的完整中文格式(示例:2025年06月11日 星期三 14:30
*/
fun getChineseDateTimeString(date: Date = Date()): String {
return SimpleDateFormat("yyyy年Md日 EEEE HH:mm:ss", Locale.CHINA).format(date)
return SimpleDateFormat("yyyy年MM月dd日 EEEE HH:mm", Locale.CHINA).format(date)
}
// 使用线程安全的日期格式化(避免 SimpleDateFormat 的线程安全问题)
@@ -52,7 +52,7 @@ object DateTimeUtils {
*/
fun realTimeChineseDateFlow(intervalMillis: Long = 1000) = flow {
while (true) {
emit(getChineseDateTimePair())
emit(getChineseDateTimeString())
delay(intervalMillis)
}
}
@@ -1,88 +1,88 @@
package com.sw.platecabinet.utils
import com.sw.platecabinet.model.response.EquipmentUserInfo
import timber.log.Timber
import kotlin.math.ceil
/**
* 列表排序工具类
*/
object ListArrangementUtil {
/**
* page item水平排序
*/
fun horizontalSortPageItem(
list: List<EquipmentUserInfo>,
columns: Int,
defaultValue: EquipmentUserInfo = EquipmentUserInfo()
): List<EquipmentUserInfo> {
Timber.d("horizontalSortPageItem")
require(columns > 0) { "Columns must be positive" }
val filledList = list.padToMultiple(columns, defaultValue)
val chunks = filledList.chunked(columns)
return (0 until columns)
.windowed(2, 2, partialWindows = true)
.flatMap { group ->
when (group.size) {
2 -> chunks.flatMap { listOf(it[group[0]], it[group[1]]) }
1 -> chunks.flatMap {
listOf(it[group[0]], EquipmentUserInfo(equipmentBoxCode = null))
}.dropLast(1)
else -> error("Unexpected group size")
}
}
}
/**
* item 垂直排序
*/
fun verticalSortItem(list: List<EquipmentUserInfo>): List<EquipmentUserInfo> {
Timber.d("verticalSortItem")
val users = list.padToEvenSize()
val half = users.size / 2
return users.take(half)
.zip(users.drop(half)) { a, b -> listOf(a, b) }
.flatten()
}
/**
* page item垂直排序
*/
fun convertToColumnFirst(
original: List<EquipmentUserInfo>,
cols: Int
): List<EquipmentUserInfo> {
Timber.d("convertToColumnFirst")
require(cols > 0) { "Columns must be positive" }
val rows = ceil(original.size.toDouble() / cols).toInt()
return List(original.size) { pos ->
original.getOrNull(pos % rows * cols + pos / rows) ?: EquipmentUserInfo()
}
}
// 提取的扩展函数
private fun List<EquipmentUserInfo>.padToMultiple(
multiple: Int,
defaultValue: EquipmentUserInfo
): List<EquipmentUserInfo> {
return if (size % multiple != 0) {
this + List(multiple - (size % multiple)) { defaultValue }
} else {
this
}
}
private fun List<EquipmentUserInfo>.padToEvenSize(): List<EquipmentUserInfo> {
return if (size % 2 != 0) {
Timber.d("列表长度必须是偶数")
this + EquipmentUserInfo()
} else {
this
}
}
}
//package com.sw.platecabinet.utils
//
//import com.sw.platecabinet.model.response.EquipmentUserInfo
//import timber.log.Timber
//import kotlin.math.ceil
//
///**
// * 列表排序工具类
// */
//object ListArrangementUtil {
//
// /**
// * page item水平排序
// */
// fun horizontalSortPageItem(
// list: List<EquipmentUserInfo>,
// columns: Int,
// defaultValue: EquipmentUserInfo = EquipmentUserInfo()
// ): List<EquipmentUserInfo> {
// Timber.d("horizontalSortPageItem")
// require(columns > 0) { "Columns must be positive" }
//
// val filledList = list.padToMultiple(columns, defaultValue)
// val chunks = filledList.chunked(columns)
//
// return (0 until columns)
// .windowed(2, 2, partialWindows = true)
// .flatMap { group ->
// when (group.size) {
// 2 -> chunks.flatMap { listOf(it[group[0]], it[group[1]]) }
// 1 -> chunks.flatMap {
// listOf(it[group[0]], EquipmentUserInfo(equipmentBoxCode = null))
// }.dropLast(1)
// else -> error("Unexpected group size")
// }
// }
// }
//
// /**
// * item 垂直排序
// */
// fun verticalSortItem(list: List<EquipmentUserInfo>): List<EquipmentUserInfo> {
// Timber.d("verticalSortItem")
// val users = list.padToEvenSize()
// val half = users.size / 2
//
// return users.take(half)
// .zip(users.drop(half)) { a, b -> listOf(a, b) }
// .flatten()
// }
//
// /**
// * page item垂直排序
// */
// fun convertToColumnFirst(
// original: List<EquipmentUserInfo>,
// cols: Int
// ): List<EquipmentUserInfo> {
// Timber.d("convertToColumnFirst")
// require(cols > 0) { "Columns must be positive" }
//
// val rows = ceil(original.size.toDouble() / cols).toInt()
// return List(original.size) { pos ->
// original.getOrNull(pos % rows * cols + pos / rows) ?: EquipmentUserInfo()
// }
// }
//
// // 提取的扩展函数
// private fun List<EquipmentUserInfo>.padToMultiple(
// multiple: Int,
// defaultValue: EquipmentUserInfo
// ): List<EquipmentUserInfo> {
// return if (size % multiple != 0) {
// this + List(multiple - (size % multiple)) { defaultValue }
// } else {
// this
// }
// }
//
// private fun List<EquipmentUserInfo>.padToEvenSize(): List<EquipmentUserInfo> {
// return if (size % 2 != 0) {
// Timber.d("列表长度必须是偶数")
// this + EquipmentUserInfo()
// } else {
// this
// }
// }
//}
@@ -77,11 +77,7 @@ class PermissionHelper private constructor(
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
data = Uri.fromParts("package", context.packageName, null)
}
if (context is Activity) {
context.startActivity(intent)
} else if (context is Fragment) {
context.startActivity(intent)
}
context.startActivity(intent)
}
}
@@ -1,13 +1,7 @@
package com.sw.platecabinet.utils
import androidx.fragment.app.FragmentActivity
import com.sw.plate.utils.ToastUtils
import com.sw.plate.utils.comn.SerialApi
import com.sw.plate.utils.comn.SerialPortManager
import com.sw.platecabinet.activity.BaseActivity
import com.sw.platecabinet.activity.MainActivity
import com.sw.platecabinet.activity.PageType
import timber.log.Timber
object PlateUtils {
@@ -19,48 +13,54 @@ object PlateUtils {
callback: () -> Unit = {}
) {
val activity = fragmentActivity as BaseActivity<*>
Timber.d("itemClick llOpen equipmentBoxCode = ${code}")
val equipmentBoxCode: Int = code?.toInt() ?: -1
if (equipmentBoxCode < 0) {
ToastUtils.showToast("餐盘柜编号错误")
return
}
activity.showWaitingDialog("请稍等")
SerialApi.openPlate(equipmentBoxCode, object : SerialPortManager.SendCallback {
override fun onSuccess() {
activity.hideWaitingDialog()
if (isSetting.not()) {
MainActivity.start(
activity,
pageType = PageType.PLATE_TIP,
isScanCode = isScanCode
)
} else {
ToastUtils.showToast("柜门打开成功")
callback()
}
}
override fun onFail(e: Exception?) {
activity.hideWaitingDialog()
ToastUtils.showToast("柜门打开失败")
callback()
}
})
activity.window.decorView.postDelayed({
callback()
}, 1500)
// activity.showWaitingDialog("请稍等")
// Timber.d("itemClick llOpen equipmentBoxCode = ${code}")
// val equipmentBoxCode: Int = code?.toInt() ?: -1
// if (equipmentBoxCode < 0) {
// ToastUtils.showToast("餐盘柜编号错误")
// return
// }
// activity.showWaitingDialog("请稍等")
// SerialApi.openPlate(equipmentBoxCode, object : SerialPortManager.SendCallback {
// override fun onSuccess() {
// activity.hideWaitingDialog()
// if (isSetting.not()) {
// MainActivity.start(
// activity,
// pageType = PageType.PLATE_TIP,
// isScanCode = isScanCode
// )
// } else {
// ToastUtils.showToast("柜门打开成功")
// callback()
// }
// }
//
// override fun onFail(e: Exception?) {
// activity.hideWaitingDialog()
// ToastUtils.showToast("柜门打开失败")
// callback()
// }
// })
}
fun openDirect(boxCode: String?) {
val boxNumber = boxCode?.toIntOrNull() ?: -1
if (boxNumber < 0) return
SerialApi.openPlate(boxNumber, object : SerialPortManager.SendCallback {
override fun onSuccess() {
}
override fun onFail(e: Exception?) {
}
})
}
// fun openDirect(boxCode: String?) {
// val boxNumber = boxCode?.toIntOrNull() ?: -1
// if (boxNumber < 0) return
// SerialApi.openPlate(boxNumber, object : SerialPortManager.SendCallback {
// override fun onSuccess() {
//
// }
//
// override fun onFail(e: Exception?) {
//
// }
// })
// }
}
@@ -1,12 +1,8 @@
package com.sw.platecabinet.utils
import com.google.gson.Gson
import com.sw.inbound.utils.GsonUtils
import com.sw.inbound.utils.SPUtil
import com.sw.inbound.utils.SPUtil.Companion.getInstance
import com.sw.platecabinet.MyApp
import com.sw.platecabinet.model.response.EquipmentUserInfo
import kotlin.text.get
object SpTool {
const val LAST_FACE_TIMESTAMP: String = "faceTimestamp"
@@ -30,18 +26,18 @@ object SpTool {
spUtil?.put(LAST_FACE_TIMESTAMP, timestamp)
}
fun savePlateData(items: List<EquipmentUserInfo>) {
val jsonData = Gson().toJson(items)
putString(PLATE_BOX_DATA, jsonData)
}
fun getPlateData(): List<EquipmentUserInfo>? {
val jsonData = spUtil?.get(PLATE_BOX_DATA, "")
if (jsonData.isNullOrBlank()) {
return null
}
return GsonUtils.fromJsonList(jsonData, EquipmentUserInfo::class.java)
}
// fun savePlateData(items: List<EquipmentUserInfo>) {
// val jsonData = Gson().toJson(items)
// putString(PLATE_BOX_DATA, jsonData)
// }
//
// fun getPlateData(): List<EquipmentUserInfo>? {
// val jsonData = spUtil?.get(PLATE_BOX_DATA, "")
// if (jsonData.isNullOrBlank()) {
// return null
// }
// return GsonUtils.fromJsonList(jsonData, EquipmentUserInfo::class.java)
// }
var firstGetFace: Boolean
get() = spUtil?.get(IS_FIRST_GET_FACE, true)?:true