diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt
index fd8669a978..fabda1fd41 100644
--- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt
+++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt
@@ -4,11 +4,17 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
+import android.text.SpannableString
+import android.text.Spanned
+import android.text.method.ScrollingMovementMethod
+import android.text.style.ForegroundColorSpan
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
+import android.widget.TextView
import androidx.localbroadcastmanager.content.LocalBroadcastManager
+import com.mogo.eagle.core.function.main.MainMoGoApplication
import com.mogo.eagle.core.network.utils.GsonUtil
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.och.common.module.utils.DateTimeUtil
@@ -28,6 +34,7 @@ import kotlinx.android.synthetic.main.taxi_debug_order.view.currentOrderStopInfo
import kotlinx.android.synthetic.main.taxi_debug_order.view.currentOrderTrajectoryInfo
import kotlinx.android.synthetic.main.taxi_debug_order.view.currentStatus
import kotlinx.android.synthetic.main.taxi_debug_order.view.currentTaskType
+import kotlinx.android.synthetic.main.taxi_debug_order.view.debugLogHistoryTextView
import kotlinx.android.synthetic.main.taxi_debug_order.view.orderEndSiteInfo
import kotlinx.android.synthetic.main.taxi_debug_order.view.orderNo
import kotlinx.android.synthetic.main.taxi_debug_order.view.orderPreLoadLines
@@ -36,16 +43,52 @@ import kotlinx.android.synthetic.main.taxi_debug_order.view.orderStatus
import kotlinx.android.synthetic.main.taxi_debug_order.view.taskEndSite
import kotlinx.android.synthetic.main.taxi_debug_order.view.taskStartSite
+
public class DebugView @JvmOverloads constructor(
- context: Context,
- attrs: AttributeSet? = null,
- defStyleAttr: Int = 0,
- defStyleRes: Int = 0
+ context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0
) : LinearLayout(context, attrs, defStyleAttr, defStyleRes), ITaxiTaskWithOrderCallback {
companion object {
const val TAG = "DebugView"
const val BROADCAST_ACTION = "com.mogo.och.driver.debugview.show"
const val BROADCAST_DATA_SHOW = "isShow"
+
+ private var logHistoryTextView: TextView? = null
+
+ fun printInfoMsg(msg: String) {
+ printMsg(msg, MainMoGoApplication.getApp().getColor(R.color.background_info))
+ }
+
+ fun printWarnMsg(msg: String) {
+ printMsg(msg, MainMoGoApplication.getApp().getColor(R.color.background_warn))
+ }
+
+ fun printErrorMsg(msg: String) {
+ printMsg(msg, MainMoGoApplication.getApp().getColor(R.color.background_error))
+ }
+
+ private fun printMsg(msg: String, textColor: Int) {
+ logHistoryTextView?.also {
+ val msg = "${currentDateTimeString()} $msg"
+ val spannableMsg = SpannableString(msg)
+
+ spannableMsg.setSpan(
+ ForegroundColorSpan(textColor), 0, msg.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
+ )
+ it.append(spannableMsg.toString())
+
+ val offset: Int = it.lineCount * it.lineHeight
+ if (offset > it.height) {
+ it.scrollTo(0, offset - it.height)
+ }
+ }
+ }
+
+ private fun currentDateTimeString(): String {
+ return DateTimeUtil.formatCalendarToString(
+ DateTimeUtil.formatLongToCalendar(System.currentTimeMillis()),
+ DateTimeUtil.yyyy_MM_dd_HH_mm_ss
+ )
+ }
}
private val broadcastReceiver = object : BroadcastReceiver() {
@@ -59,9 +102,10 @@ public class DebugView @JvmOverloads constructor(
init {
initBroadcastReceiver()
- LayoutInflater.from(context)
- .inflate(R.layout.taxi_debug_order, this, true)
+ LayoutInflater.from(context).inflate(R.layout.taxi_debug_order, this, true)
+ debugLogHistoryTextView.setMovementMethod(ScrollingMovementMethod.getInstance())
visibility = GONE
+ logHistoryTextView = debugLogHistoryTextView
}
private fun initBroadcastReceiver() {
@@ -71,11 +115,8 @@ public class DebugView @JvmOverloads constructor(
}
fun toggleOrderDebugView() {
- visibility =
- if (visibility == View.VISIBLE)
- View.GONE
- else
- View.VISIBLE
+ visibility = if (visibility == View.VISIBLE) View.GONE
+ else View.VISIBLE
val data = TaxiTaskModel.getCurrentTaskWithOrder()
initViewByData(data)
}
@@ -100,15 +141,11 @@ public class DebugView @JvmOverloads constructor(
private fun initViewByData(data: QueryCurrentTaskRespBean.Result?) {
val curContrail = TaxiTaskModel.getCurrentTaskTrajectory()
- currentDataTimestamps.text = "【当前数据返回时间】${
- DateTimeUtil.formatCalendarToString(
- DateTimeUtil.formatLongToCalendar(System.currentTimeMillis()),
- DateTimeUtil.yyyy_MM_dd_HH_mm_ss
- )
- }"
+ currentDataTimestamps.text = "【当前数据返回时间】${currentDateTimeString()}"
currentCarStatus.text =
"【当前车辆状态】${data?.servingStatus} / ${if (data?.servingStatus == 1) "开始接单" else "暂停接单"}"
- currentTaskType.text = "【当前任务类型】${data?.taskType} / ${TaskTypeEnum.valueOf(data?.taskType ?: -1)?.name}"
+ currentTaskType.text =
+ "【当前任务类型】${data?.taskType} / ${TaskTypeEnum.valueOf(data?.taskType ?: -1)?.name}"
currentStatus.text =
"【当前任务状态】${data?.currentStatus} / ${TaskStatusEnum.valueOf(data?.currentStatus ?: -1)?.name}"
currentLineId.text = "【当前任务lineId】 ${data?.lineId}"
diff --git a/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_debug_view_log_history_bg.xml b/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_debug_view_log_history_bg.xml
new file mode 100644
index 0000000000..3911b44185
--- /dev/null
+++ b/OCH/taxi/unmanned-driver/src/main/res/drawable/taxi_debug_view_log_history_bg.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/taxi_debug_order.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/taxi_debug_order.xml
index cf3b2468bc..77f9869277 100644
--- a/OCH/taxi/unmanned-driver/src/main/res/layout/taxi_debug_order.xml
+++ b/OCH/taxi/unmanned-driver/src/main/res/layout/taxi_debug_order.xml
@@ -158,4 +158,16 @@
android:text="Mock模拟轨迹"
android:textSize="12sp" />
+
+
\ No newline at end of file