Merge branch 'dev_robotaxi-d_230809_6.0.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_robotaxi-d_230809_6.0.0

This commit is contained in:
wangmingjun
2023-08-17 15:13:39 +08:00
34 changed files with 463 additions and 19 deletions

View File

@@ -0,0 +1,71 @@
package com.mogo.och.bus.passenger.ui.lockview
import android.os.Handler
import android.os.HandlerThread
import android.os.Message
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import java.util.concurrent.ConcurrentHashMap
object LockManager {
@Volatile
private var isLock:Boolean = false
private var handler:Handler?=null
private const val TAG = "LockManager"
private var mLockChnageListener = ConcurrentHashMap<String, LockStatusCallback>()
fun startLoop4Lock(){
val frequentThread = HandlerThread("frequent_drawer")
frequentThread.start()
handler = object : Handler(frequentThread.looper) {
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "2分钟没有触摸屏幕导致锁屏")
setLock(true)
}
}
reStartCountDown()
}
fun stopLoop4Lock(){
handler?.looper?.quitSafely()
handler = null
}
fun setAutoStatusCallback(tag: String, callback: LockStatusCallback?) {
if (tag.isBlank()) return
if (callback == null) {
mLockChnageListener.remove(tag)
return
}
mLockChnageListener[tag] = callback
}
fun reStartCountDown(){
handler?.removeMessages(1)
handler?.sendEmptyMessageDelayed(1,120_000)
}
@Synchronized
fun isLocak():Boolean{
CallerLogger.d(TAG,"锁定状态:${isLock}")
return isLock
}
@Synchronized
fun setLock(isLock: Boolean){
if(this.isLock!=isLock){
this.isLock = isLock
mLockChnageListener.forEach {
it.value.lockStatusChange(this.isLock)
}
}
}
interface LockStatusCallback {
fun lockStatusChange(isLock: Boolean)
}
}

View File

@@ -0,0 +1,74 @@
package com.mogo.och.bus.passenger.ui.lockview
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.bus.passenger.R
class LockViewConstrainLayout : ConstraintLayout {
private val TAG = "LockView"
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
context,
attributeSet,
defStyleAttr
)
private var acivScreenLock:UnLockView?=null
override fun onAttachedToWindow() {
super.onAttachedToWindow()
LockManager.startLoop4Lock()
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
LockManager.stopLoop4Lock()
}
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
if (acivScreenLock == null) {
acivScreenLock = findViewById(R.id.aciv_screen_lock)
}
LockManager.reStartCountDown()
var needInterceptTouch = true
acivScreenLock?.apply {
event?.let {
val location = IntArray(2)
getLocationInWindow(location)
CallerLogger.d("LockViewConstrainLayout", "${location[0]}---${location[1]}--${location[0]+width}---${location[1]+height}---${it.rawX}----${it.rawY}")
val mleft = location[0]
val mtop = location[1]
val mright = location[0]+width
val mbottom = location[1]+height
if (it.rawX > mleft && it.rawX < mright && it.rawY > mtop && it.rawY < mbottom) {
// 不拦截
needInterceptTouch = false
CallerLogger.d("LockViewConstrainLayout", "不拦截")
}
}
}
CallerLogger.d("LockViewConstrainLayout", "是否拦截 ${needInterceptTouch}")
return if(needInterceptTouch) {
if(LockManager.isLocak()){
true
}else{
super.onInterceptTouchEvent(event)
}
}else{
false
}
}
}

View File

