[DESCRIPTION] 如何让主菜单的背景显示为壁纸? [SOLUTION]
M:
1.修改res/drawable/quantum_panel_shape.xml
将 <solid android:color="@color/quantum_panel_bg_color" /> 改为: <solid android:color="@android:color/transparent" /> 2.修改Launcher.java的onResume函数 ...... if (mOnResumeState == State.WORKSPACE) { showWorkspace(false); } else if (mOnResumeState == State.APPS) { boolean launchedFromApp = (mWaitingForResume != null); // Don't update the predicted apps if the user is returning to launcher in the apps // view after launching an app, as they may be depending on the UI to be static to // switch to another app, otherwise, if it was //change animated to true from false mWorkspace.setVisibility(View.INVISIBLE); //mtk add mPageIndicators.setAlpha(0f); //mtk add showAppsView(true /* animated */, true /* resetListToTop */, !launchedFromApp /* updatePredictedApps */, false /* focusSearchBar */); // mtk modify } else if (mOnResumeState == State.WIDGETS) { showWidgetsView(false, false); } ......3.修改LauncherModel.java的bindWorkspace方法,将 if (isLoadingSynchronously) { synchronized (mDeferredBindRunnables) { mDeferredBindRunnables.add(r); }
} else { runOnMainThread(r); }
修改为
//mtk modify start //if (isLoadingSynchronously) { // synchronized (mDeferredBindRunnables) { // mDeferredBindRunnables.add(r); //}
//}else { runOnMainThread(r); // } //mtk modify end
4.修改LauncherStateTransitionAnimation.java的startAnimationToAllApps方法,将其中的getMaterialRevealViewAnimatorListener修改为如下: public AnimatorListenerAdapter getMaterialRevealViewAnimatorListener( final View revealView, final View allAppsButtonView) { return new AnimatorListenerAdapter() { public void onAnimationStart(Animator animation) { allAppsButtonView.setVisibility(View.INVISIBLE); } public void onAnimationEnd(Animator animation) { allAppsButtonView.setVisibility(View.VISIBLE); Workspace workspace= mLauncher.getWorkspace();//mtk add workspace.setVisibility(View.INVISIBLE);//mtk add } }; }
5.修改LauncherStateTransitionAnimation.java的startAnimationToWorkspaceFromAllApps方法为如下:
public AnimatorListenerAdapter getMaterialRevealViewAnimatorListener(final View revealView, final View allAppsButtonView) { return new AnimatorListenerAdapter() { public void onAnimationStart(Animator animation) { // We set the alpha instead of visibility to ensure that the focus does not // get taken from the all apps view allAppsButtonView.setVisibility(View.VISIBLE); allAppsButtonView.setAlpha(0f); Workspace workspace = mLauncher.getWorkspace();//mtk add workspace.setVisibility(View.VISIBLE);//mtk add workspace.setAlpha(0f);//mtk add }
public void onAnimationEnd(Animator animation) { // Hide the reveal view revealView.setVisibility(View.INVISIBLE);
// Show the all apps button, and focus it allAppsButtonView.setAlpha(1f); Workspace workspace = mLauncher.getWorkspace();//mtk add workspace.setAlpha(1f);//mtk add } }; }
L: 1. AppsCustomizePagedView.java修改两处如下: 1) private void setupPage(AppsCustomizeCellLayout layout) { layout.setGridSize(mCellCountX, mCellCountY); // Note: We force a measure here to get around the fact that when we do layout calculations // immediately after syncing, we don't have a proper width. That said, we already know the // expected page width, so we can actually optimize by hiding all the TextView-based // children that are expensive to measure, and let that happen naturally later. setVisibilityOnChildren(layout, View.GONE); int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST); int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST); layout.measure(widthSpec, heightSpec); if(!Launcher.DISABLE_APPLIST_WHITE_BG) {//mtk add Drawable bg = getContext().getResources().getDrawable(R.drawable.quantum_panel); if (bg != null) { bg.setAlpha(mPageBackgroundsVisible ? 255: 0); layout.setBackground(bg); } } else {//mtk add layout.setBackground(null);//mtk add }//mtk add setVisibilityOnChildren(layout, View.VISIBLE); } 2) public void syncAppsPageItems(int page, boolean immediate) { ...... AppInfo info = mApps.get(i); BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate( R.layout.apps_customize_application, layout, false); if(Launcher.DISABLE_APPLIST_WHITE_BG) {//mtk add icon.setTextColor(getContext().getResources().getColor(R.color.quantum_panel_transparent_bg_text_color));//mtk add }//mtk add icon.applyFromApplicationInfo(info); icon.setOnClickListener(mLauncher); icon.setOnLongClickListener(this); ......
2. colors.xml中新增: <color name="quantum_panel_transparent_bg_text_color">#FFFFFF</color> 3. DeviceProfile.java修改layout(Launcher launcher)方法如下: ...... pagedView.setWidgetsPageIndicatorPadding(pageIndicatorHeight); if(Launcher.DISABLE_APPLIST_WHITE_BG) {//mtk add fakePage.setBackground(null);//mtk add } else {//mtk add fakePage.setBackground(res.getDrawable(R.drawable.quantum_panel)); }//mtk add // Horizontal padding for the whole paged view int pagedFixedViewPadding = res.getDimensionPixelSize(R.dimen.apps_customize_horizontal_padding); ...... 4. Launcher.java 1) 新增: //mtk add begin /// M: Disable applist white background for jitter performance issue {@ public static boolean DISABLE_APPLIST_WHITE_BG = true; public static final String PROP_DISABLE_APPLIST_WHITE_BG = "launcher.whitebg.disable"; // should kill and restart launcher process to re-execute static block if reset properties // adb shell setprop launcher.applist.whitebg.disable true/false // adb shell stop // adb shell start static { DISABLE_APPLIST_WHITE_BG = android.os.SystemProperties.getBoolean(PROP_DISABLE_APPLIST_WHITE_BG, true); } /// @} //mtk add end 2) showAppsCustomizeHelper方法修改如下: ...... if (isWidgetTray) { revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); } else { if(Launcher.DISABLE_APPLIST_WHITE_BG) {//mtk add revealView.setBackground(null);//mtk add } else {//mtk add revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); }//mtk add } ...... 3) hideAppsCustomizeHelper方法修改如下: ...... if (isWidgetTray) { revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); } else { if(Launcher.DISABLE_APPLIST_WHITE_BG) {//mtk add revealView.setBackground(null);//mtk add } else {//mtk add revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); }//mtk add } ......