android 颜色color.xml文件及部分中英文对照

本文详细列举了各种颜色的十六进制代码及其对应的中文名称,包括白色系、黄色系、橙色系等多种色系的颜色,为设计师和开发者提供了一个全面的颜色参考指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="utf-8" ?> 
<resources> 
<color name="white">#ffffff</color><!--白色 --> 
<color name="ivory">#fffff0</color><!--象牙色 --> 
<color name="lightyellow">#ffffe0</color><!--亮黄色 --> 
<color name="yellow">#ffff00</color><!--黄色 --> 
<color name="snow">#fffafa</color><!--雪白色 --> 
<color name="floralwhite">#fffaf0</color><!--花白色 --> 
<color name="lemonchiffon">#fffacd</color><!--柠檬绸色 --> 
<color name="cornsilk">#fff8dc</color><!--米绸色 --> 
<color name="seaShell">#fff5ee</color><!--海贝色 --> 
<color name="lavenderblush">#fff0f5</color><!--淡紫红 --> 
<color name="papayawhip">#ffefd5</color><!--番木色 --> 
<color name="blanchedalmond">#ffebcd</color><!--白杏色 --> 
<color name="mistyrose">#ffe4e1</color><!--浅玫瑰色 --> 
<color name="bisque">#ffe4c4</color><!--桔黄色 --> 
<color name="moccasin">#ffe4b5</color><!--鹿皮色 --> 
<color name="navajowhite">#ffdead</color><!--纳瓦白 --> 
<color name="peachpuff">#ffdab9</color><!--桃色 --> 
<color name="gold">#ffd700</color><!--金色 --> 
<color name="pink">#ffc0cb</color><!--粉红色 --> 
<color name="lightpink">#ffb6c1</color><!--亮粉红色 --> 
<color name="orange">#ffa500</color><!--橙色 --> 
<color name="lightsalmon">#ffa07a</color><!--亮肉色 --> 
<color name="darkorange">#ff8c00</color><!--暗桔黄色 --> 
<color name="coral">#ff7f50</color><!--珊瑚色 --> 
<color name="hotpink">#ff69b4</color><!--热粉红色 --> 
<color name="tomato">#ff6347</color><!--西红柿色 --> 
<color name="orangered">#ff4500</color><!--红橙色 --> 
<color name="deeppink">#ff1493</color><!--深粉红色 --> 
<color name="fuchsia">#ff00ff</color><!--紫红色 --> 
<color name="magenta">#ff00ff</color><!--红紫色 --> 
<color name="red">#ff0000</color><!--红色 --> 
<color name="oldlace">#fdf5e6</color><!--老花色 --> 
<color name="lightgoldenrodyellow">#fafad2</color><!--亮金黄色 --> 
<color name="linen">#faf0e6</color><!--亚麻色 --> 
<color name="antiquewhite">#faebd7</color><!--古董白 --> 
<color name="salmon">#fa8072</color><!--鲜肉色 --> 
<color name="ghostwhite">#f8f8ff</color><!--幽灵白 --> 
<color name="mintcream">#f5fffa</color><!--薄荷色 --> 
<color name="whitesmoke">#f5f5f5</color><!--烟白色 --> 
<color name="beige">#f5f5dc</color><!--米色 --> 
<color name="wheat">#f5deb3</color><!--浅黄色 --> 
<color name="sandybrown">#f4a460</color><!--沙褐色 --> 
<color name="azure">#f0ffff</color><!--天蓝色 --> 
<color name="honeydew">#f0fff0</color><!--蜜色 --> 
<color name="aliceblue">#f0f8ff</color><!--艾利斯兰 --> 
<color name="khaki">#f0e68c</color><!--黄褐色 --> 
<color name="lightcoral">#f08080</color><!--亮珊瑚色 --> 
<color name="palegoldenrod">#eee8aa</color><!--苍麒麟色 --> 
<color name="violet">#ee82ee</color><!--紫罗兰色 --> 
<color name="darksalmon">#e9967a</color><!--暗肉色 --> 
<color name="lavender">#e6e6fa</color><!--淡紫色 --> 
<color name="lightcyan">#e0ffff</color><!--亮青色 --> 
<color name="burlywood">#deb887</color><!--实木色 --> 
<color name="plum">#dda0dd</color><!--洋李色 --> 
<color name="gainsboro">#dcdcdc</color><!--淡灰色 --> 
<color name="crimson">#dc143c</color><!--暗深红色 --> 
<color name="palevioletred">#db7093</color><!--苍紫罗兰色 --> 
<color name="goldenrod">#daa520</color><!--金麒麟色 --> 
<color name="orchid">#da70d6</color><!--淡紫色 --> 
<color name="thistle">#d8bfd8</color><!--蓟色 --> 
<color name="lightgray">#d3d3d3</color><!--亮灰色 --> 
<color name="lightgrey">#d3d3d3</color><!--亮灰色 --> 
<color name="tan">#d2b48c</color><!--茶色 --> 
<color name="chocolate">#d2691e</color><!--巧可力色 --> 
<color name="peru">#cd853f</color><!--秘鲁色 --> 
<color name="indianred">#cd5c5c</color><!--印第安红 --> 
<color name="mediumvioletred">#c71585</color><!--中紫罗兰色 --> 
<color name="silver">#c0c0c0</color><!--银色 --> 
<color name="darkkhaki">#bdb76b</color><!--暗黄褐色 --> 
<color name="rosybrown">#bc8f8f</color><!--褐玫瑰红 --> 
<color name="mediumorchid">#ba55d3</color><!--中粉紫色 --> 
<color name="darkgoldenrod">#b8860b</color><!--暗金黄色 --> 
<color name="firebrick">#b22222</color><!--火砖色 --> 
<color name="powderblue">#b0e0e6</color><!--粉蓝色 --> 
<color name="lightsteelblue">#b0c4de</color><!--亮钢兰色 --> 
<color name="paleturquoise">#afeeee</color><!--苍宝石绿 --> 
<color name="greenyellow">#adff2f</color><!--黄绿色 --> 
<color name="lightblue">#add8e6</color><!--亮蓝色 --> 
<color name="darkgray">#a9a9a9</color><!--暗灰色 --> 
<color name="darkgrey">#a9a9a9</color><!--暗灰色 --> 
<color name="brown">#a52a2a</color><!--褐色 --> 
<color name="sienna">#a0522d</color><!--赭色 --> 
<color name="darkorchid">#9932cc</color><!--暗紫色 --> 
<color name="palegreen">#98fb98</color><!--苍绿色 --> 
<color name="darkviolet">#9400d3</color><!--暗紫罗兰色 --> 
<color name="mediumpurple">#9370db</color><!--中紫色 --> 
<color name="lightgreen">#90ee90</color><!--亮绿色 --> 
<color name="darkseagreen">#8fbc8f</color><!--暗海兰色 --> 
<color name="saddlebrown">#8b4513</color><!--重褐色 --> 
<color name="darkmagenta">#8b008b</color><!--暗洋红 --> 
<color name="darkred">#8b0000</color><!--暗红色 --> 
<color name="blueviolet">#8a2be2</color><!--紫罗兰蓝色 --> 
<color name="lightskyblue">#87cefa</color><!--亮天蓝色 --> 
<color name="skyblue">#87ceeb</color><!--天蓝色 --> 
<color name="gray">#808080</color><!--灰色 --> 
<color name="grey">#808080</color><!--灰色 --> 
<color name="olive">#808000</color><!--橄榄色 --> 
<color name="purple">#800080</color><!--紫色 --> 
<color name="maroon">#800000</color><!--粟色 --> 
<color name="aquamarine">#7fffd4</color><!--碧绿色 --> 
<color name="chartreuse">#7fff00</color><!--黄绿色 --> 
<color name="lawngreen">#7cfc00</color><!--草绿色 --> 
<color name="mediumslateblue">#7b68ee</color><!--中暗蓝色 --> 
<color name="lightslategray">#778899</color><!--亮蓝灰 --> 
<color name="lightslategrey">#778899</color><!--亮蓝灰 --> 
<color name="slategray">#708090</color><!--灰石色 --> 
<color name="slategrey">#708090</color><!--灰石色 --> 
<color name="olivedrab">#6b8e23</color><!--深绿褐色 --> 
<color name="slateblue">#6a5acd</color><!--石蓝色 --> 
<color name="dimgray">#696969</color><!--暗灰色 --> 
<color name="dimgrey">#696969</color><!--暗灰色 --> 
<color name="mediumaquamarine">#66cdaa</color><!--中绿色 --> 
<color name="cornflowerblue">#6495ed</color><!--菊兰色 --> 
<color name="cadetblue">#5f9ea0</color><!--军兰色 --> 
<color name="darkolivegreen">#556b2f</color><!--暗橄榄绿 --> 
<color name="indigo">#4b0082</color><!--靛青色 --> 
<color name="mediumturquoise">#48d1cc</color><!--中绿宝石 --> 
<color name="darkslateblue">#483d8b</color><!--暗灰蓝色 --> 
<color name="steelblue">#4682b4</color><!--钢兰色 --> 
<color name="royalblue">#4169e1</color><!--皇家蓝 --> 
<color name="turquoise">#40e0d0</color><!--青绿色 --> 
<color name="mediumseagreen">#3cb371</color><!--中海蓝 --> 
<color name="limegreen">#32cd32</color><!--橙绿色 --> 
<color name="darkslategray">#2f4f4f</color><!--暗瓦灰色 --> 
<color name="darkslategrey">#2f4f4f</color><!--暗瓦灰色 --> 
<color name="seagreen">#2e8b57</color><!--海绿色 --> 
<color name="forestgreen">#228b22</color><!--森林绿 --> 
<color name="lightseagreen">#20b2aa</color><!--亮海蓝色 --> 
<color name="dodgerblue">#1e90ff</color><!--闪兰色 --> 
<color name="midnightblue">#191970</color><!--中灰兰色 --> 
<color name="aqua">#00ffff</color><!--浅绿色 --> 
<color name="cyan">#00ffff</color><!--青色 --> 
<color name="springgreen">#00ff7f</color><!--春绿色 --> 
<color name="lime">#00ff00</color><!--酸橙色 --> 
<color name="mediumspringgreen">#00fa9a</color><!--中春绿色 --> 
<color name="darkturquoise">#00ced1</color><!--暗宝石绿 --> 
<color name="deepskyblue">#00bfff</color><!--深天蓝色 --> 
<color name="darkcyan">#008b8b</color><!--暗青色 --> 
<color name="teal">#008080</color><!--水鸭色 --> 
<color name="green">#008000</color><!--绿色 --> 
<color name="darkgreen">#006400</color><!--暗绿色 --> 
<color name="blue">#0000ff</color><!--蓝色 --> 
<color name="mediumblue">#0000cd</color><!--中兰色 --> 
<color name="darkblue">#00008b</color><!--暗蓝色 --> 
<color name="navy">#000080</color><!--海军色 --> 
<color name="black">#000000</color><!--黑色 --> 
</resources>