@@ -0,0 +1,106 @@
package com.mogo.och.bus.passenger.ui.lockview
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.ViewGroup
import android.widget.ImageView
import androidx.appcompat.widget.AppCompatImageView
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.bus.passenger.R
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.taxi.passenger.widget.animutils.AnimationsContainer
import io.reactivex.disposables.Disposable
class UnLockView : AppCompatImageView, LockManager.LockStatusCallback {
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
context,
attributeSet,
defStyleAttr
)
val TAG = "UnLockView"
private var animations: AnimationsContainer?=null
private var aciv_screen_unlock_ani: ImageView?=null
private var unLockDelay: Disposable? = null
private var downType:DownType = DownType.NONE
override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
return super.dispatchTouchEvent(event)
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if (parent is ViewGroup) {
aciv_screen_unlock_ani = (parent as ViewGroup).findViewById(R.id.aciv_screen_unlock_ani)
aciv_screen_unlock_ani?.let {
animations = AnimationsContainer(R.array.openlock,12,it)
animations!!.setOnAnimStopListener(object :AnimationsContainer.OnAnimationStoppedListener{
override fun AnimationStopped() {
it.setImageDrawable(null)
}
})
}
}
LockManager.setAutoStatusCallback(TAG,this)
}
override fun onTouchEvent(event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
if(LockManager.isLocak()){
downType = DownType.LOCK
animations?.reStart()
RxUtils.disposeSubscribe(unLockDelay)
unLockDelay = RxUtils.createSubscribe {
LockManager.setLock(false)
animations?.stop()
}
}else{
downType = DownType.UNLOCK
}
CallerLogger.d(TAG,"ACTION_DOWN")
}
MotionEvent.ACTION_MOVE -> {}
MotionEvent.ACTION_UP -> {
if(downType==DownType.LOCK) {
RxUtils.disposeSubscribe(unLockDelay)
animations?.stop()
}else{
if (!LockManager.isLocak()) {
CallerLogger.d(TAG,"onClick")
LockManager.setLock(true)
}
}
CallerLogger.d(TAG,"ACTION_UP")
}
MotionEvent.ACTION_CANCEL -> {
RxUtils.disposeSubscribe(unLockDelay)
animations?.stop()
CallerLogger.d(TAG,"ACTION_CANCEL")
}
else -> {}
}
return true
}
enum class DownType{
NONE,LOCK,UNLOCK
}
override fun lockStatusChange(isLock: Boolean) {
if(isLock){
setImageResource(R.drawable.charter_p_lock)
}else{
setImageResource(R.drawable.charter_p_unlock)
}
}
}

View File

@@ -33,15 +33,6 @@ class OrderInfoView : ConstraintLayout, OrderInfoViewModel.ItineraryViewCallback
defStyleAttr
)
constructor(
context: Context,
attributeSet: AttributeSet,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attributeSet, defStyleAttr, defStyleRes){
initView()
}
var goneViewListener: IClearViewCallback?=null
var viewModel:OrderInfoViewModel?=null

View File

