问题
下拉状态栏时,home键、back键、recent键、hidebar以及自定义图标不会进行隐藏,仍旧出现在下拉状态栏的两侧
涉及文件:
CollapsedStatusBarFragment.java
代码地址:
SystemUI\src\com\android\systemui\statusbar\phone\CollapsedStatusBarFragment.java
原生基础上进行修改
onViewCreated中获取图标,比如home键、back键以及recent按键,安卓原生没有对其进行处理,只对clock进行了处理
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mStatusBar = (PhoneStatusBarView) view;
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_PANEL_STATE)) {
mStatusBar.restoreHierarchyState(
savedInstanceState.getSparseParcelableArray(EXTRA_PANEL_STATE));
}
mDarkIconManager = new DarkIconManager(view.findViewById(R.id.statusIcons));
mDarkIconManager.setShouldLog(true);
Dependency.get(StatusBarIconController.class).addIconGroup(mDarkIconManager);
mSystemIconArea = mStatusBar.findViewById(R.id.system_icon_area);
mClockView = mStatusBar.findViewById(R.id.clock);
//add view for home back recent and hidebtn start
mKeyHome = mStatusBar.findViewById(R.id.home);
mKeyBack = mStatusBar.findViewById(R.id.back);
mKeyRecent = mStatusBar.findViewById(R.id.recent);
mKeyHideStatus = mStatusBar.findViewById(R.id.hide_bar);
//add view for home back recent and hidebtn end
showSystemIconArea(false);
showClock(false);
initEmergencyCryptkeeperText();
initOperatorName();
}
disable中进行图标的显示和隐藏
@Override
public void disable(int displayId, int state1, int state2, boolean animate) {
if (displayId != getContext().getDisplayId()) {
return;
}
state1 = adjustDisableFlags(state1);
final int old1 = mDisabled1;
final int diff1 = state1 ^ old1;
mDisabled1 = state1;
if ((diff1 & DISABLE_SYSTEM_INFO) != 0) {
if ((state1 & DISABLE_SYSTEM_INFO) != 0) {
hideSystemIconArea(animate);
//add for hiding status bar icon start
hideStatusBarKeys(animate);
//add for hiding status bar icon end
hideOperatorName(animate);
} else {
showSystemIconArea(animate);
//add for showing status bar icon start
showStatusBarKeys(animate);
//add for showing status bar icon end
showOperatorName(animate);
}
}
...
}
增加隐藏显示方法
隐藏
public void hideStatusBarKeys(boolean animate) {
if (mKeyHome != null) {
animateHide(mKeyHome, animate);
animateHide(mKeyBack, animate);
animateHide(mKeyRecent, animate);
animateHide(mKeyHideStatus, animate);
}
}
显示
public void showStatusBarKeys(boolean animate) {
if (mKeyHome != null) {
animateShow(mKeyHome, animate);
animateShow(mKeyBack, animate);
animateShow(mKeyRecent, animate);
animateShow(mKeyHideStatus, animate);
}
}