Refactor code.
This commit is contained in:
		@@ -18,7 +18,6 @@
 | 
			
		||||
 | 
			
		||||
package com.lyndir.masterpassword.model;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author lhunath, 14-12-17
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@
 | 
			
		||||
package com.lyndir.masterpassword.model;
 | 
			
		||||
 | 
			
		||||
import com.google.common.collect.*;
 | 
			
		||||
import com.lyndir.masterpassword.model.impl.MPFileUser;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.SortedSet;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
 | 
			
		||||
package com.lyndir.masterpassword.model.impl;
 | 
			
		||||
 | 
			
		||||
import static com.lyndir.lhunath.opal.system.util.StringUtils.strf;
 | 
			
		||||
import static com.lyndir.lhunath.opal.system.util.StringUtils.*;
 | 
			
		||||
 | 
			
		||||
import com.lyndir.masterpassword.*;
 | 
			
		||||
import com.lyndir.masterpassword.model.MPQuestion;
 | 
			
		||||
@@ -70,7 +70,6 @@ public abstract class MPBasicQuestion implements MPQuestion {
 | 
			
		||||
    @Override
 | 
			
		||||
    public abstract MPBasicSite getSite();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return Objects.hashCode( getKeyword() );
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
 | 
			
		||||
package com.lyndir.masterpassword.model.impl;
 | 
			
		||||
 | 
			
		||||
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.ifNotNullElse;
 | 
			
		||||
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*;
 | 
			
		||||
 | 
			
		||||
import com.lyndir.masterpassword.*;
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,8 @@ import com.google.common.base.Charsets;
 | 
			
		||||
import com.google.common.collect.ImmutableList;
 | 
			
		||||
import com.google.common.io.CharSink;
 | 
			
		||||
import com.lyndir.lhunath.opal.system.logging.Logger;
 | 
			
		||||
import com.lyndir.masterpassword.*;
 | 
			
		||||
import com.lyndir.masterpassword.MPKeyUnavailableException;
 | 
			
		||||
import com.lyndir.masterpassword.MPMasterKey;
 | 
			
		||||
import com.lyndir.masterpassword.model.*;
 | 
			
		||||
import java.io.*;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ package com.lyndir.masterpassword.model.impl;
 | 
			
		||||
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.MPKeyUnavailableException;
 | 
			
		||||
import com.lyndir.masterpassword.model.MPConstant;
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
import org.joda.time.Instant;
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@ public class MPFlatUnmarshaller implements MPUnmarshaller {
 | 
			
		||||
                    // Ends the header.
 | 
			
		||||
                    user = new MPFileUser( fullName, keyID, MPAlgorithm.Version.fromInt( mpVersion ).getAlgorithm(),
 | 
			
		||||
                                           avatar, defaultType, new DateTime( 0 ), MPMarshalFormat.Flat,
 | 
			
		||||
                                           clearContent? MPMarshaller.ContentMode.VISIBLE : MPMarshaller.ContentMode.PROTECTED );
 | 
			
		||||
                                           clearContent? MPMarshaller.ContentMode.VISIBLE: MPMarshaller.ContentMode.PROTECTED );
 | 
			
		||||
 | 
			
		||||
                // Comment.
 | 
			
		||||
            else if (line.startsWith( "#" )) {
 | 
			
		||||
 
 | 
			
		||||
@@ -21,13 +21,14 @@ package com.lyndir.masterpassword.model.impl;
 | 
			
		||||
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.*;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.annotation.*;
 | 
			
		||||
import com.fasterxml.jackson.databind.*;
 | 
			
		||||
import com.fasterxml.jackson.databind.ObjectMapper;
 | 
			
		||||
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 java.util.LinkedHashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
import org.joda.time.Instant;
 | 
			
		||||
 | 
			
		||||
@@ -220,6 +221,7 @@ public class MPJSONFile extends MPJSONAnyObject {
 | 
			
		||||
        @Nullable
 | 
			
		||||
        Ext _ext_mpw;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static class Ext extends MPJSONAnyObject {
 | 
			
		||||
 | 
			
		||||
            @Nullable
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
 | 
			
		||||
package com.lyndir.masterpassword.model.impl;
 | 
			
		||||
 | 
			
		||||
import static com.lyndir.masterpassword.model.impl.MPJSONFile.objectMapper;
 | 
			
		||||
import static com.lyndir.masterpassword.model.impl.MPJSONFile.*;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.core.JsonProcessingException;
 | 
			
		||||
import com.lyndir.masterpassword.MPKeyUnavailableException;
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
 | 
			
		||||
package com.lyndir.masterpassword.model.impl;
 | 
			
		||||
 | 
			
		||||
import static com.lyndir.masterpassword.model.impl.MPJSONFile.objectMapper;
 | 
			
		||||
import static com.lyndir.masterpassword.model.impl.MPJSONFile.*;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.core.JsonParseException;
 | 
			
		||||
import com.fasterxml.jackson.databind.JsonMappingException;
 | 
			
		||||
 
 | 
			
		||||
@@ -64,4 +64,4 @@
 | 
			
		||||
    "_ext_other": {
 | 
			
		||||
        "save": "me"
 | 
			
		||||
    }
 | 
			
		||||
 }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -306,8 +306,8 @@ public class EmergencyActivity extends Activity {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                try {
 | 
			
		||||
                    sitePassword = masterKey.siteResult( siteName, version.getAlgorithm(), counter, MPKeyPurpose.Authentication, null, type, null
 | 
			
		||||
                    );
 | 
			
		||||
                    sitePassword = masterKey.siteResult( siteName, version.getAlgorithm(), counter,
 | 
			
		||||
                                                         MPKeyPurpose.Authentication, null, type, null );
 | 
			
		||||
 | 
			
		||||
                    runOnUiThread( new Runnable() {
 | 
			
		||||
                        @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -148,7 +148,8 @@ public final class Preferences {
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public MPResultType getDefaultResultType() {
 | 
			
		||||
        return MPResultType.values()[prefs().getInt( PREF_RESULT_TYPE, getDefaultVersion().getAlgorithm().mpw_default_result_type().ordinal() )];
 | 
			
		||||
        return MPResultType.values()[
 | 
			
		||||
                prefs().getInt( PREF_RESULT_TYPE, getDefaultVersion().getAlgorithm().mpw_default_result_type().ordinal() )];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean setDefaultVersion(final MPAlgorithm.Version value) {
 | 
			
		||||
@@ -161,6 +162,7 @@ public final class Preferences {
 | 
			
		||||
 | 
			
		||||
    @Nonnull
 | 
			
		||||
    public MPAlgorithm.Version getDefaultVersion() {
 | 
			
		||||
        return MPAlgorithm.Version.values()[prefs().getInt( PREF_ALGORITHM_VERSION, MPAlgorithm.Version.CURRENT.ordinal() )];
 | 
			
		||||
        return MPAlgorithm.Version.values()[
 | 
			
		||||
                prefs().getInt( PREF_ALGORITHM_VERSION, MPAlgorithm.Version.CURRENT.ordinal() )];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ import javax.annotation.Nullable;
 | 
			
		||||
public class MPIncognitoUser extends MPBasicUser<MPIncognitoSite> {
 | 
			
		||||
 | 
			
		||||
    public MPIncognitoUser(final String fullName) {
 | 
			
		||||
        super( fullName, MPAlgorithm.Version.CURRENT.getAlgorithm());
 | 
			
		||||
        super( fullName, MPAlgorithm.Version.CURRENT.getAlgorithm() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Nullable
 | 
			
		||||
 
 | 
			
		||||
@@ -28,9 +28,8 @@ import com.lyndir.masterpassword.MPAlgorithm;
 | 
			
		||||
import com.lyndir.masterpassword.MPResultType;
 | 
			
		||||
import com.lyndir.masterpassword.gui.Res;
 | 
			
		||||
import com.lyndir.masterpassword.gui.util.Components;
 | 
			
		||||
import com.lyndir.masterpassword.model.*;
 | 
			
		||||
import com.lyndir.masterpassword.model.MPUser;
 | 
			
		||||
import com.lyndir.masterpassword.model.impl.*;
 | 
			
		||||
import com.lyndir.masterpassword.model.impl.MPFileSite;
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import java.awt.event.*;
 | 
			
		||||
import javax.annotation.Nonnull;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user