Skip to content

Commit

Permalink
update to changed dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kryptonbutterfly committed Feb 9, 2024
1 parent ecc909d commit 02df9be
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 164 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>kryptonbutterfly</groupId>
<artifactId>tiny_totp</artifactId>
<version>3.2.0</version>
<version>4.0.0</version>
<name>TinyTOTP</name>
<description>A TOTP client</description>

Expand Down Expand Up @@ -83,7 +83,7 @@
<dependency>
<groupId>kryptonbutterfly</groupId>
<artifactId>tiny_swing_utils</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
</dependency>
<!-- https://github.com/kryptonbutterfly/maven-repo/packages/2044808 -->
<dependency>
Expand Down
28 changes: 22 additions & 6 deletions src/kryptonbutterfly/totp/TinyTotp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;

import kryptonbutterfly.monads.opt.Opt;
import kryptonbutterfly.os.BaseDirectory;
Expand All @@ -29,6 +32,7 @@
import kryptonbutterfly.totp.ui.passwd.PasswdGui;
import kryptonbutterfly.util.swing.ObservableGui;
import kryptonbutterfly.util.swing.events.GuiCloseEvent;
import kryptonbutterfly.util.swing.state.PersistableValue;
import lombok.SneakyThrows;

public class TinyTotp implements TotpConstants
Expand Down Expand Up @@ -139,12 +143,24 @@ private static void setLookAndFeel()

private static Gson createGson()
{
final var builder = new GsonBuilder();
builder.setPrettyPrinting();
builder.excludeFieldsWithoutExposeAnnotation();
builder.registerTypeAdapter(Color.class, new ColorAdapter());

return builder.create();
return new GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter(Color.class, new ColorAdapter())
.setExclusionStrategies(new ExclusionStrategy()
{
@Override
public boolean shouldSkipField(FieldAttributes f)
{
return f.getAnnotation(PersistableValue.class) == null && f.getAnnotation(Expose.class) == null;
}

@Override
public boolean shouldSkipClass(Class<?> clazz)
{
return false;
}
})
.create();
}

private static final void backgroundInit()
Expand Down
139 changes: 0 additions & 139 deletions src/kryptonbutterfly/totp/prefs/GuiPrefs.java

This file was deleted.

16 changes: 8 additions & 8 deletions src/kryptonbutterfly/totp/prefs/TotpWindowStates.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package kryptonbutterfly.totp.prefs;

import javax.swing.JFrame;

import com.google.gson.annotations.Expose;

import kryptonbutterfly.util.swing.state.WindowState;

public final class TotpWindowStates
{
@Expose
public GuiPrefs mainWindow = new GuiPrefs(100, 100, 400, 600, JFrame.NORMAL);
public WindowState mainWindow = new WindowState(100, 100, 400, 600);

@Expose
public GuiPrefs passwdWindow = new GuiPrefs(100, 100, 300, 120, JFrame.NORMAL);
public WindowState passwdWindow = new WindowState(100, 100, 300, 120);

@Expose
public GuiPrefs createDialog = new GuiPrefs(100, 100, 400, 350, JFrame.NORMAL);
public WindowState createDialog = new WindowState(100, 100, 400, 350);

@Expose
public GuiPrefs categoryDialog = new GuiPrefs(100, 100, 400, 600, JFrame.NORMAL);
public WindowState categoryDialog = new WindowState(100, 100, 400, 600);

@Expose
public GuiPrefs qrScan = new GuiPrefs(100, 100, 640, 400, JFrame.NORMAL);
public WindowState qrScan = new WindowState(100, 100, 640, 400);

@Expose
public GuiPrefs qrExport = new GuiPrefs(100, 100, 230, 280, JFrame.NORMAL);
public WindowState qrExport = new WindowState(100, 100, 230, 280);
}
8 changes: 4 additions & 4 deletions src/kryptonbutterfly/totp/ui/passwd/BL.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

import kryptonbutterfly.monads.opt.Opt;
import kryptonbutterfly.totp.TinyTotp;
import kryptonbutterfly.totp.prefs.GuiPrefs;
import kryptonbutterfly.totp.ui.misc.KeyTypedAdapter;
import kryptonbutterfly.util.swing.Logic;
import kryptonbutterfly.util.swing.events.GuiCloseEvent;
import kryptonbutterfly.util.swing.events.GuiCloseEvent.Result;
import kryptonbutterfly.util.swing.state.WindowState;

final class BL extends Logic<PasswdGui, GuiPrefs>
final class BL extends Logic<PasswdGui, WindowState>
{
private final GuiPrefs guiPrefs;
private final WindowState guiPrefs;

BL(PasswdGui gui, GuiPrefs prefs)
BL(PasswdGui gui, WindowState prefs)
{
super(gui);
this.guiPrefs = prefs;
Expand Down
8 changes: 4 additions & 4 deletions src/kryptonbutterfly/totp/ui/passwd/PasswdGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import javax.swing.JPanel;
import javax.swing.JPasswordField;

import kryptonbutterfly.totp.prefs.GuiPrefs;
import kryptonbutterfly.util.swing.ObservableGui;
import kryptonbutterfly.util.swing.events.GuiCloseEvent;
import kryptonbutterfly.util.swing.state.WindowState;

@SuppressWarnings("serial")
public final class PasswdGui extends ObservableGui<BL, char[], GuiPrefs>
public final class PasswdGui extends ObservableGui<BL, char[], WindowState>
{
final JPasswordField passwordField = new JPasswordField();

Expand All @@ -32,7 +32,7 @@ public PasswdGui()
panel.add(btnUnlock);
}

public PasswdGui(Consumer<GuiCloseEvent<char[]>> closeListener, GuiPrefs prefs)
public PasswdGui(Consumer<GuiCloseEvent<char[]>> closeListener, WindowState prefs)
{
super(closeListener, prefs);

Expand All @@ -44,7 +44,7 @@ public PasswdGui(Consumer<GuiCloseEvent<char[]>> closeListener, GuiPrefs prefs)
}

@Override
protected BL createBusinessLogic(GuiPrefs prefs)
protected BL createBusinessLogic(WindowState prefs)
{
return new BL(this, prefs);
}
Expand Down
2 changes: 1 addition & 1 deletion src/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
requires transitive java.desktop;
requires kryptonbutterfly.mathUtils;
requires kryptonbutterfly.Monads;
requires kryptonbutterfly.SwingUtils;
requires transitive kryptonbutterfly.SwingUtils;
requires kryptonbutterfly.System;
requires kryptonbutterfly.ReflectionUtils;
requires kryptonbutterfly.Cache;
Expand Down

0 comments on commit 02df9be

Please sign in to comment.