[M2] M2 状态栏

This commit is contained in:
wangmingjun
2023-02-14 18:08:35 +08:00
parent 614ce77859
commit 0979e5fd79
11 changed files with 268 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
package com.mogo.och.bus.passenger.provider;
import android.content.Context;
import android.view.View;
import com.mogo.och.bus.passenger.ui.widget.M2StatusBarView;
import androidx.annotation.NonNull;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.function.api.hmi.view.IStatusViewLayout;
/**
* @author congtaowang
* @since 2020-01-06
* <p>
* 根据优先级控制显示 window view.
*/
@Route( path = MogoServicePaths.PATH_STATUS_VIEW_MANAGER )
public class M2StatusViewManager implements IStatusViewLayout {
@NonNull
@Override
public View getStatusView(Context context) {
return new M2StatusBarView(context);
}
@Override
public void init(Context context) {
}
}

View File

@@ -0,0 +1,34 @@
package com.mogo.och.bus.passenger.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
import com.mogo.eagle.core.function.hmi.ui.widget.BlueToothView
import com.mogo.och.bus.passenger.R
import kotlinx.android.synthetic.m2.p_m2_view_blue_tooth.view.*
/**
* 魔戒蓝牙控件
* 放置于StatusBar右侧位置
* todo arrow
*/
class M2BlueToothView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : BlueToothView(context, attrs, defStyleAttr),IMoGoDevaToolsListener {
init {
LayoutInflater.from(context).inflate(R.layout.p_m2_view_blue_tooth, this, true)
}
override fun mofangStatus(status: Boolean) {
if (status) {
blueView.setImageResource(R.drawable.m2_blue_tooth_close)
} else {
blueView.setImageResource(R.drawable.m2_blue_tooth_open)
}
}
}

View File

@@ -0,0 +1,86 @@
package com.mogo.och.bus.passenger.ui.widget
import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import chassis.ChassisStatesOuterClass
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
import com.mogo.eagle.core.function.call.autopilot.CallerBatteryManagementSystemListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView
import com.mogo.och.bus.passenger.R
import kotlinx.android.synthetic.m2.p_m2_view_status_bar.view.*
import me.jessyan.autosize.utils.AutoSizeUtils
/**
* @author: wangmingjun
* @date: 2023/2/14
*/
class M2StatusBarView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs), IViewControlListener, IMoGoSkinModeChangeListener,
IMoGoBatteryManagementSystemListener {
companion object {
const val TAG = "M2StatusBarView"
}
init {
LayoutInflater.from(context).inflate(R.layout.p_m2_view_status_bar, this, true)
setBackgroundColor(Color.WHITE)
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
post {
val params: ViewGroup.LayoutParams = getLayoutParams()
params.height = AutoSizeUtils.dp2px(context,47f)
layoutParams = params
}
//添加view控制
CallerHmiViewControlListenerManager.addListener(TAG,this)
// 添加换肤监听
CallerSkinModeListenerManager.addListener(TAG, this)
//电量
CallerBatteryManagementSystemListenerManager.addListener(TAG,this)
progress.progress = 50
tv_power_cos.text = "50%"
}
override fun onSkinModeChange(skinMode: Int) {
when (skinMode) {
0 -> setStatusBarDarkOrLight(false)
1 -> setStatusBarDarkOrLight(true)
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerHmiViewControlListenerManager.removeListener(TAG)
CallerSkinModeListenerManager.removeListener(TAG)
CallerDevaToolsManager.hideStatusBar()
}
override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) {
val bmsSoc = states.bmsSoc
if(bmsSoc >1){
progress.progress = bmsSoc.toInt()
tv_power_cos.text = "${bmsSoc.toInt()}%"
}else{
val currenPower = (bmsSoc * 100).toInt()
progress.progress = currenPower
tv_power_cos.text = "$currenPower%"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dp"/>
<solid android:color="#A3BDF2" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dp"/>
<solid android:color="#66FFFFFF" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<shape android:shape="rectangle">
<corners android:radius="5dp"/>
<gradient android:startColor="#56C59C" android:endColor="#56EFA0"/>
</shape>
</scale>
</item>
</layer-list>

View File

@@ -17,7 +17,7 @@
android:id="@+id/img_drive_bg"
android:layout_width="@dimen/dp_290"
android:layout_height="@dimen/dp_140"
android:layout_marginTop="@dimen/dp_24"
android:layout_marginTop="@dimen/dp_66"
android:layout_marginLeft="@dimen/dp_24"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dp_18"
android:layout_height="@dimen/dp_26">
<ImageView
android:id="@+id/blueView"
android:layout_width="@dimen/dp_18"
android:layout_height="@dimen/dp_26"
android:scaleType="fitXY"
android:src="@drawable/m2_blue_tooth_open"
tools:ignore="ContentDescription" />
</RelativeLayout>

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"
tools:ignore="MissingDefaultResource">
<!--Wifi状态-->
<com.mogo.eagle.core.function.hmi.ui.widget.WifiStateView
android:id="@+id/wifiStateView"
android:layout_width="@dimen/dp_28"
android:layout_height="@dimen/dp_28"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_gravity="center"
android:layout_marginStart="@dimen/dp_50" />
<!--魔方连接状态 蓝牙-->
<com.mogo.och.bus.passenger.ui.widget.M2BlueToothView
android:id="@+id/blueToothView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/wifiStateView"
android:layout_width="@dimen/dp_15"
android:layout_height="@dimen/dp_22"
android:src="@drawable/m2_blue_tooth_open"
android:layout_gravity="center"
android:layout_marginStart="@dimen/dp_32" />
<SeekBar
android:id="@+id/progress"
android:layout_width="@dimen/dp_115"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_40"
android:layout_marginEnd="@dimen/dp_7"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tv_power_cos"
android:maxHeight="@dimen/dp_8"
android:minHeight="@dimen/dp_8"
android:layout_marginRight="4dp"
android:splitTrack="false"
android:progressDrawable="@drawable/m2_power_seekbar_style"
android:thumb="@null" />
<TextView
android:id="@+id/tv_power_cos"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:textSize="@dimen/dp_18"
android:textColor="@color/m2_power_tv_color"
android:layout_marginRight="@dimen/dp_50"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:src="@drawable/m2_status_bar_logo"
android:scaleType="fitXY"
android:layout_width="@dimen/dp_96"
android:layout_height="@dimen/dp_28"/>
</merge>

View File

@@ -10,6 +10,7 @@
<color name="m2_no_line_tv_color">#6B7EA6</color>
<color name="m2_light_tv_color">#2D3E5F</color>
<color name="m2_pnc_bg_color">#A5D8FF</color>
<color name="m2_power_tv_color">#1B2546</color>
<color name="bus_traffic_light_red_color_up">#FFFFA28B</color>
<color name="bus_traffic_light_red_color_down">#FFDA1100</color>