diff --git a/platform-darwin/Source/Mac/MPPasswordWindowController.xib b/platform-darwin/Source/Mac/MPPasswordWindowController.xib index d59357de..55cf0a2f 100644 --- a/platform-darwin/Source/Mac/MPPasswordWindowController.xib +++ b/platform-darwin/Source/Mac/MPPasswordWindowController.xib @@ -1,9 +1,10 @@ - - + + - + + @@ -27,7 +28,7 @@ - + @@ -35,7 +36,7 @@ - + diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/Res.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/Res.java index 415a56ac..ccfd3399 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/Res.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/Res.java @@ -51,6 +51,7 @@ public abstract class Res { private static final Executor immediateUiExecutor = new SwingExecutorService( true ); private static final Executor laterUiExecutor = new SwingExecutorService( false ); private static final Logger logger = Logger.get( Res.class ); + private static final Fonts fonts = new Fonts(); private static final Colors colors = new Colors(); public static Future job(final Runnable job) { @@ -112,88 +113,8 @@ public abstract class Res { return AVATAR_COUNT; } - public static Font emoticonsFont() { - return emoticonsRegular(); - } - - public static Font controlFont() { - return arimoRegular(); - } - - public static Font valueFont() { - return sourceSansProRegular(); - } - - public static Font bigValueFont() { - return sourceSansProBlack(); - } - - public static Font emoticonsRegular() { - return font( "fonts/Emoticons-Regular.otf" ); - } - - public static Font sourceCodeProRegular() { - return font( "fonts/SourceCodePro-Regular.otf" ); - } - - public static Font sourceCodeProBlack() { - return font( "fonts/SourceCodePro-Bold.otf" ); - } - - public static Font sourceSansProRegular() { - return font( "fonts/SourceSansPro-Regular.otf" ); - } - - public static Font sourceSansProBlack() { - return font( "fonts/SourceSansPro-Bold.otf" ); - } - - public static Font exoBold() { - return font( "fonts/Exo2.0-Bold.otf" ); - } - - public static Font exoExtraBold() { - return font( "fonts/Exo2.0-ExtraBold.otf" ); - } - - public static Font exoRegular() { - return font( "fonts/Exo2.0-Regular.otf" ); - } - - public static Font exoThin() { - return font( "fonts/Exo2.0-Thin.otf" ); - } - - public static Font arimoBold() { - return font( "fonts/Arimo-Bold.ttf" ); - } - - public static Font arimoBoldItalic() { - return font( "fonts/Arimo-BoldItalic.ttf" ); - } - - public static Font arimoItalic() { - return font( "fonts/Arimo-Italic.ttf" ); - } - - public static Font arimoRegular() { - return font( "fonts/Arimo-Regular.ttf" ); - } - - private static Font font(@NonNls final String fontResourceName) { - Map> fontsByResourceName = Maps.newHashMap(); - SoftReference fontRef = fontsByResourceName.get( fontResourceName ); - Font font = (fontRef == null)? null: fontRef.get(); - if (font == null) - try { - fontsByResourceName.put( fontResourceName, new SoftReference<>( - font = Font.createFont( Font.TRUETYPE_FONT, Resources.getResource( fontResourceName ).openStream() ) ) ); - } - catch (final FontFormatException | IOException e) { - throw logger.bug( e ); - } - - return font; + public static Fonts fonts() { + return fonts; } public static Colors colors() { @@ -257,11 +178,100 @@ public abstract class Res { } + public static class Fonts { + + public Font emoticonsFont() { + return emoticonsRegular(); + } + + public Font controlFont() { + return exoRegular(); + } + + public Font valueFont() { + return sourceSansProRegular(); + } + + public Font bigValueFont() { + return sourceSansProBlack(); + } + + public Font emoticonsRegular() { + return font( "fonts/Emoticons-Regular.otf" ); + } + + public Font sourceCodeProRegular() { + return font( "fonts/SourceCodePro-Regular.otf" ); + } + + public Font sourceCodeProBlack() { + return font( "fonts/SourceCodePro-Bold.otf" ); + } + + public Font sourceSansProRegular() { + return font( "fonts/SourceSansPro-Regular.otf" ); + } + + public Font sourceSansProBlack() { + return font( "fonts/SourceSansPro-Bold.otf" ); + } + + public Font exoBold() { + return font( "fonts/Exo2.0-Bold.otf" ); + } + + public Font exoExtraBold() { + return font( "fonts/Exo2.0-ExtraBold.otf" ); + } + + public Font exoRegular() { + return font( "fonts/Exo2.0-Regular.otf" ); + } + + public Font exoThin() { + return font( "fonts/Exo2.0-Thin.otf" ); + } + + public Font arimoBold() { + return font( "fonts/Arimo-Bold.ttf" ); + } + + public Font arimoBoldItalic() { + return font( "fonts/Arimo-BoldItalic.ttf" ); + } + + public Font arimoItalic() { + return font( "fonts/Arimo-Italic.ttf" ); + } + + public Font arimoRegular() { + return font( "fonts/Arimo-Regular.ttf" ); + } + + private static Font font(@NonNls final String fontResourceName) { + Map> fontsByResourceName = Maps.newHashMap(); + SoftReference fontRef = fontsByResourceName.get( fontResourceName ); + Font font = (fontRef == null)? null: fontRef.get(); + if (font == null) + try { + fontsByResourceName.put( fontResourceName, new SoftReference<>( + font = Font.createFont( Font.TRUETYPE_FONT, Resources.getResource( fontResourceName ).openStream() ) ) ); + } + catch (final FontFormatException | IOException e) { + throw logger.bug( e ); + } + + return font; + } + } + + public static class Colors { private final Color frameBg = Color.decode( "#5A5D6B" ); - private final Color controlBg = Color.decode( "#ECECEC" ); + private final Color controlBg = SystemColor.window; private final Color controlBorder = Color.decode( "#BFBFBF" ); + private final Color highlightFg = SystemColor.controlHighlight; private final Color errorFg = Color.decode( "#FF3333" ); public Color frameBg() { @@ -276,6 +286,10 @@ public abstract class Res { return controlBorder; } + public Color highlightFg() { + return highlightFg; + } + public Color errorFg() { return errorFg; } diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/Components.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/Components.java index 1fa3c9cd..46dd19e6 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/Components.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/util/Components.java @@ -31,8 +31,8 @@ import javax.swing.border.CompoundBorder; */ public abstract class Components { - private static final float HEADING_TEXT_SIZE = 18f; - private static final float CONTROL_TEXT_SIZE = 12f; + private static final float HEADING_TEXT_SIZE = 19f; + private static final float CONTROL_TEXT_SIZE = 13f; public static GradientPanel boxLayout(final int axis, final Component... components) { GradientPanel container = gradientPanel( null, null ); @@ -76,7 +76,7 @@ public abstract class Components { { setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder( Res.colors().controlBorder(), 1, true ), BorderFactory.createEmptyBorder( 4, 4, 4, 4 ) ) ); - setFont( Res.valueFont().deriveFont( CONTROL_TEXT_SIZE ) ); + setFont( Res.fonts().valueFont().deriveFont( CONTROL_TEXT_SIZE ) ); setAlignmentX( LEFT_ALIGNMENT ); setAlignmentY( BOTTOM_ALIGNMENT ); } @@ -107,7 +107,7 @@ public abstract class Components { public static JButton button(final String label) { return new JButton( label ) { { - setFont( Res.controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); + setFont( Res.fonts().controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); setAlignmentX( LEFT_ALIGNMENT ); setAlignmentY( BOTTOM_ALIGNMENT ); } @@ -167,7 +167,7 @@ public abstract class Components { public static JLabel heading(@Nullable final String heading, final int horizontalAlignment) { return new JLabel( heading, horizontalAlignment ) { { - setFont( Res.controlFont().deriveFont( Font.BOLD, HEADING_TEXT_SIZE ) ); + setFont( Res.fonts().controlFont().deriveFont( Font.BOLD, HEADING_TEXT_SIZE ) ); setAlignmentX( LEFT_ALIGNMENT ); setAlignmentY( BOTTOM_ALIGNMENT ); } @@ -195,7 +195,7 @@ public abstract class Components { public static JLabel label(@Nullable final String label, final int horizontalAlignment) { return new JLabel( label, horizontalAlignment ) { { - setFont( Res.controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); + setFont( Res.fonts().controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); setAlignmentX( LEFT_ALIGNMENT ); setAlignmentY( BOTTOM_ALIGNMENT ); } @@ -210,7 +210,7 @@ public abstract class Components { public static JCheckBox checkBox(final String label) { return new JCheckBox( label ) { { - setFont( Res.controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); + setFont( Res.fonts().controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); setBackground( null ); setAlignmentX( LEFT_ALIGNMENT ); setAlignmentY( BOTTOM_ALIGNMENT ); @@ -226,14 +226,9 @@ public abstract class Components { public static JComboBox comboBox(final ComboBoxModel model) { return new JComboBox( model ) { { - // CompoundBorder editorBorder = BorderFactory.createCompoundBorder( - // BorderFactory.createLineBorder( Res.colors().controlBorder(), 1, true ), - // BorderFactory.createEmptyBorder( 4, 4, 4, 4 ) ); - // ((JComponent) ((BasicComboBoxEditor) getEditor()).getEditorComponent()).setBorder(editorBorder); - setFont( Res.controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); + setFont( Res.fonts().controlFont().deriveFont( CONTROL_TEXT_SIZE ) ); setAlignmentX( LEFT_ALIGNMENT ); setAlignmentY( BOTTOM_ALIGNMENT ); - // setBorder(null); } @Override diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/FilesPanel.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/FilesPanel.java index d5c260d8..612f5160 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/FilesPanel.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/FilesPanel.java @@ -43,8 +43,8 @@ public class FilesPanel extends JPanel implements ActionListener { // User Selection add( userField ); - userField.setFont( Res.valueFont().deriveFont( userField.getFont().getSize2D() ) ); userField.addActionListener( this ); + userField.setFont( Res.fonts().valueFont().deriveFont( userField.getFont().getSize2D() ) ); userField.setRenderer( new DefaultListCellRenderer() { @Override @SuppressWarnings("unchecked") diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/UserPanel.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/UserPanel.java index b8866fe7..5b4e6bb3 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/UserPanel.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/view/UserPanel.java @@ -74,9 +74,11 @@ public class UserPanel extends Components.GradientPanel implements MPUser.Listen private static final class NoUserPanel extends JPanel { private NoUserPanel() { - super( new BorderLayout() ); + setLayout( new BoxLayout( this, BoxLayout.PAGE_AXIS ) ); - add( Components.heading( "Select a user to proceed." ), BorderLayout.CENTER ); + add( Box.createGlue() ); + add( Components.heading( "Select a user to proceed." ) ); + add( Box.createGlue() ); } } @@ -94,12 +96,11 @@ public class UserPanel extends Components.GradientPanel implements MPUser.Listen this.user = user; + add( Components.heading( user.getFullName(), SwingConstants.CENTER ) ); add( Box.createGlue() ); - add( Components.heading( user.getFullName(), SwingConstants.CENTER ) ); - add( Components.strut() ); - add( Components.label( "Master Password:" ) ); + add( Components.strut() ); add( masterPasswordField ); masterPasswordField.addActionListener( this ); masterPasswordField.getDocument().addDocumentListener( this ); @@ -107,6 +108,8 @@ public class UserPanel extends Components.GradientPanel implements MPUser.Listen errorLabel.setForeground( Res.colors().errorFg() ); add( Box.createGlue() ); + + Res.ui( false, masterPasswordField::requestFocusInWindow ); } @Override @@ -147,7 +150,7 @@ public class UserPanel extends Components.GradientPanel implements MPUser.Listen private final MPUser user; private final JLabel passwordLabel = Components.label( " ", SwingConstants.CENTER ); private final JLabel passwordField = Components.heading( " ", SwingConstants.CENTER ); - private final JLabel queryLabel = Components.label( " ", SwingConstants.CENTER ); + private final JLabel queryLabel = Components.label( " " ); private final JTextField queryField = Components.textField(); private AuthenticatedUserPanel(@Nonnull final MPUser user) { @@ -155,8 +158,13 @@ public class UserPanel extends Components.GradientPanel implements MPUser.Listen this.user = user; + add( Components.heading( user.getFullName(), SwingConstants.CENTER ) ); + add( Components.strut() ); + add( passwordLabel ); add( passwordField ); + passwordField.setForeground( Res.colors().highlightFg() ); + passwordField.setFont( Res.fonts().bigValueFont().deriveFont( Font.BOLD, 48 ) ); add( Box.createGlue() ); add( queryLabel ); @@ -165,6 +173,8 @@ public class UserPanel extends Components.GradientPanel implements MPUser.Listen queryField.addActionListener( this ); queryField.getDocument().addDocumentListener( this ); add( Box.createGlue() ); + + Res.ui( false, queryField::requestFocusInWindow ); } @Override diff --git a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java index 194a750b..1726bf59 100644 --- a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java +++ b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java @@ -42,7 +42,7 @@ class MPJSONAnyObject { @Override @SuppressWarnings({ "ChainOfInstanceofChecks", "Contract" }) - @SuppressFBWarnings({"EQ_UNUSUAL","EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", "HE_EQUALS_USE_HASHCODE"}) + @SuppressFBWarnings({ "EQ_UNUSUAL", "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", "HE_EQUALS_USE_HASHCODE" }) public boolean equals(final Object obj) { if (obj instanceof Collection) return ((Collection) obj).isEmpty();