Skip to content

Commit

Permalink
feat: Add UpdateSettingView.
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Dec 10, 2023
1 parent d24ccf4 commit 87ede51
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/main/java/viewtify/Viewtify.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import com.sun.javafx.application.PlatformImpl;

import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.binding.DoubleExpression;
Expand Down Expand Up @@ -71,9 +73,6 @@
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.stage.WindowEvent;

import com.sun.javafx.application.PlatformImpl;

import kiss.Decoder;
import kiss.Disposable;
import kiss.Encoder;
Expand Down Expand Up @@ -721,6 +720,15 @@ public Class launcher() {
return applicationLaunchingClass;
}

/**
* Find the update site.
*
* @return
*/
public String updateSite() {
return updateArchive;
}

/**
* Deactivate the current application.
*/
Expand Down Expand Up @@ -1633,7 +1641,7 @@ protected ViewDSL declareUI() {
*/
@Override
protected void initialize() {
Update.apply(updateArchive, true);
Update.apply(updateArchive, false);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/viewtify/update/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static String validate(String archive) {
// ====================================
Blueprint origin = Blueprint.detect();
if (!file.isAfter(origin.root)) {
return "The latest version is used, no need to update.";
// return "The latest version is used, no need to update.";
}

// We can update
Expand Down
53 changes: 53 additions & 0 deletions src/main/java/viewtify/update/UpdateSettingView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2023 Nameless Production Committee
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://opensource.org/licenses/mit-license.php
*/
package viewtify.update;

import kiss.Variable;
import viewtify.Viewtify;
import viewtify.ui.UIButton;
import viewtify.ui.View;
import viewtify.ui.ViewDSL;

public class UpdateSettingView extends View {

private UIButton confirm;

/**
* {@inheritDoc}
*/
@Override
protected ViewDSL declareUI() {
return new ViewDSL() {
{
$(vbox, () -> {
form(en("Confirn update"), confirm);
});
}
};
}

/**
* {@inheritDoc}
*/
@Override
public Variable<String> title() {
return en("Update");
}

/**
* {@inheritDoc}
*/
@Override
protected void initialize() {
confirm.text(en("Confirm")).action(() -> {
Update.apply(Viewtify.application().updateSite(), false);
});
}
}

0 comments on commit 87ede51

Please sign in to comment.