[change] 合并蘑戒代码

This commit is contained in:
xinfengkun
2022-08-30 11:23:20 +08:00
parent a1d9fed999
commit 2f5d2ac8c3
47 changed files with 2289 additions and 5 deletions

1
app_mogo_magic_ring/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1 @@
# 工控机测试程序

View File

@@ -0,0 +1,72 @@
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
applicationId "com.zhidao.adas.magic"
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
packagingOptions {
//解决编译时com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'META-INF/rxjava.properties'这个错误
exclude 'META-INF/rxjava.properties'
}
externalNativeBuild {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
//插入构建时间
buildTypes.each {
//设置时间格式
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd.HHmmss", Locale.getDefault())
//获取当前时间
Date curDate = new Date(System.currentTimeMillis())
String buildTime = formatter.format(curDate)
it.buildConfigField 'String', 'BUILD_TIME', "\"${buildTime}\""
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.material
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.androidxappcompat
implementation "androidx.recyclerview:recyclerview:1.2.1"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation rootProject.ext.dependencies.gson
implementation project(':libraries:mogo-adas')
compileOnly project(':core:mogo-core-data')
implementation project(':core:mogo-core-utils')
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.android.support:multidex:1.0.3'
}

26
app_mogo_magic_ring/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,26 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-----MogoMap-----
-keep class com.mogo.map.MogoNavi{
private <init>();
}

View File

@@ -0,0 +1,27 @@
package com.zhidao.adas.magic;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.zhidao.adas.magic", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.zhidao.adas.magic">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:name=".App"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ui.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,13 @@
package com.zhidao.adas.magic;
import android.app.Application;
import com.zhidao.adas.magic.utils.CrashHandler;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
CrashHandler.getInstance().init(this);
}
}

View File

@@ -0,0 +1,67 @@
package com.zhidao.adas.magic.adapter;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import com.zhidao.adas.magic.R;
import com.zhidao.adas.magic.base.BaseAdapter;
import com.zhidao.adas.magic.base.BaseViewHolder;
import com.zhidao.adas.magic.bean.IPCConnectState;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
* 连接状态
*/
public class ConnectStatusAdapter extends BaseAdapter<IPCConnectState, ConnectStatusAdapter.ViewHolder> {
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS ", Locale.getDefault());
private static final String POS = "%03d. ";
public void refreshView() {
// notifyItemChanged(mDatas.size()-1,0);
notifyItemRangeChanged(0, getItemCount());
}
@Override
public long getItemId(int position) {
return position;
}
@SuppressLint("SetTextI18n")
@Override
protected void onBindDataToItem(ViewHolder viewHolder, IPCConnectState data, int position) {
viewHolder.id.setText(String.format(Locale.getDefault(), POS, getItemCount() - position));
viewHolder.editText.setText(sdf.format(new Date(data.time)) + "\n" + data.status);
viewHolder.editText.setTextColor(mContext.getResources().getColor(data.color));
}
@Override
protected View getItemViewResource(ViewGroup viewGroup) {
return LayoutInflater.from(mContext).inflate(R.layout.item_status, viewGroup, false);
}
@Override
protected ViewHolder getViewHolder(View view) {
return new ViewHolder(view, this);
}
class ViewHolder extends BaseViewHolder<ConnectStatusAdapter> {
EditText editText;
TextView id;
public ViewHolder(View itemView, ConnectStatusAdapter adapter) {
super(itemView, adapter);
editText = itemView.findViewById(R.id.log);
id = itemView.findViewById(R.id.id);
}
}
}

View File

@@ -0,0 +1,62 @@
package com.zhidao.adas.magic.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.zhidao.adas.magic.R;
import com.zhidao.adas.magic.base.BaseAdapter;
import com.zhidao.adas.magic.base.BaseViewHolder;
import com.zhidao.adas.magic.bean.TitleBean;
import java.util.List;
/**
* @author song kenan
* @des
* @date 2021/8/13
*/
public class InfoTitleAdapter extends BaseAdapter<TitleBean, InfoTitleAdapter.ViewHolder> {
public void setSelectedPosition(int position) {
notifyItemChanged(position);
}
public InfoTitleAdapter(List<TitleBean> data) {
super(data);
}
@Override
protected void onBindDataToItem(ViewHolder viewHolder, TitleBean data, int position) {
if (data == null) {
return;
}
viewHolder.itemView.setSelected(data.isSelected);
viewHolder.title.setText(data.name);
}
@Override
protected View getItemViewResource(ViewGroup viewGroup) {
return LayoutInflater.from(mContext).inflate(R.layout.item_info, viewGroup, false);
}
@Override
protected ViewHolder getViewHolder(View view) {
return new ViewHolder(view, this);
}
class ViewHolder extends BaseViewHolder<InfoTitleAdapter> {
TextView title;
public ViewHolder(View itemView, InfoTitleAdapter adapter) {
super(itemView, adapter);
title = itemView.findViewById(R.id.tv_info_title);
}
}
}

View File

@@ -0,0 +1,107 @@
package com.zhidao.adas.magic.base;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.zhidao.adas.magic.ui.MainActivity;
import java.lang.ref.WeakReference;
public abstract class BaseActivity extends AppCompatActivity {
private BaseHandler mBaseHandler;
private Toast toast;
protected void showToastCenter(String msg) {
showToastCenter(msg, Toast.LENGTH_SHORT);
}
protected void showToastCenter(String msg, int duration) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (toast != null) {
toast.cancel();
toast = null;
}
toast = Toast.makeText(BaseActivity.this, "", duration); //如果有居中显示需求
toast.setGravity(Gravity.CENTER, 0, 0);
toast.setText(msg);
toast.show();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
if (getHandler() != null)
getHandler().removeCallbacksAndMessages(null);
}
/**
* 初始化一个Handler如果需要使用Handler先调用此方法
* 然后可以使用postRunnable(Runnable runnable)
* sendMessage在handleMessageMessage msg中接收msg
*/
public void initHandler() {
mBaseHandler = new BaseHandler(this);
}
/**
* 返回Handler在此之前确定已经调用initHandler
*
* @return Handler
*/
public Handler getHandler() {
return mBaseHandler;
}
/**
* 同Handler 的 handleMessage
* getHandler.sendMessage,发送的Message在此接收
* 在此之前确定已经调用initHandler
*
* @param msg
*/
protected void handleMessage(Message msg) {
}
/**
* 同Handler的postRunnable
* 在此之前确定已经调用initHandler
*/
protected void postRunnable(Runnable runnable) {
postRunnableDelayed(runnable, 0);
}
/**
* 同Handler的postRunnableDelayed
* 在此之前确定已经调用initHandler
*/
protected void postRunnableDelayed(Runnable runnable, long delayMillis) {
if (mBaseHandler == null) initHandler();
mBaseHandler.postDelayed(runnable, delayMillis);
}
protected static class BaseHandler extends Handler {
private final WeakReference<BaseActivity> mObjects;
public BaseHandler(BaseActivity mPresenter) {
mObjects = new WeakReference<BaseActivity>(mPresenter);
}
@Override
public void handleMessage(Message msg) {
BaseActivity mPresenter = mObjects.get();
if (mPresenter != null)
mPresenter.handleMessage(msg);
}
}
}

View File

@@ -0,0 +1,119 @@
package com.zhidao.adas.magic.base;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
/**
* RecycleView Adapter
* Created by renfeicui on 2018/10/12.
*/
public abstract class BaseAdapter<D, VH extends BaseViewHolder> extends RecyclerView.Adapter<VH> {
protected String TAG = this.getClass().getSimpleName();
protected List<D> mDatas;
protected Context mContext;
private OnItemClickListener<D> mItemClick;
public interface OnItemClickListener<D> {
void onItemClick(int position, D data);
boolean onItemLongClick(int position, D data);
}
public BaseAdapter() {
}
public BaseAdapter(List<D> mDatas) {
this.mDatas = mDatas;
}
public BaseAdapter(OnItemClickListener<D> listener) {
mItemClick = listener;
}
public BaseAdapter(List<D> mDatas, OnItemClickListener<D> listener) {
this.mDatas = mDatas;
mItemClick = listener;
}
public void setData(List<D> mDatas) {
this.mDatas = mDatas;
if (!mDatas.isEmpty())
notifyDataSetChanged();
}
public void setOnItemClickListener(OnItemClickListener<D> listener) {
mItemClick = listener;
}
/***
* 获取制定 位置的Data
* @param position 下标
* @return Data
*/
public D getItem(int position) {
return mDatas == null ? null : mDatas.get(position);
}
@Override
public int getItemCount() {
return mDatas == null ? 0 : mDatas.size();
}
@Override
public void onBindViewHolder(@NonNull VH viewHolder, int position) {
D bean = getItem(position);
onBindDataToItem(viewHolder, bean, position);
}
@NonNull
@Override
public VH onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
mContext = viewGroup.getContext();
return getViewHolder(getItemViewResource(viewGroup));
}
/***
* 同onBindViewHolder
* @param viewHolder viewHolder
* @param data 数据
* @param position 下标
*/
protected abstract void onBindDataToItem(VH viewHolder, D data, int position);
/***
* 获取Item布局
* @return id
*/
protected abstract View getItemViewResource(ViewGroup viewGroup);
/**
* 获取ViewHolder
*
* @param view
* @return
*/
protected abstract VH getViewHolder(View view);
public void onClick(BaseViewHolder viewHolder) {
if (mItemClick != null) {
mItemClick.onItemClick(viewHolder.getBindingAdapterPosition(), getItem(viewHolder.getBindingAdapterPosition()));
}
}
public boolean onLongClick(BaseViewHolder viewHolder) {
if (mItemClick != null) {
return mItemClick.onItemLongClick(viewHolder.getBindingAdapterPosition(), getItem(viewHolder.getBindingAdapterPosition()));
}
return false;
}
}

View File

@@ -0,0 +1,32 @@
package com.zhidao.adas.magic.base;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
public abstract class BaseViewHolder<T extends BaseAdapter> extends RecyclerView.ViewHolder {
private T adapter;
public View itemView;
public BaseViewHolder(View itemView, final T adapter) {
super(itemView);
this.itemView = itemView;
this.adapter = adapter;
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.onClick(BaseViewHolder.this);
}
});
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return adapter.onLongClick(BaseViewHolder.this);
}
});
}
}

View File

@@ -0,0 +1,16 @@
package com.zhidao.adas.magic.bean;
import androidx.annotation.ColorRes;
public class IPCConnectState {
public final long time;
public final String status;
@ColorRes
public final int color;
public IPCConnectState(String status, @ColorRes int color) {
this.status = status;
this.color = color;
time = System.currentTimeMillis();
}
}

View File

@@ -0,0 +1,22 @@
package com.zhidao.adas.magic.bean;
import java.util.Objects;
public class TitleBean {
public final String name;
public boolean isSelected = false;
public TitleBean(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TitleBean titleBean = (TitleBean) o;
return Objects.equals(name, titleBean.name);
}
}

View File

@@ -0,0 +1,182 @@
package com.zhidao.adas.magic.ui;
import android.app.Activity;
import android.content.Context;
import android.graphics.PixelFormat;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import androidx.recyclerview.widget.RecyclerView;
import com.zhidao.adas.magic.R;
import com.zhidao.adas.magic.adapter.ConnectStatusAdapter;
import com.zhidao.adas.magic.bean.IPCConnectState;
import com.zhidao.adas.magic.utils.MyLinearLayoutManager;
import java.lang.reflect.Field;
import java.util.List;
/**
* @author xuxinchao
* @description
* @since: 2022/4/20
*/
public class FloatWindow implements View.OnTouchListener {
private final Activity mContext;
private WindowManager.LayoutParams mWindowParams;
private WindowManager mWindowManager;
private View mFloatLayout;
private float mInViewX;
private float mInViewY;
private float mDownInScreenX;
private float mDownInScreenY;
private float mInScreenX;
private float mInScreenY;
private RecyclerView rv_status;
private ConnectStatusAdapter adapter;
private List<IPCConnectState> list;
public FloatWindow(Activity context, List<IPCConnectState> list) {
this.mContext = context;
this.list = list;
initFloatWindow();
}
public void refreshView() {
if (adapter != null) {
adapter.refreshView();
}
}
private void initRV() {
//创建默认的线性LayoutManager 横向的GridLayoutManager
MyLinearLayoutManager linearLayoutManager = new MyLinearLayoutManager(mContext);
// linearLayoutManager.setStackFromEnd(true);//列表再底部开始展示,反转后由上面开始展示
// linearLayoutManager.setReverseLayout(true);//列表翻转
rv_status.setLayoutManager(linearLayoutManager);
//如果可以确定每个item的高度是固定的设置这个选项可以提高性能
rv_status.setHasFixedSize(false);
rv_status.setNestedScrollingEnabled(false);
adapter = new ConnectStatusAdapter();
adapter.setHasStableIds(true);
rv_status.setAdapter(adapter);
adapter.setData(list);
}
private void initFloatWindow() {
LayoutInflater inflater = LayoutInflater.from(mContext);
if (inflater == null)
return;
mFloatLayout = (View) inflater.inflate(R.layout.layout_float, null);
rv_status = mFloatLayout.findViewById(R.id.rv_status);
mFloatLayout.setOnTouchListener(this);
initRV();
mWindowParams = new WindowManager.LayoutParams();
// mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
// if (Build.VERSION.SDK_INT >= 26) {//8.0新特性
// mWindowParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
// }else{
// mWindowParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
// }
mWindowManager = mContext.getWindowManager();
mWindowParams.format = PixelFormat.RGBA_8888;
mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mWindowParams.gravity = Gravity.START | Gravity.TOP;
mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
mWindowParams.alpha = 0.9F;
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return floatLayoutTouch(motionEvent);
}
private boolean floatLayoutTouch(MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
// 获取相对View的坐标即以此View左上角为原点
mInViewX = motionEvent.getX();
mInViewY = motionEvent.getY();
// 获取相对屏幕的坐标,即以屏幕左上角为原点
mDownInScreenX = motionEvent.getRawX();
mDownInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
break;
case MotionEvent.ACTION_MOVE:
// 更新浮动窗口位置参数
mInScreenX = motionEvent.getRawX();
mInScreenY = motionEvent.getRawY() - getSysBarHeight(mContext);
mWindowParams.x = (int) (mInScreenX - mInViewX);
mWindowParams.y = (int) (mInScreenY - mInViewY);
// 手指移动的时候更新小悬浮窗的位置
mWindowManager.updateViewLayout(mFloatLayout, mWindowParams);
break;
case MotionEvent.ACTION_UP:
// 如果手指离开屏幕时xDownInScreen和xInScreen相等且yDownInScreen和yInScreen相等则视为触发了单击事件。
if (mDownInScreenX == mInScreenX && mDownInScreenY == mInScreenY) {
}
break;
}
return true;
}
public void showFloatWindow(float y) {
if (mFloatLayout.getParent() == null) {
DisplayMetrics metrics = new DisplayMetrics();
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager.getDefaultDisplay().getMetrics(metrics);
// mWindowParams.x = metrics.widthPixels;
mWindowParams.x = 0;
mWindowParams.y = (int) (y);
mWindowManager.addView(mFloatLayout, mWindowParams);
}
}
public void hideFloatWindow() {
if (mFloatLayout.getParent() != null)
mWindowManager.removeView(mFloatLayout);
}
public void setFloatLayoutAlpha(boolean alpha) {
if (alpha)
mFloatLayout.setAlpha((float) 0.5);
else
mFloatLayout.setAlpha(1);
}
private int sbar = -1;
// 获取系统状态栏高度
public int getSysBarHeight(Context contex) {
if (sbar == -1) {
Class<?> c;
Object obj;
Field field;
int x;
sbar = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = contex.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
}
return sbar;
}
}

