添加了副屏显示逻辑控制

This commit is contained in:
zxj
2025-08-01 15:57:12 +08:00
parent de4c5f1c75
commit c78279a66e
27 changed files with 817 additions and 191 deletions
@@ -56,7 +56,7 @@ val Float.sp: Float
)
// 添加扩展函数
fun ImageProxy.toBitmap(): Bitmap {
fun ImageProxy.toSafeBitmap(): Bitmap {
val yBuffer = planes[0].buffer // Y
val uBuffer = planes[1].buffer // U
val vBuffer = planes[2].buffer // V
@@ -0,0 +1,37 @@
package com.sw.dualscreen.ext
/**
* 姓名脱敏处理
* 2个字:张*
* 多于2个字:张*某
*/
fun String?.maskName(): String {
if (this == null || this.isEmpty()) return ""
return when {
length == 2 -> "${this[0]}*"
length > 2 -> "${this[0]}*${this[length - 1]}"
else -> this // 1个字的情况原样返回
}
}
/**
* 手机号脱敏处理
* 将第4-7位替换为*
* 例如:138****1234
*/
fun String?.maskPhone(): String {
if (this == null || this.isEmpty()) return ""
if (this.length < 11) {
return this
}
val start = 3 // 第4位(索引从0开始)
val end = 6 // 第7位
val sb = StringBuilder(this)
for (i in start..end) {
sb.setCharAt(i, '*')
}
return sb.toString()
}