From 8bdf1755b7aa6c2c0711e9169791bfc3f8ea33bc Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Tue, 15 May 2018 17:12:42 -0400 Subject: [PATCH] Migrating to JDK 1.8 --- .../lyndir/masterpassword/model}/MPConstant.java | 2 +- .../model/impl/MPFlatMarshaller.java | 1 + .../model/impl/MPFlatUnmarshaller.java | 1 + .../masterpassword/model/impl/MPJSONFile.java | 1 + .../com/lyndir/masterpassword/MPTestSuite.java | 2 +- gradle/.idea/misc.xml | 2 +- gradle/build.gradle | 4 ++-- platform-android/build.gradle | 7 ++++--- .../lyndir/masterpassword/EmergencyActivity.java | 1 + .../java/com/lyndir/masterpassword/gui/Config.java | 4 ++-- .../java/com/lyndir/masterpassword/gui/GUI.java | 2 +- .../masterpassword/gui/model/IncognitoSite.java | 14 ++++++++++++-- .../gui/view/IncognitoAuthenticationPanel.java | 2 +- 13 files changed, 29 insertions(+), 14 deletions(-) rename core/java/{algorithm/src/main/java/com/lyndir/masterpassword => model/src/main/java/com/lyndir/masterpassword/model}/MPConstant.java (97%) diff --git a/core/java/algorithm/src/main/java/com/lyndir/masterpassword/MPConstant.java b/core/java/model/src/main/java/com/lyndir/masterpassword/model/MPConstant.java similarity index 97% rename from core/java/algorithm/src/main/java/com/lyndir/masterpassword/MPConstant.java rename to core/java/model/src/main/java/com/lyndir/masterpassword/model/MPConstant.java index e0a15cec..495651d4 100644 --- a/core/java/algorithm/src/main/java/com/lyndir/masterpassword/MPConstant.java +++ b/core/java/model/src/main/java/com/lyndir/masterpassword/model/MPConstant.java @@ -16,7 +16,7 @@ // LICENSE file. Alternatively, see . //============================================================================== -package com.lyndir.masterpassword; +package com.lyndir.masterpassword.model; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.ISODateTimeFormat; diff --git a/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatMarshaller.java b/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatMarshaller.java index 876872aa..3b648441 100644 --- a/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatMarshaller.java +++ b/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatMarshaller.java @@ -22,6 +22,7 @@ import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*; import static com.lyndir.lhunath.opal.system.util.StringUtils.*; import com.lyndir.masterpassword.*; +import com.lyndir.masterpassword.model.MPConstant; import javax.annotation.Nonnull; import org.joda.time.Instant; diff --git a/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatUnmarshaller.java b/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatUnmarshaller.java index 6b87a47c..126c1961 100644 --- a/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatUnmarshaller.java +++ b/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFlatUnmarshaller.java @@ -25,6 +25,7 @@ import com.lyndir.lhunath.opal.system.CodeUtils; import com.lyndir.lhunath.opal.system.logging.Logger; import com.lyndir.lhunath.opal.system.util.ConversionUtils; import com.lyndir.masterpassword.*; +import com.lyndir.masterpassword.model.MPConstant; import com.lyndir.masterpassword.model.MPIncorrectMasterPasswordException; import java.io.*; import java.util.regex.Matcher; diff --git a/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java b/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java index b0863e71..93189efb 100644 --- a/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java +++ b/core/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.*; import com.google.common.primitives.UnsignedInteger; import com.lyndir.lhunath.opal.system.CodeUtils; import com.lyndir.masterpassword.*; +import com.lyndir.masterpassword.model.MPConstant; import com.lyndir.masterpassword.model.MPIncorrectMasterPasswordException; import java.util.*; import javax.annotation.Nullable; diff --git a/core/java/tests/src/main/java/com/lyndir/masterpassword/MPTestSuite.java b/core/java/tests/src/main/java/com/lyndir/masterpassword/MPTestSuite.java index aac6cb51..23eb0b68 100644 --- a/core/java/tests/src/main/java/com/lyndir/masterpassword/MPTestSuite.java +++ b/core/java/tests/src/main/java/com/lyndir/masterpassword/MPTestSuite.java @@ -87,7 +87,7 @@ public class MPTestSuite implements Callable { if ("case".equals( qName )) tests.cases.add( currentCase ); if ("algorithm".equals( qName )) - currentCase.algorithm = ConversionUtils.toInteger( text ).orNull(); + currentCase.algorithm = ConversionUtils.toInteger( text ).orElse( null ); if ("fullName".equals( qName )) currentCase.fullName = text; if ("masterPassword".equals( qName )) diff --git a/gradle/.idea/misc.xml b/gradle/.idea/misc.xml index cdb95b5a..b1631feb 100644 --- a/gradle/.idea/misc.xml +++ b/gradle/.idea/misc.xml @@ -31,7 +31,7 @@ - + diff --git a/gradle/build.gradle b/gradle/build.gradle index 196c18cb..8493e69f 100644 --- a/gradle/build.gradle +++ b/gradle/build.gradle @@ -5,8 +5,8 @@ allprojects { version = 'GIT-SNAPSHOT' tasks.withType(JavaCompile) { - sourceCompatibility = '1.7' - targetCompatibility = '1.7' + sourceCompatibility = '1.8' + targetCompatibility = '1.8' } tasks.withType(FindBugs) { reports { diff --git a/platform-android/build.gradle b/platform-android/build.gradle index d082d4fb..9bf06c55 100644 --- a/platform-android/build.gradle +++ b/platform-android/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion '25.0.0' + buildToolsVersion '25.0.3' compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { @@ -15,6 +15,7 @@ android { targetSdkVersion 25 versionCode 20501 versionName '2.5.1' + jackOptions.enabled true } // release with: STORE_PW=$(mpw masterpassword.keystore) KEY_PW=$(mpw masterpassword-android) gradle assembleRelease diff --git a/platform-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java b/platform-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java index a77ff351..a062785d 100644 --- a/platform-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java +++ b/platform-android/src/main/java/com/lyndir/masterpassword/EmergencyActivity.java @@ -38,6 +38,7 @@ import com.google.common.primitives.UnsignedInteger; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.lyndir.lhunath.opal.system.logging.Logger; +import com.lyndir.masterpassword.model.MPConstant; import java.text.MessageFormat; import java.util.*; import java.util.concurrent.Executors; diff --git a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/Config.java b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/Config.java index 3faa087f..f526dfd5 100644 --- a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/Config.java +++ b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/Config.java @@ -19,7 +19,7 @@ package com.lyndir.masterpassword.gui; import com.lyndir.lhunath.opal.system.util.ConversionUtils; -import com.lyndir.masterpassword.MPConstant; +import com.lyndir.masterpassword.model.MPConstant; /** @@ -35,6 +35,6 @@ public class Config { } public boolean checkForUpdates() { - return ConversionUtils.toBoolean( System.getenv( MPConstant.env_checkUpdates ) ).or( true ); + return ConversionUtils.toBoolean( System.getenv( MPConstant.env_checkUpdates ) ).orElse( true ); } } diff --git a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/GUI.java b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/GUI.java index e6bf7d94..17e11f13 100644 --- a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/GUI.java +++ b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/GUI.java @@ -21,7 +21,6 @@ package com.lyndir.masterpassword.gui; import static com.lyndir.lhunath.opal.system.util.StringUtils.*; import com.google.common.base.Charsets; -import com.google.common.base.Optional; import com.google.common.io.CharSource; import com.google.common.io.Resources; import com.lyndir.lhunath.opal.system.logging.Logger; @@ -34,6 +33,7 @@ import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URL; import java.util.Enumeration; +import java.util.Optional; import java.util.jar.*; import javax.swing.*; diff --git a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/model/IncognitoSite.java b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/model/IncognitoSite.java index f4dbe7b8..3157128f 100644 --- a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/model/IncognitoSite.java +++ b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/model/IncognitoSite.java @@ -19,9 +19,13 @@ package com.lyndir.masterpassword.gui.model; import com.google.common.collect.ImmutableList; +import com.google.common.primitives.UnsignedInteger; +import com.lyndir.masterpassword.MPAlgorithm; +import com.lyndir.masterpassword.MPResultType; import com.lyndir.masterpassword.model.*; import com.lyndir.masterpassword.model.impl.MPBasicSite; import java.util.Collection; +import javax.annotation.Nullable; /** @@ -31,8 +35,14 @@ public class IncognitoSite extends MPBasicSite { private final IncognitoUser user; - public IncognitoSite(final IncognitoUser user, final String siteName) { - super( siteName, user.getAlgorithm() ); + public IncognitoSite(final IncognitoUser user, final String name) { + this( user, name, null, null, null, null ); + } + + public IncognitoSite(final IncognitoUser user, final String name, + @Nullable final MPAlgorithm algorithm, @Nullable final UnsignedInteger counter, + @Nullable final MPResultType resultType, @Nullable final MPResultType loginType) { + super( name, (algorithm == null)? user.getAlgorithm(): algorithm, counter, resultType, loginType ); this.user = user; } diff --git a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/view/IncognitoAuthenticationPanel.java b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/view/IncognitoAuthenticationPanel.java index bf34b7e0..8f173b98 100644 --- a/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/view/IncognitoAuthenticationPanel.java +++ b/platform-independent/gui-java/src/main/java/com/lyndir/masterpassword/gui/view/IncognitoAuthenticationPanel.java @@ -87,7 +87,7 @@ public class IncognitoAuthenticationPanel extends AuthenticationPanel