• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #1111

26 Jul 2025 06:59AM UTC coverage: 3.08% (-0.005%) from 3.085%
#1111

push

jiangxincode
fix #542: support different kinds of zip structure

0 of 21 new or added lines in 7 files covered. (0.0%)

1 existing line in 1 file now uncovered.

236 of 7663 relevant lines covered (3.08%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/swing/extend/plugin/runnable/UnzipRunnable.java
1
package edu.jiangxin.apktoolbox.swing.extend.plugin.runnable;
2

3
import edu.jiangxin.apktoolbox.swing.extend.plugin.ChangeMenuPreparePluginController;
4
import edu.jiangxin.apktoolbox.swing.extend.plugin.IPreparePluginCallback;
5
import net.lingala.zip4j.ZipFile;
6
import net.lingala.zip4j.progress.ProgressMonitor;
7
import org.apache.commons.io.FileUtils;
8
import org.apache.logging.log4j.LogManager;
9
import org.apache.logging.log4j.Logger;
10

11
import javax.swing.*;
12
import java.io.File;
13
import java.io.IOException;
14

15
public class UnzipRunnable extends AbstractRunnable {
16
    private static final Logger LOGGER = LogManager.getLogger(UnzipRunnable.class.getSimpleName());
×
17
    private final File pluginFile;
18
    private final boolean isPluginNeedUnzipToSeparateDir;
19

20
    public UnzipRunnable(File pluginFile, boolean isPluginNeedUnzipToSeparateDir, IPreparePluginCallback callback) {
21
        super("Unzipping...", callback);
×
22
        this.pluginFile = pluginFile;
×
NEW
23
        this.isPluginNeedUnzipToSeparateDir = isPluginNeedUnzipToSeparateDir;
×
UNCOV
24
    }
×
25

26
    @Override
27
    public void run() {
28
        SwingUtilities.invokeLater(() -> progressBarDialog.setVisible(true));
×
29
        LOGGER.info("Unzip file: {}", pluginFile);
×
30
        String parentDir = pluginFile.getParent();
×
NEW
31
        if (isPluginNeedUnzipToSeparateDir) {
×
NEW
32
            String dirName = pluginFile.getName().substring(0, pluginFile.getName().lastIndexOf('.'));
×
NEW
33
            parentDir = new File(parentDir, dirName).getAbsolutePath();
×
NEW
34
            FileUtils.deleteQuietly(new File(parentDir));
×
35
            try {
NEW
36
                FileUtils.forceMkdir(new File(parentDir));
×
NEW
37
            } catch (IOException e) {
×
NEW
38
                LOGGER.error("forceMkdir failed: IOException");
×
NEW
39
                callback.onUnzipFinished(ChangeMenuPreparePluginController.RESULT_UNZIP_FAILED);
×
NEW
40
                return;
×
NEW
41
            }
×
42
        }
43
        try (ZipFile zipFile = new ZipFile(pluginFile)) {
×
44
            zipFile.setRunInThread(true);
×
45
            zipFile.extractAll(parentDir);
×
46
            while (zipFile.getProgressMonitor().getState() == ProgressMonitor.State.BUSY) {
×
47
                if (isCancelled) {
×
48
                    zipFile.getProgressMonitor().setCancelAllTasks(true);
×
49
                    break;
×
50
                }
51
                progress = zipFile.getProgressMonitor().getPercentDone();
×
52
                Thread.sleep(100);
×
53
            }
54
        } catch (IOException e) {
×
55
            LOGGER.error("unzipFile failed: IOException");
×
56
            callback.onUnzipFinished(ChangeMenuPreparePluginController.RESULT_UNZIP_FAILED);
×
57
            return;
×
58
        } catch (InterruptedException e) {
×
59
            LOGGER.error("unzipFile failed: InterruptedException");
×
60
            callback.onUnzipFinished(ChangeMenuPreparePluginController.RESULT_UNZIP_FAILED);
×
61
            Thread.currentThread().interrupt();
×
62
        }
×
63

64
        if (isCancelled) {
×
65
            LOGGER.info("download cancelled");
×
66
            String fileName = pluginFile.getAbsolutePath();
×
67
            String dirName = fileName.substring(0, fileName.lastIndexOf("."));
×
68
            FileUtils.deleteQuietly(new File(dirName));
×
69
            callback.onUnzipFinished(ChangeMenuPreparePluginController.RESULT_UNZIP_CANCELLED);
×
70
        } else {
×
71
            isFinished = true;
×
72
            callback.onUnzipFinished(ChangeMenuPreparePluginController.RESULT_UNZIP_SUCCESS);
×
73
        }
74
    }
×
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc