From af26f2c25778e67b6208ef48d546fdcf7edfde39 Mon Sep 17 00:00:00 2001 From: Konloch Date: Tue, 6 Jul 2021 22:38:47 -0700 Subject: [PATCH] CTRL + L Hotkey Opens your last opened file. If there is a more well known global hotkey for this function it should be changed to that --- .../club/bytecodeviewer/BytecodeViewer.java | 8 ++++++++ .../club/bytecodeviewer/GlobalHotKeys.java | 15 +++++++++++++++ .../bytecode/club/bytecodeviewer/Settings.java | 8 ++++++++ src/main/resources/intro.html | 1 + 4 files changed, 32 insertions(+) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index c9e10dd1..55a09590 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -300,6 +300,14 @@ public class BytecodeViewer return Configuration.java; } + /** + * Returns true if there is at least one file resource loaded + */ + public static boolean hasResources() + { + return !files.isEmpty(); + } + /** * Returns true if there is currently a tab open with a resource inside of it */ diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java b/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java index 4a86f6ff..ebdd8cc6 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/GlobalHotKeys.java @@ -1,5 +1,6 @@ package the.bytecode.club.bytecodeviewer; +import sun.security.krb5.Config; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; import the.bytecode.club.bytecodeviewer.gui.components.RunOptions; import the.bytecode.club.bytecodeviewer.util.DialogueUtils; @@ -126,5 +127,19 @@ public class GlobalHotKeys if (BytecodeViewer.hasActiveResource()) BytecodeViewer.viewer.workPane.tabs.remove(BytecodeViewer.viewer.workPane.getActiveResource()); } + + //CTRL + L + //open last opened resource + else if ((e.getKeyCode() == KeyEvent.VK_L) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) + { + Configuration.lastHotKeyExecuted = System.currentTimeMillis(); + + String recentFile = Settings.getRecentFile(); + + System.out.println("Opening..." + recentFile); + + if(!BytecodeViewer.hasResources() && recentFile != null) + BytecodeViewer.openFiles(new File[]{new File(recentFile)}, false); + } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java b/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java index 8b403d2d..faab9d3b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Settings.java @@ -70,6 +70,14 @@ public class Settings } } + public static String getRecentFile() + { + if(recentFiles.isEmpty()) + return null; + + return recentFiles.get(0); + } + /** * Add to the recent plugin list * diff --git a/src/main/resources/intro.html b/src/main/resources/intro.html index 99717d65..c035abf0 100644 --- a/src/main/resources/intro.html +++ b/src/main/resources/intro.html @@ -19,6 +19,7 @@ of features BCV has, and what they do.
  • Add (Ctrl + O) - If you add a jar/zip BCV will unzip it, if you add an APK or DEX file, BCV will run dex2jar then run the jar input process.
  • +
  • Reopen Recent File (Ctrl + L) - Reopens your last recent opened file.
  • New Workspace (Ctrl + N) - It clears the opened jars/resources.
  • Run (Ctrl + R) - Runs the classfiles you've loaded into BCV in a secure sandboxed JVM instance that you can fully debug.