OSDN Git Service

feat: Now software version check is available.
authorhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Wed, 15 Sep 2021 07:59:51 +0000 (16:59 +0900)
committerhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Wed, 15 Sep 2021 07:59:51 +0000 (16:59 +0900)
README.md
src/com/ranfa/lib/CheckVersion.java
src/com/ranfa/main/DelesteRandomSelector.java
version.json

index c78c257..e5ff6a8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ THIS SOFTWARE DEPENDS ON APACHE LICENSE 2.0 BECAUSE THIS USED SOME LIBRARIES WHI
 
 |設定項目|値|デフォルト|説明|
 |:--:|:--:|:--:|:--:|
-|`checkVersion`|`true`/`false`|`true`|アプリケーションのバージョンをチェックします(機能作成中のためこの値は使用していません)|
+|`checkVersion`|`true`/`false`|`true`|アプリケーションのバージョンをチェックします|
 |`checkLibaryUpdates`|`true`/`false`|`true`|楽曲ライブラリの更新を毎回チェックします|
 |`windowWidth`|1以上の整数値|`640`|ウィンドウの横長さを指定します(機能作成中のためこの値は使用していません)|
 |`windowHeight`|1以上の整数値|`360`|ウィンドウの縦長さを指定します(機能作成中のためこの値は使用していません)|
index 06cc8ef..d4976bc 100644 (file)
@@ -1,14 +1,54 @@
 package com.ranfa.lib;
 
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.swing.JOptionPane;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ranfa.main.DelesteRandomSelector;
 
 public class CheckVersion {
-       
-       public static boolean needToBeUpdated() {
-               
+
+       private final static String URI = "https://raw.githubusercontent.com/hizumiaoba/DelesteRandomSelector/master/version.json";
+       private final static String RELEASE_STRING = "https://github.com/hizumiaoba/DelesteRandomSelector/releases";
+
+       public static void needToBeUpdated() {
+               int latestMajor = 0;
+               int latestMinor = 0;
+               int latestPatch = 0;
+               try {
+                       JsonNode node = new ObjectMapper().readTree(new URL(URI));
+                       latestMajor = node.get("major").asInt();
+                       latestMinor = node.get("minor").asInt();
+                       latestPatch = node.get("patch").asInt();
+               } catch (JsonMappingException e) {
+                       // TODO 自動生成された catch ブロック
+                       e.printStackTrace();
+               } catch (JsonProcessingException e) {
+                       // TODO 自動生成された catch ブロック
+                       e.printStackTrace();
+               } catch (MalformedURLException e) {
+                       // TODO 自動生成された catch ブロック
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       // TODO 自動生成された catch ブロック
+                       e.printStackTrace();
+               }
+               if(latestPatch > getPatchVersion()) {
+                       JOptionPane.showInputDialog(null, "ソフトウェアのバグ修正が公開されています。こちらから最新バージョンをダウンロードしてください。\n", RELEASE_STRING);
+               } else if(latestMinor > getMinorVersion()) {
+                       JOptionPane.showInputDialog(null, "ソフトウェアの軽微な機能改修が公開されています。こちらから最新バージョンをダウンロードしてください。\n", RELEASE_STRING);
+               } else if(latestMajor > getMajorVersion()) {
+                       JOptionPane.showInputDialog(null, "大規模なソフトウェアの更新が公開されています。速やかにアップデートをお願いします。\n" + RELEASE_STRING);
+               }
        }
-       
-       
+
+
        /**
         * アノテーションで記載されているバージョンを取得します
         * @since v1.0.0
index 766ead5..c5f1097 100644 (file)
@@ -38,7 +38,7 @@ import com.ranfa.lib.Song;
 import com.ranfa.lib.TwitterIntegration;
 import com.ranfa.lib.Version;
 
-@Version(major = 1, minor = 2, patch = 2)
+@Version(major = 1, minor = 3, patch = 0)
 public class DelesteRandomSelector extends JFrame {
 
        private static ArrayList<Song> selectedSongsList = new ArrayList<Song>();
@@ -124,6 +124,8 @@ public class DelesteRandomSelector extends JFrame {
                                + "\nSong Limit: " + property.getSongLimit()
                                + "\nSaveScoreLog: " + property.isSaveScoreLog()
                                + "\nOutputDebugSentences: " + property.isOutputDebugSentences());
+               if(property.isCheckVersion())
+                       CheckVersion.needToBeUpdated();
                BiConsumer<ArrayList<Song>, ArrayList<Song>> updateConsumer = (list1, list2) -> {
                        LimitedLog.println(this.getClass() + ":[INFO]: " + "Checking database updates...");
                        if(list1.size() > list2.size()) {
index f303869..edba938 100644 (file)
@@ -1,5 +1,5 @@
 {
     "major": 1,
-    "minor": 2,
-    "patch": 2
+    "minor": 3,
+    "patch": 0
 }
\ No newline at end of file