Launcher3有关的客制化工作

在工作当中对Launcher3的客制化还是比较多的,如客制化主界面,是否旋转,屏蔽掉应用列表界面等等。本文就对这些来一个总结吧。注意在本文针对高通7.1的Launcher3写的,其它平台的代码可能有所不一样。

1.客制化主界面

在前面的博客中讲到过,要客制化主界面我们需要修改partner_default_layout.xml(这个是谷歌GmsSampleLayout.apk里的文件)或者default_workspace_*x*.xml

2.是否旋转

修改res/values/config.xml文件中的<bool name="allow_rotation">true</bool>属性

3.是否显示Hotseat上中间的"AllApps"按钮

diff --git a/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java b/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java
old mode 100644
new mode 100755
index 8ee5497..3b6da3d
--- a/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java
+++ b/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java
@@ -29,14 +29,14 @@ public final class FeatureFlags {

     // When enabled the all-apps icon is not added to the hotseat.
-    public static final boolean NO_ALL_APPS_ICON = true;
+    public static final boolean NO_ALL_APPS_ICON = false;
 }

4.禁止向上滑动显示所有应用界面

diff --git a/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java b/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java
old mode 100644
new mode 100755
index 8ee5497..3b6da3d
--- a/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java
+++ b/packages/apps/Launcher3/src_config/com/android/launcher3/config/FeatureFlags.java
@@ -29,14 +29,14 @@ public final class FeatureFlags {
     public static boolean LAUNCHER3_LEGACY_FOLDER_ICON = false;
     public static boolean LAUNCHER3_USE_SYSTEM_DRAG_DRIVER = true;
     public static boolean LAUNCHER3_DISABLE_PINCH_TO_OVERVIEW = false;
-    public static boolean LAUNCHER3_ALL_APPS_PULL_UP = true;
+    public static boolean LAUNCHER3_ALL_APPS_PULL_UP = false;
}

5.屏蔽掉应用列表界面

方法一:

修改partner_default_layout.xml或者default_workspace_*x*.xml文件,显示出系统所有的应用;再去掉"AllApps"按钮和禁止向上滑动显示所有应用界面就可以了。

方法二:

在LauncherModel.java文件修改LoaderTask的run方法。再去掉"AllApps"按钮和禁止向上滑动显示所有应用界面就可以了。

diff --git a/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java b/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java
old mode 100644
new mode 100755
index 6a8f532..2cadbbf
--- a/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java
+++ b/packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java
@@ -1411,6 +1411,7 @@ public class LauncherModel extends BroadcastReceiver
     public boolean startLoader(int synchronousBindPage) {
         // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
         InstallShortcutReceiver.enableInstallQueue();
+        Log.i("Tim_L","mCallbacks=" + mCallbacks + ",page=" + synchronousBindPage);
         synchronized (mLock) {
             // Don't bother to start the thread if we know it's not going to do anything
             if (mCallbacks != null && mCallbacks.get() != null) {
@@ -1604,6 +1605,12 @@ public class LauncherModel extends BroadcastReceiver
                 // third step
                 if (DEBUG_LOADERS) Log.d(TAG, "step 3: loading deep shortcuts");
                 loadAndBindDeepShortcuts();
+
+                waitForIdle();
+                //load apps to workspace
+                if (LauncherAppState.isDisableAllApps()) {
+                    bindOtherItemsToWorkspace();
+                }
             }
 
             // Clear out this reference, otherwise we end up holding it until all of the
@@ -1620,6 +1627,28 @@ public class LauncherModel extends BroadcastReceiver
             }
         }
 
+        private void bindOtherItemsToWorkspace() {
+            final Context context = mApp.getContext();
+
+            // Cross reference all the applications in our apps list with items in the workspace
+            ArrayList<ItemInfo> tmpInfos;
+            ArrayList<ItemInfo> added = new ArrayList<ItemInfo>();
+            synchronized (sBgLock) {
+                for (AppInfo app : mBgAllAppsList.data) {
+                    tmpInfos = getItemInfoForComponentName(app.componentName, app.user);
+                    if (tmpInfos.isEmpty()) {
+                        // We are missing an application icon, so add this to the workspace
+                        added.add(app);
+                        // This is a rare event, so lets log it
+                        Log.e(TAG, "Missing Application on load: " + app);
+                    }
+                }
+            }
+            if (!added.isEmpty()) {
+                addAndBindAddedWorkspaceItems(context, added);//7.0 虽然去掉了去抽屉的代码,但留了这个方法给我们。
+            }
+        }
+

6.是否显示左边的客制化界面

packages\apps\Launcher3\src\com\android\launcher3\Launcher.java
  /** To be overridden by subclasses to hint to Launcher that we have custom content */
    protected boolean hasCustomContentToLeft() {
        /*if (mLauncherCallbacks != null) {
            return mLauncherCallbacks.hasCustomContentToLeft();
        }*/
        return false;
    }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值