Android7.1 Launcher3去除抽屉
最近接了个工作,去除公司设备上Launcher的抽屉,所有应用单层展示。网上也查找了一番,最终摸索着基本完成了工作,在此记录下去除抽屉的所有操作。
去掉searchBox bar
packages/apps/Launcher3/res/layout/qsb_default_view.xml
屏蔽掉FrameLayout中的布局
packages/apps/Launcher3/src/com/android/launcher3/QsbContainerView.java
1
2
3
4
5
6
7
8
9
10private View getDefaultView(LayoutInflater inflater, ViewGroup parent, boolean showSetup) {
View v = inflater.inflate(R.layout.qsb_default_view, parent, false);
// if (showSetup) {
// View setupButton = v.findViewById(R.id.btn_qsb_setup);
// setupButton.setVisibility(View.VISIBLE);
// setupButton.setOnClickListener(this);
// }
// v.findViewById(R.id.btn_qsb_search).setOnClickListener(this);
return v;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public void onClick(View view) {
// if (view.getId() == R.id.btn_qsb_search) {
// getActivity().startSearch("", false, null, true);
// } else if (view.getId() == R.id.btn_qsb_setup) {
// // Allocate a new widget id for QSB
// sSavedWidgetId = Launcher.getLauncher(getActivity())
// .getAppWidgetHost().allocateAppWidgetId();
// // Start intent for bind the widget
// Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, sSavedWidgetId);
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, mWidgetInfo.provider);
// startActivityForResult(intent, REQUEST_BIND_QSB);
// }
}packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks,
String description) {
if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
throw new RuntimeException("Expected custom content screen to exist");
}
// Add the custom content to the full screen custom page
CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
int spanX = customScreen.getCountX();
int spanY = customScreen.getCountY();
// CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
// lp.canReorder = false;
// lp.isFullscreen = true;
if (customContent instanceof Insettable) {
((Insettable)customContent).setInsets(mInsets);
}
// Verify that the child is removed from any existing parent.
if (customContent.getParent() instanceof ViewGroup) {
ViewGroup parent = (ViewGroup) customContent.getParent();
parent.removeView(customContent);
}
customScreen.removeAllViews();
customContent.setFocusable(true);
customContent.setOnKeyListener(new FullscreenKeyEventListener());
customContent.setOnFocusChangeListener(mLauncher.mFocusHandler
.getHideIndicatorOnFocusListener());
// customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
mCustomContentDescription = description;
mCustomContentCallbacks = callbacks;
}
去掉向上滑动的箭头
packages/apps/Launcher3/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
1 |
|
去掉第一屏firstPage
packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
1 | public void removeAllWorkspaceScreens() { |
去掉hotseat
1.packages/apps/Launcher3/res/xml/default_workspace_5x6.xml
packages/apps/Launcher3/res/xml/default_workspace_5x5.xml
屏蔽Hotseat布局
1 | <!-- Hotseat --> |
packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java
1 | // Layout the page indicators |
packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
1
2
3
4
5
6
7
8
9mDragController.addDragListener(new AccessibileDragListenerAdapter(
this, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG) {
protected void enableAccessibleDrag(boolean enable) {
super.enableAccessibleDrag(enable);
// setEnableForLayout(mLauncher.getHotseat().getLayout(),enable);
}
});1
2
3
4
5
6
7
8
9
10
11
12
13
14/**
* Returns a list of all the CellLayouts in the workspace.
*/
ArrayList<CellLayout> getWorkspaceAndHotseatCellLayouts() {
ArrayList<CellLayout> layouts = new ArrayList<CellLayout>();
int screenCount = getChildCount();
for (int screen = 0; screen < screenCount; screen++) {
layouts.add(((CellLayout) getChildAt(screen)));
}
if (mLauncher.getHotseat() != null) {
// layouts.add(mLauncher.getHotseat().getLayout());
}
return layouts;
}1
2
3
4
5if (mLauncher.getHotseat() != null && !isDragWidget(d)) {
if (isPointInSelfOverHotseat(d.x, d.y)) {
// layout = mLauncher.getHotseat().getLayout();
}
}packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
1
2
3
4
5
6
7
8private void loadExtractedColorsAndColorItems() {
// TODO: do this in pre-N as well, once the extraction part is complete.
if (Utilities.isNycOrAbove()) {
mExtractedColors.load(this);
// mHotseat.updateColor(mExtractedColors, !mPaused);
...
}
}
去掉向上滑动显示AllApps的动画效果
packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
1 | public void showOverviewMode(boolean animated) { |
packages/apps/Launcher3/src/com/android/launcher3/dragndrop/DragLayer.java
1 | if (mDragController.onInterceptTouchEvent(ev)) { |
7.packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
1 | /** |
当安装新应用时,安装的应用添加在第一层上
packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java
1 | final HashMap<ComponentName, AppInfo> addedOrUpdatedApps = new HashMap<>(); |
去掉长按时的删除选项
packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java
1 |
|
去掉桌面长按 、pinch捏动作
packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
1 | /** |
packages/apps/Launcher3/src/com/android/launcher3/PinchAnimationManager.java
1 | /** |
1 | public void animateThreshold(float threshold, Workspace.State startState, |
修改无抽屉时的异常
packages/apps/Launcher3/src/com/android/launcher3/allapps/AllAppsTransitionController.java
1 | mDiscoBounceAnimation.setTarget(this); |
packages/apps/Launcher3/src/com/android/launcher3/dragndrop/DragController.java
1 | private PointF isFlingingToDelete(DragSource source) { |
屏蔽生成文件夹
packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
1 |
|