diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..c616fa3
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,31 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):**
+ - OS: [e.g. iOS]
+ - Version [e.g. 22]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..11fc491
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.gitignore b/.gitignore
index 602223c..74abb7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,5 @@
target
.idea/
densities.json
+Resizer.eml
+resizer.iml
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index fea9e65..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-9patch-resizer
\ No newline at end of file
diff --git a/.idea/ant.xml b/.idea/ant.xml
deleted file mode 100644
index c8f67ff..0000000
--- a/.idea/ant.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 57d709b..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/Redwarp.xml b/.idea/copyright/Redwarp.xml
deleted file mode 100644
index fb25d3e..0000000
--- a/.idea/copyright/Redwarp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index 5e58e67..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index e206d70..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index f6e673a..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/.idea/libraries/gson_2_2_4.xml b/.idea/libraries/gson_2_2_4.xml
deleted file mode 100644
index 33a40e6..0000000
--- a/.idea/libraries/gson_2_2_4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 3636d50..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b..0000000
--- a/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 3b00020..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 275077f..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/README.md b/README.md
index 63dba53..89661e1 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ As simple as drag and drop can get.
And here is the [changelog](https://github.com/redwarp/9-Patch-Resizer/wiki/Changelog)
-Current version : *1.4.0*
+Current version : *1.4.2*
You're using 9patch resizer for your apps ? Don't hesitate and leave me a message!
@@ -31,8 +31,15 @@ You're using 9patch resizer for your apps ? Don't hesitate and leave me a messag
## Roadmap
-- [x] Command line support
+I'll be honest, I don't really maintain 9-Patch-Resizer anymore, as 9-patch are somewhat a thing of the past, and I use as many vector drawables as possible lately.
+
+I will of course consider bug fixes, but I might not have the bandwidth for feature requests.
+
+Sorry about that.
+
+- [ ] A proper "Settings" panel, to handle issues such as jpeg compression, etc etc...
- [ ] A few optimisations
+- [x] Command line support
- [x] Options to set the input density (if people wan't to downsize from hdpi and not from xdpi for instance)
- [x] Proper JPG support
@@ -50,7 +57,3 @@ Join us, and together, we can rule the galaxy as coders and...
## Anyway...
If for some weird reasons, some of your PNG files aren't resized properly, don't hesitate to send them to me, so that I can investigate !
-
-I hope it'll prove as useful to you as it is useful to me. If you like it, and have too much cash in you hands, don't hesitate to donate : I could use a few beers.
-
-
diff --git a/Resizer.eml b/Resizer.eml
deleted file mode 100644
index a9b5d7b..0000000
--- a/Resizer.eml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Resizer.iml b/Resizer.iml
deleted file mode 100644
index 240f3e9..0000000
--- a/Resizer.iml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 57b67e5..17672d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,12 +20,12 @@
resizer
- 1.4.1
+ 1.4.2
9Patch Resizer
${project.version}
- 3
+ 4
diff --git a/res/locale/Strings.properties b/res/locale/Strings.properties
index a2520af..88f4b25 100644
--- a/res/locale/Strings.properties
+++ b/res/locale/Strings.properties
@@ -22,3 +22,4 @@ save=Save
save_tooltip=Hit the save button to keep this settings the next time you launch 9Patch Resizer
keep_same_density_file=Keep the original
file for same density
keep_same_density_file_tooltip=In case of lossy format such as jpeg, checking this option will make sure that, instead of saving a new image, the original file is copied in it's proper directory. If the input is in xhdpi, it will be copied in the xhdpi folder.
+image_types=Choose .jpg or .png files
diff --git a/res/locale/Strings_fr.properties b/res/locale/Strings_fr.properties
index 4b2ea0b..09278be 100644
--- a/res/locale/Strings_fr.properties
+++ b/res/locale/Strings_fr.properties
@@ -22,3 +22,4 @@ save=Sauvegarder
save_tooltip=Sauvegardez les r\u00E9glages courants pour les r\u00E9utiliser la prochaine fois que vous lancerez 9Patch Resizer
keep_same_density_file=Garder le fichier
original pour la m\u00EAme densit\u00E9
keep_same_density_file_tooltip=Pour les formats, tel le jpg, o\u00F9 la compression d\u00E9grade l\'image, cochez cette option s\'assurera que le fichier original est copi\u00E9 dans le fichier de destination source, pour la m\u00EAme densit\u00E9.
+image_types=Choisissez des fichiers .jpg ou .png
diff --git a/src/net/redwarp/tool/resizer/views/MainWindow.java b/src/net/redwarp/tool/resizer/views/MainWindow.java
index 3c5b128..cf527f0 100644
--- a/src/net/redwarp/tool/resizer/views/MainWindow.java
+++ b/src/net/redwarp/tool/resizer/views/MainWindow.java
@@ -28,7 +28,10 @@
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -37,25 +40,20 @@
import javax.swing.*;
import javax.swing.border.EmptyBorder;
+
@SuppressWarnings("serial")
public class MainWindow extends JFrame {
- private JPanel inputPanel;
- private JPanel outputPanel;
-
private ImageIcon blueArrow, redArrow;
private ImageIcon blueArrowSmall, redArrowSmall;
private JButton xhdpiButton;
- private JScrollPane scrollPane;
- private JTextArea textArea;
private ResultTable resultTable;
private JLabel instructionLabel;
- private JMenuBar menuBar;
- private JMenu mnHelp;
- private JMenu mnEdit;
private JMenuItem mntmClear;
- private JMenuItem mntmAbout;
private final Action action = new SwingAction();
+ private JComboBox inputDensityChoice;
+ // private JFileChooser fileChooser;
+ private FileDialog fileDialog;
public MainWindow() {
this.setSize(new Dimension(550, 400));
@@ -87,9 +85,89 @@ public MainWindow() {
MainWindow.class.getResource("/img/red_small.png"));
this.getContentPane().setLayout(new CardLayout(0, 0));
- this.inputPanel = new JPanel();
- this.inputPanel.setPreferredSize(new Dimension(10, 140));
- this.getContentPane().add(this.inputPanel, "input");
+ fileDialog = new FileDialog(this);
+ fileDialog.setFilenameFilter(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return NameValidator.isFilenameValid(name);
+ }
+ });
+ fileDialog.setMultipleMode(true);
+ fileDialog.setTitle(Localization.get("image_types"));
+
+ this.getContentPane().add(createInputPanel(), "input");
+ this.getContentPane().add(createOutputPanel(), "output");
+
+ this.setMenuBar();
+ }
+
+ private JPanel createOutputPanel() {
+ JPanel outputPanel = new JPanel();
+ outputPanel.setLayout(new BorderLayout(0, 0));
+
+ JTextArea textArea = new JTextArea();
+ textArea.setLineWrap(true);
+ textArea.setEditable(false);
+
+ this.resultTable = new ResultTable();
+ JScrollPane scrollPane = new JScrollPane(this.resultTable);
+ scrollPane
+ .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane
+ .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ outputPanel.add(scrollPane, BorderLayout.CENTER);
+
+ FileDrop.Listener dropListener = new FileDrop.Listener() {
+
+ @Override
+ public void filesDropped(Container source, File[] files) {
+ createScaleJobs(files);
+ }
+
+ @Override
+ public void dragEnter(Container source) {
+ MainWindow.this.xhdpiButton.setSelected(true);
+ MainWindow.this.instructionLabel
+ .setIcon(MainWindow.this.redArrowSmall);
+ }
+
+ @Override
+ public void dragExit(Container source) {
+ MainWindow.this.xhdpiButton.setSelected(false);
+ MainWindow.this.instructionLabel
+ .setIcon(MainWindow.this.blueArrowSmall);
+ }
+ };
+ new FileDrop(this.getContentPane(), null, dropListener);
+ new FileDrop(outputPanel, null, dropListener);
+
+ this.instructionLabel = new JLabel("");
+ this.instructionLabel.setIcon(this.blueArrowSmall);
+ this.instructionLabel.setBorder(new EmptyBorder(4, 4, 4, 4));
+ this.instructionLabel.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ displayImagePicker();
+ }
+ });
+
+ outputPanel.add(this.instructionLabel, BorderLayout.SOUTH);
+
+ new FileDrop(textArea, null, dropListener);
+ return outputPanel;
+ }
+
+ private void displayImagePicker() {
+ fileDialog.setVisible(true);
+ File[] files = fileDialog.getFiles();
+ if (files != null) {
+ createScaleJobs(files);
+ }
+ }
+
+ private JPanel createInputPanel() {
+ JPanel inputPanel = new JPanel();
+ inputPanel.setPreferredSize(new Dimension(10, 140));
this.xhdpiButton =
new JButton(String.format(Locale.getDefault(), Localization.get("xhdpi"),
@@ -99,7 +177,7 @@ public MainWindow() {
public void actionPerformed(ActionEvent arg0) {
}
});
- this.inputPanel.setLayout(new BorderLayout(0, 0));
+ inputPanel.setLayout(new BorderLayout(0, 0));
this.xhdpiButton.setBorderPainted(false);
this.xhdpiButton.setFocusPainted(false);
this.xhdpiButton.setVerticalTextPosition(SwingConstants.BOTTOM);
@@ -109,7 +187,15 @@ public void actionPerformed(ActionEvent arg0) {
this.xhdpiButton.setSelectedIcon(this.redArrow);
this.xhdpiButton.setBorder(null);
this.xhdpiButton.setContentAreaFilled(false);
- this.inputPanel.add(this.xhdpiButton, BorderLayout.CENTER);
+ inputPanel.add(this.xhdpiButton, BorderLayout.CENTER);
+
+ this.xhdpiButton.addMouseListener(
+ new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ displayImagePicker();
+ }
+ });
JPanel optionPanel = new JPanel();
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.PAGE_AXIS));
@@ -118,10 +204,8 @@ public void actionPerformed(ActionEvent arg0) {
JLabel inputLabel = new JLabel(Localization.get("input_density"));
inputLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
optionPanel.add(inputLabel);
- final JComboBox
- inputDensityChoice =
- new JComboBox(
- new Vector(Configuration.getSettings().getSupportedScreenDensity()));
+ inputDensityChoice = new JComboBox(
+ new Vector(Configuration.getSettings().getSupportedScreenDensity()));
inputDensityChoice.setSelectedItem(Configuration.getSettings().getDefaultInputDensity());
inputDensityChoice.addActionListener(new ActionListener() {
@Override
@@ -193,104 +277,60 @@ public void run() {
optionPanel.setPreferredSize(new Dimension(200, -1));
- this.inputPanel.add(optionPanel, BorderLayout.LINE_START);
-
- this.outputPanel = new JPanel();
- this.getContentPane().add(this.outputPanel, "output");
- this.outputPanel.setLayout(new BorderLayout(0, 0));
-
- this.textArea = new JTextArea();
- this.textArea.setLineWrap(true);
- this.textArea.setEditable(false);
+ inputPanel.add(optionPanel, BorderLayout.LINE_START);
+ return inputPanel;
+ }
- this.resultTable = new ResultTable();
- this.scrollPane = new JScrollPane(this.resultTable);
- this.scrollPane
- .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- this.scrollPane
- .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- this.outputPanel.add(this.scrollPane, BorderLayout.CENTER);
+ private void createScaleJobs(File[] files) {
+ for (File input : files) {
+ String filename = input.getName();
+ if (NameValidator.isFilenameValid(filename)) {
+ MainWindow.this.mntmClear.setEnabled(true);
+ CardLayout layout = (CardLayout) MainWindow.this
+ .getContentPane().getLayout();
- FileDrop.Listener dropListener = new FileDrop.Listener() {
+ ScreenDensity selectedDensity = (ScreenDensity) inputDensityChoice.getSelectedItem();
+ instructionLabel.setText(String.format(Locale.getDefault(), Localization.get("xhdpi"),
+ selectedDensity.getName()));
+ layout.show(MainWindow.this.getContentPane(), "output");
+ Operation operation = new Operation(input);
+ MainWindow.this.resultTable.addOperation(operation);
- @Override
- public void filesDropped(Container source, File[] files) {
- for (File input : files) {
- String filename = input.getName();
- if (NameValidator.isFilenameValid(filename)) {
- MainWindow.this.mntmClear.setEnabled(true);
- CardLayout layout = (CardLayout) MainWindow.this
- .getContentPane().getLayout();
-
- ScreenDensity selectedDensity = (ScreenDensity) inputDensityChoice.getSelectedItem();
- instructionLabel.setText(String.format(Locale.getDefault(), Localization.get("xhdpi"),
- selectedDensity.getName()));
- layout.show(MainWindow.this.getContentPane(), "output");
- Operation operation = new Operation(input);
- MainWindow.this.resultTable.addOperation(operation);
-
- ImageScaler scaler = new ImageScaler(operation,
- Configuration.getSettings()
- .getDefaultInputDensity()) {
- @Override
- protected void process(
- java.util.List chunks) {
- for (Operation operation : chunks) {
- MainWindow.this.resultTable
- .notifyChange(operation);
- }
- }
- };
- scaler.post();
+ ImageScaler scaler = new ImageScaler(operation,
+ Configuration.getSettings()
+ .getDefaultInputDensity()) {
+ @Override
+ protected void process(
+ List chunks) {
+ for (Operation operation : chunks) {
+ MainWindow.this.resultTable
+ .notifyChange(operation);
+ }
}
- }
- }
-
- @Override
- public void dragEnter(Container source) {
- MainWindow.this.xhdpiButton.setSelected(true);
- MainWindow.this.instructionLabel
- .setIcon(MainWindow.this.redArrowSmall);
+ };
+ scaler.post();
}
-
- @Override
- public void dragExit(Container source) {
- MainWindow.this.xhdpiButton.setSelected(false);
- MainWindow.this.instructionLabel
- .setIcon(MainWindow.this.blueArrowSmall);
- }
- };
- new FileDrop(this.getContentPane(), null, dropListener);
- new FileDrop(this.outputPanel, null, dropListener);
-
- this.instructionLabel = new JLabel("");
- this.instructionLabel.setIcon(this.blueArrowSmall);
- this.instructionLabel.setBorder(new EmptyBorder(4, 4, 4, 4));
- this.outputPanel.add(this.instructionLabel, BorderLayout.SOUTH);
-
- new FileDrop(this.textArea, null, dropListener);
-
- this.setMenuBar();
+ }
}
private void setMenuBar() {
- this.menuBar = new JMenuBar();
- this.setJMenuBar(this.menuBar);
+ JMenuBar menuBar = new JMenuBar();
+ this.setJMenuBar(menuBar);
- this.mnEdit = new JMenu(Localization.get("menu_edit"));
- this.menuBar.add(this.mnEdit);
+ JMenu mnEdit = new JMenu(Localization.get("menu_edit"));
+ menuBar.add(mnEdit);
this.mntmClear = new JMenuItem(Localization.get("menu_item_clear"));
this.mntmClear.setAction(this.action);
this.mntmClear.setEnabled(false);
- this.mnEdit.add(this.mntmClear);
+ mnEdit.add(this.mntmClear);
- this.mnHelp = new JMenu(Localization.get("menu_help"));
- this.menuBar.add(this.mnHelp);
+ JMenu mnHelp = new JMenu(Localization.get("menu_help"));
+ menuBar.add(mnHelp);
- this.mntmAbout = new JMenuItem();
- this.mntmAbout.setAction(new AboutAction());
- this.mnHelp.add(this.mntmAbout);
+ JMenuItem mntmAbout = new JMenuItem();
+ mntmAbout.setAction(new AboutAction());
+ mnHelp.add(mntmAbout);
}
private class AboutAction extends AbstractAction {