From ba478cde2b1198b073a8a32bb66f860c64dc10dc Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期三, 22 四月 2020 16:53:13 +0800
Subject: [PATCH] 完成查看车载信号输入

---
 app/src/main/res/layout/layout_check_signal.xml                                 |   25 +++++++-
 app/src/main/res/layout/layout_signal_config.xml                                |   11 ++-
 app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java |    7 -
 app/src/main/res/drawable/tv_des_bg.xml                                         |   21 +++++-
 app/src/main/res/values/attrs.xml                                               |    3 +
 app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt      |   60 ++++++++++++++------
 app/src/main/res/layout/layout_mycustom_et.xml                                  |   10 +-
 7 files changed, 95 insertions(+), 42 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt b/app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt
index e9f6721..bbe0e23 100644
--- a/app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt
@@ -1,11 +1,9 @@
 package safeluck.drive.evaluation.customview
 
 import android.content.Context
-import android.content.res.TypedArray
-import android.os.Parcel
-import android.os.Parcelable
 import android.text.Editable
 import android.util.AttributeSet
+import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import android.widget.EditText
@@ -29,10 +27,17 @@
 
 class MyCustomEditText : LinearLayout{
 
-    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context,attrs,defStyleAttr,defStyleRes) {
-        mcontext = context
-        init()
+    private val TAG= "MyCustomEditText"
+
+    constructor(context: Context) : this(context, null)
+    constructor(context: Context, attributeSet: AttributeSet?) : this(context, attributeSet, 0)
+
+    constructor(context: Context, attributeSet: AttributeSet?, defStyleAttr: Int):super(context,attributeSet,defStyleAttr){
+        init(context,attributeSet)
     }
+
+
+
 
     // true灏辨槸鏄剧ず  false涓嶆樉绀�
      var visiblity:Boolean = true
@@ -40,38 +45,57 @@
     var str:String=""
     var desstr:String=""
 
-    var mcontext:Context?= null
     var txtDes:TextView? = null
     var txtDesUnit:TextView? = null
     var et_num:EditText? = null
     var view: View? = null
-    override fun onFinishInflate() {
-        super.onFinishInflate()
+
+
+    fun init(context: Context, attributeSet: AttributeSet?){
+        Log.i(TAG,"myCustomEditText z鑷畾涔�---------")
+        view = LayoutInflater.from(context).inflate(R.layout.layout_mycustom_et,this,true)
+
         txtDes = view?.findViewById(R.id.tv_des_et)
         txtDesUnit = view?.findViewById(R.id.tv_unit)
         et_num = view?.findViewById(R.id.et_num)
 
+        var a = context.obtainStyledAttributes(attributeSet,R.styleable.mycustom_et)
+        //鑾峰彇鏄惁瑕佹樉绀哄崟浣�
+        visiblity = a!!.getBoolean(R.styleable.mycustom_et_txt_unit,true)
+        str = a!!.getString(R.styleable.mycustom_et_txt)
+        desstr = a!!.getString(R.styleable.mycustom_et_txt_des)
+
+        var desunit = a!!.getString(R.styleable.mycustom_et_txt_unit_des)
+//        var width = a!!.getString(R.styleable.mycustom_et_view_width)
+//        var height = a!!.getString(R.styleable.mycustom_et_view_height)
+
+        Log.i(TAG,"txtDes=$desstr")
+        Log.i(TAG,"str=$str")
+        Log.i(TAG,"visiblity=$visiblity")
+
+
 
         when(visiblity){
-            true->txtDesUnit?.visibility = View.VISIBLE
+            true->{
+                txtDesUnit?.visibility = View.VISIBLE
+                txtDesUnit?.text = desunit
+            }
             else-> txtDesUnit?.visibility = View.GONE
         }
 
         txtDes?.text = desstr
         et_num?.text = Editable.Factory.getInstance().newEditable(str)
 
+        a.recycle()
+
+
     }
 
-    fun init(){
-        view = LayoutInflater.from(mcontext).inflate(R.layout.layout_mycustom_et,null)
-
-        var attributeSet = mcontext?.obtainStyledAttributes(R.styleable.mycustom_et)
-        //鑾峰彇鏄惁瑕佹樉绀哄崟浣�
-        visiblity = attributeSet?.getBoolean(R.styleable.mycustom_et_txt_unit,true)!!
-        str = attributeSet?.getString(R.styleable.mycustom_et_txt)
-        desstr = attributeSet?.getString(R.styleable.mycustom_et_txt_des)
 
 
+    fun updateStr(str:String){
+        et_num?.text = Editable.Factory.getInstance().newEditable(str)
+        invalidate()
     }
 
 }
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
index ae10e36..dc0c870 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
@@ -44,9 +44,6 @@
 
     private static final String TAG = "InspectSignalFragment";
     private static final int  VALIAD_NUM = 1;//1楂樼數骞虫湁鏁�
-
-    private TextView textView_turnLight,tv_speed,tv_engine;
-    private Toolbar toolbar;
     private Gson gson= new Gson();
     private Handler handler = new Handler();
     private LayoutCheckSignalBinding bingding;
@@ -70,8 +67,8 @@
                     handler.post(new Runnable() {
                                 @Override
                                 public void run() {
-//                                    bingding.tvRoateSpeed.setText(String.valueOf(mcuInfo.getEngine()));
-//                                    bingding.tvDangweiNum.setText(String.valueOf(mcuInfo.getSpeed()/10.0));
+                                    bingding.roatespeed.updateStr(String.valueOf(mcuInfo.getEngine()));
+                                    bingding.myspeed.updateStr(String.valueOf(mcuInfo.getSpeed()/10.0));
 
                                     for (int i = 0; i < gpios.size(); i++) {
                                         Log.i(TAG, "run: gpio["+i+"]="+gpios.get(i));
diff --git a/app/src/main/res/drawable/tv_des_bg.xml b/app/src/main/res/drawable/tv_des_bg.xml
index 0e7c229..06e2893 100644
--- a/app/src/main/res/drawable/tv_des_bg.xml
+++ b/app/src/main/res/drawable/tv_des_bg.xml
@@ -1,6 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
-    android:shape="rectangle">
-<solid android:color="#ff2b3141"/>
-    <corners android:radius="@dimen/ui_margin_5dp"/>
-</shape>
\ No newline at end of file
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
+>
+    <item>
+        <shape android:shape="rectangle">
+            <stroke android:color="#11468A" android:width="1dp"/>
+            <corners android:bottomLeftRadius="@dimen/ui_margin_5dp" android:topLeftRadius="@dimen/ui_margin_5dp"/>
+        </shape>
+    </item>
+    <item  android:top="1dp" android:left="1dp" android:bottom="1dp">
+        <shape     android:shape="rectangle">
+            <solid android:color="#ff2b3141"/>
+            <corners android:topLeftRadius="@dimen/ui_margin_5dp" android:bottomLeftRadius="@dimen/ui_margin_5dp"/>
+        </shape>
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_check_signal.xml b/app/src/main/res/layout/layout_check_signal.xml
index 5f670f2..cb48455 100644
--- a/app/src/main/res/layout/layout_check_signal.xml
+++ b/app/src/main/res/layout/layout_check_signal.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:lee="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
@@ -27,10 +28,26 @@
                 android:padding="10dp"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content">
-                <include layout="@layout/layout_mycustom_et" android:id="@+id/myspeed"
-                    android:layout_width="200dp" android:layout_height="40dp"/>
-                <include layout="@layout/layout_mycustom_et" android:id="@+id/myrotatespeed" android:layout_below="@+id/myspeed"
-                     android:layout_marginTop="@dimen/ui_margin_20dp"  android:layout_width="237dp" android:layout_height="58dp"/>
+                <safeluck.drive.evaluation.customview.MyCustomEditText
+
+                    android:id="@+id/myspeed"
+                    lee:txt="121"
+                    lee:txt_des="杞﹂��"
+                    lee:txt_unit="true"
+                    lee:txt_unit_des ="km/h"
+
+                    android:layout_height="58dp"
+                    android:layout_width="237dp"/>
+                <safeluck.drive.evaluation.customview.MyCustomEditText
+                    android:layout_marginTop="@dimen/ui_margin_20dp"
+                    android:layout_below="@+id/myspeed"
+                    lee:txt="1212"
+                    lee:txt_des="杞��"
+                    lee:txt_unit="true"
+                    lee:txt_unit_des ="r/min"
+                    android:id="@+id/roatespeed"
+                    android:layout_height="58dp"
+                    android:layout_width="237dp"/>
             </RelativeLayout>
         </FrameLayout>
 
diff --git a/app/src/main/res/layout/layout_mycustom_et.xml b/app/src/main/res/layout/layout_mycustom_et.xml
index 58e5348..872b7ad 100644
--- a/app/src/main/res/layout/layout_mycustom_et.xml
+++ b/app/src/main/res/layout/layout_mycustom_et.xml
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="horizontal" android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
+    android:orientation="horizontal" android:layout_width="237dp"
+    android:layout_height="58dp"
     android:gravity="center_vertical"
     android:background="@drawable/input_bg">
 <TextView
     android:layout_width="wrap_content"
-    android:layout_height="58dp"
+    android:layout_height="match_parent"
     android:text="杞﹂��"
     android:gravity="center_vertical"
     android:paddingLeft="@dimen/ui_margin_5dp"
@@ -18,7 +18,7 @@
     />
     <EditText
         android:layout_width="100dp"
-        android:layout_height="58dp"
+        android:layout_height="match_parent"
         android:text="123"
         android:background="@null"
         android:gravity="center"
@@ -28,7 +28,7 @@
         />
     <TextView
         android:layout_width="wrap_content"
-        android:layout_height="58dp"
+        android:layout_height="match_parent"
         android:text="km/h"
         android:gravity="center"
         android:textSize="20sp"
diff --git a/app/src/main/res/layout/layout_signal_config.xml b/app/src/main/res/layout/layout_signal_config.xml
index aaad303..467a9c0 100644
--- a/app/src/main/res/layout/layout_signal_config.xml
+++ b/app/src/main/res/layout/layout_signal_config.xml
@@ -3,22 +3,23 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:background="@android:color/white"
     android:id="@+id/ll_container"
     >
     <include layout="@layout/toolbar"/>
 <LinearLayout
     android:layout_width="match_parent"
-    android:layout_height="30dp"
-    android:padding="5dp"
-
+    android:layout_height="25dp"
+    android:layout_marginLeft="@dimen/ui_margin_10dp"
+    android:layout_marginRight="10dp"
+    android:background="@drawable/stu_score_bg"
     android:orientation="horizontal"
     android:layout_column="8">
 <TextView
     android:layout_width="0dp"
     android:layout_weight="1"
     android:layout_height="wrap_content"
-    android:textColor="@android:color/black"
+    android:textSize="15sp"
+    android:textColor="#ff888995"
     android:text="淇″彿鍚嶇О"/>
     <TextView
         android:layout_width="0dp"
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index d0465d8..5dc8219 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -18,5 +18,8 @@
         <attr name="txt" format="string"/>
         <attr name="txt_des" format="string"/>
         <attr name="txt_unit" format="boolean"/>
+        <attr name="txt_unit_des" format="string"/>
+<!--        <attr name="view_height" format="integer"/>-->
+<!--        <attr name="view_width" format="integer"/>-->
     </declare-styleable>
 </resources>
\ No newline at end of file

--
Gitblit v1.8.0