当前位置:网站首页>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?
边栏推荐
- SWIG教程《二》
- SWIG教程《一》
- 2011年下半年 系统架构设计师 下午试卷 II
- 2022年中国软饮料市场洞察
- Data product manager thing 2
- 镜像瘦身:每一层都不能放过
- Understanding_Data_Types_in_Go
- Second half of 2011 System Architect Afternoon Paper II
- Lack of comparators, op amps come to the rescue!(Op amp is recorded as a comparator circuit)
- Boss raises salary!Look at my WPF Loading!!!
猜你喜欢
随机推荐
蓝帽杯半决赛火炬木wp
注意力模型---Attention Model
老板加薪!看我做的WPF Loading!!!
王学岗————直播推流(软便)03x264集成与camera推流
波士顿房价预测
静态变量存储在哪个区
PEST 分析法
usb转rs485测试软件,usb转rs485「建议收藏」
【语义分割】DeepLab系列
How does IT Xiaobai learn PHP systematically
兆骑科创创业赛事活动发布平台,创业赛事,项目路演
[JS Advanced] Creating sub-objects and replacing this_10 in ES5 standard specification
Summary of Force Buckle Solution 640 - Solving Equations
mysql进阶(三十三)MySQL数据表添加字段
MQTT服务器搭建
Mysql语句分析、存储引擎、索引优化等详情
1004 (tree array + offline operation + discretization)
串口服务器调试助手使用教程,串口调试助手使用教程【操作方式】
阿里五位MySQL封神大佬耗17个月总结出53章性能优化法则
安装mysql报错处理