diff --git a/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MPSiteType.java b/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MPSiteType.java index da5e8509..a2c877cb 100644 --- a/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MPSiteType.java +++ b/MasterPassword/Java/masterpassword-algorithm/src/main/java/com/lyndir/masterpassword/MPSiteType.java @@ -120,7 +120,7 @@ public enum MPSiteType { return typeFeatures; } - public int getMask() { + public int getType() { int mask = typeIndex | typeClass.getMask(); for (MPSiteFeature typeFeature : typeFeatures) mask |= typeFeature.getMask(); @@ -174,6 +174,20 @@ public enum MPSiteType { return types.build(); } + /** + * @param type The type for which we look up types. + * + * @return The type registered with the given type. + */ + public static MPSiteType forType(final int type) { + + for (MPSiteType siteType : values()) + if (siteType.getType() == type) + return siteType; + + throw logger.bug( "No type: %s", type ); + } + /** * @param mask The mask for which we look up types. * @@ -181,14 +195,11 @@ public enum MPSiteType { */ public static ImmutableList forMask(final int mask) { - int typeIndex = mask & 0xF, typeMask = mask & ~0xF; - + int typeMask = mask & ~0xF; ImmutableList.Builder types = ImmutableList.builder(); - for (MPSiteType siteType : values()) { - int siteMask = siteType.getMask(), siteTypeIndex = siteMask & 0xF, siteTypeMask = siteMask & ~0xF; - if ((siteTypeMask & typeMask) != 0 && (typeIndex == 0 || siteTypeIndex == typeIndex)) + for (MPSiteType siteType : values()) + if (((siteType.getType() & ~0xF) & typeMask) != 0) types.add( siteType ); - } return types.build(); } diff --git a/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java b/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java index 0d6adf8b..aa755f27 100644 --- a/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java +++ b/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java @@ -73,7 +73,7 @@ public class GUI implements UnlockFrame.SignInCallback { String upstreamRevision = upstream.readFirstLine(); logger.inf( "Local Revision: <%s>", manifestRevision ); logger.inf( "Upstream Revision: <%s>", upstreamRevision ); - if (!manifestRevision.equalsIgnoreCase( upstreamRevision )) { + if (manifestRevision != null && !manifestRevision.equalsIgnoreCase( upstreamRevision )) { logger.wrn( "You are not running the current official version. Please update from:\n" + "http://masterpasswordapp.com/masterpassword-gui.jar" ); JOptionPane.showMessageDialog( null, "A new version of Master Password is available.\n" diff --git a/MasterPassword/Java/masterpassword-gui/src/main/resources/fonts/SourceCodePro-ExtraLight.otf b/MasterPassword/Java/masterpassword-gui/src/main/resources/fonts/SourceCodePro-ExtraLight.otf new file mode 100644 index 00000000..5cb8e5fb Binary files /dev/null and b/MasterPassword/Java/masterpassword-gui/src/main/resources/fonts/SourceCodePro-ExtraLight.otf differ diff --git a/MasterPassword/Java/masterpassword-gui/src/main/resources/fonts/SourceCodePro-Regular.otf b/MasterPassword/Java/masterpassword-gui/src/main/resources/fonts/SourceCodePro-Regular.otf new file mode 100644 index 00000000..8f031da9 Binary files /dev/null and b/MasterPassword/Java/masterpassword-gui/src/main/resources/fonts/SourceCodePro-Regular.otf differ diff --git a/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteMarshaller.java b/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteMarshaller.java index 0673fd6f..27ddbf19 100644 --- a/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteMarshaller.java +++ b/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteMarshaller.java @@ -65,7 +65,7 @@ public class MPSiteMarshaller { header.append( "# Key ID: " ).append( user.exportKeyID() ).append( '\n' ); header.append( "# Version: " ).append( MasterKey.VERSION ).append( '\n' ); header.append( "# Algorithm: " ).append( MasterKey.ALGORITHM ).append( '\n' ); - header.append( "# Default Type: " ).append( user.getDefaultType().getMask() ).append( '\n' ); + header.append( "# Default Type: " ).append( user.getDefaultType().getType() ).append( '\n' ); header.append( "# Passwords: " ).append( contentMode.name() ).append( '\n' ); header.append( "##\n" ); header.append( "#\n" ); @@ -81,7 +81,7 @@ public class MPSiteMarshaller { rfc3339.print( site.getLastUsed() ), // lastUsed site.getUses(), // uses strf( "%d:%d:%d", // - site.getSiteType().getMask(), // type + site.getSiteType().getType(), // type site.getMPVersion(), // algorithm site.getSiteCounter() ), // counter ifNotNullElse( site.getLoginName(), "" ), // loginName diff --git a/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteUnmarshaller.java b/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteUnmarshaller.java index 14d5527a..0f02be03 100644 --- a/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteUnmarshaller.java +++ b/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPSiteUnmarshaller.java @@ -88,7 +88,7 @@ public class MPSiteUnmarshaller { else if ("Passwords".equalsIgnoreCase( name )) clearContent = value.equalsIgnoreCase( "visible" ); else if ("Default Type".equalsIgnoreCase( name )) - defaultType = Iterables.getOnlyElement( MPSiteType.forMask( ConversionUtils.toIntegerNN( value ) ) ); + defaultType = MPSiteType.forType( ConversionUtils.toIntegerNN( value ) ); } } } @@ -126,7 +126,7 @@ public class MPSiteUnmarshaller { site = new MPSite( ConversionUtils.toIntegerNN( siteMatcher.group( 4 ).replace( ":", "" ) ), // rfc3339.parseDateTime( siteMatcher.group( 1 ) ).toInstant(), // siteMatcher.group( 5 ), // - Iterables.getOnlyElement( MPSiteType.forMask( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ) ), + MPSiteType.forType( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ), MPSite.DEFAULT_COUNTER, // ConversionUtils.toIntegerNN( siteMatcher.group( 2 ) ), // null, // @@ -137,7 +137,7 @@ public class MPSiteUnmarshaller { site = new MPSite( ConversionUtils.toIntegerNN( siteMatcher.group( 4 ).replace( ":", "" ) ), // rfc3339.parseDateTime( siteMatcher.group( 1 ) ).toInstant(), // siteMatcher.group( 7 ), // - Iterables.getOnlyElement( MPSiteType.forMask( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ) ), + MPSiteType.forType( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ), ConversionUtils.toIntegerNN( siteMatcher.group( 5 ).replace( ":", "" ) ), // ConversionUtils.toIntegerNN( siteMatcher.group( 2 ) ), // siteMatcher.group( 6 ), //