Android 7.0 SystemUI 状态栏左侧应用图标显示控制流程

SystemUI 状态栏左侧应用图标如下图所示:

状态栏StatusBar显示分为三个区域,分别是左侧应用图标显示区域(USB图标,下载图标,截屏图标),中右侧系统图标显示(Wifi 蓝牙 信号栏图标显示)和最右侧电池电量及时间显示区域,本次重点讲述左侧应用图标显示控制流程:

 PhoneStatusBar.java: 

 makeStatusBarView()-->createIconController()
    protected void createIconController() {
        mIconController = new StatusBarIconController(
                mContext, mStatusBarView, mKeyguardStatusBar, this);
    }

StatusBarIconController.java:
    mNotificationIconAreaController = SystemUIFactory.getInstance()
                .createNotificationIconAreaController(context, phoneStatusBar);
    mNotificationIconAreaInner =
                mNotificationIconAreaController.getNotificationInnerAreaView();


NotificationIconAreaController.java
 /**
  * Returns the view that represents the notification area.
  */
    public View getNotificationInnerAreaView() {
        return mNotificationIconArea; 
    }
mNotificationIconArea实际是notification_icon_area.xml layout布局文件

**/
   ViewGroup notificationIconArea =
                (ViewGroup) statusBar.findViewById(R.id.notification_icon_area);
 notificationIconArea是status_bar.xml layout 布局文件中的一个组件:
   <com.android.systemui.statusbar.AlphaOptimizedFrameLayout
            android:id="@+id/notification_icon_area"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal" />

   notificationIconArea.addView(mNotificationIconAreaInner);


所有第三方应用发送的通知图标都会添加在notificationIconArea中显示:

NotificationIconAreaController.java:
  /**
   * Updates the notifications with the given list of notifications to display.
   */
    public void updateNotificationIcons(NotificationData notificationData) {

   ....
    ArrayList<StatusBarIconView> toShow = new ArrayList<>(size);
    ....
    ArrayList<View> toRemove = new ArrayList<>();

   ....
    }

  以上方法中会包含本次刷新需要显示或者移除的状态栏应用通知小图标。

猜你喜欢

转载自blog.csdn.net/tj_shenzhendaxue/article/details/72466245