diff --git a/pom.xml b/pom.xml index 7a633f61..65465760 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 2.11.0 3.12.0 1.9 - 3.0.0 + 3.0.1-SNAPSHOT 0.4.1 5.2.1.Final v49 @@ -66,6 +66,10 @@ jitpack.io https://jitpack.io + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java index b47a56cc..3ff59f92 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/WaitBusyIcon.java @@ -1,8 +1,15 @@ package the.bytecode.club.bytecodeviewer.gui.components; import javax.swing.Icon; + +import com.github.weisj.darklaf.components.RotatableIconAnimator; +import com.github.weisj.darklaf.components.loading.LoadingIndicator; +import com.github.weisj.darklaf.iconset.AllIcons; +import com.github.weisj.darklaf.properties.icons.RotatableIcon; import the.bytecode.club.bytecodeviewer.resources.IconResources; +import java.awt.event.*; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -27,17 +34,20 @@ import the.bytecode.club.bytecodeviewer.resources.IconResources; */ public class WaitBusyIcon extends JMenuItemIcon { + private final RotatableIconAnimator animator; + public WaitBusyIcon() { - super(loadIcon()); - setAlignmentY(0.65f); - } - - public static Icon loadIcon() - { - if(IconResources.busyIcon != null) - return IconResources.busyIcon; - - return IconResources.busyB64Icon; + super(new RotatableIcon(IconResources.busyIcon)); + animator = new RotatableIconAnimator(8, (RotatableIcon) getIcon(), this); + addHierarchyListener(e -> { + if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0) + { + if (getParent() == null) + animator.stop(); + else + animator.start(); + } + }); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java index bc5a1dac..49b9feae 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java @@ -5,8 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.swing.ImageIcon; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeNode; import org.apache.commons.io.FilenameUtils; @@ -21,7 +20,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceType; public class ResourceListIconRenderer extends DefaultTreeCellRenderer { //TODO the icon cache needs to be cleared on treenode removal - public static Map iconCache = new HashMap<>(); + public static Map iconCache = new HashMap<>(); //called every time there is a pane update @Override @@ -134,7 +133,7 @@ public class ResourceListIconRenderer extends DefaultTreeCellRenderer return ret; } - public void cacheNodeIcon(ResourceTreeNode node, ImageIcon icon) + public void cacheNodeIcon(ResourceTreeNode node, Icon icon) { iconCache.put(node, icon); setIcon(icon); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java index 3dfd995d..5a1dacb8 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java @@ -26,6 +26,7 @@ import org.apache.commons.io.FilenameUtils; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.gui.contextmenu.ContextMenu; +import the.bytecode.club.bytecodeviewer.resources.IconResources; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.resources.importing.Import; import the.bytecode.club.bytecodeviewer.translation.TranslatedComponents; @@ -72,8 +73,8 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File public final JPopupMenu rightClickMenu = new JPopupMenu(); public final JCheckBox exact = new TranslatedJCheckBox("Exact path", TranslatedComponents.EXACT_PATH); public final JCheckBox caseSensitive = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE); - public final JButton open = new JButton("+"); - public final JButton close = new JButton("-"); + public final JButton open = new JButton(IconResources.add); + public final JButton close = new JButton(IconResources.remove); public final ResourceTreeNode treeRoot = new ResourceTreeNode("Loaded Files:"); public final ResourceTree tree = new ResourceTree(treeRoot); public final JTextField quickSearch = new TranslatedJTextField("Quick file search (no file extension)", TranslatedComponents.QUICK_FILE_SEARCH_NO_FILE_EXTENSION); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java index ec7418b5..28b5189f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java @@ -2,17 +2,17 @@ package the.bytecode.club.bytecodeviewer.gui.theme; import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.listener.UIUpdater; -import com.github.weisj.darklaf.theme.DarculaTheme; -import com.github.weisj.darklaf.theme.HighContrastDarkTheme; -import com.github.weisj.darklaf.theme.HighContrastLightTheme; -import com.github.weisj.darklaf.theme.IntelliJTheme; -import com.github.weisj.darklaf.theme.OneDarkTheme; -import com.github.weisj.darklaf.theme.SolarizedDarkTheme; -import com.github.weisj.darklaf.theme.SolarizedLightTheme; +import com.github.weisj.darklaf.properties.icons.IconLoader; +import com.github.weisj.darklaf.theme.*; import java.awt.*; +import java.util.Properties; import javax.swing.*; +import javax.swing.text.JTextComponent; +import com.github.weisj.darklaf.theme.info.PresetIconRule; +import com.github.weisj.darklaf.theme.spec.ColorToneRule; +import org.checkerframework.checker.guieffect.qual.UI; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialog; @@ -134,11 +134,18 @@ public enum LAFTheme LafManager.install(new HighContrastLightTheme()); break; } - + //test theme installed correctly if(darkLAF) failSafe(); - + + if (!LafManager.isInstalled()) + { + setupIconColors(); + // Invalidate themed icons + IconLoader.updateThemeStatus(new Object()); + } + Configuration.showDarkLAFComponentIcons = darkLAF; if(BytecodeViewer.viewer != null) @@ -157,7 +164,7 @@ public enum LAFTheme SettingsDialog.dialogs.forEach(Dialog::dispose); } } - + /** * Attempts to failsafe by forcing an error before the mainviewer is called. * It then defaults to the system theme @@ -184,4 +191,52 @@ public enum LAFTheme UIUpdater.registerComponent(comp); } } + + private void setupIconColors() + { + Properties properties = new Properties(); + JTextComponent colorTemplateComponent = new JTextField(); + properties.put("textForeground", colorTemplateComponent.getForeground()); + colorTemplateComponent.setEnabled(false); + properties.put("textForegroundInactive", colorTemplateComponent.getForeground()); + properties.put("textSelectionForeground", colorTemplateComponent.getSelectedTextColor()); + + new LightIconThemeSupplier().loadIconTheme(properties, UIManager.getDefaults(), IconLoader.get()); + + UIManager.getLookAndFeelDefaults().putAll(properties); + } + + private static class LightIconThemeSupplier extends Theme + { + + @Override + protected PresetIconRule getPresetIconRule() + { + return PresetIconRule.LIGHT; + } + + @Override + public String getPrefix() + { + return "DO NOT USE"; + } + + @Override + public String getName() + { + return getPrefix(); + } + + @Override + protected Class getLoaderClass() + { + return LightIconThemeSupplier.class; + } + + @Override + public ColorToneRule getColorToneRule() + { + return ColorToneRule.LIGHT; + } + } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java index 783cde2b..ec67bb18 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginTemplate.java @@ -4,6 +4,7 @@ import java.io.IOException; import org.apache.commons.io.FilenameUtils; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.resources.IconResources; +import the.bytecode.club.bytecodeviewer.resources.Resource; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -46,7 +47,7 @@ public enum PluginTemplate public String getContents() throws IOException { if(contents == null) - contents = IconResources.loadResourceAsString(resourcePath); + contents = Resource.loadResourceAsString(resourcePath); return contents; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java index 7e2a89a6..b17d6484 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java @@ -1,22 +1,16 @@ package the.bytecode.club.bytecodeviewer.resources; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Objects; import javax.imageio.ImageIO; import javax.swing.Icon; -import javax.swing.ImageIcon; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; + +import com.github.weisj.darklaf.iconset.AllIcons; +import com.github.weisj.darklaf.properties.icons.IconLoader; +import com.github.weisj.darklaf.properties.icons.IconResolver; import org.imgscalr.Scalr; import the.bytecode.club.bytecodeviewer.BytecodeViewer; @@ -46,62 +40,57 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; public class IconResources { - static protected final int HALF_SIZE = 4; static protected final int SIZE = 9; - public static List iconList; - public static BufferedImage icon; - public static ImageIcon nextIcon; - public static ImageIcon prevIcon; - public static ImageIcon busyIcon; - public static ImageIcon busyB64Icon; - public static ImageIcon batIcon; - public static ImageIcon shIcon; - public static ImageIcon csharpIcon; - public static ImageIcon cplusplusIcon; - public static ImageIcon configIcon; - public static ImageIcon jarIcon; - public static ImageIcon zipIcon; - public static ImageIcon packagesIcon; - public static ImageIcon folderIcon; - public static ImageIcon androidIcon; - public static ImageIcon unknownFileIcon; - public static ImageIcon textIcon; - public static ImageIcon classIcon; - public static ImageIcon imageIcon; - public static ImageIcon decodedIcon; - public static ImageIcon javaIcon; + public static final List iconList; + public static final BufferedImage icon; + public static final Icon add; + public static final Icon remove; + public static final Icon nextIcon; + public static final Icon prevIcon; + public static final Icon busyIcon; + public static final Icon batIcon; + public static final Icon shIcon; + public static final Icon csharpIcon; + public static final Icon cplusplusIcon; + public static final Icon configIcon; + public static final Icon jarIcon; + public static final Icon zipIcon; + public static final Icon packagesIcon; + public static final Icon folderIcon; + public static final Icon androidIcon; + public static final Icon unknownFileIcon; + public static final Icon textIcon; + public static final Icon classIcon; + public static final Icon imageIcon; + public static final Icon decodedIcon; + public static final Icon javaIcon; static { - icon = b642IMG("iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAUd0lEQVR42pWaWXRbVZaGq5iHqgaSeJZsy7YkD7KtwZItebblQfI8x/HseIodO3bixE5iZw4ZSBwyACkCXQ003dD0oigq1UBqFVQ1HSB0wkyvXt1VPNSiavHCC288/b3/I11ZSszQDzuRfO89Z39n/3uffST9BMBP17Dbgna72B1hdmfQ7hK7W+yeoN0btPvE7v8Rdl+Y3Rsc4+7guHcF5wif9/ag3fYd/v70J/zHWlGFcLPRKqth99Yoc1TVKssTc1b74Krxw1Vbh3yxAl+9Mre/QZmnrvFHG+/Xnud4alwxzpEXnJOm+UGfbEH/wv2NAHkwMQ4P6GLk/1hlDyXFKVuXFI/1yQnKolJ0yqLTEhFjTEKsKRlxZgPi01OQkJ6qTJeRBn2mEYlZpjWN13gP7+VzfJ7G8WjRqXo1xwZDQmhe+kBfHhR7QHz7O300fq6LUhYBQkJ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3/OjsZzfZzT8+uzdsjO/68dkP/vDs/wBUXNeRym9KEQAAAABJRU5ErkJggg=="); - nextIcon = new ImageIcon(b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX" - + "///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYqPBJSG" - + "/ZAAAASUlEQVR42mNgwAbS0oAEE4yHyWBmYAzjYDC694OJ4f9" - + "+BoY3H0BSbz6A2MxA6VciFyDqGAWQTWVkYEkCUrcOsDD8OwtkvMViMwAb8xEUHlHcFAAAAABJRU5ErkJggg==")); - prevIcon = new ImageIcon(b642IMG("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEX" - + "///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAABnRSTlMANzlYgKhxpRi1AAAATElEQVR42mNgwAZYHIAEExA7qUAYLApMDmCGEwODCojByM/A8FEAyPi/moFh9QewYjCAM1iA+D2KqYwMrIlA6tUGFoa/Z4GMt1hsBgCe1wuKber+SwAAAABJRU5ErkJggg==")); - busyIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/loading.gif"))); - busyB64Icon = new ImageIcon(b642IMG("R0lGODlhEAALAPQAAP" - + "///wAAANra2tDQ0Orq6gcHBwAAAC8vL4KCgmFhYbq6uiMjI0tLS4qKimVlZb6+vicnJwUFBU9PT" - + "+bm5tjY2PT09Dk5Odzc3PLy8ra2tqCgoMrKyu7u7gAAAAAAAAAAACH5BAkLAAAAIf4aQ3JlYXRlZCB3aXRoIGFqYXhsb2FkLmluZm8AIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAALAAAFLSAgjmRpnqSgCuLKAq5AEIM4zDVw03ve27ifDgfkEYe04kDIDC5zrtYKRa2WQgAh+QQJCwAAACwAAAAAEAALAAAFJGBhGAVgnqhpHIeRvsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjothLOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAsAAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00kj5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpyHCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAABS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7")); - - batIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/bat.png"))); - shIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/sh.png"))); - csharpIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/c#.png"))); - cplusplusIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/c++.png"))); - configIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/config.png"))); - jarIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/jar.png"))); - zipIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/zip.png"))); - packagesIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/package.png"))); - folderIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/folder.png"))); - androidIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/android.png"))); - unknownFileIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/file.png"))); - textIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/text.png"))); - classIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/class.png"))); - imageIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/image.png"))); - decodedIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/decoded.png"))); - javaIcon = new ImageIcon(Objects.requireNonNull(IconResources.class.getResource("/gui/java.png"))); + IconResolver iconResolver = IconLoader.get(); + icon = loadImageFromResource("gui/bcv_icon.png"); + add = AllIcons.Action.Add.get(); + remove = AllIcons.Action.Remove.get(); + nextIcon = iconResolver.getIcon("gui/next.svg", true); + prevIcon = iconResolver.getIcon("gui/previous.svg", true); + busyIcon = AllIcons.Misc.Progress.get(); + batIcon = iconResolver.getIcon("gui/bat.svg", true); + shIcon = batIcon; + csharpIcon = iconResolver.getIcon("gui/cs.svg", true); + cplusplusIcon = iconResolver.getIcon("gui/cpp.svg", true); + configIcon = iconResolver.getIcon("gui/config.svg", true); + jarIcon = iconResolver.getIcon("gui/jarDirectory.svg", true); + zipIcon = iconResolver.getIcon("gui/archive.svg", true); + packagesIcon = iconResolver.getIcon("gui/package.svg", true); + folderIcon = AllIcons.Files.Folder.get(); + androidIcon = iconResolver.getIcon("gui/android.svg"); + unknownFileIcon = AllIcons.Files.General.get(); + textIcon = AllIcons.Files.Text.get(); + classIcon = iconResolver.getIcon("gui/javaClass.svg", true); + imageIcon = AllIcons.Files.Image.get(); + decodedIcon = iconResolver.getIcon("gui/decodedResource.svg", true); + javaIcon = iconResolver.getIcon("gui/java.svg", true); iconList = new ArrayList<>(); int size = 16; @@ -112,85 +101,16 @@ public class IconResources } } - public static String loadResourceAsString(String resourcePath) throws IOException - { - try (InputStream is = IconResources.class.getResourceAsStream(resourcePath)) { - if (is == null) - return null; - return IOUtils.toString(is, StandardCharsets.UTF_8); - } - } - - public static BufferedImage resize(BufferedImage image, int width, int height) { + private static BufferedImage resize(BufferedImage image, int width, int height) { return Scalr.resize(image, Scalr.Method.ULTRA_QUALITY, width, height); } - /** - * Decodes a Base64 String as a BufferedImage - */ - public static BufferedImage b642IMG(String imageString) { - BufferedImage image = null; - byte[] imageByte; - + private static BufferedImage loadImageFromResource(String imageLocation) { try { - imageByte = Base64.decodeBase64(imageString); - try (ByteArrayInputStream bis = new ByteArrayInputStream(imageByte)) { - image = ImageIO.read(bis); - } - } catch (Exception e) { + return ImageIO.read(Objects.requireNonNull(IconResources.class.getResourceAsStream("/" + imageLocation))); + } catch (IOException e) { BytecodeViewer.handleException(e); } - - return image; - } - - - /** - * The minus sign button icon - */ - public static class ExpandedIcon implements Icon, Serializable - { - static public Icon createExpandedIcon() { - return new ExpandedIcon(); - } - - public void paintIcon(Component c, Graphics g, int x, int y) - { - Color backgroundColor = c.getBackground(); - if(backgroundColor != null) - g.setColor(backgroundColor); - else - g.setColor(Color.white); - - g.fillRect(x, y, SIZE-1, SIZE-1); - g.setColor(Color.gray); - g.drawRect(x, y, SIZE-1, SIZE-1); - g.setColor(Color.black); - g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE); - } - - public int getIconWidth() { - return SIZE; - } - - public int getIconHeight() { - return SIZE; - } - } - - /** - * The plus sign button icon - */ - public static class CollapsedIcon extends ExpandedIcon - { - static public Icon createCollapsedIcon() { - return new CollapsedIcon(); - } - - public void paintIcon(Component c, Graphics g, int x, int y) - { - super.paintIcon(c, g, x, y); - g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3)); - } + return null; } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java index f36035e7..6b7a2a45 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/Resource.java @@ -1,7 +1,12 @@ package the.bytecode.club.bytecodeviewer.resources; +import org.apache.commons.io.IOUtils; import org.objectweb.asm.tree.ClassNode; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * @@ -36,6 +41,15 @@ public class Resource this.workingName = workingName; this.container = container; } + + public static String loadResourceAsString(String resourcePath) throws IOException + { + try (InputStream is = IconResources.class.getResourceAsStream(resourcePath)) { + if (is == null) + return null; + return IOUtils.toString(is, StandardCharsets.UTF_8); + } + } /** * Returns the resource bytes from the resource container diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java index 6613bc2d..dd02c3b4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java @@ -2,7 +2,7 @@ package the.bytecode.club.bytecodeviewer.resources; import java.util.HashMap; import java.util.Map; -import javax.swing.ImageIcon; +import javax.swing.*; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -53,7 +53,7 @@ public enum ResourceType public static final Map imageExtensionMap = new HashMap<>(); public static final Map supportedBCVExtensionMap = new HashMap<>(); - private final ImageIcon icon; + private final Icon icon; private final String[] extensions; //private final byte[][] headerMagicNumber; @@ -79,13 +79,13 @@ public enum ResourceType supportedBCVExtensionMap.put(extension, ANDROID_ARCHIVE); } - ResourceType(ImageIcon icon, String... extensions) + ResourceType(Icon icon, String... extensions) { this.icon = icon; this.extensions = extensions; } - public ImageIcon getIcon() + public Icon getIcon() { return icon; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java index a240d5e3..03ee1035 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java @@ -14,6 +14,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.api.BCV; import the.bytecode.club.bytecodeviewer.resources.IconResources; +import the.bytecode.club.bytecodeviewer.resources.Resource; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -158,7 +159,7 @@ public enum Language if(translationMap == null) { translationMap = BytecodeViewer.gson.fromJson( - IconResources.loadResourceAsString(resourcePath), + Resource.loadResourceAsString(resourcePath), new TypeToken>() {}.getType()); } @@ -178,7 +179,7 @@ public enum Language return; LinkedMap translationMap = BytecodeViewer.gson.fromJson( - IconResources.loadResourceAsString(resourcePath), + Resource.loadResourceAsString(resourcePath), new TypeToken>(){}.getType()); Set existingKeys = new HashSet<>(); diff --git a/src/main/resources/gui/android.png b/src/main/resources/gui/android.png deleted file mode 100644 index 6c242f0a..00000000 Binary files a/src/main/resources/gui/android.png and /dev/null differ diff --git a/src/main/resources/gui/android.svg b/src/main/resources/gui/android.svg new file mode 100644 index 00000000..cabac2c9 --- /dev/null +++ b/src/main/resources/gui/android.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/archive.svg b/src/main/resources/gui/archive.svg new file mode 100644 index 00000000..7964fa3b --- /dev/null +++ b/src/main/resources/gui/archive.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/bat.png b/src/main/resources/gui/bat.png deleted file mode 100644 index c28dd638..00000000 Binary files a/src/main/resources/gui/bat.png and /dev/null differ diff --git a/src/main/resources/gui/bat.svg b/src/main/resources/gui/bat.svg new file mode 100644 index 00000000..f761c7f1 --- /dev/null +++ b/src/main/resources/gui/bat.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/src/main/resources/gui/bcv_icon.png b/src/main/resources/gui/bcv_icon.png new file mode 100644 index 00000000..3336018a Binary files /dev/null and b/src/main/resources/gui/bcv_icon.png differ diff --git a/src/main/resources/gui/c#.png b/src/main/resources/gui/c#.png deleted file mode 100644 index ffb8fc93..00000000 Binary files a/src/main/resources/gui/c#.png and /dev/null differ diff --git a/src/main/resources/gui/c++.png b/src/main/resources/gui/c++.png deleted file mode 100644 index a87cf847..00000000 Binary files a/src/main/resources/gui/c++.png and /dev/null differ diff --git a/src/main/resources/gui/class.png b/src/main/resources/gui/class.png deleted file mode 100644 index 0a7d6f4a..00000000 Binary files a/src/main/resources/gui/class.png and /dev/null differ diff --git a/src/main/resources/gui/config.png b/src/main/resources/gui/config.png deleted file mode 100644 index 106f5aa3..00000000 Binary files a/src/main/resources/gui/config.png and /dev/null differ diff --git a/src/main/resources/gui/config.svg b/src/main/resources/gui/config.svg new file mode 100644 index 00000000..71581d2e --- /dev/null +++ b/src/main/resources/gui/config.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/cpp.svg b/src/main/resources/gui/cpp.svg new file mode 100644 index 00000000..040f7f08 --- /dev/null +++ b/src/main/resources/gui/cpp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/cs.svg b/src/main/resources/gui/cs.svg new file mode 100644 index 00000000..36201a90 --- /dev/null +++ b/src/main/resources/gui/cs.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/decoded.png b/src/main/resources/gui/decoded.png deleted file mode 100644 index 44ccbf81..00000000 Binary files a/src/main/resources/gui/decoded.png and /dev/null differ diff --git a/src/main/resources/gui/decodedResource.svg b/src/main/resources/gui/decodedResource.svg new file mode 100644 index 00000000..df8367f7 --- /dev/null +++ b/src/main/resources/gui/decodedResource.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/file.png b/src/main/resources/gui/file.png deleted file mode 100644 index 8b8b1ca0..00000000 Binary files a/src/main/resources/gui/file.png and /dev/null differ diff --git a/src/main/resources/gui/folder.png b/src/main/resources/gui/folder.png deleted file mode 100644 index 784e8fa4..00000000 Binary files a/src/main/resources/gui/folder.png and /dev/null differ diff --git a/src/main/resources/gui/image.png b/src/main/resources/gui/image.png deleted file mode 100644 index 4a158fef..00000000 Binary files a/src/main/resources/gui/image.png and /dev/null differ diff --git a/src/main/resources/gui/jar.png b/src/main/resources/gui/jar.png deleted file mode 100644 index 5f9f44d4..00000000 Binary files a/src/main/resources/gui/jar.png and /dev/null differ diff --git a/src/main/resources/gui/jarDirectory.svg b/src/main/resources/gui/jarDirectory.svg new file mode 100644 index 00000000..0a41d296 --- /dev/null +++ b/src/main/resources/gui/jarDirectory.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/main/resources/gui/java.png b/src/main/resources/gui/java.png deleted file mode 100644 index 4eb93e6f..00000000 Binary files a/src/main/resources/gui/java.png and /dev/null differ diff --git a/src/main/resources/gui/java.svg b/src/main/resources/gui/java.svg new file mode 100644 index 00000000..0eadbb2e --- /dev/null +++ b/src/main/resources/gui/java.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/javaClass.svg b/src/main/resources/gui/javaClass.svg new file mode 100644 index 00000000..df6867b8 --- /dev/null +++ b/src/main/resources/gui/javaClass.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/gui/loading.gif b/src/main/resources/gui/loading.gif deleted file mode 100644 index 23b21c29..00000000 Binary files a/src/main/resources/gui/loading.gif and /dev/null differ diff --git a/src/main/resources/gui/next.svg b/src/main/resources/gui/next.svg new file mode 100644 index 00000000..5f7d9139 --- /dev/null +++ b/src/main/resources/gui/next.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/src/main/resources/gui/package.png b/src/main/resources/gui/package.png deleted file mode 100644 index 0afea5b8..00000000 Binary files a/src/main/resources/gui/package.png and /dev/null differ diff --git a/src/main/resources/gui/package.svg b/src/main/resources/gui/package.svg new file mode 100644 index 00000000..83c83049 --- /dev/null +++ b/src/main/resources/gui/package.svg @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/main/resources/gui/previous.svg b/src/main/resources/gui/previous.svg new file mode 100644 index 00000000..b536587b --- /dev/null +++ b/src/main/resources/gui/previous.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/main/resources/gui/sh.png b/src/main/resources/gui/sh.png deleted file mode 100644 index b3d8ce01..00000000 Binary files a/src/main/resources/gui/sh.png and /dev/null differ diff --git a/src/main/resources/gui/text.png b/src/main/resources/gui/text.png deleted file mode 100644 index b93e7760..00000000 Binary files a/src/main/resources/gui/text.png and /dev/null differ diff --git a/src/main/resources/gui/zip.png b/src/main/resources/gui/zip.png deleted file mode 100644 index fd4bbccd..00000000 Binary files a/src/main/resources/gui/zip.png and /dev/null differ diff --git a/src/test/java/the/bytecode/club/bytecodeviewer/IconDemo.java b/src/test/java/the/bytecode/club/bytecodeviewer/IconDemo.java new file mode 100644 index 00000000..018d4e04 --- /dev/null +++ b/src/test/java/the/bytecode/club/bytecodeviewer/IconDemo.java @@ -0,0 +1,103 @@ +package the.bytecode.club.bytecodeviewer; + +import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.properties.icons.*; +import the.bytecode.club.bytecodeviewer.gui.theme.LAFTheme; +import the.bytecode.club.bytecodeviewer.resources.IconResources; +import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem; + +import javax.swing.*; +import java.awt.*; + +public class IconDemo +{ + + public static void main(String[] args) + { + SwingUtilities.invokeLater(() -> { + switchToLaf(LAFTheme.SYSTEM); + JFrame frame = new JFrame("Icon Demo"); + JMenuBar menuBar = new JMenuBar(); + frame.setJMenuBar(menuBar); + + JMenu menu = menuBar.add(new JMenu("Theme")); + ButtonGroup lafGroup = new ButtonGroup(); + for (LAFTheme theme : LAFTheme.values()) + { + JRadioButtonMenuItem item = new TranslatedJRadioButtonMenuItem(theme.getReadableName(), theme.getTranslation()); + if (LAFTheme.SYSTEM.equals(theme)) + item.setSelected(true); + lafGroup.add(item); + item.addActionListener(e -> switchToLaf(theme)); + menu.add(item); + } + + IconEntry[] iconEntries = new IconEntry[] { + new IconEntry("Next", IconResources.nextIcon), + new IconEntry("Previous", IconResources.prevIcon), + new IconEntry("Busy", IconResources.busyIcon), + new IconEntry(".bat", IconResources.batIcon), + new IconEntry(".sh", IconResources.shIcon), + new IconEntry(".cs", IconResources.csharpIcon), + new IconEntry(".cpp", IconResources.cplusplusIcon), + new IconEntry(".Config", IconResources.configIcon), + new IconEntry(".jar", IconResources.jarIcon), + new IconEntry(".zip", IconResources.zipIcon), + new IconEntry("Package", IconResources.packagesIcon), + new IconEntry("Folder", IconResources.folderIcon), + new IconEntry("Android", IconResources.androidIcon), + new IconEntry("Unknown File", IconResources.unknownFileIcon), + new IconEntry("Text", IconResources.textIcon), + new IconEntry(".class", IconResources.classIcon), + new IconEntry("Image", IconResources.imageIcon), + new IconEntry("Decoded", IconResources.decodedIcon), + new IconEntry(".java", IconResources.javaIcon), + }; + JList iconList = new JList<>(iconEntries); + iconList.setCellRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) + { + super.getListCellRendererComponent(list, ((IconEntry) value).name, index, isSelected, cellHasFocus); + setIcon(((IconEntry) value).icon); + return this; + } + }); + JComponent content = new JScrollPane(iconList); + content.setPreferredSize(new Dimension(200, 400)); + frame.setContentPane(content); + frame.pack(); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + } + + private static void switchToLaf(LAFTheme theme) + { + try + { + theme.setLAF(); + LafManager.updateLaf(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + private static class IconEntry + { + private static final int DISPLAY_SIZE = 50; + + private final String name; + private final Icon icon; + + private IconEntry(String name, Icon icon) + { + this.name = name; + this.icon = IconLoader.createDerivedIcon(icon, DISPLAY_SIZE, DISPLAY_SIZE); + } + } +}