public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (localName.equals(TAG_SETUPMENU)) { mrows = Integer.valueOf(atts.getValue("row")); mcolumns = Integer.valueOf(atts.getValue("columns")); } else if (localName.equals(TAG_MENU)) { SetupTabMenu menu = new SetupTabMenu(); menu.id = Integer.valueOf(atts.getValue("id")); menu.name = atts.getValue("name"); smenu = menu; mTabMenus.add(menu); ArrayList<SetupMenuItem> menulist = new ArrayList<SetupMenuItem>(); mMenuItems.put(Integer.valueOf(menu.id), menulist); } else if (localName.equals(TAG_ITEM)) { ArrayList<SetupMenuItem> menuitems = mMenuItems.get(Integer.valueOf(smenu.id)); if (menuitems != null) { SetupMenuItem mi = new SetupMenuItem(); mi.page = smenu.id; mi.id = Integer.valueOf(atts.getValue("id")); mi.name = atts.getValue("name"); mi.icon = SETUPMENU_FOLDERNAME + atts.getValue("icon"); try { mi.iconbmp = ThemeManager.getInstance().getBitmap(mi.icon); // mi.iconbmp = // Tools.getImageFromInStream(iLoongLauncher.getInstance().getAssets().open(mi.icon)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if (atts.getValue("icon2") != null) { mi.icon2 = SETUPMENU_FOLDERNAME + atts.getValue("icon2"); try { mi.icon2bmp = ThemeManager.getInstance().getBitmap(mi.icon2); // mi.icon2bmp = // Tools.getImageFromInStream(iLoongLauncher.getInstance().getAssets().open(mi.icon2)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } menuitems.add(mi); } } }
public void LoadSetupMenuXml() { SetupTabMenu smenu; if (!DefaultLayout.setup_menu_support_scroll_page) { try { mrows = iLoongLauncher.getInstance().getResources().getInteger(RR.integer.setup_menu_row); mcolumns = iLoongLauncher.getInstance().getResources().getInteger(RR.integer.setup_menu_columns); String[] menus; menus = iLoongLauncher.getInstance().getResources().getStringArray(RR.array.setupMenuAll); // wanghongjian add start //enable_DefaultScene if (FeatureConfig.enable_DefaultScene) { // Log.v("", "DefaultLayout.scene_main_menu is " + // DefaultLayout.scene_main_menu); if (DefaultLayout.scene_main_menu) // 如果是场景桌面的菜单选项 { menus = iLoongLauncher.getInstance().getResources().getStringArray(RR.array.setupMenuScene); if (menus.length == 5) { mrows = 2; mcolumns = 2; } } } // wanghongjian add end ArrayList<String> menulistall = new ArrayList<String>(); ArrayList<String> menulistallid = new ArrayList<String>(); for (int i = 0; i < menus.length; i++) { menulistall.add(menus[i]); String[] tmp = menus[i].split(","); menulistallid.add(tmp[0]); } for (int i = 0; i < menulistall.size(); i++) { if (DefaultLayout.setupmenu_show_theme) { if (Integer.parseInt(menulistallid.get(i)) == ActionSetting.ACTION_SOFTWARE_MANAGEMENT) { menulistall.remove(i); menulistallid.remove(i); } } else { if (Integer.parseInt(menulistallid.get(i)) == ActionSetting.ACTION_THEME) { menulistall.remove(i); menulistallid.remove(i); } } // xiatian add start //DefaultScene if (FeatureConfig.enable_DefaultScene && (getSceneMenu("com.cooee.scene") > 0)) // 判断手机里是否有场景桌面) { if (Integer.parseInt(menulistallid.get(i)) == ActionSetting.ACTION_SCREEN_EDITING) { menulistall.remove(i); menulistallid.remove(i); } } else if ((FeatureConfig.enable_DefaultScene && (getSceneMenu("com.cooee.scene") == 0)) || !FeatureConfig.enable_DefaultScene) // 当不为场景时或者为场景却没安装的时候不显示场景桌面主菜单入口 { if (Integer.parseInt(menulistallid.get(i)) == ActionSetting.ACTION_START_SCENE) { menulistall.remove(i); menulistallid.remove(i); } } // xiatian add end // wanghongjian add start //enable_DefaultScene if (DefaultLayout.scene_main_menu) { int size = getSceneMenu("com.cooee.scene"); // 判断手机里是否有场景桌面 if (size == 1) { for (int j = 0; j < menulistall.size(); j++) { if (Integer.parseInt(menulistallid.get(j)) == ActionSetting.ACTION_CHANGE_SCENE) { menulistall.remove(j); menulistallid.remove(j); } } if (menulistall.size() == 4) { mrows = 1; mcolumns = 3; } } } // wanghongjian add end } // final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); // final PackageManager pm = mContext.getPackageManager(); // List<ResolveInfo> apps = pm.queryIntentActivities(mainIntent, 0); // final String name = "xxxxxxxxxxxxxxxxx";//不显示解锁 // int n = 0; // for(n = 0; n < apps.size(); n++){ // String pName = apps.get(n).activityInfo.packageName; // if(pName.equals(name)){ // for (int i=0; i<menulistall.size(); i++) // { // if (Integer.parseInt(menulistallid.get(i)) == // ActionSetting.ACTION_SCREEN_EDITING){ // menulistall.remove(i); // menulistallid.remove(i); // break; // } // } // break; // } // } // if (n==apps.size()) { for (int i = 0; i < menulistall.size(); i++) { if (Integer.parseInt(menulistallid.get(i)) == ActionSetting.ACTION_LOCKER_SETTING) { menulistall.remove(i); menulistallid.remove(i); break; } } // } for (int i = 0; i < menulistall.size(); i++) { if (DefaultLayout.hide_desktop_setup) { if (Integer.parseInt(menulistallid.get(i)) == ActionSetting.ACTION_DESKTOP_SETTINGS) { menulistall.remove(i); menulistallid.remove(i); } } } if (DefaultLayout.popmenu_style == POPMENU_STYLE_ANDROID4) { mrows = menulistall.size() - 1; mcolumns = 1; } SetupTabMenu menu = new SetupTabMenu(); String[] menuAttrs = menulistall.get(0).split(","); menu.id = Integer.parseInt(menuAttrs[0]); Field f = (Field) RR.getStringClass().getDeclaredField(menuAttrs[1]); menu.name = R3D.getString(f.getInt(RR.getStringClass())); smenu = menu; mTabMenus.add(menu); ArrayList<SetupMenuItem> menulist = new ArrayList<SetupMenuItem>(); mMenuItems.put(Integer.valueOf(menu.id), menulist); for (int i = 1; i < menulistall.size(); i++) { ArrayList<SetupMenuItem> menuitems = mMenuItems.get(Integer.valueOf(smenu.id)); if (menuitems != null) { String[] tmp = menulistall.get(i).split(","); SetupMenuItem mi = new SetupMenuItem(); mi.page = smenu.id; mi.id = Integer.parseInt(tmp[0]); Field tmpF = (Field) RR.getStringClass().getDeclaredField(tmp[1]); mi.name = R3D.getString(tmpF.getInt(RR.getStringClass())); mi.icon = SETUPMENU_FOLDERNAME + tmp[2] + ".png"; mi.iconbmp = ThemeManager.getInstance().getBitmap((mi.icon)); menuitems.add(mi); } } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { XmlResourceParser xmlParser = iLoongLauncher.getInstance().getResources().getXml(RR.xml.setupmenu); int stringID; try { while (xmlParser.getEventType() != XmlResourceParser.END_DOCUMENT) { if (xmlParser.getEventType() == XmlResourceParser.START_TAG) { String s = xmlParser.getName(); if (s.equals(TAG_SETUPMENU)) { // int resid = xmlParser.getAttributeResourceValue(null, "id", 0); // String sn = xmlParser.getAttributeValue(null, "mystr"); mrows = xmlParser.getAttributeIntValue(null, "row", 0); mcolumns = xmlParser.getAttributeIntValue(null, "columns", 0); xmlParser.next(); } // tagName = xmlParser.getName(); if (XmlResourceParser.START_TAG == xmlParser.getEventType() && xmlParser.getName().equals("menu")) { PagedView.PageCount++; // zqh add ,this flag indicates the count of pages SetupTabMenu menu = new SetupTabMenu(); menu.id = xmlParser.getAttributeIntValue(null, "id", 0); stringID = xmlParser.getAttributeResourceValue(null, "name", 0); menu.name = R3D.getString(stringID); menu.count = xmlParser.getAttributeIntValue(null, "count", 0); smenu = menu; mTabMenus.add(menu); ArrayList<SetupMenuItem> menulist = new ArrayList<SetupMenuItem>(); mMenuItems.put(Integer.valueOf(menu.id), menulist); xmlParser.next(); // tagName = xmlParser.getName(); int count = 0; // while (count < mrows * mcolumns) { while (count < menu.count) { // tagName = xmlParser.getName(); // int type = xmlParser.getEventType(); if (XmlResourceParser.START_TAG == xmlParser.getEventType() && xmlParser.getName().equals("item")) { ArrayList<SetupMenuItem> menuitems = mMenuItems.get(Integer.valueOf(smenu.id)); if (menuitems != null) { SetupMenuItem mi = new SetupMenuItem(); mi.page = smenu.id; mi.id = xmlParser.getAttributeIntValue(null, "id", 0); stringID = xmlParser.getAttributeResourceValue(null, "name", 0); mi.name = R3D.getString(stringID); mi.icon = SETUPMENU_FOLDERNAME + xmlParser.getAttributeValue(null, "icon"); mi.iconbmp = Tools.getImageFromInStream( iLoongLauncher.getInstance().getAssets().open(mi.icon)); // mi.iconbmp // =Tools.getImageFromInStream(SetMenuDesktop.class.getResourceAsStream(mi.icon)); if (xmlParser.getAttributeValue(null, "icon2") != null) { mi.icon2 = SETUPMENU_FOLDERNAME + xmlParser.getAttributeValue(null, "icon2"); mi.icon2bmp = Tools.getImageFromInStream( SetMenuDesktop.class.getResourceAsStream(mi.icon2)); } menuitems.add(mi); } count++; } xmlParser.next(); } } // } } else if (xmlParser.getEventType() == XmlResourceParser.END_TAG) {; } else if (xmlParser.getEventType() == XmlResourceParser.TEXT) { // String s1 = xmlParser.getText(); } xmlParser.next(); } } catch (XmlPullParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } xmlParser.close(); } }