当前位置:网站首页>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?
边栏推荐
- 正则表达式(包含各种括号,echo,正则三剑客以及各种正则工具)
- 无线网络、HTTP缓存、IPv6
- d为何用模板参数
- 产品使用说明书小程序开发制作说明
- PyTorch 多机多卡训练:DDP 实战与技巧
- How does IT Xiaobai learn PHP systematically
- 中学数学建模书籍及相关的视频等(2022.08.09)
- Parallels 将扩展桌面平台产品,以进一步改善在 Mac 上运行 Windows 的用户体验和工作效率
- fatal error C1083 Unable to open include file 'io.h' No such file
- How to code like a pro in 2022 and avoid If-Else
猜你喜欢

win2012安装Oraclerac失败

阿里五位MySQL封神大佬耗17个月总结出53章性能优化法则

1W字详解线程本地存储 ThreadLocal

Using data intelligence, Amazon cloud technology helps companies build endogenous brand growth

Understanding_Data_Types_in_Go

波士顿房价预测

数学建模学习视频及资料集(2022.08.10)

Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
![[Gazebo Introductory Tutorial] Lecture 3 Static/Dynamic Programming Modeling of SDF Files](/img/ec/87566763daf7faa3769ee186f93ee0.jpg)
[Gazebo Introductory Tutorial] Lecture 3 Static/Dynamic Programming Modeling of SDF Files

微信小程序,自定义输入框与导航胶囊对其
随机推荐
1W字详解线程本地存储 ThreadLocal
websocket实现实时变化图表内容
WSL 提示音关闭
普林斯顿微积分读本05第四章--求解多项式的极限问题
紫金示例
Alibaba的秒杀系统—千亿级并发设计手册上线了
MySQL - storage engine for databases
PHP judges whether the file has content, and if there is no content, copy another file to write
640. Solving Equations: Simple Simulation Problems
sql语句 异常 Err] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your
物资采购小程序开发制作功能介绍
pm2之静态文件服务
易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!
640. 求解方程 : 简单模拟题
High-paid programmers & interview questions series 135 How do you understand distributed?Do you know CAP theory?
@RequestBody的使用[通俗易懂]
数字藏品平台系统开发实战
镜像瘦身:每一层都不能放过
Go Context基本使用
Epoll learn to think: a high performance server processing framework