@@ -0,0 +1,152 @@
package com.mogo.och.taxi.passenger.widget.animutils
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.drawable.BitmapDrawable
import android.os.Handler
import android.os.Looper
import android.widget.ImageView
import com.mogo.commons.AbsMogoApplication
import java.lang.ref.SoftReference
class AnimationsContainer(resId: Int, fps: Int, imageView: ImageView) {
private lateinit var mFrames: IntArray // 帧数组
private var mIndex = 0 // 当前帧
private var mShouldRun = false // 开始/停止播放用
private var mIsRunning = false // 动画是否正在播放,防止重复播放
private var mSoftReferenceImageView: SoftReference<ImageView>? = null // 软引用ImageView以便及时释放掉
private var mHandler: Handler? = null
private var mDelayMillis = 0
private var mOnAnimationStoppedListener: OnAnimationStoppedListener? = null//播放停止监听
private var mBitmap: Bitmap? = null
private var mBitmapOptions: BitmapFactory.Options? = null //Bitmap管理类可有效减少Bitmap的OOM问题
init {
createAnimation(imageView, getData(resId), fps)
}
private fun createAnimation(imageView: ImageView, frames: IntArray, fps: Int) {
mHandler = Handler(Looper.myLooper()!!)
mFrames = frames
mIndex = -1
mSoftReferenceImageView = SoftReference(imageView)
mShouldRun = false
mIsRunning = false
mDelayMillis = 1000 / fps //帧动画时间间隔,毫秒
imageView.setImageResource(mFrames[0])
// 当图片大小类型相同时进行复用避免频繁GC
val bmp = (imageView.drawable as BitmapDrawable).bitmap
val width = bmp.width
val height = bmp.height
val config = bmp.config
mBitmap = Bitmap.createBitmap(width, height, config)
mBitmapOptions = BitmapFactory.Options()
//设置Bitmap内存复用
mBitmapOptions!!.inBitmap = mBitmap //Bitmap复用内存块类似对象池避免不必要的内存分配和回收
mBitmapOptions!!.inMutable = true //解码时返回可变Bitmap
mBitmapOptions!!.inSampleSize = 1 //缩放比例
}
//循环读取下一帧
private val next: Int
get() {
mIndex++
if (mIndex >= mFrames.size) mIndex = 0
return mFrames[mIndex]
}
@Synchronized
fun reStart(){
mIndex = 0
start()
}
/**
* 播放动画,同步锁防止多线程读帧时,数据安全问题
*/
@Synchronized
fun start() {
mShouldRun = true
if (mIsRunning) return
val runnable: Runnable = object : Runnable {
override fun run() {
val imageView = mSoftReferenceImageView!!.get()
if (!mShouldRun || imageView == null) {
mIsRunning = false
if (mOnAnimationStoppedListener != null) {
mOnAnimationStoppedListener!!.AnimationStopped()
}
return
}
mIsRunning = true
//新开线程去读下一帧
mHandler!!.postDelayed(this, mDelayMillis.toLong())
if (imageView.isShown) {
val imageRes: Int = next
if (mBitmap != null) { // so Build.VERSION.SDK_INT >= 11
var bitmap: Bitmap? = null
try {
bitmap = BitmapFactory.decodeResource(
imageView.resources,
imageRes,
mBitmapOptions
)
} catch (e: Exception) {
e.printStackTrace()
}
if (bitmap != null) {
imageView.setImageBitmap(bitmap)
} else {
imageView.setImageResource(imageRes)
mBitmap!!.recycle()
mBitmap = null
}
} else {
imageView.setImageResource(imageRes)
}
}
}
}
mHandler!!.post(runnable)
}
/**
* 停止播放
*/
@Synchronized
fun stop() {
mShouldRun = false
}
/**
* 设置停止播放监听
* @param listener 设置监听
*/
fun setOnAnimStopListener(listener: OnAnimationStoppedListener?) {
mOnAnimationStoppedListener = listener
}
/**
* 从xml中读取帧数组
* @param resId
* @return
*/
private fun getData(resId: Int): IntArray {
val array = AbsMogoApplication.getApp().resources.obtainTypedArray(resId)
val len = array.length()
val intArray = IntArray(array.length())
for (i in 0 until len) {
intArray[i] = array.getResourceId(i, 0)
}
array.recycle()
return intArray
}
/**
* 停止播放监听
*/
interface OnAnimationStoppedListener {
fun AnimationStopped()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.mogo.och.bus.passenger.ui.lockview.LockViewConstrainLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -40,14 +40,33 @@
app:layout_constraintBottom_toTopOf="@+id/bb_boorombar"
app:layout_constraintEnd_toEndOf="parent" />
<!--V2X预警红色边框-->
<com.mogo.eagle.core.function.hmi.ui.widget.V2XWarningView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/aciv_screen_lock_bg"
android:layout_width="@dimen/dp_138"
android:layout_height="@dimen/dp_138"
android:src="@drawable/charter_p_lock_bg"
app:layout_constraintBottom_toTopOf="@+id/aciv_map_2_default"
app:layout_constraintEnd_toEndOf="parent" />
<com.mogo.och.bus.passenger.ui.lockview.UnLockView
android:id="@+id/aciv_screen_lock"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:src="@drawable/charter_p_unlock"
app:layout_constraintTop_toTopOf="@+id/aciv_screen_lock_bg"
app:layout_constraintBottom_toBottomOf="@+id/aciv_screen_lock_bg"
app:layout_constraintStart_toStartOf="@+id/aciv_screen_lock_bg"
app:layout_constraintEnd_toEndOf="@+id/aciv_screen_lock_bg"
/>
<ImageView
android:id="@+id/aciv_screen_unlock_ani"
android:layout_width="@dimen/dp_90"
android:layout_height="@dimen/dp_90"
app:layout_constraintTop_toTopOf="@+id/aciv_screen_lock_bg"
app:layout_constraintBottom_toBottomOf="@+id/aciv_screen_lock_bg"
app:layout_constraintStart_toStartOf="@+id/aciv_screen_lock_bg"
app:layout_constraintEnd_toEndOf="@+id/aciv_screen_lock_bg" />
<!--pnc行为决策-->
<com.mogo.eagle.core.function.hmi.ui.vehicle.PncActionsView
@@ -153,4 +172,4 @@
app:layout_constraintEnd_toEndOf="@+id/mapBizView"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.mogo.och.bus.passenger.ui.lockview.LockViewConstrainLayout>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="openlock">
<item>@drawable/open_lock_000</item>
<item>@drawable/open_lock_001</item>
<item>@drawable/open_lock_002</item>
<item>@drawable/open_lock_003</item>
<item>@drawable/open_lock_004</item>
<item>@drawable/open_lock_005</item>
<item>@drawable/open_lock_006</item>
<item>@drawable/open_lock_007</item>
<item>@drawable/open_lock_008</item>
<item>@drawable/open_lock_009</item>
<item>@drawable/open_lock_010</item>
<item>@drawable/open_lock_011</item>
<item>@drawable/open_lock_012</item>
<item>@drawable/open_lock_013</item>
<item>@drawable/open_lock_014</item>
<item>@drawable/open_lock_015</item>
<item>@drawable/open_lock_016</item>
<item>@drawable/open_lock_017</item>
<item>@drawable/open_lock_018</item>
<item>@drawable/open_lock_019</item>
<item>@drawable/open_lock_020</item>
<item>@drawable/open_lock_021</item>
<item>@drawable/open_lock_022</item>
<item>@drawable/open_lock_023</item>
</string-array>
</resources>