Android系统应用开发(六)Android framework系统默认设置修改

原文地址:http://blog.csdn.net/tiantian715/

launcher 总结: 
1、launcher的布局太居中,要想两边拉伸

<\packages\apps\Launcher2\res\values\dimens.xml>
    40dp
    40dp
apps tab栏的宽度(Launcher2 icon 数目、大小)
\packages\apps\Launcher2\res\layout-sw720dp\workspace.xml>
    launcher:cellCountX="10"
    launcher:cellCountY="6"
2、或者不想改数目:
<\packages\apps\Launcher2\src\com\android\launcher2\AppsCustomizeTabHost.java>
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          mTabs.getLayoutParams().width = contentWidth + 108;
3、workspace、AppsCustomize的cell大小:
<\packages\apps\Launcher2\res\values-sw600dp\dimens.xml>
    110dip
    110dip
 
    110dp
    110dp

4、里面icon的大小:

<\packages\apps\Launcher2\res\values-sw600dp\dimens.xml>
     80dp

5、workspace没有拖动,第二页第一个icon出现在第一页的最右边:
加大workspace的宽度,或间距:
workspace的paddingLeft、paddingRight:
<\packages\apps\Launcher2\res\values-sw600dp-land\dimens.xml>
    50dip
    50dip
 
workspace两屏间距:
100dp
 
修改workspace的字体大小:
如果没有就添加:
<\packages\apps\Launcher2\res\values-sw480dp\styles.xml>
    

6、加wallpaper:
1.<\packages\apps\Launcher2\res\values-sw600dp\wallpapers.xml>
   加wallpaper的名字
2.<\packages\apps\Launcher2\res\drawable-nodpi>
   加如wallpaper 

7、gallery的widget默认添加到workspace上:
<\packages\apps\Launcher2\res\xml\default_workspace.xml>
    
    
 
<\packages\apps\Gallery2\src\com\android\gallery3d\gadget\PhotoAppWidgetProvider.java>
    @Override
    public void onUpdate(Context context,  
            for (int id : appWidgetIds) {
                if(id == 2){ 
                    helper.setWidget(id,WidgetDatabaseHelper.TYPE_SHUFFLE, null);                  
                }
        
    }

8、在桌面上添加网页的快捷方式:
<\packages\apps\Launcher2\res\xml\default_workspace.xml> 
    

9、在桌面上默认放文件夹:
<\packages\apps\Launcher2\res\xml\default_workspace.xml>
     
         
         
     

     
    
      

10、桌面上添加快捷方式,点击播放视频:

<\packages\apps\Launcher2\res\xml-sw720dp\default_workspace.xml>
 
 
11、安装apk,显示隐藏的google play:
1.写google显示的apk:
GooglePlayShow的activity:
        ComponentName componentname = new ComponentName("com.android.vending", "com.android.vending.AssetBrowserActivity");
        packagemanager.setComponentEnabledSetting(componentname, 1, 1);
         
        componentname = new ComponentName("com.example.googleplayshow", "com.example.googleplayshow.MainActivity");
        packagemanager.setComponentEnabledSetting(componentname, 2, 1);
 
2.<\packages\apps\Launcher2\src\com\android\launcher2\LauncherModel.java>
            } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
                if (!replacing) {
                         if(packageName.equals("com.example.googleplayshow")){
                              context.startActivity(new Intent().setComponent(new ComponentName("com.example.googleplayshow", "com.example.googleplayshow.MainActivity")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                         }
                    op = PackageUpdatedTask.OP_ADD;
                } else {
                    op = PackageUpdatedTask.OP_UPDATE;
                }
            }
 
隐藏google search:
<\packages\apps\Launcher2\src\com\android\launcher2\Launcher.java>
    private void setupViews() {
        mSearchDropTargetBar = (SearchDropTargetBar) mDragLayer.findViewById(R.id.qsb_bar);
        mSearchDropTargetBar.hideSearchBar(false);
 
    void showWorkspace(boolean animated, Runnable onCompleteRunnable) {
        //mSearchDropTargetBar.showSearchBar(wasInSpringLoadedMode);
 
12、widget中隐藏google play:
<\packages\apps\Launcher2\src\com\android\launcher2\AppsCustomizePagedView.java>
updatePackages里面添加:
if(!widget.provider.getPackageName().equals("com.android.vending") && !widget.provider.getPackageName().equals("com.android.vending.MarketWidgetProvider")){
    mWidgets.add(widget);
}
13、clock的widget下部分显示不全,向上调
<\packages\amlogic\Launcher2\res\values\dimens.xml>
10dp
 
修改widget的text的size:
<\packages\amlogic\Launcher2\res\layout\apps_customize_widget.xml>
  
14、launcher中隐藏一个app:
需要该app的packageName,例如要隐藏settings:
<\packages\apps\Launcher2\src\com\android\launcher2\LauncherModel.java>
        private void loadAllAppsByBatch() { 
                    apps = packageManager.queryIntentActivities(mainIntent, 0); 
 
                    ResolveInfo removeApp = null;
                    for(ResolveInfo info:apps){
                        if(info.activityInfo.packageName.equals("com.android.settings")){
                                removeApp = info;
                        }
 
                    }
 
                    if(removeApp != null){
                        apps.remove(removeApp);
                    }

15launcher中隐藏多个app红色为改动部分

<\packages\apps\Launcher2\src\com\android\launcher2\LauncherModel.java>
      private void loadAllAppsByBatch() {  
   final PackageManager packageManager = mContext.getPackageManager();
            List apps = new ArrayList();
            List allApps = null;
 
 
            int N = Integer.MAX_VALUE;
 
            int startIndex;
            int i=0;
            int batchSize = -1;
            while (i < N && !mStopped) {
                if (i == 0) {
                    mAllAppsList.clear();
                    final long qiaTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
 
                    allApps = packageManager.queryIntentActivities(mainIntent, 0);
                    for(ResolveInfo info : allApps){
                        if(info.activityInfo != null 
                                && !info.activityInfo.packageName.equalsIgnoreCase("com.android.email")
                                && !info.activityInfo.packageName.equalsIgnoreCase("com.android.providers.downloads.ui")
                                && !info.activityInfo.packageName.equalsIgnoreCase("com.adobe.flashplayer")){
                            apps.add(info);
                        }
                    }

settings 问题总结:

1.入口,设置分屏显示

frameworks\base\core\res\res\values\bools.xml 下的 preferences_prefer_dual_pane 为true.
true
2.top level headers--这里可以去掉左边的headers

private void updateHeaderList(List
target) { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { target.remove(header); }

3.默认字体:

public void readFontSizePreference(ListPreference pref) {
     ActivityManagerNative.getDefault().getConfiguration()
 
系统的Configuration是从ActivityManagerService设置的:
 
<\frameworks\base\services\java\com\android\server\am\ActivityManagerService.java>
mConfiguration.setToDefaults();
fontScale = Float.parseFloat(SystemProperties.get("ro.fontScale","1"));
4.settings的theme:
<\packages\apps\Settings\AndroidManifest.xml>
    
 
<\frameworks\base\core\res\res\values\themes.xml>