From 6b6a62ca3293ed5f52ee07ee3d39e920d42ba887 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Tue, 8 Mar 2016 09:23:03 +0100 Subject: [PATCH] Java 1.6+ compatibility (at least) instead of 1.8+ only TODO: fix Locale problem (doesn't seem to work for non-default currently) --- src/be/nikiroo/jvcard/i18n/Trans.java | 4 ++-- src/be/nikiroo/jvcard/tui/Main.java | 6 ++++-- src/be/nikiroo/jvcard/tui/TuiLauncher.java | 2 +- src/be/nikiroo/jvcard/tui/panes/ContactDetails.java | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/be/nikiroo/jvcard/i18n/Trans.java b/src/be/nikiroo/jvcard/i18n/Trans.java index b41fbde..0b2af47 100644 --- a/src/be/nikiroo/jvcard/i18n/Trans.java +++ b/src/be/nikiroo/jvcard/i18n/Trans.java @@ -132,7 +132,7 @@ public class Trans { if (lang == null) { locale = Locale.getDefault(); } else { - locale = Locale.forLanguageTag(lang); + locale = new Locale(lang); } map = Bundles.getBundle("resources", locale); @@ -153,7 +153,7 @@ public class Trans { public static void main(String[] args) throws IOException { String path = args[0]; for (int i = 1; i < args.length; i++) { - Locale locale = Locale.forLanguageTag(args[i].replaceAll("_", "-")); + Locale locale = new Locale(args[i].replaceAll("_", "-")); String code = locale.toString(); Trans trans = new Trans(code); diff --git a/src/be/nikiroo/jvcard/tui/Main.java b/src/be/nikiroo/jvcard/tui/Main.java index db6e522..4884e70 100644 --- a/src/be/nikiroo/jvcard/tui/Main.java +++ b/src/be/nikiroo/jvcard/tui/Main.java @@ -170,8 +170,10 @@ public class Main { Field charset = Charset.class.getDeclaredField("defaultCharset"); charset.setAccessible(true); charset.set(null, null); - } catch (SecurityException | NoSuchFieldException - | IllegalArgumentException | IllegalAccessException e) { + } catch (SecurityException e) { + } catch (NoSuchFieldException e) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { } } } diff --git a/src/be/nikiroo/jvcard/tui/TuiLauncher.java b/src/be/nikiroo/jvcard/tui/TuiLauncher.java index 2cfcc3e..deb09d4 100644 --- a/src/be/nikiroo/jvcard/tui/TuiLauncher.java +++ b/src/be/nikiroo/jvcard/tui/TuiLauncher.java @@ -36,7 +36,7 @@ public class TuiLauncher { } if (win instanceof MainWindow) { - MainWindow mwin = (MainWindow) win; + final MainWindow mwin = (MainWindow) win; mwin.refresh(terminal.getTerminalSize()); terminal.addResizeListener(new ResizeListener() { @Override diff --git a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java index 2a69e41..06c88fc 100644 --- a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java +++ b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java @@ -1,10 +1,10 @@ package be.nikiroo.jvcard.tui.panes; import java.awt.Image; -import java.util.Base64; import java.util.LinkedList; import java.util.List; +import javax.xml.bind.DatatypeConverter; import javax.swing.ImageIcon; import be.nikiroo.jvcard.Contact; @@ -116,7 +116,7 @@ public class ContactDetails extends MainContent { if (encoding != null && encoding.getValue() != null && encoding.getValue().equalsIgnoreCase("b")) { - image = new ImageIcon(Base64.getDecoder().decode( + image = new ImageIcon(DatatypeConverter.parseBase64Binary( photo.getValue())).getImage(); } } -- 2.27.0