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

jiangxincode / ApkToolBoxGUI / #734

19 May 2024 01:23PM UTC coverage: 3.151%. Remained the same
#734

push

jiangxincode
merge some menu to settings menu

0 of 127 new or added lines in 11 files covered. (0.0%)

229 existing lines in 9 files now uncovered.

236 of 7489 relevant lines covered (3.15%)

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/file/checksum/panel/CompareFilesPanel.java
1
package edu.jiangxin.apktoolbox.file.checksum.panel;
2

3
import edu.jiangxin.apktoolbox.swing.extend.EasyChildTabbedPanel;
4
import edu.jiangxin.apktoolbox.swing.extend.filepanel.FilePanel;
5
import edu.jiangxin.apktoolbox.utils.Constants;
6
import org.apache.commons.codec.digest.DigestUtils;
7
import org.apache.commons.lang3.StringUtils;
8

9
import javax.swing.*;
10
import java.awt.*;
11
import java.io.File;
12
import java.io.FileInputStream;
13
import java.io.FileNotFoundException;
14
import java.io.IOException;
15

16
public class CompareFilesPanel extends EasyChildTabbedPanel {
×
17
    private FilePanel firstFilePanel;
18
    private FilePanel secondFilePanel;
19

20
    private JPanel operationPanel;
21

22
    private JTextField resultTextField;
23

24
    @Override
25
    public void createUI() {
NEW
26
        BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
×
NEW
27
        setLayout(boxLayout);
×
28

NEW
29
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
30
        createFilePanel();
×
NEW
31
        add(firstFilePanel);
×
NEW
32
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
NEW
33
        add(secondFilePanel);
×
34

NEW
35
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
36
        createOperationPanel();
×
NEW
37
        add(operationPanel);
×
38

NEW
39
        add(Box.createVerticalGlue());
×
40
    }
×
41

42
    private void createFilePanel() {
UNCOV
43
        firstFilePanel = new FilePanel("First File");
×
44
        secondFilePanel = new FilePanel("Second File");
×
UNCOV
45
    }
×
46

47
    private void createOperationPanel() {
48
        operationPanel = new JPanel();
×
49

50
        JButton compareButton = new JButton("Compare");
×
51
        compareButton.setFocusPainted(false);
×
52
        compareButton.addActionListener(event -> {
×
53
            File firstFile = firstFilePanel.getFile();
×
54
            File secondFile = secondFilePanel.getFile();
×
UNCOV
55
            if (firstFile == null || secondFile == null) {
×
UNCOV
56
                resultTextField.setText("File is not valid");
×
57
                resultTextField.setForeground(Color.YELLOW);
×
UNCOV
58
                return;
×
59
            }
60

61
            boolean isChecksumSame = false;
×
62

63
            try (FileInputStream firstFis = new FileInputStream(firstFile);
×
64
                 FileInputStream secondFis = new FileInputStream(secondFile)) {
×
65
                String firstSha512 = DigestUtils.sha512Hex(firstFis);
×
66
                String secondSha512 = DigestUtils.sha512Hex(secondFis);
×
67
                isChecksumSame = StringUtils.equalsIgnoreCase(firstSha512, secondSha512);
×
68
            } catch (FileNotFoundException e) {
×
UNCOV
69
                logger.error("calculate, FileNotFoundException");
×
70
            } catch (IOException e) {
×
71
                logger.error("calculate, IOException");
×
72
            }
×
73

UNCOV
74
            if (isChecksumSame) {
×
UNCOV
75
                resultTextField.setText("File is same");
×
76
                resultTextField.setForeground(Color.GREEN);
×
77
                return;
×
78
            }
79

80
            resultTextField.setText("File is different");
×
81
            resultTextField.setForeground(Color.RED);
×
82
        });
×
83

84
        resultTextField = new JTextField("To be comparing");
×
85
        resultTextField.setPreferredSize(new Dimension(100, 25));
×
86
        resultTextField.setEditable(false);
×
UNCOV
87
        resultTextField.setBorder(null);
×
88
        Font font = new Font(null, Font.BOLD, 16);
×
89
        resultTextField.setFont(font);
×
90
        resultTextField.setForeground(Color.YELLOW);
×
91

92
        operationPanel.setLayout(new BoxLayout(operationPanel, BoxLayout.X_AXIS));
×
93
        operationPanel.add(compareButton);
×
UNCOV
94
        operationPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
UNCOV
95
        operationPanel.add(resultTextField);
×
UNCOV
96
        operationPanel.add(Box.createHorizontalGlue());
×
UNCOV
97
    }
×
98
}
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