View File

@@ -0,0 +1,140 @@
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zhidao.adas.magic.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/**
* DividerItemDecoration is a {@link RecyclerView.ItemDecoration} that can be used as a divider
* between items of a {@link LinearLayoutManager}. It supports both {@link #HORIZONTAL} and
* {@link #VERTICAL} orientations.
*
* <pre>
* mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
* mLayoutManager.getOrientation());
* recyclerView.addItemDecoration(mDividerItemDecoration);
* </pre>
*/
public class HorizontalDividerItemDecoration extends RecyclerView.ItemDecoration {
public static final int HORIZONTAL = LinearLayout.HORIZONTAL;
public static final int VERTICAL = LinearLayout.VERTICAL;
private static final String TAG = "DividerItem";
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
private Drawable mDivider;
private final Rect mBounds = new Rect();
/**
* Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
* {@link LinearLayoutManager}.
*
* @param context Current context, it will be used to access resources.
*/
public HorizontalDividerItemDecoration(Context context) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
if (mDivider == null) {
Log.w(TAG, "@android:attr/listDivider was not set in the theme used for this "
+ "DividerItemDecoration. Please set that attribute all call setDrawable()");
}
a.recycle();
}
/**
* Sets the {@link Drawable} for this divider.
*
* @param drawable Drawable that should be used as a divider.
*/
public void setDrawable(@NonNull Drawable drawable) {
if (drawable == null) {
throw new IllegalArgumentException("Drawable cannot be null.");
}
mDivider = drawable;
}
/**
* @return the {@link Drawable} for this divider.
*/
@Nullable
public Drawable getDrawable() {
return mDivider;
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (parent.getLayoutManager() == null || mDivider == null) {
return;
}
drawHorizontal(c, parent);
}
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
canvas.save();
final int top;
final int bottom;
//noinspection AndroidLintNewApi - NewApi lint fails to handle overrides.
if (parent.getClipToPadding()) {
top = parent.getPaddingTop();
bottom = parent.getHeight() - parent.getPaddingBottom();
canvas.clipRect(parent.getPaddingLeft(), top,
parent.getWidth() - parent.getPaddingRight(), bottom);
} else {
top = 0;
bottom = parent.getHeight();
}
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; ) {
final View child = parent.getChildAt(i);
parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
final int right = mBounds.right + Math.round(child.getTranslationX());
final int left = right - mDivider.getIntrinsicWidth();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
i += 2;
}
canvas.restore();
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
if (mDivider == null) {
outRect.set(0, 0, 0, 0);
return;
}
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}

View File

