コード例 #1
0
 private void applyNewTheme() {
   ThemeManager mThemeManager = ThemeManager.getInstance();
   Vector<ThemeDescription> vector = mThemeManager.getThemeDescriptions();
   if (vector.size() <= 1) {
     return;
   }
   ThemeDescription current = mThemeManager.getCurrentThemeDescription();
   int currentIndex = vector.indexOf(current);
   int random = getRandomIndex(vector.size(), currentIndex);
   mThemeManager.ApplyTheme(vector.elementAt(random));
 }
コード例 #2
0
ファイル: SetupMenu.java プロジェクト: norain2050/daima111
 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);
     }
   }
 }
コード例 #3
0
ファイル: WidgetIcon.java プロジェクト: norain2050/daima111
 public static WidgetIcon createWidgetIcon(ShortcutInfo info, boolean ifShadow) {
   WidgetIcon widgetIcon = null;
   InputStream is = null;
   String imagePath =
       DefaultLayout.getDefaultVirtureImage(info.intent.getComponent().getPackageName());
   boolean scale = false;
   if (imagePath == null) {
     scale = true;
     imagePath =
         DefaultLayout.GetVirtureImageWithPkgClassName(
             info.intent.getComponent().getPackageName(),
             info.intent.getComponent().getClassName());
     if (imagePath == null) return null;
     if (DefaultLayout.useCustomVirtual) {
       try {
         is = new FileInputStream(imagePath);
       } catch (FileNotFoundException e) {
         e.printStackTrace();
       }
     } else {
       is = ThemeManager.getInstance().getInputStream(imagePath);
     }
     if (info.intent.getComponent().getPackageName().equals("coco.desktopsettings")) {
       InputStream dtis =
           ThemeManager.getInstance().getCurrThemeInput("theme/icon/80/desksettings.png");
       if (dtis != null) {
         scale = false;
         try {
           dtis.close();
         } catch (IOException e) {
         }
       }
     }
   } else {
     is = ThemeManager.getInstance().getInputStream(imagePath);
     scale = !(ThemeManager.getInstance().loadFromTheme(imagePath));
   }
   Bitmap origBmp = ThemeManager.getInstance().getBitmap(is);
   try {
     if (is != null) {
       is.close();
     }
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   int iconSize = DefaultLayout.app_icon_size;
   if (DefaultLayout.thirdapk_icon_scaleFactor != 1.0f
       && !R3D.doNotNeedScale(
           info.intent.getComponent().getPackageName(), info.intent.getComponent().getClassName())
       && scale) {
     iconSize *= DefaultLayout.thirdapk_icon_scaleFactor;
   }
   if (origBmp == null) return null;
   BitmapDrawable drawable = new BitmapDrawable(origBmp);
   drawable.setTargetDensity(iLoongLauncher.getInstance().getResources().getDisplayMetrics());
   Bitmap bmp = Utilities.createIconBitmap(drawable, iLoongLauncher.getInstance(), iconSize);
   origBmp.recycle();
   // teapotXu add start:
   Bitmap bg = null;
   if (iconSize != DefaultLayout.app_icon_size) bg = Icon3D.getIconBg();
   widgetIcon = new WidgetIcon((String) info.title, bmp, (String) info.title, bg, ifShadow);
   // teapotXu add end
   widgetIcon.setItemInfo(info);
   bmp.recycle();
   bmp = null;
   /** ********************** added by diaosixu begin ************************** */
   AppReminder.Info aInfo = iLoongLauncher.getInstance().appReminder.new Info();
   boolean r =
       iLoongLauncher
           .getInstance()
           .appReminder
           .isRemindApp(info.intent.getComponent().getPackageName(), aInfo);
   if (r) {
     Gdx.app.log("diaosixu", "show red point");
     widgetIcon.setAppRemind(true);
     iLoongLauncher
         .getInstance()
         .appReminder
         .startReminding(aInfo.packageName, widgetIcon, aInfo.remindNo);
   }
   /** ********************** added by diaosixu end ************************** */
   return widgetIcon;
 }
コード例 #4
0
ファイル: SetupMenu.java プロジェクト: norain2050/daima111
 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();
   }
 }
