[m1 1.0.0]

[剩余设置、图片替换]
This commit is contained in:
yangyakun
2023-02-02 11:53:39 +08:00
parent bc24620f7c
commit 474b2d0d1d
26 changed files with 288 additions and 36 deletions

View File

@@ -1,11 +1,21 @@
package com.mogo.och.bus.passenger.ui
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.ScaleDrawable
import android.media.AudioManager
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.widget.SeekBar
import android.widget.SeekBar.OnSeekBarChangeListener
import com.mogo.commons.mvp.MvpFragment
import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.presenter.BusPassengerFunctionSoftPresenter
import com.yangyakun.main.ui.loading.drawable.MineGradientDrawable
import kotlinx.android.synthetic.m1.bus_p_function_setting_soft_fragment.*
import me.jessyan.autosize.utils.AutoSizeUtils
/**
* @author: yangyakun
@@ -41,32 +51,90 @@ class BusPassengerFunctionSoftFragment :
}
rg_select_function.check(R.id.tv_setting_aircondition)
tv_light_top_01.setOnCheckedChangeListener { buttonView, isChecked ->
setLightImage(isChecked,tv_light_top_02.isChecked,tv_light_atmosphere.isChecked)
setLightImage(isChecked, tv_light_top_02.isChecked, tv_light_atmosphere.isChecked)
}
tv_light_top_02.setOnCheckedChangeListener { buttonView, isChecked ->
setLightImage(tv_light_top_01.isChecked,isChecked,tv_light_atmosphere.isChecked)
setLightImage(tv_light_top_01.isChecked, isChecked, tv_light_atmosphere.isChecked)
}
tv_light_atmosphere.setOnCheckedChangeListener { buttonView, isChecked ->
setLightImage(tv_light_top_01.isChecked,tv_light_top_02.isChecked,isChecked)
setLightImage(tv_light_top_01.isChecked, tv_light_top_02.isChecked, isChecked)
}
setVoiceInfo()
}
private var mAudioManager: AudioManager? = null
private var mMaxVolume: Int? = 100;
private fun setVoiceInfo() {
val dp2px = AutoSizeUtils.dp2px(context, 26f)//进度条高度
val temp03 =
MineGradientDrawable(Color.parseColor("#2CBFFC"), Color.parseColor("#1060FF"), dp2px)
val scaleDrawable3 = ScaleDrawable(temp03, Gravity.START, 1f, 0f)
val temp01 =
MineGradientDrawable(Color.parseColor("#96A5C2"), Color.parseColor("#96A5C2"), dp2px)
val arr = arrayOf(temp01, scaleDrawable3)
val ld = LayerDrawable(arr)
ld.setDrawableByLayerId(android.R.id.background, temp01)
ld.setDrawableByLayerId(android.R.id.progress, scaleDrawable3)
sb_voice_bar.setProgressDrawableTiled(ld)
sb_voice_bar.max = 100
sb_voice_bar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
tv_current_voice_value.text = "$progress%"
if (fromUser) {
mMaxVolume?.let {
mAudioManager?.setStreamVolume(
AudioManager.STREAM_MUSIC,
((progress.toFloat() / 100) * it).toInt(),
AudioManager.FLAG_SHOW_UI
)
}
}
if (progress == 0) {
iv_voice.setImageResource(R.drawable.bus_p_function_voice_middle_select)
iv_end_voice.setImageResource(R.drawable.bus_p_function_voice_min)
} else {
iv_voice.setImageResource(R.drawable.bus_p_function_voice_middle_selected)
iv_end_voice.setImageResource(R.drawable.bus_p_function_voice_max)
}
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
})
context?.let {
mAudioManager = it.getSystemService(Context.AUDIO_SERVICE) as AudioManager
mMaxVolume = mAudioManager?.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
val mCurrentVolume = mAudioManager?.getStreamVolume(AudioManager.STREAM_MUSIC)
mMaxVolume?.let { max ->
mCurrentVolume?.let { current ->
val fl = current.toFloat() / max * 100
sb_voice_bar.progress = fl.toInt()
}
}
}
}
private fun setLightImage(leftLight:Boolean, rightLight:Boolean, atmosphereLight:Boolean){
if(leftLight&&rightLight){
private fun setLightImage(leftLight: Boolean, rightLight: Boolean, atmosphereLight: Boolean) {
if (leftLight && rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_middle_selected)// 都打开
}else if(!leftLight&&!rightLight){
} else if (!leftLight && !rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_nor)// 都关闭
}else {
if(leftLight){
} else {
if (leftLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_left)// 左面开
}
if(rightLight){
if (rightLight) {
iv_top_light_setting.setImageResource(R.drawable.bus_p_function_light_select_right)// 左面开
}
}
if(atmosphereLight){
if (atmosphereLight) {
iv_bottom_light_setting.setImageResource(R.drawable.bus_p_function_atmosphere_select)
}else{
} else {
iv_bottom_light_setting.setImageResource(R.drawable.bus_p_function_atmosphere_nor)
}
}

View File

@@ -0,0 +1,95 @@
package com.yangyakun.main.ui.loading.drawable
import android.graphics.*
import android.graphics.drawable.Drawable
import android.util.Log
import androidx.core.graphics.toRectF
class MineGradientDrawable(colorStart: Int = Color.BLUE,colorEnd:Int = Color.RED,height:Int) : Drawable() {
private var mPaint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
private var colorStart:Int = Color.BLUE
private var colorEnd:Int = Color.RED
private var colorWith = 4f
private var transparentWidth = 4f
private var index = arrayOf(0.53,0.76,0.92)
private var tartHeight = 0
private var heightDex = 0
private var currendDex = mutableListOf<Double>()
init {
this.colorStart = colorStart
this.colorEnd = colorEnd
this.tartHeight = height
Color.TRANSPARENT
mPaint.isAntiAlias = true
index.forEachIndexed { index, d ->
currendDex += (1-d)/2
}
}
override fun draw(canvas: Canvas) {
val rect = bounds
mPaint.shader = LinearGradient(0f, 0f, rect.right.toFloat(), rect.bottom.toFloat(), intArrayOf(colorStart,colorEnd), floatArrayOf(0f,1f), Shader.TileMode.CLAMP)
var size = (rect.width() / (colorWith + transparentWidth)).toInt()
if((colorWith+transparentWidth)*size+colorWith>rect.right){
size -= 1
}
if(rect.height()>tartHeight){
//实际高度大于目标高度 上增加高度差 下减去高度差
heightDex = (rect.height() - tartHeight) / 2
}
var countstep = 0
while (true){
val rectF = rect.toRectF()
var height = 0f
height = if(rect.height()>tartHeight){
tartHeight.toFloat()
}else{
rectF.bottom - rectF.top
}
// 计算前几个和后几个特殊高度递增和递减
var dex = 0f;
if(countstep<currendDex.size){
dex = (height * currendDex[countstep]).toFloat()
}
if(size>currendDex.size) {
if (size >= countstep && (size - countstep) < currendDex.size) {
dex = (height * currendDex[size - countstep]).toFloat()
}
}
rectF.top = dex+heightDex
rectF.bottom = rectF.bottom-dex-heightDex
rectF.left = (colorWith+transparentWidth)*countstep
rectF.right = colorWith+(colorWith+transparentWidth)*countstep
if(rectF.right>= rect.right){
break
}
countstep++
canvas.drawRoundRect(rectF,48f,48f,mPaint)
}
Log.d("MineGradientDrawable","$countstep-------------$size")
}
override fun setAlpha(alpha: Int) {
mPaint.alpha = alpha
invalidateSelf()
}
override fun setColorFilter(colorFilter: ColorFilter?) {
mPaint.colorFilter = colorFilter
invalidateSelf()
}
override fun getOpacity(): Int {
return PixelFormat.TRANSLUCENT
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 KiB

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bus_p_function_soft_press" android:state_checked="true"/>
<item android:drawable="@drawable/bus_p_function_soft_normal" android:state_checked="false"/>
<item android:drawable="@drawable/bus_p_function_soft_press" android:state_pressed="true"/>
<item android:drawable="@drawable/bus_p_function_soft_normal" android:state_pressed="false"/>
<item android:drawable="@drawable/bus_p_function_soft_normal"/>
</selector>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bus_p_function_information_press" android:state_checked="true"/>
<item android:drawable="@drawable/bus_p_function_information_normal" android:state_checked="false"/>
<item android:drawable="@drawable/bus_p_function_information_press" android:state_pressed="true"/>
<item android:drawable="@drawable/bus_p_function_information_normal" android:state_pressed="false"/>
<item android:drawable="@drawable/bus_p_function_information_normal"/>
</selector>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bus_p_function_soft_press" android:state_checked="true"/>
<item android:drawable="@drawable/bus_p_function_soft_normal" android:state_checked="false"/>
<item android:drawable="@drawable/bus_p_function_soft_press" android:state_pressed="true"/>
<item android:drawable="@drawable/bus_p_function_soft_normal" android:state_pressed="false"/>
<item android:drawable="@drawable/bus_p_function_soft_normal"/>
</selector>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/bus_p_function_voice_select" android:gravity="center"
android:drawable="@drawable/bus_p_function_voice_left_select_src" android:gravity="center"
android:left="@dimen/dp_31"
android:top="@dimen/dp_2"
android:width="@dimen/dp_17"

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/bus_p_function_voice_selected"
android:drawable="@drawable/bus_p_function_voice_left_selected_src"
android:left="@dimen/dp_31"
android:top="@dimen/dp_2"
android:width="@dimen/dp_17"

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/bus_p_function_voice_humb" android:gravity="center"
android:top="@dimen/dp_4"
android:width="@dimen/dp_46"
android:height="@dimen/dp_46"/>
</layer-list >

View File

@@ -6,31 +6,31 @@
<ImageView
android:id="@+id/cb_bp_video_player"
android:src="@drawable/bus_p_function_device_go_normal_src"
android:src="@drawable/bus_p_function_bottom_information_bg_selector"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintEnd_toStartOf="@+id/cb_bp_setting_soft"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_95"
android:layout_height="@dimen/dp_95"/>
android:layout_width="@dimen/dp_162"
android:layout_height="@dimen/dp_179"/>
<ImageView
android:id="@+id/cb_bp_setting_soft"
android:src="@drawable/bus_p_function_device_closedoor_normal_src"
android:src="@drawable/bus_p_function_bottom_soft_bg_selector"
app:layout_constraintStart_toEndOf="@+id/cb_bp_video_player"
app:layout_constraintEnd_toStartOf="@+id/cb_bp_setting_device"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_95"
android:layout_height="@dimen/dp_95"/>
android:layout_width="@dimen/dp_181"
android:layout_height="@dimen/dp_179"/>
<ImageView
android:id="@+id/cb_bp_setting_device"
android:src="@drawable/bus_p_function_device_opendoor_normal_src"
android:src="@drawable/bus_p_function_bottom_device_bg_selector"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cb_bp_setting_soft"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_95"
android:layout_height="@dimen/dp_95"/>
android:layout_width="@dimen/dp_181"
android:layout_height="@dimen/dp_179"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -15,34 +15,34 @@
<CheckBox
android:id="@+id/cb_bp_video_player"
android:background="@drawable/bus_p_function_device_go_normal_src"
android:background="@drawable/bus_p_function_bottom_information_bg_selector"
android:button="@null"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintEnd_toStartOf="@+id/cb_bp_setting_soft"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_95"
android:layout_height="@dimen/dp_95"/>
android:layout_width="@dimen/dp_162"
android:layout_height="@dimen/dp_179"/>
<CheckBox
android:id="@+id/cb_bp_setting_soft"
android:background="@drawable/bus_p_function_device_closedoor_normal_src"
android:background="@drawable/bus_p_function_bottom_soft_bg_selector"
android:button="@null"
app:layout_constraintStart_toEndOf="@+id/cb_bp_video_player"
app:layout_constraintEnd_toStartOf="@+id/cb_bp_setting_device"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_95"
android:layout_height="@dimen/dp_95"/>
android:layout_width="@dimen/dp_181"
android:layout_height="@dimen/dp_179"/>
<CheckBox
android:id="@+id/cb_bp_setting_device"
android:background="@drawable/bus_p_function_device_opendoor_normal_src"
android:background="@drawable/bus_p_function_bottom_device_bg_selector"
android:button="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cb_bp_setting_soft"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_95"
android:layout_height="@dimen/dp_95"/>
android:layout_width="@dimen/dp_181"
android:layout_height="@dimen/dp_179"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -85,7 +85,7 @@
android:id="@+id/g_aircondition_setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:visibility="gone"
app:constraint_referenced_ids="iv_aircondition" />
<!--endregion-->
@@ -179,24 +179,81 @@
<!--endregion-->
<!--region 空调调整-->
<!--region 声音调整-->
<ImageView
android:id="@+id/iv_voice"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:src="@drawable/bus_p_function_aircondition_nor"
android:src="@drawable/bus_p_function_voice_middle_select"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/gl_right"
app:layout_constraintStart_toStartOf="@+id/gl_left"
app:layout_constraintTop_toTopOf="parent" />
<SeekBar
android:id="@+id/sb_voice_bar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:splitTrack="false"
app:layout_constraintVertical_bias="0.404"
app:layout_constraintWidth_percent="0.253"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:thumbOffset="@dimen/dp_2"
android:thumb="@drawable/bus_p_function_voice_right_process_humb"
app:layout_constraintStart_toEndOf="@+id/gl_right"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_voice_title"
android:text="音量"
android:textColor="#374968"
android:textSize="@dimen/dp_24"
android:layout_marginBottom="@dimen/dp_19"
app:layout_constraintStart_toStartOf="@+id/sb_voice_bar"
app:layout_constraintBottom_toTopOf="@+id/sb_voice_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_current_voice_value"
android:text="0%"
android:textColor="#374968"
android:textSize="@dimen/dp_40"
android:layout_marginBottom="@dimen/dp_19"
app:layout_constraintEnd_toEndOf="@+id/sb_voice_bar"
app:layout_constraintBottom_toTopOf="@+id/sb_voice_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/iv_start_voice"
android:layout_marginTop="@dimen/dp_24"
android:src="@drawable/bus_p_function_voice_min"
app:layout_constraintTop_toBottomOf="@+id/sb_voice_bar"
app:layout_constraintStart_toStartOf="@+id/sb_voice_bar"
android:layout_width="@dimen/dp_21"
android:layout_height="@dimen/dp_23"/>
<ImageView
android:id="@+id/iv_end_voice"
android:layout_marginTop="@dimen/dp_24"
android:scaleType="fitEnd"
android:src="@drawable/bus_p_function_voice_max"
app:layout_constraintTop_toBottomOf="@+id/sb_voice_bar"
app:layout_constraintEnd_toEndOf="@+id/sb_voice_bar"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_23"/>
<androidx.constraintlayout.widget.Group
android:id="@+id/g_voice_setting"
android:layout_marginTop="@dimen/dp_24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="iv_voice" />
android:visibility="visible"
app:constraint_referenced_ids="iv_voice,sb_voice_bar,tv_voice_title,iv_end_voice,iv_start_voice,tv_current_voice_value" />
<!--endregion-->