当前位置:网站首页>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?
边栏推荐
猜你喜欢
随机推荐
epoll学习:思考一种高性能的服务器处理框架
PAT甲级 1014 排队等候(队列大模拟+格式化时间)
缺少比较器,运放来救场!(运放当做比较器电路记录)
leetcode 739. Daily Temperatures 每日温度(中等)
E. Cross Swapping(并查集变形/好题)
图式图例规范尺寸
sql语句 异常 Err] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your
2022年中国软饮料市场洞察
微信扫码登陆(1)—扫码登录流程讲解、获取授权登陆二维码
Summary of tensorflow installation stepping on the pit
文件系统设计
fatal error C1083 无法打开包括文件'io.h' No such file
PyTorch multi-machine multi-card training: DDP combat and skills
这一次,话筒给你:向自由软件之父斯托曼 提问啦!
Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
MySQL advanced (thirty-three) MySQL data table adding fields
vue 怎么清除tab 切换缓存问题 ?
Existing in the rain of PFAS chemical poses a threat to the safety of drinking water
舵机内部结及工作原理浅析[通俗易懂]
Lack of comparators, op amps come to the rescue!(Op amp is recorded as a comparator circuit)









