lizhanwei
2020-03-04 de8c957f910882394cd430af5a59968d8d31fb39
联网测试全屏增加考试平台状态,卫星颗数,RTK状态,时间等
14个文件已修改
1个文件已添加
138 ■■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/DB/appstatusdb/AppStatusWorker.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/MainActivity.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/im/MessageProcessor.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/antenna.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/antenna_red.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/drawable/gps.png 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_main.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_net_train.xml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/layout_train_fragment.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/networktoolbar.xml 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/profile_layout.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/dimens.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/values/strings.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/DB/appstatusdb/AppStatusWorker.java
@@ -1,6 +1,7 @@
package safeluck.drive.evaluation.DB.appstatusdb;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.work.Worker;
@@ -34,6 +35,7 @@
    public Result doWork() {
        String[] str = getInputData().getStringArray(Constant.APP_STATUS);
        JSONObject jsonObject = null;
        Log.i(TAG,"doWork:"+str[0]+": "+str[1]);
        try {
            jsonObject = new JSONObject(str[1]);
            switch (str[0]) {
app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -10,6 +10,8 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
@@ -156,7 +158,8 @@
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //全屏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        // TODO
        //  进行tcp连接
@@ -324,11 +327,13 @@
    @Override
    public void onConnecting() {
        MyLog.i(TAG,"TCP onConnecting");
    }
    @Override
    public void onConnected() {
        ExamPlatformData.getInstance().setExamplatformStatus(ExamPlatformData.TCP_CONNECTED);
        MyLog.i(TAG,"TCP连接成功");
        //TODO 判断SPUtils 是否保存有des密码;如果没有则进行注册JKMessage0100,如果有密码则进行鉴权JKMessage0101
        String hexPwd = (String) SPUtils.get(this,SPUtils.DES_HEX_PWD,"");
@@ -356,6 +361,7 @@
    @Override
    public void onConnectFailed() {
        ExamPlatformData.getInstance().setExamplatformStatus(ExamPlatformData.TCP_DISCONNECT);
        MyLog.i(TAG,"TCP连接失败");
    }
app/src/main/java/safeluck/drive/evaluation/bean/ExamPlatformData.java
@@ -5,11 +5,17 @@
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModelProviders;
import androidx.work.Data;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import com.anyun.exam.lib.MyLog;
import java.util.HashMap;
import java.util.Random;
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.DB.appstatusdb.AppStatusWorker;
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.util.SPUtils;
import safeluck.drive.evaluation.viewmodels.ExamPlatformModel;
@@ -19,6 +25,26 @@
    private static final ExamPlatformData ourInstance = new ExamPlatformData();
    private int exam_id =12345;//考试唯一ID
    public static final int TCP_DISCONNECT = 1;
    public static final int TCP_CONNECTED = 2;///2-未连接(tcp连接不上)
    public static final int DEV_NOT_REGISTERED = 3;
    public static final int DEV_REGISTERED = 4;
    public static final int DEV_NOT_LOGIN = 5;
    public static final int DEV_LOGIN = 6;
    private static HashMap<Integer,String> examPlatformStrs = new HashMap<>();
    static {
        examPlatformStrs.put(TCP_DISCONNECT,"未连接");
        examPlatformStrs.put(TCP_CONNECTED,"已连接");
        examPlatformStrs.put(DEV_NOT_REGISTERED,"未注册");
        examPlatformStrs.put(DEV_REGISTERED,"已注册");
        examPlatformStrs.put(DEV_NOT_LOGIN,"未登录");
        examPlatformStrs.put(DEV_LOGIN,"已登录");
    }
    private static final String WORK_PLATFORM_STATUS = " work_platform";
    private int examplatformStatus =1;//1-未连接(tcp连接不上)   3-未注册(设备没有注册)   5-未登录(鉴权未通过)
    private String id;//身份证
@@ -115,4 +141,25 @@
        carPath = (String) SPUtils.get(app.getAppContext(),SPUtils.CAR_PATH,"");
        return carPath;
    }
    public int getExamplatformStatus() {
        return examplatformStatus;
    }
    public void setExamplatformStatus(int examplatformStatus) {
        String[] conn_strs = new String[2];
        conn_strs[0] = Constant.WORK_PLATFORM_STATUS_COLUMN;
        conn_strs[1] = "{"+WORK_PLATFORM_STATUS+":"+examplatformStatus+"}";
        //RTK平台连接状态
        Data connStatusData = new Data.Builder().putStringArray(Constant.APP_STATUS,conn_strs).build();
        OneTimeWorkRequest oneTimeWorkRequest = new OneTimeWorkRequest.Builder(AppStatusWorker.class).
                setInputData(connStatusData).build();
        WorkManager.getInstance(app.getAppContext()).enqueue(oneTimeWorkRequest);
        this.examplatformStatus = examplatformStatus;
    }
    public String getExamplatformStatusStr(int work_platform) {
        return examPlatformStrs.get(work_platform);
    }
}
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -83,7 +83,7 @@
    private int item_id;//扣分分数总和
    private ExamStatusViewModel examStatusViewModel;
    private static final int ADD_DATA = 1;
    private TextView tv_speed,tv_total_score,tv_sat_num,tv_name,tv_id;
    private TextView tv_speed,tv_total_score,tv_sat_num,tv_name,tv_id,tv_work_platform;
    private double speed=0.0;
    private ImageView iv_rtk_status,iv_head;
@@ -229,6 +229,7 @@
                if (appStatus != null){
                    Log.i(TAG, "onChanged: "+appStatus.toString());
                    iv_rtk_status.getDrawable().setLevel(appStatus.getRtk_connect_status());
                    tv_work_platform.setText(getString(R.string.platform_status,ExamPlatformData.getInstance().getExamplatformStatusStr(appStatus.getWork_platform())));
                    tv_sat_num.setText(String.valueOf(appStatus.getDefault_observe1()).length()==1?"0"+appStatus.getDefault_observe1():String.valueOf(appStatus.getDefault_observe1()));
                }
            }
@@ -341,6 +342,7 @@
        houseView = view.findViewById(R.id.hv);
        tv_name = view.findViewById(R.id.tv_name);
        tv_id = view.findViewById(R.id.tv_ID);
        tv_work_platform = view.findViewById(R.id.platform);
        iv_rtk_status = view.findViewById(R.id.iv_rtk_connect);
        iv_head = view.findViewById(R.id.iv_head);
app/src/main/java/safeluck/drive/evaluation/im/MessageProcessor.java
@@ -19,6 +19,7 @@
import safeluck.drive.evaluation.Constant;
import safeluck.drive.evaluation.DB.StudentInfoUpdateWork;
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.bean.ExamPlatformData;
import safeluck.drive.evaluation.platformMessage.JK2019MessageBase;
import safeluck.drive.evaluation.platformMessage.JKMessage0001;
import safeluck.drive.evaluation.platformMessage.JKMessage0100;
@@ -73,12 +74,18 @@
                JKMessage0101 jkMessage0101 = new JKMessage0101();
                jkMessage0101.des =((JKMessage8100) jk2019MessageBase).des;
                jkMessage0101.timestamp = (int) System.currentTimeMillis();
                ExamPlatformData.getInstance().setExamplatformStatus(ExamPlatformData.DEV_REGISTERED);
            }else{
                ExamPlatformData.getInstance().setExamplatformStatus(ExamPlatformData.DEV_REGISTERED);
            }
        }else if (jk2019MessageBase instanceof JKMessage8001){
            JKMessage8001 jkMessage8001 = (JKMessage8001) jk2019MessageBase;
            String hexMessageId = jkMessage8001.respMessageId;
            if (hexMessageId.equalsIgnoreCase("0101")){
                MyLog.i(PlatFormConstant.TAG,"鉴权成功");
                ExamPlatformData.getInstance().setExamplatformStatus(ExamPlatformData.DEV_LOGIN);
            }else{
                ExamPlatformData.getInstance().setExamplatformStatus(ExamPlatformData.DEV_NOT_LOGIN);
            }
        }else if (jk2019MessageBase instanceof JKMessage8201){
            JKMessage8201 jkMessage8201 = (JKMessage8201) jk2019MessageBase;
app/src/main/res/drawable/antenna.png

app/src/main/res/drawable/antenna_red.png

app/src/main/res/drawable/gps.png

app/src/main/res/layout/activity_main.xml
@@ -6,6 +6,7 @@
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <FrameLayout
        android:id="@+id/fl_container"
        android:layout_width="match_parent"
app/src/main/res/layout/layout_net_train.xml
@@ -5,7 +5,10 @@
  android:layout_width="0dp"
    android:layout_weight="4"
    android:layout_height="match_parent"
    android:padding="5dp"
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@color/train_bg"
app/src/main/res/layout/layout_train_fragment.xml
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/home_bg_color">
<include layout="@layout/networktoolbar"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/ll"
            android:orientation="vertical">
            <include  android:layout_marginBottom="10dp"  android:layout_width="match_parent" android:layout_height="120dp" android:id="@+id/profile" layout="@layout/profile_layout"/>
            <include android:layout_marginBottom="10dp"  android:layout_width="match_parent" android:layout_height="170dp"  layout="@layout/layout_net_train"/>
            <include  android:layout_marginBottom="2dp"  android:layout_width="match_parent" android:layout_height="110dp" android:id="@+id/profile" layout="@layout/profile_layout"/>
            <include android:layout_marginBottom="2dp"  android:layout_width="match_parent" android:layout_height="140dp"  layout="@layout/layout_net_train"/>
            <include android:layout_marginBottom="10dp" android:layout_width="match_parent" android:layout_height="240dp" layout="@layout/layout_stu_score"/>
            <include android:layout_marginBottom="2dp" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/layout_stu_score"/>
        </LinearLayout>
</ScrollView>
</LinearLayout>
app/src/main/res/layout/networktoolbar.xml
New file
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
    <com.google.android.material.appbar.AppBarLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/actionbarsizehalf"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/AppTheme.NoActionBar.PopupOverlay"
            app:titleTextAppearance="@style/Toolbar_TextAppearance_White">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="02"
                android:gravity="center"
                android:drawableLeft="@drawable/gps"
                android:textColor="@android:color/white" />
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/iv_rtk_connect"
                android:layout_marginLeft="50dp"
                android:src="@drawable/antennaxml"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:id="@+id/network_time"
                android:singleLine="true"
                android:textColor="@android:color/white"
                android:text="12:34:33"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/platform"
                android:singleLine="true"
                android:layout_gravity="end"
                android:textColor="@android:color/white"
                android:text="@string/platform_status"/>
        </androidx.appcompat.widget.Toolbar>
    </com.google.android.material.appbar.AppBarLayout>
</layout>
app/src/main/res/layout/profile_layout.xml
@@ -124,6 +124,7 @@
    </LinearLayout>
    <RelativeLayout
        android:visibility="gone"
        android:layout_width="0dp"
        android:layout_height="90dp"
        android:layout_marginLeft="10dp"
app/src/main/res/values/dimens.xml
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="bottombar_height">0dp</dimen>
    <dimen name="actionbarsizehalf">28dp</dimen>
</resources>
app/src/main/res/values/strings.xml
@@ -34,4 +34,5 @@
    <string name="mcu_info">协处理器信息:</string>
    <string name="chesu">车速:</string>
    <string name="engine">转速:</string>
    <string name="platform_status">考试平台:%1$s</string>
</resources>