当前位置:网站首页>Systemui status bar to add a new icon
Systemui status bar to add a new icon
2022-08-10 14:53:00 【Indulge_Yiren Qianying】
Added a new icon to the right of the status bar
需求描述
Add a custom icon to the right of the status bar,Update icon based on broadcast.
代码实现
framework部分修改
frameworks/base/core/res/res/values/config.xml最上方config_statusBarIcons.The native comments are clearly written,Translate it with a free translator:
不要翻译.
Defines the slot for the icon on the right.
That is, there is no notification icon in the status bar
1、config_statusBarIconsAdd custom icons to the arrayxiguatong
2、在下方添加string xiguatong
frameworks/base/core/res/res/values/config.xml中config_statusBarIconsThe order of the indicates the order of the icons in the status bar on the right,We added one in front of the battery iconxiguatong
<!-- Do not translate. Defines the slots for the right-hand side icons. That is to say, the icons in the status bar that are not notifications. -->
<string-array name="config_statusBarIcons">
<item><xliff:g id="id">@string/status_bar_alarm_clock</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_rotate</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_headset</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_data_saver</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_ime</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_sync_failing</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_sync_active</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_nfc</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_tty</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_speakerphone</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_cdma_eri</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_data_connection</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_phone_evdo_signal</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_phone_signal</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_secure</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_bluetooth</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_managed_profile</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_cast</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_screen_record</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_vpn</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_camera</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_microphone</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_location</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_mute</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_volume</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_zen</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_ethernet</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_wifi</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_hotspot</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_mobile</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_airplane</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_xiguatong</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_battery</xliff:g></item>
<item><xliff:g id="id">@string/status_bar_sensors_off</xliff:g></item>
</string-array>
<string translatable="false" name="status_bar_xiguatong">xiguatong</string>
<string translatable="false" name="status_bar_rotate">rotate</string>
<string translatable="false" name="status_bar_headset">headset</string>
<string translatable="false" name="status_bar_data_saver">data_saver</string>
<string translatable="false" name="status_bar_managed_profile">managed_profile</string>
<string translatable="false" name="status_bar_ime">ime</string>
<string translatable="false" name="status_bar_sync_failing">sync_failing</string>
<string translatable="false" name="status_bar_sync_active">sync_active</string>
<string translatable="false" name="status_bar_cast">cast</string>
<string translatable="false" name="status_bar_hotspot">hotspot</string>
<string translatable="false" name="status_bar_location">location</string>
<string translatable="false" name="status_bar_bluetooth">bluetooth</string>
<string translatable="false" name="status_bar_nfc">nfc</string>
<string translatable="false" name="status_bar_tty">tty</string>
<string translatable="false" name="status_bar_speakerphone">speakerphone</string>
<string translatable="false" name="status_bar_zen">zen</string>
<string translatable="false" name="status_bar_mute">mute</string>
<string translatable="false" name="status_bar_volume">volume</string>
<string translatable="false" name="status_bar_wifi">wifi</string>
<string translatable="false" name="status_bar_cdma_eri">cdma_eri</string>
<string translatable="false" name="status_bar_data_connection">data_connection</string>
<string translatable="false" name="status_bar_phone_evdo_signal">phone_evdo_signal</string>
<string translatable="false" name="status_bar_phone_signal">phone_signal</string>
<string translatable="false" name="status_bar_battery">battery</string>
<string translatable="false" name="status_bar_alarm_clock">alarm_clock</string>
<string translatable="false" name="status_bar_secure">secure</string>
<string translatable="false" name="status_bar_clock">clock</string>
<string translatable="false" name="status_bar_mobile">mobile</string>
<string translatable="false" name="status_bar_vpn">vpn</string>
<string translatable="false" name="status_bar_ethernet">ethernet</string>
<string translatable="false" name="status_bar_microphone">microphone</string>
<string translatable="false" name="status_bar_camera">camera</string>
<string translatable="false" name="status_bar_airplane">airplane</string>
<string translatable="false" name="status_bar_sensors_off">sensors_off</string>
<string translatable="false" name="status_bar_screen_record">screen_record</string>
frameworks/base/core/res/res/values/symbols.xml中添加xiguatong id,Otherwise, the resource cannot be referenced
<java-symbol type="string" name="status_bar_xiguatong" />
<java-symbol type="string" name="status_bar_battery" />
systemui部分
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
private final StatusBarIconController mIconController;//Status bar icon controller
//Add your own watermelon bucket icon
private final String mXiGuaTong;
private boolean mXiGuaTongVisible;
@Inject
public PhoneStatusBarPolicy(...){
...
//
mXiGuaTong = resources.getString(com.android.internal.R.string.status_bar_xiguatong);
mXiGuaTongVisible = true;
...
}
public void init() {
...
//xiGuaTong:字符串,图片,button description
mIconController.setIcon(mXiGuaTong, R.drawable.stat_sys_xiguatong,null);
//Set the picture to be visible or not:字符串,Boolean值
mIconController.setIconVisibility(mXiGuaTong, mXiGuaTongVisible);
...
}
以上,A new icon can be added to the right of the status bar.
遗留问题
1、How is the icon added to the right of the status bar,完整流程?
2、How to add an icon to the left of the status bar?
3、状态栏、下拉状态栏、2pull down the status bar、锁屏、The status bar icons will change in these states,Where is it controlled?
边栏推荐
猜你喜欢
关于已拦截跨源请求CORS 头缺少 ‘Access-Control-Allow-Origin‘问题解决
Error: Rule can only have one resource source (provided resource and test + include + exclude)
MySQL 原理与优化:Update 优化
Appium进行APP自动化测试
2022年中国软饮料市场洞察
微信小程序,自定义输入框与导航胶囊对其
物资采购小程序开发制作功能介绍
Existing in the rain of PFAS chemical poses a threat to the safety of drinking water
王学岗—————————哔哩哔哩直播-手写哔哩哔哩硬编码录屏推流(硬编)(26节课)
【有限元分析】异型密封圈计算泄漏量与参数化优化过程(带分析源文件)
随机推荐
epoll学习:思考一种高性能的服务器处理框架
data product manager
【MinIO】Using tools
强意识 压责任 安全培训筑牢生产屏障
PEST 分析法
【语义分割】DeepLab系列
写不完的数学试卷-----试卷生成器(Qt含源码)
正则表达式(包含各种括号,echo,正则三剑客以及各种正则工具)
IT小白怎么系统的php学习
640. Solving Equations: Simple Simulation Problems
MySQL - 数据库的存储引擎
蓝帽杯半决赛火炬木wp
每个月工资表在数据库如何存储?求一个设计思路
等保2.0一个中心三重防护指的是什么?如何理解?
王学岗————直播推流(软便)03x264集成与camera推流
公网IP和内网IP的区别[通俗易懂]
物资采购小程序开发制作功能介绍
[Gazebo Introductory Tutorial] Lecture 3 Static/Dynamic Programming Modeling of SDF Files
使用mysq语句操作数据库
How is the monthly salary table stored in the database?Ask for a design idea