[状态栏]修正展示崩溃;乘客屏不展示状态栏;修正小红点逻辑
This commit is contained in:
@@ -144,13 +144,13 @@ fun Context.enqueuePop(content: View, width: Int, height: Int, key: String = "",
|
||||
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
fun Context.normalPop(content: View, width: Int, height: Int, key: String = "", startX: Int = 0, startY: Int = 0, gravity: Int = Gravity.START, onOuterViewClicked:((focus: View) -> Unit)? = null, isFocusable: Boolean = true): () -> Unit {
|
||||
fun Context.normalPop(content: View, width: Int, height: Int, startX: Int = 0, startY: Int = 0, gravity: Int = Gravity.START, onOuterViewClicked:((focus: View) -> Unit)? = null, isFocusable: Boolean = true): () -> Unit {
|
||||
val activity = (this as? FragmentActivity) ?: throw IllegalStateException("please use Activity to trigger pop show.")
|
||||
val isImmersiveMode = BarUtils.isImmersiveMode(activity)
|
||||
var tempPop: PopupWindow? = null
|
||||
activity.lifecycleScope.launchWhenResumed {
|
||||
val decorView = activity.window.decorView
|
||||
val pop = PopupWindow(width, height).also {
|
||||
tempPop = it
|
||||
it.isOutsideTouchable = true
|
||||
it.isTouchable = true
|
||||
it.isFocusable = isFocusable
|
||||
@@ -166,7 +166,6 @@ fun Context.normalPop(content: View, width: Int, height: Int, key: String = "",
|
||||
if (out.contains(event.x.toInt(), event.y.toInt()) && isVisibleOnPoint(content, event.x.toInt(), event.y.toInt())) {
|
||||
return@setTouchInterceptor false
|
||||
}
|
||||
|
||||
when(event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
x = event.x
|
||||
@@ -187,7 +186,7 @@ fun Context.normalPop(content: View, width: Int, height: Int, key: String = "",
|
||||
try {
|
||||
return@setTouchInterceptor true
|
||||
} finally {
|
||||
activity.window.decorView.dispatchTouchEvent(event)
|
||||
decorView.dispatchTouchEvent(event)
|
||||
}
|
||||
}
|
||||
it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
@@ -201,7 +200,14 @@ fun Context.normalPop(content: View, width: Int, height: Int, key: String = "",
|
||||
pop.exitTransition = transition
|
||||
}
|
||||
pop.contentView = content
|
||||
pop.showAtLocation(activity.window.decorView, gravity, startX, if (isImmersiveMode) 0 else BarUtils.getStatusBarHeight() + startY)
|
||||
decorView.doOnAttach {
|
||||
try {
|
||||
pop.showAtLocation(it, gravity, startX, if (isImmersiveMode) 0 else BarUtils.getStatusBarHeight() + startY)
|
||||
tempPop = pop
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
tempPop?.takeIf { it.isShowing }?.dismiss()
|
||||
|
||||
@@ -121,7 +121,7 @@ internal class CanStatus(var enabled: Boolean = false): Status() {
|
||||
/**
|
||||
* 寻迹/算路/未知
|
||||
*/
|
||||
internal class TracingStatus(var state: Tracing): Status() {
|
||||
internal class TracingStatus(var state: Tracing = UNKNOWN): Status() {
|
||||
|
||||
enum class Tracing(val code: String? = "") {
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ internal class CanImpl(ctx: Context): IFlow<CanStatus>(ctx), IMoGoAutopilotVehic
|
||||
private fun timeOutCheck() {
|
||||
job?.safeCancel()
|
||||
launch(Dispatchers.Default) {
|
||||
delay(1000)
|
||||
delay(4000)
|
||||
send(CanStatus(false))
|
||||
}.also { job = it }
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.nets
|
||||
|
||||
import android.*
|
||||
import android.content.*
|
||||
import android.location.*
|
||||
import android.net.*
|
||||
import android.net.wifi.*
|
||||
import android.os.Build.VERSION
|
||||
import android.os.Build.VERSION_CODES
|
||||
import android.util.*
|
||||
import androidx.core.location.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.NetStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.NetStatus.Speed
|
||||
@@ -90,7 +94,7 @@ internal class NetsImpl(ctx: Context): IFlow<NetStatus>(ctx) {
|
||||
private fun checkAndSend() {
|
||||
val connectionInfo = wifiMgr.connectionInfo
|
||||
val enabled = isNetConnected()
|
||||
val name = connectionInfo.ssid?.replace(Regex("[\\W]"), "")
|
||||
val name = if (isLocationEnabled()) connectionInfo.ssid?.replace(Regex("[\\W]"), "") else "Wi-Fi"
|
||||
loopCheckAndSendJob?.safeCancel()
|
||||
launch(Dispatchers.Default) { delay(1000); checkAndSend() }.also { loopCheckAndSendJob = it }
|
||||
var tr = 0
|
||||
@@ -106,6 +110,9 @@ internal class NetsImpl(ctx: Context): IFlow<NetStatus>(ctx) {
|
||||
send(enabled, name, speed)
|
||||
}
|
||||
|
||||
private fun isLocationEnabled() =
|
||||
LocationManagerCompat.isLocationEnabled(ctx.getSystemService(Context.LOCATION_SERVICE) as LocationManager) && PermissionUtils.isGranted(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
|
||||
|
||||
private fun isNetConnected(): Boolean =
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
||||
@@ -127,6 +134,5 @@ internal class NetsImpl(ctx: Context): IFlow<NetStatus>(ctx) {
|
||||
connectMgr.unregisterNetworkCallback(cb)
|
||||
}
|
||||
loopCheckAndSendJob?.safeCancel()
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,32 +4,58 @@ import android.content.*
|
||||
import android.util.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RTKStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import kotlinx.coroutines.*
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
|
||||
internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotCarStateListener {
|
||||
internal class RTKImpl(ctx: Context): IFlow<RTKStatus>(ctx), IMoGoAutopilotCarStateListener, IMoGoAutopilotStatusListener {
|
||||
companion object {
|
||||
const val TAG = "RTKImpl"
|
||||
}
|
||||
|
||||
private var job: Job? = null
|
||||
|
||||
override fun onCreate() {
|
||||
send(RTKStatus(isRTKEnabled()))
|
||||
Log.d(TAG, "-- onCreate --")
|
||||
CallerAutopilotCarStatusListenerManager.addListener(TAG, this)
|
||||
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun isRTKEnabled() =
|
||||
CallerAutoPilotManager.isConnected() && CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode() != "EHW_RTK" && CallerAutopilotCarStatusListenerManager.getCurrentGnssInfo() != null
|
||||
|
||||
override fun onAutopilotCarStateData(gnssInfo: GnssInfo?) {
|
||||
Log.d(TAG, "-- onAutopilotCarStateData --")
|
||||
send(RTKStatus(isRTKEnabled()))
|
||||
timeOutCheck()
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
if (!CallerAutoPilotManager.isConnected()) {
|
||||
send(RTKStatus(false))
|
||||
}
|
||||
}
|
||||
|
||||
private fun timeOutCheck() {
|
||||
job?.safeCancel()
|
||||
launch(Dispatchers.Default) {
|
||||
delay(4000)
|
||||
send(RTKStatus(false))
|
||||
}.also { job = it }
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Log.d(TAG, "-- onDestroy --")
|
||||
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
|
||||
try {
|
||||
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
} finally {
|
||||
job?.safeCancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
|
||||
|
||||
override fun onCreate() {
|
||||
Log.d(TAG, "-- onCreate --")
|
||||
val autoPilotReportMessageCode = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode()
|
||||
old = autoPilotReportMessageCode
|
||||
send(TracingStatus(autoPilotReportMessageCode.toState()))
|
||||
val code = CallerAutoPilotStatusListenerManager.getAutoPilotReportMessageCode()
|
||||
old = code
|
||||
send(TracingStatus(code.toState()))
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ internal class StatusModel : ViewModel() {
|
||||
synchronized(old) {
|
||||
val v = old.get()?.second ?: status.value?.second ?: throw IllegalStateException("live data can't be null.")
|
||||
val nv = ArrayList(v).also { it.updateOrInsert(s) }
|
||||
fixData(nv)
|
||||
val data = Pair(getExceptionStatus(nv), nv)
|
||||
old.set(data)
|
||||
Log.d(TAG, "status: $s")
|
||||
@@ -51,40 +50,6 @@ internal class StatusModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun fixData(data: ArrayList<Status>) {
|
||||
var netStatus: NetStatus? = null
|
||||
var gpsStatus: GpsStatus? = null
|
||||
for (d in data) {
|
||||
if (d is NetStatus) {
|
||||
netStatus = d
|
||||
}
|
||||
if (d is GpsStatus) {
|
||||
gpsStatus = d
|
||||
}
|
||||
}
|
||||
|
||||
if (netStatus != null && !netStatus.enabled) {
|
||||
for (i in data) {
|
||||
when(i) {
|
||||
is RTKStatus ->
|
||||
i.enabled = false
|
||||
is CanStatus ->
|
||||
i.enabled = false
|
||||
is TracingStatus ->
|
||||
i.state = UNKNOWN
|
||||
else -> continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (netStatus != null && gpsStatus != null) {
|
||||
val wifiName = netStatus.name
|
||||
if (!gpsStatus.enabled || !gpsStatus.isGranted || wifiName != null && wifiName.startsWith("unknow")) {
|
||||
netStatus.name = "Wi-Fi"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getExceptionStatus(l: ArrayList<Status>): Status? {
|
||||
var ret: Status? = null
|
||||
for (s in l) {
|
||||
@@ -118,9 +83,7 @@ internal class StatusModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
is TracingStatus -> {
|
||||
if (CallerAutoPilotManager.isConnected() &&
|
||||
(CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().pilotmode == 1) &&
|
||||
s.state.isException()) {
|
||||
if (CallerAutoPilotManager.isConnected() && (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().pilotmode == 1) && s.state.isException()) {
|
||||
s
|
||||
} else {
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user