Code Cleanup/Refactoring
This commit is contained in:
parent
17ecc2b7e1
commit
45bae59ac9
4 changed files with 17 additions and 24 deletions
|
@ -7,6 +7,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
|||
import the.bytecode.club.bytecodeviewer.gui.components.RunOptions;
|
||||
import the.bytecode.club.bytecodeviewer.util.DialogUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||
|
||||
/***************************************************************************
|
||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||
|
@ -113,20 +114,15 @@ public class GlobalHotKeys
|
|||
{
|
||||
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||
|
||||
File file = fc.getSelectedFile();
|
||||
|
||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||
file = new File(file.getAbsolutePath() + ".zip");
|
||||
File file = MiscUtils.autoAppendFileExtension(".zip", fc.getSelectedFile());
|
||||
|
||||
if (!DialogUtils.canOverwriteFile(file))
|
||||
return;
|
||||
|
||||
final File file2 = file;
|
||||
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Thread jarExport = new Thread(() -> {
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
file2.getAbsolutePath());
|
||||
file.getAbsolutePath());
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Jar Export");
|
||||
jarExport.start();
|
||||
|
|
|
@ -101,15 +101,9 @@ public class APKExport implements Exporter
|
|||
{
|
||||
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||
|
||||
final File file = fc.getSelectedFile();
|
||||
String output = file.getAbsolutePath();
|
||||
final File file = MiscUtils.autoAppendFileExtension(".apk", fc.getSelectedFile());
|
||||
|
||||
//auto append .apk
|
||||
if (!output.endsWith(".apk"))
|
||||
output += ".apk";
|
||||
|
||||
final File file2 = new File(output);
|
||||
if (!DialogUtils.canOverwriteFile(file2))
|
||||
if (!DialogUtils.canOverwriteFile(file))
|
||||
return;
|
||||
|
||||
Thread saveThread = new Thread(() ->
|
||||
|
@ -120,7 +114,7 @@ public class APKExport implements Exporter
|
|||
|
||||
Thread buildAPKThread = new Thread(() ->
|
||||
{
|
||||
APKTool.buildAPK(new File(input), file2, finalContainer);
|
||||
APKTool.buildAPK(new File(input), file, finalContainer);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Process APK");
|
||||
buildAPKThread.start();
|
||||
|
|
|
@ -8,6 +8,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
|||
import the.bytecode.club.bytecodeviewer.resources.exporting.Exporter;
|
||||
import the.bytecode.club.bytecodeviewer.util.DialogUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||
|
||||
/***************************************************************************
|
||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||
|
@ -54,21 +55,15 @@ public class ZipExport implements Exporter
|
|||
{
|
||||
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||
|
||||
File file = fc.getSelectedFile();
|
||||
|
||||
//auto append .zip
|
||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||
file = new File(file.getAbsolutePath() + ".zip");
|
||||
final File file = MiscUtils.autoAppendFileExtension(".zip", fc.getSelectedFile()); //auto append .zip extension
|
||||
|
||||
if (!DialogUtils.canOverwriteFile(file))
|
||||
return;
|
||||
|
||||
final File file2 = file;
|
||||
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Thread saveThread = new Thread(() ->
|
||||
{
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file2.getAbsolutePath());
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file.getAbsolutePath());
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Jar Export");
|
||||
saveThread.start();
|
||||
|
|
|
@ -178,6 +178,14 @@ public class MiscUtils
|
|||
fileContents[1], fileContents[2],fileContents[3]);
|
||||
}
|
||||
|
||||
public static File autoAppendFileExtension(String extension, File file)
|
||||
{
|
||||
if (!file.getName().endsWith(extension))
|
||||
file = new File(file.getName() + extension);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public static String extension(String name) {
|
||||
return name.substring(name.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue