Resolve warnings and inspections.
This commit is contained in:
parent
c51262ccc2
commit
2db0bb35d5
@ -48,5 +48,5 @@ public interface MPQuestion extends Comparable<MPQuestion> {
|
|||||||
// -- Relationship
|
// -- Relationship
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
MPSite getSite();
|
MPSite<?> getSite();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author lhunath, 2018-05-14
|
* @author lhunath, 2018-05-14
|
||||||
*/
|
*/
|
||||||
public interface MPSite<Q extends MPQuestion> extends Comparable<MPSite<Q>> {
|
public interface MPSite<Q extends MPQuestion> extends Comparable<MPSite<?>> {
|
||||||
|
|
||||||
// - Meta
|
// - Meta
|
||||||
|
|
||||||
|
@ -29,13 +29,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
*/
|
*/
|
||||||
public class MPSiteResult implements Comparable<MPSiteResult> {
|
public class MPSiteResult implements Comparable<MPSiteResult> {
|
||||||
|
|
||||||
private final MPSite site;
|
private final MPSite<?> site;
|
||||||
|
|
||||||
public MPSiteResult(final MPSite site) {
|
public MPSiteResult(final MPSite<?> site) {
|
||||||
this.site = site;
|
this.site = site;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MPSite getSite() {
|
public MPSite<?> getSite() {
|
||||||
return site;
|
return site;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author lhunath, 2018-05-14
|
* @author lhunath, 2018-05-14
|
||||||
*/
|
*/
|
||||||
public interface MPUser<S extends MPSite> extends Comparable<MPUser<?>> {
|
public interface MPUser<S extends MPSite<?>> extends Comparable<MPUser<?>> {
|
||||||
|
|
||||||
// - Meta
|
// - Meta
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package com.lyndir.masterpassword.model;
|
package com.lyndir.masterpassword.model;
|
||||||
|
|
||||||
import com.google.common.collect.*;
|
import com.google.common.collect.*;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.SortedSet;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,8 +35,8 @@ public abstract class MPUserManager<U extends MPUser<?>> {
|
|||||||
usersByName.put( user.getFullName(), user );
|
usersByName.put( user.getFullName(), user );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<U> getUsers() {
|
public Collection<U> getUsers() {
|
||||||
return FluentIterable.from( usersByName.values() ).toSortedSet( Ordering.natural() );
|
return ImmutableList.copyOf( usersByName.values() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public U getUserNamed(final String fullName) {
|
public U getUserNamed(final String fullName) {
|
||||||
|
@ -68,7 +68,7 @@ public abstract class MPBasicQuestion implements MPQuestion {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public abstract MPBasicSite getSite();
|
public abstract MPBasicSite<?> getSite();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -164,7 +164,7 @@ public abstract class MPBasicSite<Q extends MPQuestion> implements MPSite<Q> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull final MPSite<Q> o) {
|
public int compareTo(@NotNull final MPSite<?> o) {
|
||||||
return getName().compareTo( o.getName() );
|
return getName().compareTo( o.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* @author lhunath, 2014-06-08
|
* @author lhunath, 2014-06-08
|
||||||
*/
|
*/
|
||||||
public abstract class MPBasicUser<S extends MPBasicSite> implements MPUser<S> {
|
public abstract class MPBasicUser<S extends MPBasicSite<?>> implements MPUser<S> {
|
||||||
|
|
||||||
private int avatar;
|
private int avatar;
|
||||||
private final String fullName;
|
private final String fullName;
|
||||||
|
@ -20,8 +20,6 @@ package com.lyndir.masterpassword.model.impl;
|
|||||||
|
|
||||||
import com.google.common.primitives.UnsignedInteger;
|
import com.google.common.primitives.UnsignedInteger;
|
||||||
import com.lyndir.masterpassword.*;
|
import com.lyndir.masterpassword.*;
|
||||||
import com.lyndir.masterpassword.model.MPSite;
|
|
||||||
import com.lyndir.masterpassword.model.MPUser;
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.time.Instant;
|
import org.joda.time.Instant;
|
||||||
|
@ -96,15 +96,12 @@ public class MPFileUserManager extends MPUserManager<MPFileUser> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableList<File> listUserFiles(final File userFilesDirectory) {
|
private static ImmutableList<File> listUserFiles(final File userFilesDirectory) {
|
||||||
return ImmutableList.copyOf( ifNotNullElse( userFilesDirectory.listFiles( new FilenameFilter() {
|
return ImmutableList.copyOf( ifNotNullElse( userFilesDirectory.listFiles( (dir, name) -> {
|
||||||
@Override
|
|
||||||
public boolean accept(final File dir, final String name) {
|
|
||||||
for (final MPMarshalFormat format : MPMarshalFormat.values())
|
for (final MPMarshalFormat format : MPMarshalFormat.values())
|
||||||
if (name.endsWith( format.fileSuffix() ))
|
if (name.endsWith( format.fileSuffix() ))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
} ), new File[0] ) );
|
} ), new File[0] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +121,7 @@ public class MPFileUserManager extends MPUserManager<MPFileUser> {
|
|||||||
public void save(final MPFileUser user, final MPMasterKey masterKey)
|
public void save(final MPFileUser user, final MPMasterKey masterKey)
|
||||||
throws MPKeyUnavailableException {
|
throws MPKeyUnavailableException {
|
||||||
try {
|
try {
|
||||||
final MPMarshalFormat format = user.getFormat();
|
MPMarshalFormat format = user.getFormat();
|
||||||
new CharSink() {
|
new CharSink() {
|
||||||
@Override
|
@Override
|
||||||
public Writer openStream()
|
public Writer openStream()
|
||||||
|
@ -33,6 +33,7 @@ import java.util.regex.Pattern;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.Instant;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +78,7 @@ public class MPFlatUnmarshaller implements MPUnmarshaller {
|
|||||||
else
|
else
|
||||||
// Ends the header.
|
// Ends the header.
|
||||||
user = new MPFileUser( fullName, keyID, MPAlgorithm.Version.fromInt( mpVersion ).getAlgorithm(),
|
user = new MPFileUser( fullName, keyID, MPAlgorithm.Version.fromInt( mpVersion ).getAlgorithm(),
|
||||||
avatar, defaultType, new DateTime( 0 ), MPMarshalFormat.Flat,
|
avatar, defaultType, new Instant( 0 ), MPMarshalFormat.Flat,
|
||||||
clearContent? MPMarshaller.ContentMode.VISIBLE: MPMarshaller.ContentMode.PROTECTED );
|
clearContent? MPMarshaller.ContentMode.VISIBLE: MPMarshaller.ContentMode.PROTECTED );
|
||||||
|
|
||||||
// Comment.
|
// Comment.
|
||||||
|
@ -25,6 +25,7 @@ import javax.annotation.Nonnull;
|
|||||||
/**
|
/**
|
||||||
* @author lhunath, 14-12-07
|
* @author lhunath, 14-12-07
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface MPMarshaller {
|
public interface MPMarshaller {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -86,7 +86,7 @@ public final class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getTestsPassed() {
|
public Set<String> getTestsPassed() {
|
||||||
return prefs().getStringSet( PREF_TESTS_PASSED, ImmutableSet.<String>of() );
|
return prefs().getStringSet( PREF_TESTS_PASSED, ImmutableSet.of() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setRememberFullName(final boolean enabled) {
|
public boolean setRememberFullName(final boolean enabled) {
|
||||||
|
@ -28,13 +28,12 @@ import android.view.View;
|
|||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import com.google.common.collect.FluentIterable;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.util.concurrent.*;
|
import com.google.common.util.concurrent.*;
|
||||||
import com.lyndir.lhunath.opal.system.logging.Logger;
|
import com.lyndir.lhunath.opal.system.logging.Logger;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
|
|||||||
private ListenableFuture<Boolean> testFuture;
|
private ListenableFuture<Boolean> testFuture;
|
||||||
@Nullable
|
@Nullable
|
||||||
private Runnable action;
|
private Runnable action;
|
||||||
private ImmutableSet<String> testNames;
|
private Set<String> testNames;
|
||||||
|
|
||||||
public static void startNoSkip(final Context context) {
|
public static void startNoSkip(final Context context) {
|
||||||
context.startActivity( new Intent( context, TestActivity.class ) );
|
context.startActivity( new Intent( context, TestActivity.class ) );
|
||||||
@ -80,35 +79,22 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
|
|||||||
setContentView( R.layout.activity_test );
|
setContentView( R.layout.activity_test );
|
||||||
ButterKnife.bind( this );
|
ButterKnife.bind( this );
|
||||||
|
|
||||||
nativeKDFField.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
|
nativeKDFField.setOnCheckedChangeListener( (buttonView, isChecked) -> {
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
|
|
||||||
preferences.setNativeKDFEnabled( isChecked );
|
preferences.setNativeKDFEnabled( isChecked );
|
||||||
// TODO: MasterKey.setAllowNativeByDefault( isChecked );
|
// TODO: MasterKey.setAllowNativeByDefault( isChecked );
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setStatus( 0, 0, null );
|
setStatus( 0, 0, null );
|
||||||
testSuite = new MPTestSuite();
|
testSuite = new MPTestSuite();
|
||||||
testSuite.setListener( this );
|
testSuite.setListener( this );
|
||||||
testNames = FluentIterable.from( testSuite.getTests().getCases() ).transform(
|
testNames = testSuite.getTests().getCases().stream()
|
||||||
new Function<MPTests.Case, String>() {
|
.map( input -> (input == null)? null: input.identifier )
|
||||||
@Nullable
|
.filter( Objects::nonNull ).collect( Collectors.toSet() );
|
||||||
@Override
|
|
||||||
public String apply(@Nullable final MPTests.Case input) {
|
|
||||||
return (input == null)? null: input.identifier;
|
|
||||||
}
|
|
||||||
} ).filter( Predicates.notNull() ).toSet();
|
|
||||||
}
|
}
|
||||||
catch (final MPTestSuite.UnavailableException e) {
|
catch (final MPTestSuite.UnavailableException e) {
|
||||||
logger.err( e, "While loading test suite" );
|
logger.err( e, "While loading test suite" );
|
||||||
setStatus( R.string.tests_unavailable, R.string.tests_btn_unavailable, new Runnable() {
|
setStatus( R.string.tests_unavailable, R.string.tests_btn_unavailable, this::finish );
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,31 +119,18 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable final Boolean result) {
|
public void onSuccess(@Nullable final Boolean result) {
|
||||||
if ((result != null) && result)
|
if ((result != null) && result)
|
||||||
setStatus( R.string.tests_passed, R.string.tests_btn_passed, new Runnable() {
|
setStatus( R.string.tests_passed, R.string.tests_btn_passed, () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
preferences.setTestsPassed( testNames );
|
preferences.setTestsPassed( testNames );
|
||||||
finish();
|
finish();
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
else
|
else
|
||||||
setStatus( R.string.tests_failed, R.string.tests_btn_failed, new Runnable() {
|
setStatus( R.string.tests_failed, R.string.tests_btn_failed, () -> startTestSuite() );
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
startTestSuite();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable t) {
|
public void onFailure(final Throwable t) {
|
||||||
logger.err( t, "While running test suite" );
|
logger.err( t, "While running test suite" );
|
||||||
setStatus( R.string.tests_failed, R.string.tests_btn_failed, new Runnable() {
|
setStatus( R.string.tests_failed, R.string.tests_btn_failed, () -> finish() );
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}, mainExecutor );
|
}, mainExecutor );
|
||||||
}
|
}
|
||||||
@ -184,14 +157,11 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progress(final int current, final int max, final String messageFormat, final Object... args) {
|
public void progress(final int current, final int max, final String messageFormat, final Object... args) {
|
||||||
runOnUiThread( new Runnable() {
|
runOnUiThread( () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
logView.append( strf( "%n" + messageFormat, args ) );
|
logView.append( strf( "%n" + messageFormat, args ) );
|
||||||
|
|
||||||
progressView.setMax( max );
|
progressView.setMax( max );
|
||||||
progressView.setProgress( current );
|
progressView.setProgress( current );
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,15 +189,11 @@ public class ModelAuthenticationPanel extends AuthenticationPanel<MPFileUser> im
|
|||||||
}
|
}
|
||||||
}, new JButton( Res.iconQuestion() ) {
|
}, new JButton( Res.iconQuestion() ) {
|
||||||
{
|
{
|
||||||
addActionListener( new ActionListener() {
|
addActionListener( e -> JOptionPane.showMessageDialog(
|
||||||
@Override
|
ModelAuthenticationPanel.this, //
|
||||||
public void actionPerformed(final ActionEvent e) {
|
|
||||||
JOptionPane.showMessageDialog( ModelAuthenticationPanel.this, //
|
|
||||||
strf( "Reads users and sites from the directory at:%n%s",
|
strf( "Reads users and sites from the directory at:%n%s",
|
||||||
MPFileUserManager.get().getPath().getAbsolutePath() ), //
|
MPFileUserManager.get().getPath().getAbsolutePath() ), //
|
||||||
"Help", JOptionPane.INFORMATION_MESSAGE );
|
"Help", JOptionPane.INFORMATION_MESSAGE ) );
|
||||||
}
|
|
||||||
} );
|
|
||||||
setToolTipText( "More information." );
|
setToolTipText( "More information." );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -28,6 +28,7 @@ import com.lyndir.masterpassword.*;
|
|||||||
import com.lyndir.masterpassword.gui.Res;
|
import com.lyndir.masterpassword.gui.Res;
|
||||||
import com.lyndir.masterpassword.gui.util.Components;
|
import com.lyndir.masterpassword.gui.util.Components;
|
||||||
import com.lyndir.masterpassword.gui.util.UnsignedIntegerModel;
|
import com.lyndir.masterpassword.gui.util.UnsignedIntegerModel;
|
||||||
|
import com.lyndir.masterpassword.model.MPSite;
|
||||||
import com.lyndir.masterpassword.model.MPUser;
|
import com.lyndir.masterpassword.model.MPUser;
|
||||||
import com.lyndir.masterpassword.model.impl.*;
|
import com.lyndir.masterpassword.model.impl.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -46,7 +47,7 @@ import javax.swing.event.DocumentListener;
|
|||||||
/**
|
/**
|
||||||
* @author lhunath, 2014-06-08
|
* @author lhunath, 2014-06-08
|
||||||
*/
|
*/
|
||||||
public abstract class PasswordFrame<U extends MPUser<S>, S extends MPBasicSite> extends JFrame implements DocumentListener {
|
public abstract class PasswordFrame<U extends MPUser<S>, S extends MPSite<?>> extends JFrame implements DocumentListener {
|
||||||
|
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
@SuppressWarnings("FieldCanBeLocal")
|
||||||
private final Components.GradientPanel root;
|
private final Components.GradientPanel root;
|
||||||
|
@ -48,7 +48,7 @@ public class UnlockFrame extends JFrame {
|
|||||||
private Future<?> identiconFuture;
|
private Future<?> identiconFuture;
|
||||||
private boolean incognito;
|
private boolean incognito;
|
||||||
@Nullable
|
@Nullable
|
||||||
private MPUser<? extends MPSite> user;
|
private MPUser<? extends MPSite<?>> user;
|
||||||
|
|
||||||
public UnlockFrame(final SignInCallback signInCallback) {
|
public UnlockFrame(final SignInCallback signInCallback) {
|
||||||
super( "Unlock Master Password" );
|
super( "Unlock Master Password" );
|
||||||
@ -144,7 +144,7 @@ public class UnlockFrame extends JFrame {
|
|||||||
SwingUtilities.invokeLater( () -> ifNotNullElse( authenticationPanel.getFocusComponent(), signInButton ).requestFocusInWindow() );
|
SwingUtilities.invokeLater( () -> ifNotNullElse( authenticationPanel.getFocusComponent(), signInButton ).requestFocusInWindow() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateUser(@Nullable final MPUser<? extends MPSite> user) {
|
void updateUser(@Nullable final MPUser<? extends MPSite<?>> user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
checkSignIn();
|
checkSignIn();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user