diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt index 17151d727e..42ff1b43d0 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MBoxBubbleView.kt @@ -55,7 +55,7 @@ class MBoxBubbleView @JvmOverloads constructor( UiThreadHandler.post { if(category == MsgCategory.NOTICE){ if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X - || msgBoxList.type == MsgBoxType.OBU){ + || msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){ MsgBoxConfig.noticeList.add(msgBoxList) if(isShowData){ CallerMsgBoxEventListenerManager.invokeUpdateTipListener(true) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxBubbleView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxBubbleView.kt index e382698b28..e6daa2e3ed 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxBubbleView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxBubbleView.kt @@ -52,14 +52,9 @@ class MMsgBoxBubbleView @JvmOverloads constructor( UiThreadHandler.post { if(category == MsgCategory.NOTICE){ if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X - || msgBoxList.type == MsgBoxType.OBU){ + || msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){ update(msgBoxList) } - if(msgBoxList.type == MsgBoxType.OPERATION){ - if((msgBoxList.bean as OperationMsg).type == 2){ - update(msgBoxList) - } - } } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxListView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxListView.kt index e881c94369..726a6dae6d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxListView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/MMsgBoxListView.kt @@ -59,21 +59,12 @@ class MMsgBoxListView @JvmOverloads constructor( UiThreadHandler.post{ if(category == MsgCategory.NOTICE){ if(msgBoxList.type == MsgBoxType.NOTICE || msgBoxList.type == MsgBoxType.V2X - || msgBoxList.type == MsgBoxType.OBU){ + || msgBoxList.type == MsgBoxType.OBU || msgBoxList.type == MsgBoxType.OPERATION){ noticeList?.add(0,msgBoxList) noticeList?.let { mMsgBoxListAdapter?.setData(it) } } - if(msgBoxList.type == MsgBoxType.OPERATION){ - if((msgBoxList.bean as OperationMsg).type == 2){ - noticeList?.add(0,msgBoxList) - noticeList?.let { - mMsgBoxListAdapter?.setData(it) - } - } - } - } } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/SharpView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/SharpView.java new file mode 100644 index 0000000000..af4567c9dd --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/SharpView.java @@ -0,0 +1,59 @@ +package com.mogo.eagle.core.function.hmi.ui.msgbox; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.util.AttributeSet; +import android.view.View; + +import androidx.annotation.Nullable; + +public class SharpView extends View { + + private int mWidth =0; //三角形的宽度 + private int mHeight =0; //三角形的高度 + private Context mContext; + + public SharpView(Context context) { + super(context); + this.mContext=context; + initView(); + } + + public SharpView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + this.mContext=context; + initView(); + } + + private void initView() { + mWidth = 25; + mHeight = 25; + } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + setMeasuredDimension(mWidth,mHeight); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + //创建画笔 + Paint paint = new Paint(); + paint.setColor(Color.parseColor("#FFFFFFFF")); + paint.setAntiAlias(true); //抗锯齿 + paint.setStyle(Paint.Style.FILL);//实线 + //创建路径 + Path path = new Path(); + path.moveTo(0,mHeight); + path.lineTo(mWidth,mHeight); + path.lineTo(mWidth/2,0); + path.close();//闭合路径 + //画在画布上 + canvas.drawPath(path,paint); + } + +} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt index c95913d7e7..83842d19e9 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/MBoxBubbleAdapter.kt @@ -21,6 +21,7 @@ class MBoxBubbleAdapter(private val activity: Activity): RecyclerView.Adapter){ @@ -37,6 +38,10 @@ class MBoxBubbleAdapter(private val activity: Activity): RecyclerView.Adapter { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_m_box_operation,parent,false) + BubbleOperationHolder(view) + } else -> { val view = LayoutInflater.from(parent.context).inflate(R.layout.item_m_box_v2x,parent,false) BubbleV2XHolder(view) @@ -61,6 +66,14 @@ class MBoxBubbleAdapter(private val activity: Activity): RecyclerView.Adapter { + //运营消息 + data?.let { + val operationMsg = it[position].msgBoxBean.bean as OperationMsg + holder.tvMOperationTime.text = TimeUtils.millis2String(it[position].msgBoxBean.timestamp,getHourMinFormat()) + holder.tvMOperationContent.text = operationMsg.content + } + } is BubbleV2XHolder -> { data?.let { val msgBoxBean = it[position] @@ -74,7 +87,7 @@ class MBoxBubbleAdapter(private val activity: Activity): RecyclerView.Adapter { + mWidth = getWidth(); + if (toExpand) { + setExpandText(); + } else { + setCloseText(); + } + }); + } + + public void toggle() { + toggle(!mIsExpanding); + } + + /** + * 设置TextView可显示的最大行数 + * + * @param maxLines 最大行数 + */ + @Override + public void setMaxLines(int maxLines) { + if (mMaxLines == 0) { + // 这里对mMaxLines记录一次就可以 + this.mMaxLines = maxLines; + } + super.setMaxLines(maxLines); + } + + public void setToDBC(boolean toDBC) { + ToDBC = toDBC; + } + + public int getToExpandImageWidth() { + return mToExpandImageWidth; + } + + public int getToCloseImageWidth() { + return mToCloseImageWidth; + } + + public void setToExpandImageWidth(int mToExpandImageWidth) { + this.mToExpandImageWidth = mToExpandImageWidth; + } + + public void setToCloseImageWidth(int mToCloseImageWidth) { + this.mToCloseImageWidth = mToCloseImageWidth; + } + + public SpannableString getDefaultToExpandSpannableString() { + SpannableString spannableString = new SpannableString("... "); + // 测量文字的高度,用于设置图片大小 + Paint paint = getPaint(); + Paint.FontMetrics fontMetrics = paint.getFontMetrics(); + setToExpandImageWidth((int) (fontMetrics.descent - fontMetrics.ascent)); + // 对图片的宽高设置 + @SuppressLint("UseCompatLoadingForDrawables") + Drawable drawable = getResources().getDrawable(R.drawable.ic_expand_more_black); + drawable.setBounds(0, 0 , getToExpandImageWidth(), getToExpandImageWidth()); + ImageSpan span = new ImageSpan(drawable); + spannableString.setSpan(span, spannableString.length() - 1, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + // 对imageSpan设置点击事件,也可以这里不设置,在Activity对expandTextView整个事件设置点击事件 + return spannableString; + } + + + public SpannableString getDefaultToCloseSpannableString() { + // 因为末尾要插入图片,这里空格是占位符 + SpannableString spannableString = new SpannableString(" "); + // 测量文字的高度,用于设置图片大小 + Paint paint = getPaint(); + Paint.FontMetrics fontMetrics = paint.getFontMetrics(); + setToCloseImageWidth((int) (fontMetrics.descent - fontMetrics.ascent)); + // 对图片的宽高设置 + @SuppressLint("UseCompatLoadingForDrawables") + Drawable drawable = getResources().getDrawable(R.drawable.ic_expand_less_black); + drawable.setBounds(0, 0 , getToCloseImageWidth(), getToCloseImageWidth()); + ImageSpan span = new ImageSpan(drawable); + spannableString.setSpan(span, spannableString.length() - 1, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + return spannableString; + } + + /** + * 设置文本收起 + */ + public void setCloseText() { + mIsExpanding = false; + setMaxLines(mMaxLines); + + boolean needAppend = false; + String workingText = originText; + + if (mMaxLines != 0) { + Layout originLayout = createWorkingLayout(originText); + mOriginTextLines = originLayout.getLineCount(); + // 原始文本的行数 大于 最大能显示行数 + if (mOriginTextLines > mMaxLines) { + // 获取mMaxLines行的文本 + workingText = originText.substring(0, originLayout.getLineEnd(mMaxLines - 1)).trim(); + // 计算mMaxLines行的文本的宽度 + float allWidth = getPaint().measureText(workingText); + // 当前显示需要的宽度 + float realWidth = getPaint().measureText(workingText + SPAN_TO_EXPAND) + mToExpandImageWidth; + + while (realWidth > allWidth) { + int lastSpace = workingText.length() - 1; + if (lastSpace == -1) { + break; + } + workingText = workingText.substring(0, lastSpace); + realWidth = getPaint().measureText(workingText + SPAN_TO_EXPAND) + mToExpandImageWidth; + } + + needAppend = true; + } + } + setText(workingText); + if (needAppend) { + // 必须使用append,不能在上面使用+连接,否则spannable会无效 + append(SPAN_TO_EXPAND); + } + setMovementMethod(LinkMovementMethod.getInstance()); + } + + /** + * 设置文本展开 + */ + public void setExpandText() { + if (mOriginTextLines <= mMaxLines) { + return; + } + mIsExpanding = true; + setMaxLines(Integer.MAX_VALUE); + + Layout originLayout = createWorkingLayout(originText); + Layout compareLayout = createWorkingLayout(originText + SPAN_TO_CLOSE); + if (compareLayout.getLineCount() > originLayout.getLineCount()) { + setText(originText + "\n"); + } else { + setText(originText); + } + append(SPAN_TO_CLOSE); + setMovementMethod(LinkMovementMethod.getInstance()); + } + + /** + * 返回textview的显示区域的layout + */ + private Layout createWorkingLayout(String workingText) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { + return StaticLayout.Builder.obtain(workingText, 0, workingText.length(), getPaint(), mWidth).build(); + } else { + return new StaticLayout(workingText, getPaint(), mWidth - getPaddingLeft() - getPaddingRight(), + Layout.Alignment.ALIGN_NORMAL, getLineSpacingMultiplier(), getLineSpacingExtra(), false); + } + } + + /** + * 屏蔽长按事件,防止崩溃 + */ + @Override + public void setLongClickable(boolean longClickable) { + super.setLongClickable(false); + } + + /** + * 转全角 + */ + private static String toDBC(String input) { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\n') { + + } else if (c[i] == ' ') { + c[i] = '\u3000'; + } else if (c[i] < '\177') { + c[i] = (char) (c[i] + 65248); + } + } + return new String(c); + } + + /** + * 转半角 + */ + public static String ToDBC(String input) { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == '\u3000') { + c[i] = ' '; + } else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { + c[i] = (char) (c[i] - 65248); + + } + } + return new String(c); + } + + /** + * 用于生成 文本末尾要追加的SpannableString + */ + public interface CreateAppenderListener { + SpannableString getDefaultToCloseSpannableString(); + SpannableString getDefaultToExpandSpannableString(); + } + +} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/ic_expand_less_black.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/ic_expand_less_black.png new file mode 100644 index 0000000000..233b1c27ff Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/ic_expand_less_black.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/ic_expand_more_black.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/ic_expand_more_black.png new file mode 100644 index 0000000000..6e2b5e9fdd Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/ic_expand_more_black.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_operation.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_operation.xml new file mode 100644 index 0000000000..7e563fa97f --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_operation.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml index 60eab23068..80d40787cb 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_box_v2x.xml @@ -44,7 +44,7 @@ android:ellipsize="end" android:textColor="#FF203555" android:textSize="@dimen/dp_18" - android:layout_marginStart="@dimen/dp_20" + android:layout_marginStart="@dimen/dp_18" android:layout_marginEnd="@dimen/dp_18" /> diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_box_operation.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_box_operation.xml index de8d8eae24..716146b2a1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_box_operation.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_box_operation.xml @@ -41,10 +41,11 @@ android:gravity="start" android:textColor="#FF203555" android:textSize="20dp" + android:textStyle="bold" android:layout_marginStart="@dimen/dp_13" android:layout_marginEnd="@dimen/dp_13" + android:maxLines="2" + android:ellipsize="end" /> - - \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_list_operation.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_list_operation.xml index a064113ef4..075ede3c2a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_list_operation.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_m_msg_list_operation.xml @@ -1,7 +1,7 @@ - diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java index a95b51813f..1d275b58ef 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/MogoRouteOverlayManager.java @@ -44,7 +44,7 @@ public class MogoRouteOverlayManager implements public void init() { CallerPlanningTrajectoryListenerManager.INSTANCE.addListener(TAG, this); CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this); - CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, this); + CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 20,this); } public static MogoRouteOverlayManager getInstance() { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt index 6a108df146..8f0933ac44 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt @@ -32,7 +32,7 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, initMapView() CallerSkinModeListenerManager.addListener(TAG, this) - CallerChassisLocationWGS84ListenerManager.addListener(TAG, this) + CallerChassisLocationWGS84ListenerManager.addListener(TAG, 20,this) CallerChassisLamplightListenerManager.addListener(TAG, this) } diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ02ListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ02ListenerManager.kt index 0c20a62a84..13693d165d 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ02ListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationGCJ02ListenerManager.kt @@ -73,7 +73,19 @@ object CallerChassisLocationGCJ02ListenerManager : CallerBase 0) { + // 计算是否进入下一次回调周期 + val nowTime = TimeUtils.getNowMills() + if (nowTime - hzLastSendTime > hzTime) { + syncLocationCallback(tag, it, mGnssInfo!!, sourceType) + } + } else { + syncLocationCallback(tag, it, mGnssInfo!!, sourceType) + } } } } diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt index a0212d23ee..7c38e0fad2 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt @@ -59,7 +59,19 @@ object CallerChassisLocationWGS84ListenerManager : CallerBase 0) { + // 计算是否进入下一次回调周期 + val nowTime = TimeUtils.getNowMills() + if (nowTime - hzLastSendTime > hzTime) { + syncLocationCallback(tag, it, mGnssInfo, sourceType) + } + } else { + syncLocationCallback(tag, it, mGnssInfo, sourceType) + } } } }