The layout relationship of the status bar is analyzed above . This article mainly records some basic modifications, such as status bar and qs background modification, removal of the brightness adjustment bar, return to directly close the status bar, and other minor and scattered modifications.
1. Remove the background color
As mentioned above , the background and foreground colors are ScrimView, so you can modify ScrimView:
ScrimView.java->onDraw() method modification:
@Override
protected void onDraw(Canvas canvas) {
//ScrimView:qs面板出来后的bg、fg蒙板
if (mDrawAsSrc || mDrawable.getAlpha() > 0) {
PorterDuff.Mode mode = mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
//改为绘制颜色透明色,去除灰色蒙板
canvas.drawColor(Color.TRANSPARENT, mode);
//以下为源码,注释即可
/**if (!mHasExcludedArea) {
...
**/
}
}
Change mask painting to paint transparent color.
2. The background of the main part of the QS panel
Corresponding to qs_panel.xml:
<View
android:id="@+id/quick_settings_background"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/qs_background_primary"
android:elevation="4dp" />
Just modify qs_background_primary
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape>
<!-- qs_background_dark 改为 8effffff -->
<solid android:color="#6effffff" />
<!-- 圆角改为10dp -->
<corners android:radius="10dp" />
</shape>
</inset>
3. The background color of the status bar when expanded
The same is the qs_panel.xml file
<View
android:id="@+id/quick_settings_status_bar_background"
android:layout_width="match_parent"
android:layout_height="@*android:dimen/quick_qs_offset_height"
android:background="#00000000"
android:clipChildren="false"
android:clipToPadding="false" />
Just modify the background.
4. Remove the "date, phone status icon bar" in the Header
That is, the place in Figure 2 above, corresponding to quick_status_bar_expanded_header.xml
<include layout="@layout/quick_qs_status_icons"
android:visibility="gone"/>
<com.android.systemui.qs.QuickQSPanel
android:layout_marginTop="80dp"
....
/>
QuickQSPanel is located under quick_qs_status_icons, hide it and add a marginTop accordingly.
5. Expand all by default
By default, when the source code is pulled down, only the header and the notification bar are displayed (see the picture in 4). Modify it to pull down and directly expand the shortcut setting panel. NotificationPanelView.java->isOpenQsEvent can directly return true
private boolean isOpenQsEvent(MotionEvent event) {
.....
//直接返回true,展开整个qs面板
return true;
}
6. Click Back to close the status bar directly
The original effect is that when the header is currently displayed, press the return button to close the page. If the current Qs panel is fully expanded, first close the expansion item, slide to the header, and click back again to close the page.
StatusBar.java modifies the onBackPressed method:
public boolean onBackPressed() {
...
if (mNotificationPanel.isQsExpanded()) {
if (mNotificationPanel.isQsDetailShowing()) {
mNotificationPanel.closeQsDetail();
} else {
// mNotificationPanel.animateCloseQs(); //只关闭qs展开部分 animateCollapsePanels(); //关闭整个qs面板
}
return true;
}
....
}
7. Swipe up to close the menu directly
When sliding up on the Qs panel, the performance is similar to that of the back button. First fold to the header, and then slide up again to close the entire page. NotificationPanelView.java modifies the onQsIntercept method:
private boolean onQsIntercept(MotionEvent event) {
...
case MotionEvent.ACTION_MOVE:
....
//以下代码用于拦截事件,返回true则不会直接关闭整个面板,而是先折叠,显示header ,注释掉
/**
if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)
&& shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, h)) {
mQsTracking = true;
onQsExpansionStarted();
notifyExpandingFinished();
mInitialHeightOnTouch = mQsExpansionHeight;
mInitialTouchY = y;
mInitialTouchX = x;
mIntercepting = false;
mNotificationStackScroller.cancelLongPress();
return true;
}
**/
break;
....
}
Comment the intercept method in MotionEvent.ACTION_MOVE.
8. Remove the brightness bar
The brightness adjustment bar is created in QSPanel.java, directly setting Visibility
public QSPanel(Context context, AttributeSet attrs) {
...
addView(mBrightnessView);
//创建完隐藏掉
mBrightnessView.setVisibility(GONE);
....
}
@Override
public void onTuningChanged(String key, String newValue) {
if (QS_SHOW_BRIGHTNESS.equals(key)) {
// 这里会显示亮度条,注释掉
// updateViewVisibilityForTuningValue(mBrightnessView, newValue);
}
}
The onTuningChanged method will also display the brightness bar, which is also commented out.