中英文对照:
 古典白色 :古典白色antiquewhite
浅绿色:浅绿色aqua
碧绿色:碧绿色aquamarine
天蓝色:天蓝色azure(汗。。。)
米色:米色beige
桔黄色:桔黄色bisque
黑色:黑色black
白杏色:白杏色blanchedalmond
蓝色:蓝色blue
蓝紫色:蓝紫色blueviolet
褐色:褐色brown
实木色:实木色burlywood
刺桧蓝色:刺桧蓝色cadetblue
亮黄绿色:亮黄绿色chartreuse
巧克力色:巧克力色chocolate
珊瑚色:珊瑚色coral
矢车菊色:矢车菊色cornflowerblue
谷丝色:谷丝色cornsilk
深红色:深红色crimson
蓝绿色:蓝绿色cyan
深蓝色:深蓝色darkblue
深青色:深青色darkcyan
深金杆色:深金杆色darkgoldenrod
深灰色:深灰色darkgray
深绿色:深绿色darkgreen
深黄褐色:深黄褐色darkkhaki
深洋红色:深洋红色darkmagenta
深橄榄绿色:深橄榄绿色darkolivegreen
深橙色:深橙色darkorange
深紫色:深紫色darkorchid
深红色:深红色darkred
深肉色:深肉色darksalmon
深海绿色:深海绿色darkseagreen
深暗灰蓝色:深暗灰蓝色darkslateblue
深暗蓝灰色:深暗蓝灰色darkslategray
深青绿色:深青绿色darkturquoise
深紫色:深紫色darkviolet
深粉色:深粉色deeppink
深天蓝色:深天蓝色deepskyblue
暗灰色:暗灰色dimgray
遮板蓝色:遮板蓝色dodgerblue
砖色:砖色firebrick
花白色:花白色floralwhite
葱绿色:葱绿色forestgreen
紫红色:紫红色fushcia
庚斯博罗灰色:庚斯博罗灰色gainsboro
幽灵白色:幽灵白色ghostwhite
金黄色:金黄色gold
金杆黄色:金杆黄色goldenrod
灰色:灰色gray
绿色:绿色green
绿黄色:绿黄色greenyellow
蜜汁色:蜜汁色honeydew
亮粉色:亮粉色hotpink
印第安红色:印第安红色indianred
靛青色:靛青色indigo
象牙色:象牙色ivory
黄褐色:黄褐色khaki
淡紫色:淡紫色lavender
浅紫红色:浅紫红色lavenderblush
草绿色:草绿色lawngreen
柠檬纱色:柠檬纱色lemonchiffon
浅蓝色:浅蓝色lightblue
浅珊瑚色:浅珊瑚色 lightcoral
浅金杆黄色:浅金杆黄色lightgoldenrodyellow

