[清扫车] 左上角车辆基本信息布局处理

This commit is contained in:
bxb
2023-01-11 17:07:37 +08:00
parent c656ceea58
commit 792cbf89a5
11 changed files with 102 additions and 36 deletions

View File

@@ -3,6 +3,7 @@ package com.mogo.och.sweeper.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -22,7 +23,6 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import chassis.Chassis;
import chassis.ChassisStatesOuterClass;
import chassis.VehicleStateOuterClass;
import planning.RoboSweeperTaskIndexOuterClass;
public class SweeperTrafficDataView extends ConstraintLayout {
@@ -32,6 +32,9 @@ public class SweeperTrafficDataView extends ConstraintLayout {
private TextView speedTextView;//速度值
private TurnSignalView sweeperTurnSignal;//转向灯
private SweeperLimitingVelocityView sweeperLimitingVelocity;//限速
private TextView tvBattery;//电量百分比展示
private ImageView ivBgWaterWarning;//水位预警背景图
private ImageView ivWater;//水位图标
public SweeperTrafficDataView(@NonNull Context context) {
super(context);
@@ -56,6 +59,9 @@ public class SweeperTrafficDataView extends ConstraintLayout {
speedTextView = findViewById(R.id.sweeperSpeedText);
sweeperTurnSignal = findViewById(R.id.sweeperTurnSignal);
sweeperLimitingVelocity = findViewById(R.id.sweeperLimitingVelocity);
tvBattery = findViewById(R.id.tvBattery);
ivBgWaterWarning = findViewById(R.id.sweeperIvBgWaterWarning);
ivWater = findViewById(R.id.sweeperIvWater);
}
@Override
protected void onAttachedToWindow() {
@@ -79,15 +85,21 @@ public class SweeperTrafficDataView extends ConstraintLayout {
@Override
public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) {
if (cleanSystemState!=null&&cleanSystemState.hasSecuCleanWaterTankLow()) {//清水箱水位低不能清洗作业报警信号
ivBgWaterWarning.setVisibility(View.VISIBLE);
ivWater.setSelected(true);
}else{
ivBgWaterWarning.setVisibility(View.GONE);
ivWater.setSelected(false);
}
}
@Override
public void onBMSSystemStates(@NonNull ChassisStatesOuterClass.BMSSystemStates bmsSystemStates) {
if (bmsSystemStates!=null){
tvBattery.setText(String.format("%s%",65));
}
}
/**
* 车辆转向灯
* @param lightSwitch

View File

@@ -139,18 +139,15 @@ public class SweeperTrafficLightView extends IViewTrafficLight {
switch (lightId) {
case 1:
mLightIconIV.setBackgroundResource(R.drawable.sweeper_light_red_nor);
SweeperTrafficLightView.this.setVisibility(VISIBLE);
break;
case 2:
mLightIconIV.setBackgroundResource(R.drawable.sweeper_lightyellow_nor);
SweeperTrafficLightView.this.setVisibility(VISIBLE);
break;
case 3:
mLightIconIV.setBackgroundResource(R.drawable.sweeper_light_green_nor);
SweeperTrafficLightView.this.setVisibility(VISIBLE);
break;
default:
SweeperTrafficLightView.this.setVisibility(GONE);
mLightIconIV.setBackgroundResource(R.drawable.sweeper_light_gay_nor);
break;
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

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/icon_water_select" android:state_selected="true" />
<item android:drawable="@drawable/icon_water_nor" android:state_selected="false"/>
</selector>

View File

@@ -3,17 +3,18 @@
android:layout_width="@dimen/dp_616"
android:layout_height="@dimen/dp_320"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/sweeper_bg_traffic_data"
android:paddingStart="@dimen/dp_47"
android:paddingTop="@dimen/dp_22">
<ImageView
android:id="@+id/sweeperSpeedImage"
android:layout_width="@dimen/dp_154"
android:layout_height="@dimen/dp_154"
android:layout_width="@dimen/dp_200"
android:layout_height="@dimen/dp_200"
android:background="@drawable/sweeper_bg_traffic_data_speed"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="@dimen/dp_22"
android:layout_marginTop="@dimen/dp_4"
/>
<TextView
android:id="@+id/sweeperSpeedText"
@@ -25,7 +26,7 @@
android:text="0"
android:gravity="center"
android:textSize="@dimen/dp_48"
android:layout_marginTop="@dimen/dp_38"
android:layout_marginTop="@dimen/dp_43"
android:textColor="@color/white"
android:textStyle="bold"
/>
@@ -45,12 +46,12 @@
android:id="@+id/sweeperTrafficPosition"
android:layout_width="@dimen/dp_200"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginStart="@dimen/dp_20"
app:defaultColor="@color/acc_default_txt_color"
app:layout_constraintLeft_toRightOf="@+id/sweeperSpeedImage"
app:layout_constraintTop_toTopOf="parent"
app:selectColor="@color/dark_mode_select_txt_color"
android:layout_marginTop="@dimen/dp_35"/>
android:layout_marginTop="@dimen/dp_30"/>
<View
android:id="@+id/line1"
android:layout_width="@dimen/dp_1"
@@ -58,7 +59,7 @@
app:layout_constraintStart_toEndOf="@+id/sweeperTrafficPosition"
app:layout_constraintTop_toTopOf="@+id/sweeperTrafficPosition"
app:layout_constraintBottom_toBottomOf="@+id/sweeperTrafficPosition"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginStart="@dimen/dp_3"
android:background="#414869"/>
<com.mogo.och.sweeper.view.SweeperLimitingVelocityView
android:id="@+id/sweeperLimitingVelocity"
@@ -67,7 +68,7 @@
app:layout_constraintStart_toEndOf="@+id/line1"
app:layout_constraintTop_toTopOf="@+id/sweeperTrafficPosition"
app:layout_constraintBottom_toBottomOf="@+id/sweeperTrafficPosition"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginStart="@dimen/dp_26"
/>
<com.mogo.och.sweeper.view.TurnSignalView
android:id="@+id/sweeperTurnSignal"
@@ -75,8 +76,8 @@
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/sweeperTrafficPosition"
app:layout_constraintLeft_toRightOf="@+id/sweeperSpeedImage"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginStart="@dimen/dp_30"/>
android:layout_marginStart="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"/>
<View
android:id="@+id/line2"
android:layout_width="@dimen/dp_1"
@@ -84,14 +85,66 @@
app:layout_constraintStart_toEndOf="@+id/sweeperTurnSignal"
app:layout_constraintTop_toTopOf="@+id/sweeperTurnSignal"
app:layout_constraintBottom_toBottomOf="@+id/sweeperTurnSignal"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginStart="@dimen/dp_3"
android:background="#414869"/>
<com.mogo.och.sweeper.view.SweeperTrafficLightView
android:layout_width="@dimen/dp_120"
android:layout_height="@dimen/dp_120"
app:layout_constraintStart_toEndOf="@+id/line2"
app:layout_constraintTop_toTopOf="@+id/sweeperTurnSignal"
app:layout_constraintBottom_toBottomOf="@+id/sweeperTurnSignal"
android:layout_width="@dimen/dp_170"
android:layout_height="@dimen/dp_170"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="@dimen/dp_70"
android:layout_marginEnd="@dimen/dp_6"
/>
<ImageView
android:id="@+id/sweeperIvBattery"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginBottom="@dimen/dp_54"
android:layout_marginStart="@dimen/dp_120"
android:src="@drawable/icon_battery"/>
<TextView
android:id="@+id/tvBattery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@+id/sweeperIvBattery"
app:layout_constraintTop_toTopOf="@+id/sweeperIvBattery"
app:layout_constraintBottom_toBottomOf="@+id/sweeperIvBattery"
android:textColor="@color/white"
tools:text="65%"
android:layout_marginStart="6dp"
android:textSize="@dimen/dp_24"/>
<View
android:id="@+id/line3"
android:layout_width="@dimen/dp_1"
android:layout_height="@dimen/dp_34"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/sweeperIvBattery"
app:layout_constraintBottom_toBottomOf="@+id/sweeperIvBattery"
android:layout_marginStart="@dimen/dp_20"
android:background="#6D87B0"/>
<ImageView
android:id="@+id/sweeperIvBgWaterWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:src="@drawable/icon_water_level_warning"
android:layout_marginBottom="@dimen/dp_40"
android:layout_marginEnd="@dimen/dp_110"
tools:visibility="visible"
android:visibility="gone"
/>
<ImageView
android:id="@+id/sweeperIvWater"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginBottom="@dimen/dp_54"
android:layout_marginEnd="@dimen/dp_150"
android:src="@drawable/sweeper_water_selector"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<ImageView
android:id="@+id/sweeper_traffic_light_iv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/sweeper_light_red_nor"/>
android:src="@drawable/sweeper_light_gay_nor"/>
<TextView
android:id="@+id/sweeper_traffic_light_time_tv"
android:layout_width="match_parent"
@@ -16,6 +16,6 @@
android:textSize="@dimen/dp_24"
android:layout_gravity="center"
android:gravity="center"
android:text="10"
tools:text="10"
android:textColor="@color/white"/>
</FrameLayout>

View File

@@ -5,15 +5,14 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/turnLeftView"
android:layout_width="@dimen/dp_50"
android:layout_height="@dimen/dp_50"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:src="@drawable/turn_signal_left_selector"
android:layout_weight="1"/>
<ImageView
android:id="@+id/turnRightView"
android:layout_width="@dimen/dp_50"
android:layout_height="@dimen/dp_50"
android:layout_width="@dimen/dp_80"
android:layout_height="@dimen/dp_80"
android:src="@drawable/turn_signal_right_selector"
android:layout_marginStart="@dimen/dp_20"
android:layout_weight="1"/>
</LinearLayout>