コード例 #5
0
ファイル: WidgetIcon.java プロジェクト: norain2050/daima111
 public void onThemeChanged() {
   if (!(info instanceof ShortcutInfo)) return;
   Log.d("theme", "WidgetIcon onThemeChanged:" + info.title);
   ShortcutInfo shortcutInfo = (ShortcutInfo) info;
   if (shortcutInfo.intent == null) {
     return;
   }
   width = R3D.workspace_cell_width;
   height = R3D.workspace_cell_height;
   originX = width / 2.0f;
   originY = height / 2.0f;
   String imagePath =
       DefaultLayout.getDefaultVirtureImage(shortcutInfo.intent.getComponent().getPackageName());
   boolean needbg = false;
   if (imagePath == null) {
     imagePath =
         DefaultLayout.GetVirtureImageWithPkgClassName(
             shortcutInfo.intent.getComponent().getPackageName(),
             shortcutInfo.intent.getComponent().getClassName());
     needbg = true;
     if (shortcutInfo.intent.getComponent().getPackageName().equals("coco.desktopsettings")) {
       InputStream is =
           ThemeManager.getInstance().getCurrThemeInput("theme/icon/80/desksettings.png");
       if (is != null) {
         needbg = false;
         try {
           is.close();
         } catch (IOException e) {
         }
       }
     }
     if (imagePath == null) return;
   }
   InputStream is = null;
   Bitmap origBmp = null;
   if (DefaultLayout.useCustomVirtual) {
     try {
       is = new FileInputStream(imagePath);
       origBmp = BitmapFactory.decodeStream(is);
       is.close();
     } catch (FileNotFoundException e) {
       e.printStackTrace();
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   } else {
     origBmp = ThemeManager.getInstance().getBitmap(imagePath);
   }
   if (origBmp == null) {
     return;
   }
   Bitmap bmp =
       Utilities.createIconBitmap(new BitmapDrawable(origBmp), iLoongLauncher.getInstance());
   origBmp.recycle();
   if (region != null && shortcutInfo.title != null) {
     if (needbg) {
       bmp = Tools.resizeBitmap(bmp, DefaultLayout.thirdapk_icon_scaleFactor);
       if (shortcutInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
         ((BitmapTexture) this.region.getTexture())
             .changeBitmap(
                 Utils3D.IconToPixmap3D(
                     bmp,
                     shortcutInfo.title.toString(),
                     Icon3D.getIconBg(),
                     titleBg,
                     false,
                     false),
                 true);
       } else {
         ((BitmapTexture) this.region.getTexture())
             .changeBitmap(
                 Utils3D.IconToPixmap3D(
                     bmp, shortcutInfo.title.toString(), Icon3D.getIconBg(), titleBg, false),
                 true);
       }
     } else {
       if (shortcutInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
         ((BitmapTexture) this.region.getTexture())
             .changeBitmap(
                 Utils3D.IconToPixmap3D(
                     bmp,
                     shortcutInfo.title.toString(),
                     Icon3D.getIconBg(),
                     titleBg,
                     false,
                     false),
                 true);
       } else {
         ((BitmapTexture) this.region.getTexture())
             .changeBitmap(
                 Utils3D.IconToPixmap3D(bmp, shortcutInfo.title.toString(), null, titleBg, false),
                 true);
       }
     }
     region.setV2(1);
   }
   if (DefaultLayout.hotseat_hide_title && shortcutInfo.container == Favorites.CONTAINER_HOTSEAT) {
     Utils3D.changeTextureRegion(this, Utils3D.getIconBmpHeight(), true);
   }
 }