2015年11月24日 星期二

Launcher2

環境:imx6 + Android 4.4

出處:泡泡糖

更換預設的wallpaper(只能在Launcher第一次运行或者恢复默认设置时才需要设置显示) packages/apps/Launcher2/src/com/android/launcher2/Launcher.java
public void showFirstRunWorkspaceCling() {
        // Enable the clings only if they have not been dismissed before
        if (isClingsEnabled() &&
                !mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false) &&
                !skipCustomClingIfNoAccounts() ) {
            // If we're not using the default workspace layout, replace workspace cling
            // with a custom workspace cling (usually specified in an overlay)
            // For now, only do this on tablets
            if (mSharedPrefs.getInt(LauncherProvider.DEFAULT_WORKSPACE_RESOURCE_ID, 0) != 0 &&
                    getResources().getBoolean(R.bool.config_useCustomClings)) {
                // Use a custom cling
                View cling = findViewById(R.id.workspace_cling);
                ViewGroup clingParent = (ViewGroup) cling.getParent();
                int clingIndex = clingParent.indexOfChild(cling);
                clingParent.removeViewAt(clingIndex);
                View customCling = mInflater.inflate(R.layout.custom_workspace_cling, clingParent, false);
                clingParent.addView(customCling, clingIndex);
                customCling.setId(R.id.workspace_cling);
            }
            initCling(R.id.workspace_cling, null, false, 0);
            setDefaultWallPaper();
        } else {
            removeCling(R.id.workspace_cling);
        }
    }    

    private void setDefaultWallPaper()
    {
        //修改默認背景,可以在Framework替换默認静態圖default_wallpaper
        WallpaperManager mwallpaerManager;
        mwallpaerManager = WallpaperManager.getInstance(this);
        try
        {
            mwallpaerManager.setResource(R.drawable.launcher_default_bg);
            //路徑:res/drawable/launcher_default_bg.png
        }
        catch (IOException e)
        {
                Log.e(TAG, "set default wallpaper error");
                e.printStackTrace();
        }
    }
---------------------------------------------------------

更換 screen 數量:
To decrease the number of screens; example from 5 to 3:
- change launcher:defaultScreen="2" to launcher:defaultScreen="1" where 1 is the middle screen of the 3 screens. numbers convension are 0,1,2.

- From:
<include android:id="@id/cell1" layout="@layout/workspace_screen" />
<include android:id="@id/cell2" layout="@layout/workspace_screen" />
<include android:id="@id/cell3" layout="@layout/workspace_screen" />
<include android:id="@id/cell4" layout="@layout/workspace_screen" />
<include android:id="@id/cell5" layout="@layout/workspace_screen" />
- To:
<include android:id="@id/cell1" layout="@layout/workspace_screen" />
<include android:id="@id/cell2" layout="@layout/workspace_screen" />
<include android:id="@id/cell3" layout="@layout/workspace_screen" />

To increase the number of screens; example from 5 to 7
- change launcher:defaultScreen="2" to launcher:defaultScreen="2" where 3 is the middle screen of the 7 screens. numbers convension are 0,1,2,3,4,5,6

- From:
<include android:id="@id/cell1" layout="@layout/workspace_screen" />
<include android:id="@id/cell2" layout="@layout/workspace_screen" />
<include android:id="@id/cell3" layout="@layout/workspace_screen" />
<include android:id="@id/cell4" layout="@layout/workspace_screen" />
<include android:id="@id/cell5" layout="@layout/workspace_screen" />


- To:
<include android:id="@id/cell1" layout="@layout/workspace_screen" />
<include android:id="@id/cell2" layout="@layout/workspace_screen" />
<include android:id="@id/cell3" layout="@layout/workspace_screen" />
<include android:id="@id/cell4" layout="@layout/workspace_screen" />
<include android:id="@id/cell5" layout="@layout/workspace_screen" />
<include android:id="@id/cell6" layout="@layout/workspace_screen" />
<include android:id="@id/cell7" layout="@layout/workspace_screen" />

ref:
1. 泡泡糖
2. xda-developers

沒有留言:

張貼留言