package com.adayo.service.atsmode.atsview; /** * Copyright (c) 2015 FORYOU GENERAL ELECTRONICS CO.,LTD. All Rights Reserved. */ import android.animation.Animator; import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.RectF; import android.hardware.fgecomservice.V1_0.EMessageID; import android.hardware.fgecomservice.V1_0.IFgeComService; import android.hardware.fgecomservice.V1_0.Message; import android.media.AudioAttributes; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.os.Handler; import android.os.RemoteException; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.view.animation.LinearInterpolator; import android.widget.ImageView; import android.widget.TextView; import android.widget.VideoView; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.lifecycle.LifecycleRegistry; import com.adayo.proxy.infrastructure.sourcemng.Beans.AppConfigType; import com.adayo.proxy.infrastructure.sourcemng.Beans.SourceInfo; import com.adayo.proxy.infrastructure.sourcemng.Control.SrcMngAudioSwitchManager; import com.adayo.proxy.infrastructure.sourcemng.Control.SrcMngSwitchManager; import com.adayo.proxy.infrastructure.sourcemng.Interface.IAdayoAudioFocusChange; import com.adayo.proxy.setting.system.utils.LogUtil; import com.adayo.service.atsmode.R; import com.adayo.service.atsmode.atsconfig.ATSConfig; import com.airbnb.lottie.LottieAnimationView; import com.jakewharton.rxbinding4.view.RxView; import com.jeremyliao.liveeventbus.LiveEventBus; import org.jetbrains.annotations.NotNull; import org.json.JSONObject; import java.io.IOException; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; import autodispose2.AutoDispose; import autodispose2.androidx.lifecycle.AndroidLifecycleScopeProvider; import static com.adayo.service.atsmode.atsconfig.ATSConfig.ATS_MODE_WADE; import static com.adayo.service.atsmode.atsconfig.ATSConfig.ATS_TAG; import static com.adayo.service.atsmode.atsconfig.ATSConfig.CONFIG_CAR_MODEL_B41V; import static com.adayo.service.atsmode.atsconfig.ATSConfig.CONFIG_CAR_MODEL_B41VS; import static com.adayo.service.atsmode.atsconfig.ATSConfig.CONFIG_CAR_MODEL_B60VS; import static com.adayo.service.atsmode.atsconfig.ATSConfig.EVENT_ATS_RESET_COUNTER; import static com.adayo.service.atsmode.atsconfig.ATSConfig.FLAG_OPERATE_UPDATE; import static com.adayo.service.atsmode.atsconfig.ATSConfig.MODEL_CONFIGURATION_VERSION_C; import static com.adayo.service.atsmode.atsconfig.ATSConfig.MODEL_CONFIGURATION_VERSION_P; /** * @ClassName: ATSContainerView * @Description: ATS驾驶模式容器view * @Author: yongqiang.wen@foryouge.com.cn * @CreateDate: 2022/12/13 14:03 */ public class ATSContainerView extends ConstraintLayout { SvgPathView svgPathView = null; VideoView videoView = null; TextView atsModeName = null; View atsToastTipsContainer = null; View atsToastIconContainer = null; ImageView atsLoadingView = null; ImageView atsErrorIcon = null; TextView atsToastTips = null; LottieAnimationView lottieAnimationView = null; String currentPathName = ""; String requestedModeName = ""; String confirmModeName = ""; private OnATSViewCloseListener closeListener = null; // 生命周期感知注册 private LifecycleRegistry lifecycleRegistry = null; // ATS驾驶模式ID对应关系表 private HashMap<Integer, String> pathIds = new HashMap<>(); // 用于查找驾驶模式中英文对照 // private HashMap<String, String> pathMaps = new HashMap<>(); // 加载下一个模式,用于判断是否播放剩余的50%动效 private boolean notYetSwitchNext = false; // 信号值标记,用于记录是否有信号过来 private int operateFlag; // 上一个模式记录 private String previousModePathName; // ATS驾驶模式关闭按钮 private ImageView atsClose; // 型号配置字 int carModelConfig = -1; // 模式配置字 int configuration = -1; // 是否有效信号 private boolean isValidSignal = false; private IFgeComService mIFgeComService = null; private MediaPlayer mediaPlayer; public ATSContainerView(Context context) { this(context, null); } public ATSContainerView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ATSContainerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public void initATSView() { // 初始化子View initChildView(); // 初始化视频播放器 initVideoView(); // 初始化连接服务 initComService(); } private void initComService() { if (mIFgeComService == null) { try { mIFgeComService = IFgeComService.getService(); } catch (RemoteException e) { e.printStackTrace(); } } } public int getCarModelConfig() { return carModelConfig; } public void setCarModelConfig(int carModelConfig) { this.carModelConfig = carModelConfig; initATSSrcData(carModelConfig); if (svgPathView != null && !svgPathView.hasInitialize()) { svgPathView.init(); } LogUtil.e(ATSConfig.ATS_TAG, "ATSContainerView init carModelConfig byte value is ====>>" + carModelConfig); } public void initATSSrcData(int carModelConfig) { if (carModelConfig == CONFIG_CAR_MODEL_B41V) { // 生成41V模式数据 genAtsModeData(); } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS || carModelConfig == CONFIG_CAR_MODEL_B41VS) { // 生成60VS模式数据 gen60VAtsModeData(); } } public int getConfiguration() { return configuration; } public void setConfiguration(int configuration) { this.configuration = configuration; LogUtil.e(ATSConfig.ATS_TAG, "ATSContainerView init configuration byte value is ====>>" + configuration); } private void initChildView() { svgPathView = getRootView().findViewById(R.id.svg_view); videoView = getRootView().findViewById(R.id.video_view); atsModeName = getRootView().findViewById(R.id.tv_ats_mode_name); atsClose = getRootView().findViewById(R.id.iv_ats_close); atsToastTipsContainer = getRootView().findViewById(R.id.toast_ats_mode_enter_tips); atsToastIconContainer = getRootView().findViewById(R.id.view_icon_container); atsLoadingView = getRootView().findViewById(R.id.iv_toast_loading); atsErrorIcon = getRootView().findViewById(R.id.iv_toast_icon); atsToastTips = getRootView().findViewById(R.id.tv_toast_msg); RxView.clicks(atsClose) .throttleFirst(500, TimeUnit.MILLISECONDS) .to(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleRegistry))) .subscribe(unit -> closeListener.onClose()); } public OnATSViewCloseListener getCloseListener() { return closeListener; } public void setCloseListener(OnATSViewCloseListener closeListener) { this.closeListener = closeListener; } int showMode = -1; private void initVideoView() { videoView.setOnCompletionListener(MediaPlayer::stop); videoView.setOnPreparedListener(mp -> { // 设置MediaPlayer不需要音频焦点 // mp.setAudioAttributes(new AudioAttributes.Builder() // .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) // .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) // .build()); // 判断切换模式动效View是否显示,进行隐藏 if (lottieAnimationView.getVisibility() == View.VISIBLE) { lottieAnimationView.setVisibility(View.INVISIBLE); atsModeName.setVisibility(View.VISIBLE); atsModeName.setText(getATSModeName(currentPathName)); } }); } private void handlingSpecialModeSignals() { showMode = -1; switch (currentPathName) { case "wad": if (carModelConfig == CONFIG_CAR_MODEL_B41V) { showMode = ATSConfig.ATS_MODE_WADE; } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS || carModelConfig == CONFIG_CAR_MODEL_B41VS) { showMode = ATSConfig.ATS60_MODE_WAD; } break; case "rock": if (carModelConfig == CONFIG_CAR_MODEL_B41V) { showMode = ATSConfig.ATS_MODE_ROCK; } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS || carModelConfig == CONFIG_CAR_MODEL_B41VS) { showMode = ATSConfig.ATS60_MODE_ROCK; } break; } if (showMode == ATSConfig.ATS_MODE_ROCK) { LogUtil.e(ATS_TAG, "ready to send enter rock mode signal to QNX"); } LiveEventBus.get(EVENT_ATS_RESET_COUNTER, Integer.class).post(showMode); // postDelayed(() -> { // if (showMode == ATSConfig.ATS_MODE_WADE && isValidSignal) { // String wadeTips = getContext().getString(R.string.tips_enter_the_water_depth_detection); // showModeEnterToast(wadeTips, true); // } else if (showMode == ATSConfig.ATS_MODE_ROCK && isValidSignal) { // String rockTips = getContext().getString(R.string.tips_enter_the_transparent_chassis); // showModeEnterToast(rockTips, true); // } // removeCallbacks(hideCustomToastRunnable); // postDelayed(hideCustomToastRunnable, 3000); // }, 2000); } private void hideCustomToast() { if (atsToastTipsContainer.getVisibility() == VISIBLE) { atsToastTipsContainer.setVisibility(GONE); } } private ObjectAnimator rotationAnimator = null; public void showModeEnterToast(String tips, boolean showLoading) { if (atsToastTipsContainer.getVisibility() == GONE) { atsToastTipsContainer.setVisibility(VISIBLE); } if (showLoading) { atsToastIconContainer.setVisibility(VISIBLE); atsLoadingView.setVisibility(VISIBLE); atsErrorIcon.setVisibility(GONE); // 创建旋转动画 if (rotationAnimator == null) { rotationAnimator = ObjectAnimator.ofFloat(atsLoadingView, "rotation", 0f, 360f); rotationAnimator.setDuration(1000); // 动画持续时间,单位为毫秒 rotationAnimator.setRepeatCount(ObjectAnimator.INFINITE); // 无限重复 rotationAnimator.setInterpolator(new LinearInterpolator()); // 线性插值器,使旋转平滑 // 启动动画 rotationAnimator.start(); } } else { atsToastIconContainer.setVisibility(GONE); atsLoadingView.setVisibility(GONE); } atsToastTipsContainer.setBackground(getResources().getDrawable(R.drawable.customize_toast_bg)); atsToastTips.setTextColor(getResources().getColor(R.color.drawable_dialog_text_color)); atsToastTips.setText(tips); } public void showErrorToast() { removeCallbacks(hideCustomToastRunnable); if (atsToastTipsContainer.getVisibility() == GONE) { atsToastTipsContainer.setVisibility(VISIBLE); } atsToastIconContainer.setVisibility(VISIBLE); atsErrorIcon.setVisibility(VISIBLE); atsLoadingView.setVisibility(GONE); atsToastTips.setText(getContext().getString(R.string.fail)); } /** * @param * @return void * @method observeRequestedModeDisplay * @description 切换模式回调 * @date: 2022/12/13 14:56 * @author: yongqiang.wen@foryouge.com.cn */ public void observeRequestedModeDisplay(int signal) { if (videoView != null && videoView.isPlaying()) { videoView.stopPlayback(); videoView.setBackground(getBackground()); setVideoViewVisibility(GONE); } setSvgPathViewVisibility(VISIBLE); requestedModeName = pathIds.get(signal); isValidSignal = false; if (checkInvalidSignal(signal)) return; isValidSignal = true; LogUtil.e(ATS_TAG, "The ATS mode requested signal has been received, current signal ===>> " + signal); requestedModeName = pathIds.get(signal); currentPathName = requestedModeName; // 如果上一个模式记录为空,则记录本次切换的模式路径 if (TextUtils.isEmpty(previousModePathName)) previousModePathName = currentPathName; LogUtil.d(ATS_TAG, "The ATS mode requested signal has been received, current mode ===>> " + currentPathName); atsModeName.setText(""); if (videoView.isPlaying()) { videoView.pause(); } atsModeName.setVisibility(View.GONE); if (lottieAnimationView != null && lottieAnimationView.isAnimating()) { // 处理当动效未结束,快速切换的问题 notYetSwitchNext = false; if (svgPathView.getSelect() != null) { previousModePathName = svgPathView.getSelect().getId(); } } if (signal >= 0 && signal < 12 || signal == 15) { // 由于目前41和60都是同样的模式范围,如果后续有变动,此处需要变更 showSwitchTips(); } removeCallbacks(hideCustomToastRunnable); switchNextMode(currentPathName); } private void showSwitchTips() { // atsToastTips.setVisibility(VISIBLE); String modeName = getATSModeName(currentPathName); String tipsTxt = getContext().getString(R.string.tips_switch_mode_txt, modeName); LogUtil.e(ATS_TAG, "The ATS mode requested signal has been received, current mode ===>> " + currentPathName); LogUtil.e(ATS_TAG, "The ATS mode requested signal has been received, current mode ===>> " + modeName + ", tipsTxt ===>>" + tipsTxt); showModeEnterToast(tipsTxt, false); // atsModeEnterTips.setText(tipsTxt); } /** * ATS岩石模式切换 发送给qnx * * @param rockModeState state */ public void updateRockModeStatus(int rockModeState) { LogUtil.i(ATS_TAG, "rockModeState = " + rockModeState); String id = "atsstatus"; String sub = ""; //装入json try { JSONObject command = new JSONObject(); command.put("id", id); command.put("sub", sub); JSONObject content = new JSONObject(); content.put("status", rockModeState); JSONObject all = new JSONObject(); all.put("command", command); all.put("content", content); String all_message = all.toString(); // LogUtil.i(ATS_TAG, "all_message = " + all_message); Message msg = new Message(); //看协议ID:device_070,然后看源码文件types.hal查看ID msg.id = EMessageID.MSG_DEVICE_ATSSTATUS; msg.content = all_message; LogUtil.i(ATS_TAG, "msg send = " + msg.content); if (mIFgeComService != null) { mIFgeComService.fgeSendMessage2ComService(msg); } } catch (Exception e) { LogUtil.e(ATS_TAG, "e = " + e.toString()); } } /** * @param * @return void * @method observeConfirmedModeDisplay * @description 确认模式回调 * @date: 2022/12/13 14:57 * @author: yongqiang.wen@foryouge.com.cn */ public boolean observeConfirmedModeDisplay(int signal) { if (checkInvalidSignal(signal)) return false; confirmModeName = pathIds.get(signal); atsModeName.setVisibility(View.GONE); LogUtil.d(ATS_TAG, "The ATS mode confirmation signal has been received,current mode ===>>" + getATSModeName(currentPathName)); if (TextUtils.equals(requestedModeName, confirmModeName)) { post(() -> runSwitchModeDisplayVideo(confirmModeName)); // atsClose.setVisibility(VISIBLE); String modeName = getATSModeName(confirmModeName); LogUtil.e(ATS_TAG, "setting current modeName ==>> " + modeName); atsModeName.setText(modeName); atsModeName.setVisibility(View.VISIBLE); queryOtherCMD(); return true; } return false; } public void setSvgPathViewVisibility(int visibility) { LogUtil.e(ATS_TAG, "setSvgPathViewVisibility called, visibility = " + visibility); if (svgPathView != null) { svgPathView.setVisibility(visibility); } if (atsClose != null) { atsClose.setVisibility(visibility); } if (atsModeName != null && atsModeName.getVisibility() == VISIBLE) { atsModeName.setVisibility(INVISIBLE); } } public void setVideoViewVisibility(int visibility) { LogUtil.e(ATS_TAG, "setVideoViewVisibility called, visibility = " + visibility); if (videoView != null) { videoView.setVisibility(visibility); } if (atsClose != null) { atsClose.setVisibility(visibility); } if (atsModeName != null) { atsModeName.setVisibility(visibility); } } private boolean checkInvalidSignal(int signal) { if (videoView.getVisibility() == VISIBLE) { setVideoViewVisibility(GONE); } if (carModelConfig == CONFIG_CAR_MODEL_B41V) { return signal == ATSConfig.ATS_MODE_RESERVED1 || signal == ATSConfig.ATS_MODE_RESERVED2; // if (signal == ATSConfig.ATS_MODE_FAULT || signal == ATSConfig.ATS_MODE_NOT_INITIALIZED) { // showErrorToast(); // return true; // } } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS || carModelConfig == CONFIG_CAR_MODEL_B41VS) { return signal == ATSConfig.ATS60_MODE_SINGLE_PEDAL || signal == ATSConfig.ATS60_MODE_RAPIDLY || signal == ATSConfig.ATS60_MODE_RESERVED1 || signal == ATSConfig.ATS60_MODE_NOT_INITIALIZED; // if (signal == ATSConfig.ATS60_MODE_FAULT || signal == ATSConfig.ATS60_MODE_NOT_INITIALIZED) { // showErrorToast(); // return true; // } } return false; } /** * 特定模式下需要额外处理开启某功能,比如涉水模式要切换到涉水信息界面 */ private void queryOtherCMD() { if (!TextUtils.equals(currentPathName, pathIds.get(ATSConfig.ATS_MODE_ROCK))) { // 非岩石模式需要给QNX发送退出岩石模式信号 LogUtil.e(ATS_TAG, "ready to send exit rock mode signal to QNX"); updateRockModeStatus(ATSConfig.EXTRA_ROCK_STATE_EXIT); } // if (TextUtils.equals(currentPathName, pathIds.get(ATS_MODE_WADE))) { // 涉水模式 需要打开涉水页面 // Map<String, String> map = new HashMap<>(); // map.put("source", "carsetting"); // map.put("dest", "wddc"); // SourceInfo sourceInfo = new SourceInfo("com.adayo.app.bcm", map, // AppConfigType.SourceSwitch.APP_ON.getValue(), // AppConfigType.SourceType.UI_AUDIO.getValue()); // SrcMngSwitchManager.getInstance().requestSwitchApp(sourceInfo); // } } public void resetPreviousModePathName() { previousModePathName = ""; } /** * 获取当前模式 * @param currentMode */ private String getATSModeName(String currentMode) { if (carModelConfig == CONFIG_CAR_MODEL_B60VS) { // 北汽B60VS车型 if (currentMode.equals("snow")) { currentMode = "snow_60"; } } int modeRes = getResources().getIdentifier(currentMode, "string", getContext().getPackageName()); String currentName = ""; if (modeRes != 0) { currentName = getContext().getString(modeRes); } return currentName; } /** * @param * @return void * @method genAtsModeData * @description 生成ATS驾驶模式数据关系表,用于切换不同模式定位path * @date: 2022/11/28 9:43 * @author: yongqiang.wen@foryouge.com.cn */ private void genAtsModeData() { // 生成ATSMode映射关系表 pathIds.clear(); pathIds.put(ATSConfig.ATS_MODE_ECO, "eco"); pathIds.put(ATSConfig.ATS_MODE_COMFORT, "conf"); pathIds.put(ATSConfig.ATS_MODE_AUTO, "auto"); pathIds.put(ATSConfig.ATS_MODE_SNOW, "snow"); pathIds.put(ATSConfig.ATS_MODE_DEEP_SNOW, "deep_snow"); pathIds.put(ATSConfig.ATS_MODE_CROSS, "cross"); pathIds.put(ATSConfig.ATS_MODE_SAND, "sand"); pathIds.put(ATSConfig.ATS_MODE_MUD, "mud"); pathIds.put(ATSConfig.ATS_MODE_SLIP_MUD, "mud"); pathIds.put(ATSConfig.ATS_MODE_ROCK, "rock"); pathIds.put(ATSConfig.ATS_MODE_WADE, "wad"); pathIds.put(ATSConfig.ATS_MODE_SPORT, "sport"); // 系统未初始化的时候不显示任何模式 pathIds.put(ATSConfig.ATS_MODE_NOT_INITIALIZED, ""); // 当系统连接失败或者错误时,默认显示‘舒适’模式 pathIds.put(ATSConfig.ATS_MODE_FAULT, "conf"); } /** * @param * @return void * @method genAtsModeData * @description 生成ATS驾驶模式数据关系表,用于切换不同模式定位path * @date: 2023/6/12 9:43 * @author: yongqiang.wen@foryouge.com.cn */ private void gen60VAtsModeData() { // 生成ATSMode映射关系表 pathIds.clear(); pathIds.put(ATSConfig.ATS60_MODE_ECO, "eco"); pathIds.put(ATSConfig.ATS60_MODE_COMFORT, "conf"); pathIds.put(ATSConfig.ATS60_MODE_LIGHT_SNOW, "snow"); pathIds.put(ATSConfig.ATS60_MODE_DEEP_SNOW, "snow"); // pathIds.put(ATSConfig.ATS60_MODE_SINGLE_PEDAL, "single_pedal"); pathIds.put(ATSConfig.ATS60_MODE_RAPIDLY, "rapidly"); pathIds.put(ATSConfig.ATS60_MODE_THROUGH, "cross"); pathIds.put(ATSConfig.ATS60_MODE_SAND, "sand"); pathIds.put(ATSConfig.ATS60_MODE_DEEP_MUD, "mud"); pathIds.put(ATSConfig.ATS60_MODE_SHALLOW_MUD, "mud"); pathIds.put(ATSConfig.ATS60_MODE_ROCK, "rock"); pathIds.put(ATSConfig.ATS60_MODE_WAD, "wad"); pathIds.put(ATSConfig.ATS60_MODE_SPORT, "sport"); // 系统未初始化的时候不显示任何模式 pathIds.put(ATSConfig.ATS_MODE_NOT_INITIALIZED, ""); // 当系统连接失败或者错误时,默认显示‘舒适’模式 pathIds.put(ATSConfig.ATS_MODE_FAULT, "conf"); } private void switchNextMode(String pathName) { if (TextUtils.isEmpty(pathName)) return; if (lottieAnimationView == null) { ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lottieAnimationView = new LottieAnimationView(getContext()); // lottieAnimationView.addAnimatorListener(animatorListener); lottieAnimationView.addAnimatorUpdateListener(animation -> lottieAnimationView.setProgress(0.5f)); addView(lottieAnimationView, layoutParams); } lottieAnimationView.setVisibility(View.VISIBLE); runLottieAnim(pathName); } private final Animator.AnimatorListener animatorListener = new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { LogUtil.d(ATS_TAG, "animation start!" + animation.toString()); } @Override public void onAnimationEnd(Animator animation) { // 当上一个记录的模式路径与当前不一致时代表模式已经切换, // 需要先播放上一个路径消失的动效再播放新模式的加载动效 // if (!TextUtils.equals(currentPathName, previousModePathName)) { // previousModePathName = currentPathName; // switchNextMode(currentPathName); // } else if (notYetSwitchNext) { // lottieAnimationView.setMinAndMaxProgress(0.5f, 1); // notYetSwitchNext = false; // } LogUtil.d(ATS_TAG, "animation end!"); } @Override public void onAnimationCancel(Animator animation) { LogUtil.d(ATS_TAG, "animation cancel!"); } @Override public void onAnimationRepeat(Animator animation) { LogUtil.d(ATS_TAG, "animation repeat!"); } }; private void runSwitchModeDisplayVideo(String pathName) { // 切换模式需要让未播放的视频暂停 videoView.pause(); String currentPathName = ""; if (carModelConfig == CONFIG_CAR_MODEL_B41V) { // 北汽B41V车型 currentPathName = getB41VModelPath(pathName); } else if (carModelConfig == CONFIG_CAR_MODEL_B41VS) { // 北汽B41VS车型 currentPathName = getB41VSModelPath(pathName); } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS) { // 北汽B60VS车型 currentPathName = getB60VSModelPath(pathName); } if (TextUtils.isEmpty(currentPathName)) return; svgPathView.setPathSelect(pathName); // 根据path name通过资源文件获取对应的动效视频路径 int videoSrc = getResources().getIdentifier(currentPathName, "raw", getContext().getPackageName()); String videoPath = "android.resource://" + getContext().getPackageName() + "/" + videoSrc; post(() -> videoView.setVideoPath(videoPath)); LogUtil.d(ATS_TAG, "current Video path is " + videoPath + ",currentPathName is " + currentPathName); if (videoSrc == 0) { return; } post(() -> { String tipsStr = getTipsStringByConfig(); if (!TextUtils.equals(confirmModeName, pathIds.get(ATSConfig.ATS60_MODE_RAPIDLY))) { // 极速模式没有提示文案 showModeEnterToast(tipsStr, false); removeCallbacks(hideCustomToastRunnable); postDelayed(hideCustomToastRunnable, 5000); } else { hideCustomToast(); } videoView.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE); // SrcMngAudioSwitchManager.getInstance().requestAdayoAudioFocus(3, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT, "com.adayo.service.atsmode", mFocusChange,getContext()); videoView.setBackground(null); //设置音频策略跟随ktv通道 videoView.setAudioAttributes(new AudioAttributes.Builder() .setUsage(43) .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC) .build()); // videoView.setAudioAttributes(new AudioAttributes.Builder() // .setLegacyStreamType(3) // .build()); videoView.start(); setSvgPathViewVisibility(INVISIBLE); setVideoViewVisibility(VISIBLE); handlingSpecialModeSignals(); // mediaPlayer = new MediaPlayer(); // int videoSrc2 = getResources().getIdentifier("deepsnow", "raw", getContext().getPackageName()); // try { // mediaPlayer.setDataSource(getContext(), Uri.parse("android.resource://" + getContext().getPackageName() + "/" + videoSrc2)); // } catch (IOException e) { // e.printStackTrace(); // } // // mediaPlayer.setAudioAttributes(new AudioAttributes.Builder() // .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) // .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) // .build()); // // mediaPlayer.prepareAsync(); // mediaPlayer.setLooping(true); // mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // @Override // public void onPrepared(MediaPlayer mediaPlayer) { // mediaPlayer.start(); // } // }); // // // // new Handler().postDelayed(new Runnable() { // @Override // public void run() { // mediaPlayer.stop(); // mediaPlayer.reset(); // } // },7000); }); } private String getTipsStringByConfig() { int tipsRes = 0; String tipsStr = ""; if (carModelConfig == CONFIG_CAR_MODEL_B41V) { // 北汽B41V车型 tipsRes = getResources().getIdentifier("tips41_" + confirmModeName, "string", getContext().getPackageName()); } else if (carModelConfig == CONFIG_CAR_MODEL_B41VS) { if (TextUtils.equals(confirmModeName, pathIds.get(ATSConfig.ATS60_MODE_RAPIDLY))) { return ""; } // tipsRes = getResources().getIdentifier("tips41vs_" + confirmModeName, "string", getContext().getPackageName()); tipsRes = getResources().getIdentifier("tips60_" + confirmModeName, "string", getContext().getPackageName()); } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS) { if (TextUtils.equals(confirmModeName, pathIds.get(ATSConfig.ATS60_MODE_RAPIDLY))) { return ""; } tipsRes = getResources().getIdentifier("tips60_" + confirmModeName, "string", getContext().getPackageName()); } tipsStr = getContext().getString(tipsRes); return tipsStr; } @NotNull private String getB41VModelPath(String pathName) { String currentPathName; // 根据配置字来匹配展示的动效文件 if (configuration == MODEL_CONFIGURATION_VERSION_C) { LogUtil.d(ATS_TAG, "current model configuration is C Version"); currentPathName = pathName + "_c"; } else if (configuration == MODEL_CONFIGURATION_VERSION_P) { LogUtil.d(ATS_TAG, "current model configuration is P Version"); currentPathName = pathName + "_p"; } else { LogUtil.d(ATS_TAG, "can not require current model configuration"); currentPathName = pathName + "_p"; } return currentPathName; } @NotNull private String getB60VSModelPath(String pathName) { String currentPathName; // 根据配置字来匹配展示的动效文件 currentPathName = pathName + "_60vs"; return currentPathName; } @NotNull private String getB41VSModelPath(String pathName) { String currentPathName; // 鏍规嵁閰嶇疆瀛楁潵鍖归厤灞曠ず鐨勫姩鏁堟枃浠? currentPathName = pathName + "_41vs"; return currentPathName; } private final Runnable hideCustomToastRunnable = this::hideCustomToast; private void runLottieAnim(String pathName) { // 播放切换动效 RectF rectF = svgPathView.getSelectRectF(pathName); if (lottieAnimationView != null && rectF != null) { // // 切换其他模式要先播放之前模式的隐藏动效 // if (!TextUtils.equals(previousModePathName, pathName) && lottieAnimationView.getVisibility() == VISIBLE) { // lottieAnimationView.playAnimation(); // return; // } // 设置lottieView宽高 lottieAnimationView.getLayoutParams().width = (int) rectF.width(); lottieAnimationView.getLayoutParams().height = (int) rectF.height(); // 设置lottieView对应的位置坐标 lottieAnimationView.setX(rectF.centerX() - rectF.width() / 2); lottieAnimationView.setY(rectF.centerY() - rectF.height() / 2); String animSrc = getStringLottiePathSrc(pathName); if (TextUtils.isEmpty(animSrc)) return; LogUtil.d(ATS_TAG, "lottie res file path :" + animSrc); lottieAnimationView.setAnimation(animSrc); lottieAnimationView.setRepeatCount(0); lottieAnimationView.setSpeed(0f); lottieAnimationView.setFrame(16); // if (!notYetSwitchNext) { // // 由于UI给的动效文件是完整的动画过程,50%是动效加载并显示的过程,剩余的50% // lottieAnimationView.setMinAndMaxProgress(0.5f, 0.5f); // notYetSwitchNext = true; // } lottieAnimationView.playAnimation(); operateFlag = FLAG_OPERATE_UPDATE; } } @NotNull private String getStringLottiePathSrc(String pathName) { // 处理多语言的情况,目前只有中英文 Locale locale = getResources().getConfiguration().locale; String language = locale.getLanguage(); LogUtil.d(ATS_TAG, "current system language is: " + language); String animSrc = null; if (carModelConfig == CONFIG_CAR_MODEL_B41V) { // 根据path加载对应的Lottie动画资源文件 if (TextUtils.equals(language, "en")) { animSrc = pathName + "41_en.json"; } else { animSrc = pathName + "41.json"; } } else if (carModelConfig == CONFIG_CAR_MODEL_B41VS) { // 根据path加载对应的Lottie动效资源文件 if (TextUtils.equals(language, "en")) { animSrc = pathName + "60_en.json"; } else { animSrc = pathName + "60.json"; } } else if (carModelConfig == CONFIG_CAR_MODEL_B60VS) { // 根据path加载对应的Lottie动画资源文件 if (TextUtils.equals(language, "en")) { animSrc = pathName + "60_en.json"; } else { animSrc = pathName + "60.json"; } } return animSrc; } public LifecycleRegistry getLifecycleRegistry() { return lifecycleRegistry; } public void setLifecycleRegistry(LifecycleRegistry lifecycleRegistry) { this.lifecycleRegistry = lifecycleRegistry; } public interface OnATSViewCloseListener { void onClose(); } private static IAdayoAudioFocusChange mFocusChange = new IAdayoAudioFocusChange() { @Override public void onAdayoAudioOnGain() { } @Override public void onAdayoAudioOnLoss() { } @Override public void onAdayoAudioLossTransient() { } @Override public void onAdayoAudioLossTransientCanDuck() { } }; }
08-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值