【隐藏谷歌原生Qsb,将Widget中的Qsb组件替换至原位(解决GMS包添加后默认Qsb搜索框无法操作的问题)】
1. 删除原来的Google SearchBox
File Path:res/layout/search_container_workspace.xml b/res/layout/search_container_workspace.xml
Patch File:
<com.android.launcher3.qsb.QsbContainerView>
· · ·
+ <!--To hide Google Qsb-->
+ <!--<fragmentandroid:name="com.android.launcher3.qsb.QsbContainerView$QsbFragment"android:layout_width="match_parent"android:tag="qsb_view"
- android:layout_height="match_parent"/>
+ android:layout_height="match_parent"/>-->
</com.android.launcher3.qsb.QsbContainerView>
File Path:src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
Patch File:
//Execute Android native logiclp = new CellLayoutLayoutParams(0, 0, cellHSpan, 1);}
- lp.canReorder = false;
+ // To hide Google Qsb
+ /*lp.canReorder = false;if (!firstPage.addViewToCellLayout(mFirstPagePinnedItem, 0, R.id.search_container_workspace, lp, true)) {Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");mFirstPagePinnedItem = null;
- }
+ }*/}
File Path:src/com/android/launcher3/Workspace.java
Patch File:
@@ -620,12 +620,13 @@public void removeAllWorkspaceScreens() {
diff --git a/src_build_config/com/android/launcher3/BuildConfig.java b/src_build_config/com/android/launcher3/BuildConfig.java
index 1f2e0e5..c5abae5 100644
--- a/src_build_config/com/android/launcher3/BuildConfig.java
+++ b/src_build_config/com/android/launcher3/BuildConfig.java
@@ -24,7 +24,7 @@* Flag to state if the QSB is on the first screen and placed on the top,* this can be overwritten in other launchers with a different value, if needed.*/
- public static final boolean QSB_ON_FIRST_SCREEN = true;
+ public static final boolean QSB_ON_FIRST_SCREEN = false;// To hide Google Qsb/*** Flag to control various developer centric features
2. 在桌面布局配置文件中添加GoogleSearchBox组件
需要根据实际项目进行调整,首先需要定位当前Launcher使用的xml布局文件
File Path:apps/GmsSampleIntegration/res_dhs_full/xml/partner_default_layout.xml(参考)
Patch File:
@@ -2,19 +2,18 @@<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 Google Inc. All Rights Reserved. -->
<favorites>
+ <!-- This is GoogleQuickSearchWidget -->
+ <appwidget screen="0" x="2" y="4" spanX="2" spanY="1" packageName="com.google.android.googlequicksearchbox" className="com.google.android.googlequicksearchbox.SearchWidgetProvider"/>