Android10.0 SystemUI 最近任务“清除全部“按钮修改为始终显示

Android10.0 SystemUI 最近任务"清除全部"按钮修改为始终显示

修改文件1

frameworks/base/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/RecentsView.java

修改1.1 添加全局开关

public static final boolean CLEAR_BTN_ALWAYS_SHOW = true;

修改1.2

    /**
     * Called from RecentsActivity when the task stack is updated.
     */
    public void updateStack(TaskStack stack, boolean setStackViewTasks) {
 		// ...
		 // begin for CLEAR_BTN_ALWAYS_SHOW
		if (CLEAR_BTN_ALWAYS_SHOW) {
			mStackActionButton.setVisibility(stack.getTaskCount() > 0 ? View.VISIBLE :  View.INVISIBLE);
		}
		// end
    }

修改1.3


    public final void onBusEvent(ShowStackActionButtonEvent event) {
		// begin for CLEAR_BTN_ALWAYS_SHOW
        if (CLEAR_BTN_ALWAYS_SHOW) {
			showStackActionButton(SHOW_STACK_ACTION_BUTTON_DURATION, false);
			return;
		}
		// end
		// ...
    }

修改1.4

    /**
     * Hides the stack action button.
     */
    private void hideStackActionButton(int duration, boolean translate) {
	    if(CLEAR_BTN_ALWAYS_SHOW) return; // for CLEAR_BTN_ALWAYS_SHOW
        // ...
    }

修改1.5


    /**
     * @return the bounds of the stack action button.
     */
    Rect getStackActionButtonBoundsFromStackLayout() {
		// ...
		if (CLEAR_BTN_ALWAYS_SHOW) top -= 27; // for CLEAR_BTN_ALWAYS_SHOW
        actionButtonRect.set(left, top, left + mStackActionButton.getMeasuredWidth(),
                top + mStackActionButton.getMeasuredHeight());
        return actionButtonRect;
    }

修改文件2

frameworks/base/packages/SystemUI/legacy/recents/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java

修改2.1


    /**
     * Reloads the layout for the current configuration.
     */
    public void reloadOnConfigurationChange(Context context) {
      	// ... 
        mTaskGridLayoutAlgorithm.reloadOnConfigurationChange(context);
        mTaskStackLowRamLayoutAlgorithm.reloadOnConfigurationChange(context);
        mMinMargin = res.getDimensionPixelSize(R.dimen.recents_layout_min_margin);
        mBaseTopMargin = getDimensionForDevice(context,
                R.dimen.recents_layout_top_margin_phone,
                R.dimen.recents_layout_top_margin_tablet,
                R.dimen.recents_layout_top_margin_tablet_xlarge,
                R.dimen.recents_layout_top_margin_tablet);
		if (RecentsView.CLEAR_BTN_ALWAYS_SHOW) mBaseTopMargin += 20; // for CLEAR_BTN_ALWAYS_SHOW
		// ... 
    }

附录

android9.0对应的路径为:
frameworks/base/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
frameworks/base/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java

mtk android9.0对应的路径为:
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
overlay/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java

posted @ 2022-03-12 22:04  xiaomodecnblogs  阅读(215)  评论(0)    收藏  举报