6.7.0-tmp] bone update
@@ -458,7 +458,7 @@
|
||||
android:layout_width="@dimen/dp_1046"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="100dp"
|
||||
android:visibility="gone"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -3,18 +3,36 @@ package com.mogo.eagle.core.function.hmi.ui.bone
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.clBoneTabChild
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.clCarInfo
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tbCarInfo
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchCarInfo
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchMore
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchMsgBox
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchReport
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class BoneTabLayout @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private enum class TabType {
|
||||
NONE,
|
||||
CAR_INFO,
|
||||
MSG_INFO,
|
||||
REPORT_INFO,
|
||||
MORE_INFO
|
||||
}
|
||||
|
||||
private var tabType by Delegates.observable(TabType.NONE) { _, oldValue, newValue ->
|
||||
if (oldValue != newValue) {
|
||||
updateTab(oldValue, false)
|
||||
updateTab(newValue, true)
|
||||
} else {
|
||||
updateTab(oldValue, false)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_bone_tab, this, true)
|
||||
@@ -22,14 +40,66 @@ class BoneTabLayout @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
tbCarInfo.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked){
|
||||
clBoneTabChild.visibility = View.VISIBLE
|
||||
clCarInfo.visibility = View.VISIBLE
|
||||
}else{
|
||||
clCarInfo.visibility = View.GONE
|
||||
clBoneTabChild.visibility = View.GONE
|
||||
tabSwitchCarInfo.setOnClickListener {
|
||||
updateTabType(TabType.CAR_INFO)
|
||||
}
|
||||
tabSwitchMsgBox.setOnClickListener {
|
||||
updateTabType(TabType.MSG_INFO)
|
||||
}
|
||||
tabSwitchReport.setOnClickListener {
|
||||
updateTabType(TabType.REPORT_INFO)
|
||||
}
|
||||
tabSwitchMore.setOnClickListener {
|
||||
updateTabType(TabType.MORE_INFO)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTabType(changeType: TabType) {
|
||||
tabType = if (tabType == changeType) {
|
||||
TabType.NONE
|
||||
} else {
|
||||
TabType.CAR_INFO
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTab(tabType: TabType, check: Boolean) {
|
||||
when (tabType) {
|
||||
TabType.CAR_INFO -> {
|
||||
tabSwitchCarInfo.switchTab(check)
|
||||
if(check){
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TabType.MSG_INFO -> {
|
||||
tabSwitchMsgBox.switchTab(check)
|
||||
if(check){
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TabType.REPORT_INFO -> {
|
||||
tabSwitchReport.switchTab(check)
|
||||
if(check){
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TabType.MORE_INFO -> {
|
||||
tabSwitchMore.switchTab(check)
|
||||
if(check){
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,60 @@ package com.mogo.eagle.core.function.hmi.ui.bone
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import kotlinx.android.synthetic.main.view_tab_switch.view.ivTabClick
|
||||
import kotlinx.android.synthetic.main.view_tab_switch.view.ivTabClickBg
|
||||
import kotlinx.android.synthetic.main.view_tab_switch.view.ivTabDefault
|
||||
|
||||
class TabSwitchView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var tabDefaultRes = -1
|
||||
private var tabClickRes = -1
|
||||
private var tabClickBgRes = -1
|
||||
|
||||
private var isCheck = false
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_tab_switch, this, true)
|
||||
try {
|
||||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TabSwitch)
|
||||
tabDefaultRes = typedArray.getResourceId(R.styleable.TabSwitch_defaultRes, -1)
|
||||
tabClickRes = typedArray.getResourceId(R.styleable.TabSwitch_clickRes, -1)
|
||||
tabClickBgRes = typedArray.getResourceId(R.styleable.TabSwitch_clickBgRes, -1)
|
||||
typedArray.recycle()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
ivTabDefault.setImageResource(tabDefaultRes)
|
||||
ivTabClick.setImageResource(tabClickRes)
|
||||
ivTabClickBg.setImageResource(tabClickBgRes)
|
||||
}
|
||||
|
||||
fun switchTab(isCheck: Boolean) {
|
||||
if (isCheck != this.isCheck) {
|
||||
this.isCheck = isCheck
|
||||
notifyView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifyView() {
|
||||
if (isCheck) {
|
||||
ivTabClick.visibility = View.VISIBLE
|
||||
ivTabClickBg.visibility = View.VISIBLE
|
||||
} else {
|
||||
ivTabClick.visibility = View.GONE
|
||||
ivTabClickBg.visibility = View.GONE
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 14 KiB |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/icon_tab_car_info" android:state_checked="false" />
|
||||
<item android:drawable="@drawable/icon_tab_car_info_open" android:state_checked="true"/>
|
||||
<item android:drawable="@drawable/icon_tab_car_info_click" android:state_checked="true"/>
|
||||
</selector>
|
||||
@@ -27,10 +27,9 @@
|
||||
<com.mogo.eagle.core.function.hmi.ui.bone.BoneTabLayout
|
||||
android:id="@+id/clBoneTab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/dp_385"
|
||||
android:elevation="20dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,71 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/dp_964"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_224"
|
||||
android:layout_marginBottom="@dimen/dp_m_2"
|
||||
android:background="@drawable/bone_tab_bg"
|
||||
android:orientation="horizontal"
|
||||
android:elevation="10dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbCarInfo"
|
||||
<com.mogo.eagle.core.function.hmi.ui.bone.TabSwitchView
|
||||
android:id="@+id/tabSwitchCarInfo"
|
||||
android:layout_width="@dimen/dp_220"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/selector_tab_car_info"
|
||||
android:checked="false"
|
||||
android:gravity="center" />
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginStart="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
app:defaultRes="@drawable/icon_tab_car_info"
|
||||
app:clickRes="@drawable/icon_tab_car_info_click"
|
||||
app:clickBgRes="@drawable/icon_tab_click_bg"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbMsgBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:gravity="center" />
|
||||
<com.mogo.eagle.core.function.hmi.ui.bone.TabSwitchView
|
||||
android:id="@+id/tabSwitchMsgBox"
|
||||
android:layout_width="@dimen/dp_220"
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
app:defaultRes="@drawable/icon_tab_msg_box"
|
||||
app:clickRes="@drawable/icon_tab_msg_box_click"
|
||||
app:clickBgRes="@drawable/icon_tab_click_bg"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tabSwitchCarInfo"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbReport"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:gravity="center" />
|
||||
<com.mogo.eagle.core.function.hmi.ui.bone.TabSwitchView
|
||||
android:id="@+id/tabSwitchReport"
|
||||
android:layout_width="@dimen/dp_220"
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
app:defaultRes="@drawable/icon_tab_report"
|
||||
app:clickRes="@drawable/icon_tab_report_click"
|
||||
app:clickBgRes="@drawable/icon_tab_click_bg"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tabSwitchMsgBox"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbMoreInfo"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:checked="false"
|
||||
android:gravity="center" />
|
||||
</LinearLayout>
|
||||
<com.mogo.eagle.core.function.hmi.ui.bone.TabSwitchView
|
||||
android:id="@+id/tabSwitchMore"
|
||||
android:layout_width="@dimen/dp_220"
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
app:defaultRes="@drawable/icon_tab_more"
|
||||
app:clickRes="@drawable/icon_tab_more_click"
|
||||
app:clickBgRes="@drawable/icon_tab_click_bg"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tabSwitchReport"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clBoneTabChild"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_1128"
|
||||
android:elevation="1dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:elevation="1dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clCarInfo"
|
||||
android:background="@color/acc_default_txt_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/acc_default_txt_color" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,18 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/dp_220"
|
||||
android:layout_height="@dimen/dp_140">
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbTabClick"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:checked="false"
|
||||
android:gravity="center"
|
||||
android:textOff=""
|
||||
android:textOn="" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivTabDefault"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -21,17 +13,20 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivTabClick"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:scaleType="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivTabClickBg"
|
||||
@@ -41,13 +36,14 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<View
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/vTabNotice"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -152,4 +152,10 @@
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TabSwitch" >
|
||||
<attr name="defaultRes" format="reference"/>
|
||||
<attr name="clickRes" format="reference"/>
|
||||
<attr name="clickBgRes" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||