@@ -487,9 +487,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
} }
@Override
public void onPointCloud(MessagePad.Header header, MogoPointCloudOuterClass.MogoPointCloud pointCloud) {
}
@Override @Override
public void onPointCloud(byte[] pointCloud) { public void onPointCloud(byte[] pointCloud) {
@@ -501,7 +499,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
@Override @Override
public void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq) { public void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq) {
AdasManager.getInstance().sendBasicInfoResp("", 0); AdasManager.getInstance().sendBasicInfoResp("", 0, com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DEBUG);
} }
@Override @Override
@@ -529,6 +527,16 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
public void onStatusQueryResp(MessagePad.Header header, SystemStatusInfo.StatusInfo statusInfo) { public void onStatusQueryResp(MessagePad.Header header, SystemStatusInfo.StatusInfo statusInfo) {
} }
@Override
public void onRecordDataConfigResp(MessagePad.Header header, MessagePad.RecordDataConfig config) {
}
@Override
public void onPlanningActionMsg(MessagePad.Header header, MessagePad.PlanningActionMsg planningActionMsg) {
}
private void initAdas() { private void initAdas() {
CupidLogUtils.e(TAG, "--->初始化"); CupidLogUtils.e(TAG, "--->初始化");

View File

@@ -0,0 +1,293 @@
package com.zhidao.adas.magic.utils;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* ClassName: CrashHandler
* Function: UncaughtException处理类,当程序发生Uncaught异常的时候,由该类来接管程序,并记录发送错误报告.
*
* @author Norris Norris.sly@gmail.com
* @Date 2013 2013-3-24 下午12:27:10
* @Fields ──────────────────────────────────────────────────────────────────────────────────────────────────────
* @Methods ──────────────────────────────────────────────────────────────────────────────────────────────────────
* 2013-3-24下午12:27:10 Modified By Norris
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
* @see ──────────────────────────────────────────────────────────────────────────────────────────────────────
* @since Ver 1.0 I used to be a programmer like you, then I took an arrow in the knee
*/
public class CrashHandler implements UncaughtExceptionHandler {
/**
* Log日志的tag
* String : TAG
*
* @since 2013-3-21下午8:44:28
*/
private static final String TAG = "NorrisInfo";
/**
* 系统默认的UncaughtException处理类
* Thread.UncaughtExceptionHandler : mDefaultHandler
*
* @since 2013-3-21下午8:44:43
*/
private UncaughtExceptionHandler mDefaultHandler;
/**
* CrashHandler实例
* CrashHandler : mInstance
*
* @since 2013-3-21下午8:44:53
*/
private static CrashHandler mInstance = new CrashHandler();
/**
* 程序的Context对象
* Context : mContext
*
* @since 2013-3-21下午8:45:02
*/
private Context mContext;
/**
* 用来存储设备信息和异常信息
* Map<String,String> : mLogInfo
*
* @since 2013-3-21下午8:46:15
*/
private Map<String, String> mLogInfo = new HashMap<String, String>();
/**
* 用于格式化日期,作为日志文件名的一部分(FIXME 注意在windows下文件名无法使用等符号)
* SimpleDateFormat : mSimpleDateFormat
*
* @since 2013-3-21下午8:46:39
*/
private SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("yyyyMMdd_HH-mm-ss");
/**
* Creates a new instance of CrashHandler.
*/
private CrashHandler() {
}
/**
* getInstance:{获取CrashHandler实例 ,单例模式 }
* ──────────────────────────────────
*
* @return CrashHandler
* @throws
* @since I used to be a programmer like you, then I took an arrow in the knee Ver 1.0
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
* 2013-3-21下午8:52:24 Modified By Norris
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
*/
public static CrashHandler getInstance() {
return mInstance;
}
/**
* init:{初始化}
* ──────────────────────────────────
*
* @param paramContext
* @return void
* @throws
* @since I used to be a programmer like you, then I took an arrow in the knee Ver 1.0
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
* 2013-3-21下午8:52:45 Modified By Norris
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
*/
public void init(Context paramContext) {
mContext = paramContext;
// 获取系统默认的UncaughtException处理器
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
// 设置该CrashHandler为程序的默认处理器
Thread.setDefaultUncaughtExceptionHandler(this);
}
/**
* 当UncaughtException发生时会转入该重写的方法来处理
* (non-Javadoc)
*
* @see UncaughtExceptionHandler#uncaughtException(Thread, Throwable)
*/
public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
// 获取设备参数信息
getDeviceInfo(mContext);
// mLogInfo.put("versionName", String.valueOf(BuildConfig.VERSION_CODE));
// mLogInfo.put("versionCode", BuildConfig.VERSION_NAME);
// 保存日志文件
String result = saveCrashLogToFile(paramThrowable);
mDefaultHandler.uncaughtException(paramThread, paramThrowable);
// if (!handleException(paramThrowable) && mDefaultHandler != null) {
// // 如果自定义的没有处理则让系统默认的异常处理器来处理
// mDefaultHandler.uncaughtException(paramThread, paramThrowable);
// } else {
//// try {
//// // 如果处理了让程序继续运行1秒再退出保证文件保存并上传到服务器
//// paramThread.sleep(1000);
//// } catch (InterruptedException e) {
//// e.printStackTrace();
//// }
// // 退出程序
// android.os.Process.killProcess(android.os.Process.myPid());
// System.exit(1);
// }
}
/**
* handleException:{自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.}
* ──────────────────────────────────
*
* @param paramThrowable
* @return true:如果处理了该异常信息;否则返回false.
* @throws
* @since I used to be a programmer like you, then I took an arrow in the knee Ver 1.0
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
* 2013-3-24下午12:28:53 Modified By Norris
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
*/
public boolean handleException(Throwable paramThrowable) {
if (paramThrowable == null)
return false;
new Thread() {
public void run() {
Looper.prepare();
Toast.makeText(mContext, "很抱歉,程序出现异常,即将退出", Toast.LENGTH_SHORT).show();
Looper.loop();
}
}.start();
// 获取设备参数信息
getDeviceInfo(mContext);
// 保存日志文件
String result = saveCrashLogToFile(paramThrowable);
//上传崩溃日志
return true;
}
/**
* getDeviceInfo:{获取设备参数信息}
* ──────────────────────────────────
*
* @param paramContext
* @throws
* @since I used to be a programmer like you, then I took an arrow in the knee Ver 1.0
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
* 2013-3-24下午12:30:02 Modified By Norris
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
*/
public void getDeviceInfo(Context paramContext) {
try {
// 获得包管理器
PackageManager mPackageManager = paramContext.getPackageManager();
// 得到该应用的信息即主Activity
PackageInfo mPackageInfo = mPackageManager.getPackageInfo(
paramContext.getPackageName(), PackageManager.GET_ACTIVITIES);
if (mPackageInfo != null) {
String versionName = mPackageInfo.versionName == null ? "null"
: mPackageInfo.versionName;
String versionCode = mPackageInfo.versionCode + "";
mLogInfo.put("versionName", versionName);
mLogInfo.put("versionCode", versionCode);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
// 反射机制
Field[] mFields = Build.class.getDeclaredFields();
// 迭代Build的字段key-value 此处的信息主要是为了在服务器端手机各种版本手机报错的原因
for (Field field : mFields) {
try {
field.setAccessible(true);
mLogInfo.put(field.getName(), field.get("").toString());
Log.d(TAG, field.getName() + ":" + field.get(""));
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
/**
* saveCrashLogToFile:{将崩溃的Log保存到本地}
* TODO 可拓展将Log上传至指定服务器路径
* ──────────────────────────────────
*
* @param paramThrowable
* @return FileName
* @throws
* @since I used to be a programmer like you, then I took an arrow in the knee Ver 1.0
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
* 2013-3-24下午12:31:01 Modified By Norris
* ──────────────────────────────────────────────────────────────────────────────────────────────────────
*/
private String saveCrashLogToFile(Throwable paramThrowable) {
StringBuffer mStringBuffer = new StringBuffer();
for (Map.Entry<String, String> entry : mLogInfo.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
mStringBuffer.append(key + "=" + value + "\r\n");
}
Writer mWriter = new StringWriter();
PrintWriter mPrintWriter = new PrintWriter(mWriter);
paramThrowable.printStackTrace(mPrintWriter);
paramThrowable.printStackTrace();
Throwable mThrowable = paramThrowable.getCause();
// 迭代栈队列把所有的异常信息写入writer中
while (mThrowable != null) {
mThrowable.printStackTrace(mPrintWriter);
// 换行 每个个异常栈之间换行
mThrowable = mThrowable.getCause();
}
//记得关闭
String mResult = mWriter.toString();
// String mResult = mWriter.toString().replace("\n", "").replace(":", "").replace("/", "").replace("\t", "");
mStringBuffer.append(mResult);
// 保存文件,设置文件名
String mTime = mSimpleDateFormat.format(new Date());
String mFileName = mContext.getPackageName() + "_Exception-" + mTime + ".log";
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
try {
File mDirectory = new File(Constants.FILE_PATH);
Log.d(TAG, mDirectory.toString());
if (!mDirectory.exists())
mDirectory.mkdirs();
FileOutputStream mFileOutputStream = new FileOutputStream(mDirectory + File.separator + mFileName);
mFileOutputStream.write(mStringBuffer.toString().getBytes());
mFileOutputStream.close();
return mResult;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return mResult;
}
}

View File

@@ -0,0 +1,36 @@
package com.zhidao.adas.magic.utils;
import android.content.Context;
import android.util.AttributeSet;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class MyLinearLayoutManager extends LinearLayoutManager {
public MyLinearLayoutManager(Context context) {
super(context);
}
public MyLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public MyLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
//override this method and implement code as below
try {
super.onLayoutChildren(recycler, state);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,286 @@
package com.zhidao.adas.client.utils;
import android.content.Context;
import android.content.SharedPreferences;
public class PreferencesUtils {
public static String PREFERENCE_NAME = "control";
public static boolean hasString(Context context, String key) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.contains(key);
}
/**
* put string preferences
*
* @param context
* @param key The name of the preference to modify
* @param value The new value for the preference
* @return True if the new values were successfully written to persistent
* storage.
*/
public static boolean putString(Context context, String key, String value) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putString(key, value);
return editor.commit();
}
/**
* get string preferences
*
* @param context
* @param key The name of the preference to retrieve
* @return The preference value if it exists, or null. Throws
* ClassCastException if there is a preference with this name that
* is not a string
* @see #getString(Context, String, String)
*/
public static String getString(Context context, String key) {
if (context == null) return null;
return getString(context, key, null);
}
/**
* get string preferences
*
* @param context
* @param key The name of the preference to retrieve
* @param defaultValue Value to return if this preference does not exist
* @return The preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that
* is not a string
*/
public static String getString(Context context, String key,
String defaultValue) {
if (context == null) return defaultValue;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getString(key, defaultValue);
}
/**
* put int preferences
*
* @param context
* @param key The name of the preference to modify
* @param value The new value for the preference
* @return True if the new values were successfully written to persistent
* storage.
*/
public static boolean putInt(Context context, String key, int value) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putInt(key, value);
return editor.commit();
}
/**
* get int preferences
*
* @param context
* @param key The name of the preference to retrieve
* @return The preference value if it exists, or -1. Throws
* ClassCastException if there is a preference with this name that
* is not a int
* @see #getInt(Context, String, int)
*/
public static int getInt(Context context, String key) {
if (context == null) return -1;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return getInt(context, key, -1);
}
/**
* get int preferences
*
* @param context
* @param key The name of the preference to retrieve
* @param defaultValue Value to return if this preference does not exist
* @return The preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that
* is not a int
*/
public static int getInt(Context context, String key, int defaultValue) {
if (context == null) return defaultValue;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getInt(key, defaultValue);
}
/**
* put long preferences
*
* @param context
* @param key The name of the preference to modify
* @param value The new value for the preference
* @return True if the new values were successfully written to persistent
* storage.
*/
public static boolean putLong(Context context, String key, long value) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putLong(key, value);
return editor.commit();
}
/**
* get long preferences
*
* @param context
* @param key The name of the preference to retrieve
* @return The preference value if it exists, or -1. Throws
* ClassCastException if there is a preference with this name that
* is not a long
* @see #getLong(Context, String, long)
*/
public static long getLong(Context context, String key) {
if (context == null) return -1;
return getLong(context, key, -1);
}
/**
* get long preferences
*
* @param context
* @param key The name of the preference to retrieve
* @param defaultValue Value to return if this preference does not exist
* @return The preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that
* is not a long
*/
public static long getLong(Context context, String key, long defaultValue) {
if (context == null) return defaultValue;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getLong(key, defaultValue);
}
/**
* put float preferences
*
* @param context
* @param key The name of the preference to modify
* @param value The new value for the preference
* @return True if the new values were successfully written to persistent
* storage.
*/
public static boolean putFloat(Context context, String key, float value) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putFloat(key, value);
return editor.commit();
}
/**
* get float preferences
*
* @param context
* @param key The name of the preference to retrieve
* @return The preference value if it exists, or -1. Throws
* ClassCastException if there is a preference with this name that
* is not a float
* @see #getFloat(Context, String, float)
*/
public static float getFloat(Context context, String key) {
if (context == null) return -1;
return getFloat(context, key, -1);
}
/**
* get float preferences
*
* @param context
* @param key The name of the preference to retrieve
* @param defaultValue Value to return if this preference does not exist
* @return The preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that
* is not a float
*/
public static float getFloat(Context context, String key, float defaultValue) {
if (context == null) return defaultValue;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getFloat(key, defaultValue);
}
/**
* put boolean preferences
*
* @param context
* @param key The name of the preference to modify
* @param value The new value for the preference
* @return True if the new values were successfully written to persistent
* storage.
*/
public static boolean putBoolean(Context context, String key, boolean value) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(key, value);
return editor.commit();
}
/**
* get boolean preferences, default is false
*
* @param context
* @param key The name of the preference to retrieve
* @return The preference value if it exists, or false. Throws
* ClassCastException if there is a preference with this name that
* is not a boolean
* @see #getBoolean(Context, String, boolean)
*/
public static boolean getBoolean(Context context, String key) {
if (context == null) return false;
return getBoolean(context, key, false);
}
/**
* get boolean preferences
*
* @param context
* @param key The name of the preference to retrieve
* @param defaultValue Value to return if this preference does not exist
* @return The preference value if it exists, or defValue. Throws
* ClassCastException if there is a preference with this name that
* is not a boolean
*/
public static boolean getBoolean(Context context, String key,
boolean defaultValue) {
if (context == null) return defaultValue;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
return settings.getBoolean(key, defaultValue);
}
public static boolean delete(Context context, String key) {
if (context == null) return false;
SharedPreferences settings = context.getSharedPreferences(
PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.remove(key);
return editor.commit();
}
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FAFFFFFF" />
<stroke
android:width="0.8dp"
android:color="#81666666" />
<!-- 圆角 -->
<corners android:radius="6dp" />
</shape>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<!-- 圆角深红色按钮 -->
<solid android:color="#4D0A0A" />
<corners android:radius="8dip" />
</shape>
</item>
<item android:state_pressed="false">
<shape android:shape="rectangle">
<!-- 圆角红色按钮 -->
<solid android:color="#D9534F" />
<corners android:radius="8dip" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="63.9375dp"
android:height="32dp"
android:viewportWidth="2046"
android:viewportHeight="1024">
<path
android:pathData="M921.83,43.77C950.53,17.96 989.47,-6.02 1026.11,1.35c36.85,-5.52 71.62,20.29 100.28,42.42l886.1,802.25c45.01,40.56 45.01,106.96 0,147.55s-118.69,40.56 -163.7,0l-824.56,-763.52L197.46,993.55c-45.01,40.59 -118.69,40.59 -163.7,0s-45.01,-106.96 0,-147.53L921.83,43.77z"
android:fillColor="#ffffff"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="63.9375dp"
android:height="32dp"
android:viewportWidth="2046"
android:viewportHeight="1024">
<path
android:pathData="M1124.33,980.23c-28.65,25.81 -67.52,49.79 -104.37,42.42 -36.83,5.54 -71.59,-20.29 -100.24,-42.42L33.76,177.95C-11.25,137.42 -11.25,71 33.76,30.44s118.68,-40.58 163.68,0l824.49,763.46L1848.65,30.44c45,-40.58 118.66,-40.58 163.68,0s45,106.96 0,147.52L1124.33,980.23z"
android:fillColor="#ffffff"/>
</vector>

View File

@@ -0,0 +1,69 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M871.68,277.12L972.8,491.52V569.6s-8.32,76.16 -78.08,95.36H108.16S57.6,668.16 44.8,646.4V516.48s-2.56,-34.56 38.4,-52.48l202.24,-49.28s123.52,-136.32 154.24,-144.64l432,7.04z"
android:fillColor="#F8F8FF"/>
<path
android:pathData="M99.84,678.4c-17.92,0 -53.12,-3.2 -65.92,-25.6 -1.28,-1.92 -1.92,-4.48 -1.92,-6.4V516.48c0,-5.76 0,-44.16 46.08,-64 0.64,0 1.28,-0.64 1.92,-0.64l198.4,-48c26.24,-28.8 126.72,-136.96 157.44,-145.28 1.28,0 2.56,-0.64 3.84,-0.64l432,6.4c5.12,0 9.6,3.2 11.52,7.04L984.32,486.4c0.64,1.92 1.28,3.84 1.28,5.76V571.52c-0.64,3.2 -10.24,85.12 -87.68,106.88 -1.28,0 -2.56,0.64 -3.2,0.64H108.16c-1.28,-0.64 -4.48,-0.64 -8.32,-0.64zM57.6,642.56c8.32,8.32 33.92,11.52 49.92,10.24H892.8c56.32,-16.64 66.56,-76.8 67.2,-83.84V494.72l-96,-204.8 -421.76,-6.4c-19.2,7.68 -88.32,76.16 -146.56,140.16 -1.92,1.92 -3.84,3.2 -6.4,3.84l-201.6,49.28c-30.72,14.08 -30.08,38.4 -30.08,39.04v126.72z"
android:fillColor="#708DB7"/>
<path
android:pathData="M771.2,659.2m-140.16,0a140.16,140.16 0,1 0,280.32 0,140.16 140.16,0 1,0 -280.32,0Z"
android:fillColor="#CBD6E2"/>
<path
android:pathData="M771.2,812.16c-84.48,0 -152.96,-68.48 -152.96,-152.96s68.48,-152.96 152.96,-152.96 152.96,68.48 152.96,152.96 -69.12,152.96 -152.96,152.96zM771.2,531.84c-70.4,0 -127.36,56.96 -127.36,127.36s56.96,127.36 127.36,127.36c70.4,0 127.36,-56.96 127.36,-127.36s-57.6,-127.36 -127.36,-127.36z"
android:fillColor="#708DB7"/>
<path
android:pathData="M771.2,659.2m-56.32,0a56.32,56.32 0,1 0,112.64 0,56.32 56.32,0 1,0 -112.64,0Z"
android:fillColor="#DFECF7"/>
<path
android:pathData="M771.2,728.32c-38.4,0 -69.12,-30.72 -69.12,-69.12s30.72,-69.12 69.12,-69.12 69.12,30.72 69.12,69.12 -31.36,69.12 -69.12,69.12zM771.2,615.68c-23.68,0 -43.52,19.2 -43.52,43.52s19.2,43.52 43.52,43.52 43.52,-19.2 43.52,-43.52 -19.84,-43.52 -43.52,-43.52z"
android:fillColor="#708DB7"/>
<path
android:pathData="M305.92,667.52m-140.16,0a140.16,140.16 0,1 0,280.32 0,140.16 140.16,0 1,0 -280.32,0Z"
android:fillColor="#CBD6E2"/>
<path
android:pathData="M305.92,820.48c-84.48,0 -152.96,-68.48 -152.96,-152.96s68.48,-152.96 152.96,-152.96 152.96,68.48 152.96,152.96 -69.12,152.96 -152.96,152.96zM305.92,540.16c-70.4,0 -127.36,56.96 -127.36,127.36s56.96,127.36 127.36,127.36c70.4,0 127.36,-56.96 127.36,-127.36s-57.6,-127.36 -127.36,-127.36z"
android:fillColor="#708DB7"/>
<path
android:pathData="M305.92,667.52m-56.32,0a56.32,56.32 0,1 0,112.64 0,56.32 56.32,0 1,0 -112.64,0Z"
android:fillColor="#DFECF7"/>
<path
android:pathData="M305.92,736.64c-38.4,0 -69.12,-30.72 -69.12,-69.12s30.72,-69.12 69.12,-69.12 69.12,30.72 69.12,69.12 -31.36,69.12 -69.12,69.12zM305.92,624c-23.68,0 -43.52,19.2 -43.52,43.52s19.2,43.52 43.52,43.52 43.52,-19.2 43.52,-43.52 -19.84,-43.52 -43.52,-43.52z"
android:fillColor="#708DB7"/>
<path
android:pathData="M117.76,464s5.76,64 -65.92,96.64l1.92,-55.68s2.56,-28.8 32.64,-39.04l31.36,-8.32v6.4z"
android:fillColor="#FEF185"/>
<path
android:pathData="M38.4,580.48l2.56,-76.8c0,-1.28 3.2,-37.12 40.96,-49.92h0.64L128,441.6l2.56,21.12c0,3.2 5.76,73.6 -73.6,109.44L38.4,580.48zM65.92,505.6l-0.64,32.64c31.36,-21.76 38.4,-49.92 39.68,-64.64l-15.36,4.48c-20.48,7.04 -23.04,25.6 -23.68,27.52z"
android:fillColor="#708DB7"/>
<path
android:pathData="M850.56,309.12l55.04,131.2 -568.96,-9.6 122.24,-128.64z"
android:fillColor="#D0E5FE"/>
<path
android:pathData="M905.6,454.4l-569.6,-10.24c-5.12,0 -9.6,-3.2 -11.52,-8.32s-1.28,-10.24 2.56,-14.08l122.24,-128.64c2.56,-2.56 5.76,-4.48 9.6,-3.84l391.68,6.4c5.12,0 9.6,3.2 11.52,7.68l55.68,131.2c1.92,3.84 1.28,8.96 -1.28,12.8 -2.56,4.48 -6.4,7.04 -10.88,7.04zM366.08,418.56l520.32,8.32 -44.8,-105.6 -377.6,-6.4 -97.92,103.68z"
android:fillColor="#708DB7"/>
<path
android:pathData="M582.4,300.8v147.2"
android:fillColor="#F8F8FF"/>
<path
android:pathData="M569.6,300.8h25.6v147.2h-25.6z"
android:fillColor="#708DB7"/>
<path
android:pathData="M246.4,355.2h-0.64c-7.04,-0.64 -12.16,-6.4 -12.16,-13.44 1.92,-31.36 27.52,-42.88 44.16,-42.88 7.04,0 12.8,5.76 12.8,12.8s-5.76,12.8 -12.8,12.8c-3.84,0 -17.28,1.92 -18.56,19.2 0,6.4 -5.76,11.52 -12.8,11.52z"
android:fillColor="#708DB7"/>
<path
android:pathData="M197.76,336.64h-0.64c-7.04,-0.64 -12.16,-6.4 -12.16,-13.44 3.2,-51.84 44.8,-65.92 66.56,-65.92 7.04,0 12.8,5.76 12.8,12.8s-5.76,12.8 -12.8,12.8c-3.84,0 -38.4,1.92 -40.96,41.6 -0.64,6.4 -6.4,12.16 -12.8,12.16z"
android:fillColor="#708DB7"/>
<path
android:pathData="M136.32,322.56h-0.64c-7.04,-0.64 -12.16,-6.4 -12.16,-13.44 4.48,-83.2 71.04,-104.96 104.96,-104.96 7.04,0 12.8,5.76 12.8,12.8s-5.76,12.8 -12.8,12.8c-3.2,0 -74.88,1.28 -80,80.64 0,7.04 -5.76,12.16 -12.16,12.16z"
android:fillColor="#708DB7"/>
<path
android:pathData="M524.8,486.4h44.8"
android:fillColor="#F8F8FF"/>
<path
android:pathData="M569.6,499.2h-44.8c-7.04,0 -12.8,-5.76 -12.8,-12.8s5.76,-12.8 12.8,-12.8h44.8c7.04,0 12.8,5.76 12.8,12.8s-5.76,12.8 -12.8,12.8z"
android:fillColor="#708DB7"/>
</vector>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape android:shape="rectangle">
<!-- 圆角红色按钮 -->
<solid android:color="#00BFFF" />
<corners android:radius="8dp" />
<!--边框填充色,边框宽度-->
<stroke android:width="1dp" android:color="#B0E0E6" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<!-- 圆角深红色按钮 -->
<solid android:color="#808080" />
<corners android:radius="8dp" />
</shape>
</item>
<item android:state_pressed="false">
<shape android:shape="rectangle">
<!-- 圆角红色按钮 -->
<solid android:color="#C0C0C0" />
<corners android:radius="8dp" />
<!--边框填充色,边框宽度-->
<stroke android:width="1dp" android:color="#808080" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#7CFC00" android:state_pressed="true" />
<item android:color="#7CFC00" android:state_checked="true" />
<item android:color="#8B4513" android:state_selected="true" />
<item android:color="#FFFFFF" />
</selector>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_pack_up" android:state_selected="true" />
<item android:drawable="@drawable/ic_pull" />
</selector>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F5F5F5"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
tools:context=".ui.MainActivity">
<include
android:id="@+id/include_title"
layout="@layout/item_main" />
<TextView
android:id="@+id/hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hint"
android:textColor="#666666"
android:textSize="12sp" />
<TextView
android:id="@+id/gnss_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:textColor="#000000"
android:textSize="12sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/info_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="3dp" />
</LinearLayout>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center">
<EditText
android:id="@+id/et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:digits="0123456789"
android:gravity="center"
android:imeOptions="flagNoExtractUi"
android:inputType="number"
android:maxLength="10"
android:maxLines="1"
android:minWidth="100dp"
android:textColor="#000"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:text="ms"
android:textColor="#000"
android:textSize="16sp" />
</LinearLayout>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/colorSlateGray"/>
</LinearLayout>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="4dp"
android:background="@drawable/item_bg"
android:gravity="center"
android:minHeight="100dp">
<TextView
android:id="@+id/tv_info_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:text="INFO"
android:textColor="@drawable/item_text_color"
android:textSize="16sp" />
</LinearLayout>

View File

@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@color/colorBlue2"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:id="@+id/layout_ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/app_name"
android:textColor="@color/colorWhile"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_connect_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:gravity="center"
android:layoutDirection="ltr"
android:text="未连接"
android:textColor="@color/colorWhile"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/ipc_ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="IPC IP"
android:textColor="@color/colorWhile"
android:textSize="10dp"
android:textStyle="bold"
android:visibility="gone" />
<TextView
android:id="@+id/local_ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="本机IP"
android:textColor="@color/colorWhile"
android:textSize="10dp"
android:textStyle="bold" />
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_toEndOf="@id/layout_ip"
android:layoutDirection="rtl">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/disconnect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="8dp"
android:background="@drawable/btn_bg"
android:text="断开"
android:textColor="@color/colorWhile"
android:textSize="16dp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/btn_bg"
android:text="连接"
android:textColor="@color/colorWhile"
android:textSize="16dp"
android:textStyle="bold" />
<View
android:id="@+id/line"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="10dp"
android:layout_toStartOf="@+id/connect"
android:background="#fff124" />
<RadioGroup
android:id="@+id/connection_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layoutDirection="ltr"
android:orientation="horizontal">
<RadioButton
android:id="@+id/assign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="指定"
android:textColor="#ffffff" />
<RadioButton
android:id="@+id/fixation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="固定"
android:textColor="#ffffff" />
</RadioGroup>
<EditText
android:id="@+id/et_ip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:digits="0123456789.:"
android:gravity="right|center_vertical"
android:hint="输入指定IP:PORT"
android:imeOptions="flagNoExtractUi"
android:inputType="number"
android:layoutDirection="ltr"
android:maxLength="21"
android:maxLines="1"
android:minWidth="206dp"
android:paddingStart="40dp"
android:textColor="@color/colorWhile"
android:textColorHint="#DEDEDE"
android:textSize="16sp" />
<ImageView
android:id="@+id/tv_ip"
android:layout_width="26dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginStart="-42dp"
android:scaleType="centerInside"
android:src="@drawable/selector_history_ip" />
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/colorBlock"
android:textSize="16sp" />

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?><!--测试列表Item-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="3dp"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal">
<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="12sp" />
<EditText
android:id="@+id/log"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:cursorVisible="false"
android:focusable="false"
android:textColor="#ff0000"
android:textSize="12sp" />
</LinearLayout>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_adas_dialog"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_status"
android:layout_width="260dp"
android:layout_height="280dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp" />
</LinearLayout>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorGold">#FFD700</color>
<color name="colorBlue">#102b6a</color>
<color name="colorBlue2">#224b8f</color>
<color name="colorWhile">#FFFFFF</color>
<color name="colorBlock">#000000</color>
<color name="colorDeepPink">#FF1493</color>
<color name="colorCrimson">#DC143C</color>
<color name="colorLimeGreen">#32CD32</color>
<color name="colorSlateGray">#708090</color>
<color name="connect_status_connected">#32CD32</color>
<color name="connect_status_disconnected">#DC143C</color>
<color name="connect_status_connecting">#FF00FF</color>
<color name="connect_status_disconnecting">#DAA520</color>
<color name="connect_status_search_address">#1E90FF</color>
</resources>

View File

@@ -0,0 +1,5 @@
<resources>
<string name="app_name">蘑戒</string>
<string name="hint">复位按钮:下发减速命令之后需要复位操作\n减速按钮单机触发减速长按配置减速发送频率\n鸣笛按钮单机触发鸣笛长按配置鸣笛时长</string>
</resources>

View File

@@ -0,0 +1,34 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#224b8f</item>
<item name="colorPrimaryDark">@color/colorBlue</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
</style>
<style name="CustomDialog" parent="Theme.MaterialComponents.Light.Dialog">
<!--背景颜色及和透明程度-->
<item name="android:windowBackground">@android:color/transparent</item>
<!--是否去除标题 -->
<item name="android:windowNoTitle">true</item>
<!--是否去除边框-->
<item name="android:windowFrame">@null</item>
<!--是否浮现在activity之上-->
<item name="android:windowIsFloating">true</item>
<!--是否模糊-->
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

View File

@@ -0,0 +1,17 @@
package com.zhidao.adas.magic;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@@ -1036,5 +1036,88 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType) { public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType) {
return subscribeInterface != null && subscribeInterface.subscribeInterface(role, type, messageType); return subscribeInterface != null && subscribeInterface.subscribeInterface(role, type, messageType);
} }
/**
* 向左变道
*
* @return boolean
*/
@Override
public boolean sendOperatorCmdChangeLaneLeft() {
MessagePad.OperatorCmdReq req = MessagePad.OperatorCmdReq
.newBuilder()
.setCmdType(MessagePad.OperatorCmdType.OPERATOR_CMD_CHANGE_LANE)
.setValue(1)
.build();
return sendPBMessage(MessageType.TYPE_SEND_OPERATOR_CMD_REQ.typeCode, req.toByteArray());
}
/**
* 向右变道
*
* @return boolean
*/
@Override
public boolean sendOperatorCmdChangeLaneRight() {
MessagePad.OperatorCmdReq req = MessagePad.OperatorCmdReq
.newBuilder()
.setCmdType(MessagePad.OperatorCmdType.OPERATOR_CMD_CHANGE_LANE)
.setValue(2)
.build();
return sendPBMessage(MessageType.TYPE_SEND_OPERATOR_CMD_REQ.typeCode, req.toByteArray());
}
/**
* 发送设置加速度
*
* @param acc acc>0加速 acc<0减速 acc=0复位
* @return boolean
*/
@Override
public boolean sendOperatorCmdSetAcceleratedSpeed(double acc) {
MessagePad.OperatorCmdReq req = MessagePad.OperatorCmdReq
.newBuilder()
.setCmdType(MessagePad.OperatorCmdType.OPERATOR_CMD_SET_ACCELERATED_SPEED)
.setValue(acc)
.build();
return sendPBMessage(MessageType.TYPE_SEND_OPERATOR_CMD_REQ.typeCode, req.toByteArray());
}
/**
* 鸣笛
*
* @param value 1: honk 2: stop honking
* @return boolean
*/
@Override
public boolean sendOperatorCmdSetHorn(double value) {
MessagePad.OperatorCmdReq req = MessagePad.OperatorCmdReq
.newBuilder()
.setCmdType(MessagePad.OperatorCmdType.OPERATOR_CMD_SET_HORN)
.setValue(value)
.build();
return sendPBMessage(MessageType.TYPE_SEND_OPERATOR_CMD_REQ.typeCode, req.toByteArray());
}
/**
* 开始鸣笛
*
* @return boolean
*/
@Override
public boolean sendOperatorCmdStartHonking() {
return sendOperatorCmdSetHorn(1);
}
/**
* 停止鸣笛
*
* @return boolean
*/
@Override
public boolean sendOperatorCmdStopHonking() {
return sendOperatorCmdSetHorn(2);
}
} }

View File

@@ -546,6 +546,37 @@ public class AdasManager implements IAdasNetCommApi {
return mChannel != null && mChannel.subscribeInterface(role, type, messageType); return mChannel != null && mChannel.subscribeInterface(role, type, messageType);
} }
@Override
public boolean sendOperatorCmdChangeLaneLeft() {
return mChannel != null && mChannel.sendOperatorCmdChangeLaneLeft();
}
@Override
public boolean sendOperatorCmdChangeLaneRight() {
return mChannel != null && mChannel.sendOperatorCmdChangeLaneRight();
}
@Override
public boolean sendOperatorCmdSetAcceleratedSpeed(double acc) {
return mChannel != null && mChannel.sendOperatorCmdSetAcceleratedSpeed(acc);
}
@Override
public boolean sendOperatorCmdSetHorn(double value) {
return mChannel != null && mChannel.sendOperatorCmdSetHorn(value);
}
@Override
public boolean sendOperatorCmdStartHonking() {
return mChannel != null && mChannel.sendOperatorCmdStartHonking();
}
@Override
public boolean sendOperatorCmdStopHonking() {
return mChannel != null && mChannel.sendOperatorCmdStopHonking();
}
/** /**
* 获取工控机固定IP列表 * 获取工控机固定IP列表
* *

View File

@@ -275,6 +275,50 @@ public interface IAdasNetCommApi {
*/ */
boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType); boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType);
/**
* 向左变道
*
* @return boolean
*/
boolean sendOperatorCmdChangeLaneLeft();
/**
* 向右变道
*
* @return boolean
*/
boolean sendOperatorCmdChangeLaneRight();
/**
* 发送设置加速度
*
* @param acc acc>0加速 acc<0减速 acc=0复位
* @return boolean
*/
boolean sendOperatorCmdSetAcceleratedSpeed(double acc);
/**
* 鸣笛
*
* @param value 1: honk 2: stop honking
* @return boolean
*/
boolean sendOperatorCmdSetHorn(double value);
/**
* 开始鸣笛
*
* @return boolean
*/
boolean sendOperatorCmdStartHonking();
/**
* 停止鸣笛
*
* @return boolean
*/
boolean sendOperatorCmdStopHonking();
// TODO 需求暂停 待讨论 // TODO 需求暂停 待讨论
// boolean getRoutes(); // boolean getRoutes();

