From c5e39c0da4097b10614fb0d81ada1ba0b2aa570c Mon Sep 17 00:00:00 2001 From: redwarp Date: Fri, 20 Feb 2015 10:51:26 +0100 Subject: [PATCH 01/14] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 63dba53..a1ddc4f 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ You're using 9patch resizer for your apps ? Don't hesitate and leave me a messag ## Roadmap +- [ ] A proper "Settings" panel, to handle issues such as jpeg compression, etc etc... - [x] Command line support - [ ] A few optimisations - [x] Options to set the input density (if people wan't to downsize from hdpi and not from xdpi for instance) From fb2b2739e755967897b7216c97af62838cae9ec8 Mon Sep 17 00:00:00 2001 From: redwarp Date: Fri, 20 Feb 2015 14:12:37 +0100 Subject: [PATCH 02/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1ddc4f..ef7a502 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ You're using 9patch resizer for your apps ? Don't hesitate and leave me a messag ## Roadmap - [ ] A proper "Settings" panel, to handle issues such as jpeg compression, etc etc... -- [x] Command line support - [ ] 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 From 994854e4fdffaa4ce86d09426a4a6d02880358d5 Mon Sep 17 00:00:00 2001 From: Benoit Vermont Date: Sat, 21 Feb 2015 13:31:57 +0100 Subject: [PATCH 03/14] Git cleanup --- .gitignore | 2 + .idea/.name | 1 - .idea/ant.xml | 2 - .idea/compiler.xml | 32 ------- .idea/copyright/Redwarp.xml | 9 -- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 5 -- .idea/gradle.xml | 3 - .idea/libraries/gson_2_2_4.xml | 13 --- .idea/modules.xml | 9 -- .idea/scopes/scope_settings.xml | 5 -- .idea/uiDesigner.xml | 125 -------------------------- .idea/vcs.xml | 7 -- Resizer.eml | 13 --- Resizer.iml | 2 - 15 files changed, 2 insertions(+), 229 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/ant.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/Redwarp.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/libraries/gson_2_2_4.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/scopes/scope_settings.xml delete mode 100644 .idea/uiDesigner.xml delete mode 100644 .idea/vcs.xml delete mode 100644 Resizer.eml delete mode 100644 Resizer.iml 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/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 From 3d486c22cdf6b938f613f7fa048b3f643864a1f3 Mon Sep 17 00:00:00 2001 From: redwarp Date: Sat, 21 Mar 2015 15:03:32 +0100 Subject: [PATCH 04/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef7a502..123f205 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.1* You're using 9patch resizer for your apps ? Don't hesitate and leave me a message! From 3366dea65b21f3075151ad9ce92cc95dd9e71c05 Mon Sep 17 00:00:00 2001 From: redwarp Date: Wed, 1 Apr 2015 17:15:38 +0200 Subject: [PATCH 05/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 123f205..623229f 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,6 @@ Join us, and together, we can rule the galaxy as coders and... 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. +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 will probably use it on beers though, so you should probably not bother, if you care for my health. From 0b93221bfa1c937226bd23653d07a2bf727e8d7e Mon Sep 17 00:00:00 2001 From: redwarp Date: Tue, 30 Jun 2015 17:40:59 +0200 Subject: [PATCH 06/14] On click in windows, launch a file picker dialog --- .../tool/resizer/views/MainWindow.java | 96 ++++++++++++------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/src/net/redwarp/tool/resizer/views/MainWindow.java b/src/net/redwarp/tool/resizer/views/MainWindow.java index 3c5b128..81e9b85 100644 --- a/src/net/redwarp/tool/resizer/views/MainWindow.java +++ b/src/net/redwarp/tool/resizer/views/MainWindow.java @@ -28,6 +28,8 @@ 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.util.ArrayList; import java.util.List; @@ -56,6 +58,7 @@ public class MainWindow extends JFrame { private JMenuItem mntmClear; private JMenuItem mntmAbout; private final Action action = new SwingAction(); + private final JComboBox inputDensityChoice; public MainWindow() { this.setSize(new Dimension(550, 400)); @@ -111,6 +114,31 @@ public void actionPerformed(ActionEvent arg0) { this.xhdpiButton.setContentAreaFilled(false); this.inputPanel.add(this.xhdpiButton, BorderLayout.CENTER); + final JFileChooser fileChooser = new JFileChooser() { + @Override + public boolean accept(File f) { + return NameValidator.isFilenameValid(f.getName()); + } + }; + fileChooser.setMultiSelectionEnabled(true); + + this.xhdpiButton.addMouseListener( + new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + System.out.println("Clicked"); + int returnVal = fileChooser.showOpenDialog(MainWindow.this); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File[] files = fileChooser.getSelectedFiles(); + + createScaleJobs(files); + } else { + System.out.println("Attachment cancelled by user."); + } + } + }); + JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.PAGE_AXIS)); optionPanel.add(Box.createVerticalGlue()); @@ -118,10 +146,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 @@ -215,35 +241,7 @@ public void run() { @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(); - } - } + createScaleJobs(files); } @Override @@ -273,6 +271,38 @@ public void dragExit(Container source) { this.setMenuBar(); } + 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(); + + 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( + List chunks) { + for (Operation operation : chunks) { + MainWindow.this.resultTable + .notifyChange(operation); + } + } + }; + scaler.post(); + } + } + } + private void setMenuBar() { this.menuBar = new JMenuBar(); this.setJMenuBar(this.menuBar); From 0be6b94b1700cadb3d3896bc4fc4436cb618d467 Mon Sep 17 00:00:00 2001 From: redwarp Date: Tue, 30 Jun 2015 17:55:23 +0200 Subject: [PATCH 07/14] Refactoring --- .../tool/resizer/views/MainWindow.java | 165 +++++++++--------- 1 file changed, 83 insertions(+), 82 deletions(-) diff --git a/src/net/redwarp/tool/resizer/views/MainWindow.java b/src/net/redwarp/tool/resizer/views/MainWindow.java index 81e9b85..00fd69f 100644 --- a/src/net/redwarp/tool/resizer/views/MainWindow.java +++ b/src/net/redwarp/tool/resizer/views/MainWindow.java @@ -42,23 +42,15 @@ @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 final JComboBox inputDensityChoice; + private JComboBox inputDensityChoice; + private JFileChooser fileChooser; public MainWindow() { this.setSize(new Dimension(550, 400)); @@ -90,9 +82,73 @@ 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"); + + fileChooser = new JFileChooser() { + @Override + public boolean accept(File f) { + return NameValidator.isFilenameValid(f.getName()); + } + }; + fileChooser.setMultiSelectionEnabled(true); + + 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)); + outputPanel.add(this.instructionLabel, BorderLayout.SOUTH); + + new FileDrop(textArea, null, dropListener); + return outputPanel; + } + + private JPanel createInputPanel() { + JPanel inputPanel = new JPanel(); + inputPanel.setPreferredSize(new Dimension(10, 140)); this.xhdpiButton = new JButton(String.format(Locale.getDefault(), Localization.get("xhdpi"), @@ -102,7 +158,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); @@ -112,15 +168,8 @@ 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); - final JFileChooser fileChooser = new JFileChooser() { - @Override - public boolean accept(File f) { - return NameValidator.isFilenameValid(f.getName()); - } - }; - fileChooser.setMultiSelectionEnabled(true); this.xhdpiButton.addMouseListener( new MouseAdapter() { @@ -219,56 +268,8 @@ 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); - - 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); - - 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(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(); + inputPanel.add(optionPanel, BorderLayout.LINE_START); + return inputPanel; } private void createScaleJobs(File[] files) { @@ -304,23 +305,23 @@ protected void process( } 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 { From 1246d6f2166155a1b412ffd7e3beff8cea6ff599 Mon Sep 17 00:00:00 2001 From: redwarp Date: Tue, 30 Jun 2015 17:58:19 +0200 Subject: [PATCH 08/14] Add file chooser to output panel --- .../redwarp/tool/resizer/views/MainWindow.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/net/redwarp/tool/resizer/views/MainWindow.java b/src/net/redwarp/tool/resizer/views/MainWindow.java index 00fd69f..7a4d53c 100644 --- a/src/net/redwarp/tool/resizer/views/MainWindow.java +++ b/src/net/redwarp/tool/resizer/views/MainWindow.java @@ -140,6 +140,19 @@ public void dragExit(Container source) { 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) { + int returnVal = fileChooser.showOpenDialog(MainWindow.this); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File[] files = fileChooser.getSelectedFiles(); + + createScaleJobs(files); + } + } + }); + outputPanel.add(this.instructionLabel, BorderLayout.SOUTH); new FileDrop(textArea, null, dropListener); @@ -175,15 +188,12 @@ public void actionPerformed(ActionEvent arg0) { new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - System.out.println("Clicked"); int returnVal = fileChooser.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fileChooser.getSelectedFiles(); createScaleJobs(files); - } else { - System.out.println("Attachment cancelled by user."); } } }); From d2cb0053bb75f7801aa910cba9d78dfb724eca85 Mon Sep 17 00:00:00 2001 From: redwarp Date: Wed, 1 Jul 2015 11:53:28 +0200 Subject: [PATCH 09/14] Use file dialog instead of JFileChooser (looks more "system like") --- res/locale/Strings.properties | 1 + res/locale/Strings_fr.properties | 1 + .../tool/resizer/views/MainWindow.java | 43 +++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) 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 7a4d53c..cf527f0 100644 --- a/src/net/redwarp/tool/resizer/views/MainWindow.java +++ b/src/net/redwarp/tool/resizer/views/MainWindow.java @@ -31,6 +31,7 @@ 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; @@ -39,6 +40,7 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; + @SuppressWarnings("serial") public class MainWindow extends JFrame { @@ -50,7 +52,8 @@ public class MainWindow extends JFrame { private JMenuItem mntmClear; private final Action action = new SwingAction(); private JComboBox inputDensityChoice; - private JFileChooser fileChooser; + // private JFileChooser fileChooser; + private FileDialog fileDialog; public MainWindow() { this.setSize(new Dimension(550, 400)); @@ -82,14 +85,15 @@ public MainWindow() { MainWindow.class.getResource("/img/red_small.png")); this.getContentPane().setLayout(new CardLayout(0, 0)); - - fileChooser = new JFileChooser() { + fileDialog = new FileDialog(this); + fileDialog.setFilenameFilter(new FilenameFilter() { @Override - public boolean accept(File f) { - return NameValidator.isFilenameValid(f.getName()); + public boolean accept(File dir, String name) { + return NameValidator.isFilenameValid(name); } - }; - fileChooser.setMultiSelectionEnabled(true); + }); + fileDialog.setMultipleMode(true); + fileDialog.setTitle(Localization.get("image_types")); this.getContentPane().add(createInputPanel(), "input"); this.getContentPane().add(createOutputPanel(), "output"); @@ -143,13 +147,7 @@ public void dragExit(Container source) { this.instructionLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - int returnVal = fileChooser.showOpenDialog(MainWindow.this); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File[] files = fileChooser.getSelectedFiles(); - - createScaleJobs(files); - } + displayImagePicker(); } }); @@ -159,6 +157,14 @@ public void mouseClicked(MouseEvent e) { 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)); @@ -183,18 +189,11 @@ public void actionPerformed(ActionEvent arg0) { this.xhdpiButton.setContentAreaFilled(false); inputPanel.add(this.xhdpiButton, BorderLayout.CENTER); - this.xhdpiButton.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - int returnVal = fileChooser.showOpenDialog(MainWindow.this); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File[] files = fileChooser.getSelectedFiles(); - - createScaleJobs(files); - } + displayImagePicker(); } }); From 85794f1d67ddfa3528331096ef71ad9a215f73de Mon Sep 17 00:00:00 2001 From: redwarp Date: Wed, 1 Jul 2015 14:23:04 +0200 Subject: [PATCH 10/14] Update version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From f3256eaa9bb82e81be4e5887727ba7849564dc58 Mon Sep 17 00:00:00 2001 From: redwarp Date: Wed, 1 Jul 2015 14:24:49 +0200 Subject: [PATCH 11/14] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 623229f..082f358 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.1* +Current version : *1.4.2* You're using 9patch resizer for your apps ? Don't hesitate and leave me a message! From 8ae468684e6cae44cfa2f82fc067770e9ea27b6c Mon Sep 17 00:00:00 2001 From: Benoit Vermont Date: Tue, 28 Mar 2017 16:38:00 +0200 Subject: [PATCH 12/14] Update README.md Remove the donate section, was great when I was a student but, don't really need it no more. --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 082f358..e0807ab 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,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 will probably use it on beers though, so you should probably not bother, if you care for my health. - - From 7efe188b3a1bb7e740161c12e7c6a1b335ff8fe9 Mon Sep 17 00:00:00 2001 From: Benoit Vermont Date: Thu, 14 Feb 2019 17:15:23 +0100 Subject: [PATCH 13/14] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 31 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md 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. From d434a2e7a4310136ef5ab6be808ea22669261940 Mon Sep 17 00:00:00 2001 From: Benoit Vermont Date: Thu, 12 Sep 2019 10:14:24 +0200 Subject: [PATCH 14/14] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e0807ab..89661e1 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ You're using 9patch resizer for your apps ? Don't hesitate and leave me a messag ## Roadmap +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