launcher源码,在源码基础上二次开发 ,以下是修改记录:
1.横竖屏控制Launcher.java类中,修改如下方法:
@Thunk void setOrientation() {
if (mRotationEnabled) {
unlockScreenOrientation(true);
} else {
setRequestedOrientation(
ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
}
}
2.隐藏主屏Google搜索栏,FeatureFlags.java修改如下:
// Feature flag to enable moving the QSB on the 0th screen of the workspace.
public static final boolean QSB_ON_FIRST_SCREEN = false;
3.隐藏抽屉页面搜索及line,修改AlphabeticalAppsList.java 类中注释掉
// Add the search divider
mAdapterItems.add(AdapterItem.asSearchDivider(position++));
all_apps.xml中,隐藏如下代码:
<FrameLayout
android:id="@+id/search_container"
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_search_bar_height"
android:layout_gravity="center|top"
android:gravity="center|bottom"
android:visibility="gone"
android:orientation="horizontal"
android:saveEnabled="false">
4.隐藏app长按弹出的popup例如应用信息,微件等,Workspace.java类中注释beginDragShared方法中:
// if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) {
// PopupContainerWithArrow popupContainer = PopupContainerWithArrow
// .showForIcon((BubbleTextView) child);
// if (popupContainer != null) {
// dragOptions.preDragCondition = popupContainer.createPreDragCondition();
//
// mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
// }
// }
5.配置桌面默认显示时钟微件,default_workspace找到对应的默认文件:
<!-- 普通设备 -->
<appwidget
launcher:className="com.android.alarmclock.DigitalAppWidgetProvider"
launcher:packageName="com.android.deskclock"
launcher:screen="1"
launcher:spanX="3"
launcher:spanY="1"
launcher:x="0"
launcher:y="0" />
<!--华为设备-->
<appwidget
launcher:className="com.android.alarmclock.DigitalClockAppWidgetProvider"
launcher:packageName="com.android.deskclock"
launcher:screen="0"
launcher:spanX="3"
launcher:spanY="1"
launcher:x="0"
launcher:y="0" />
特别值得注意的是:default_workspace_33.xml default_workspace_44.xml default_workspace_55.xml default_workspace_56.xml找准对应的布局,这个不难做到,另外配置的packageName 和className如果与对应设备不匹配就会导致桌面不显示。
网友评论