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; }
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); } }