View File

@@ -45,10 +45,11 @@ public enum MessageType {
TYPE_SEND_STATUS_QUERY_REQ(MessagePad.MessageType.MsgTypeStatusQueryReq, "状态查询请求"), TYPE_SEND_STATUS_QUERY_REQ(MessagePad.MessageType.MsgTypeStatusQueryReq, "状态查询请求"),
TYPE_RECEIVE_STATUS_QUERY_RESP(MessagePad.MessageType.MsgTypeStatusQueryResp, "状态查询应答"), TYPE_RECEIVE_STATUS_QUERY_RESP(MessagePad.MessageType.MsgTypeStatusQueryResp, "状态查询应答"),
TYPE_SEND_SET_RAIN_MODE_REQ(MessagePad.MessageType.MsgTypeSetRainModeReq, "设置雨天模式"), TYPE_SEND_SET_RAIN_MODE_REQ(MessagePad.MessageType.MsgTypeSetRainModeReq, "设置雨天模式"),
TYPE_SEND_OPERATOR_CMD_REQ(MessagePad.MessageType.MsgTypeOperatorCmdReq, "操控指令"),
TYPE_SEND_RECORD_DATA_CONFIG_REQ(MessagePad.MessageType.MsgTypeRecordDataConfigReq, "数据采集配置查询"), TYPE_SEND_RECORD_DATA_CONFIG_REQ(MessagePad.MessageType.MsgTypeRecordDataConfigReq, "数据采集配置查询"),
TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP(MessagePad.MessageType.MsgTypeRecordDataConfigResp, "数据采集配置"), TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP(MessagePad.MessageType.MsgTypeRecordDataConfigResp, "数据采集配置"),
TYPE_SEND_SUBSCRIBE_DATA_REQ(MessagePad.MessageType.MsgTypeSubscribeDataReq, "数据订阅、取消订阅请求"), TYPE_SEND_SUBSCRIBE_DATA_REQ(MessagePad.MessageType.MsgTypeSubscribeDataReq, "数据订阅、取消订阅请求"),
//透传 原始pb文件中不存在以下type。由于Java中无法强转所以在ADAS_DATA message_pad.proto中放开注释 //透传 原始pb文件中不存在以下type。由于Java中无法强转所以在mogo-adas-data message_pad.proto中放开注释
TYPE_RECEIVE_PLANNING_DECISION_STATE(MessagePad.MessageType.MsgTypePlanningDecisionState, "Planning决策状态"); TYPE_RECEIVE_PLANNING_DECISION_STATE(MessagePad.MessageType.MsgTypePlanningDecisionState, "Planning决策状态");

View File

@@ -1,6 +1,7 @@
rootProject.name = 'MoGoEagleEye' rootProject.name = 'MoGoEagleEye'
include ':app' include ':app'
include ':app_ipc_monitoring' include ':app_ipc_monitoring'
include ':app_mogo_magic_ring'
// 核心模块 // 核心模块