Pārlūkot izejas kodu

Merge pull request #564 from greboid/dev2

Add launcher version to the about dialog.
pull/566/head
Chris Smith 9 gadus atpakaļ
vecāks
revīzija
61ca75ff81

+ 5
- 3
src/com/dmdirc/commandline/CommandLineParser.java Parādīt failu

@@ -38,6 +38,7 @@ import java.nio.file.Paths;
38 38
 import java.rmi.RemoteException;
39 39
 import java.util.ArrayList;
40 40
 import java.util.List;
41
+import java.util.Optional;
41 42
 
42 43
 import javax.annotation.Nullable;
43 44
 import javax.inject.Inject;
@@ -78,7 +79,7 @@ public class CommandLineParser {
78 79
     /** Whether to disable error reporting or not. */
79 80
     private boolean disablereporting;
80 81
     /** The version string passed for the launcher. */
81
-    private String launcherVersion;
82
+    private Optional<String> launcherVersion;
82 83
     /** The configuration directory. */
83 84
     private String configDirectory;
84 85
     /** The RMI server we're using. */
@@ -101,6 +102,7 @@ public class CommandLineParser {
101 102
         this.globalConfigProvider = globalConfigProvider;
102 103
         this.uriParser = uriParser;
103 104
         this.systemInfo = systemInfo;
105
+        launcherVersion = Optional.empty();
104 106
     }
105 107
 
106 108
     /**
@@ -239,7 +241,7 @@ public class CommandLineParser {
239 241
                 doHelp();
240 242
                 break;
241 243
             case 'l':
242
-                launcherVersion = param;
244
+                launcherVersion = Optional.ofNullable(param);
243 245
                 break;
244 246
             case 'p':
245 247
                 doDirectory(Paths.get(systemInfo.getProperty("user.dir")));
@@ -416,7 +418,7 @@ public class CommandLineParser {
416 418
      *
417 419
      * @return The version supplied by the launcher, or {@code null} if no launcher is identified.
418 420
      */
419
-    public String getLauncherVersion() {
421
+    public Optional<String> getLauncherVersion() {
420 422
         return launcherVersion;
421 423
     }
422 424
 

+ 7
- 2
src/com/dmdirc/ui/core/about/CoreAboutDialogModel.java Parādīt failu

@@ -26,6 +26,7 @@ import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.commandline.CommandLineOptionsModule;
28 28
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
29
+import com.dmdirc.commandline.CommandLineParser;
29 30
 import com.dmdirc.events.ClientInfoRequestEvent;
30 31
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31 32
 import com.dmdirc.interfaces.ui.AboutDialogModel;
@@ -65,17 +66,19 @@ public class CoreAboutDialogModel implements AboutDialogModel {
65 66
     private List<Developer> otherDevelopers;
66 67
     private List<InfoItem> info;
67 68
     private List<LicensedComponent> licences;
69
+    private CommandLineParser commandLineParser;
68 70
 
69 71
     @Inject
70 72
     public CoreAboutDialogModel(@GlobalConfig final AggregateConfigProvider globalConfig,
71 73
             @Directory(CommandLineOptionsModule.DirectoryType.BASE) final Path baseDirectory,
72 74
             final ClientInfo clientInfo, final DMDircMBassador eventBus,
73
-            final PluginManager pluginManager) {
75
+            final PluginManager pluginManager, final CommandLineParser commandLineParser) {
74 76
         this.globalConfig = globalConfig;
75 77
         this.baseDirectory = baseDirectory;
76 78
         this.clientInfo = clientInfo;
77 79
         this.eventBus = eventBus;
78 80
         this.pluginManager = pluginManager;
81
+        this.commandLineParser = commandLineParser;
79 82
         about = "";
80 83
         mainDevelopers = new ArrayList<>();
81 84
         otherDevelopers = new ArrayList<>();
@@ -118,7 +121,9 @@ public class CoreAboutDialogModel implements AboutDialogModel {
118 121
                         InfoItem.create("Java Default charset",
119 122
                                 Charset.defaultCharset().displayName()),
120 123
                         InfoItem.create("Client Uptime",
121
-                                DateUtils.formatDuration((int) clientInfo.getUptime() / 1000)));
124
+                                DateUtils.formatDuration((int) clientInfo.getUptime() / 1000)),
125
+                        InfoItem.create("Launcher Version",
126
+                                commandLineParser.getLauncherVersion().orElse("Unknown")));
122 127
     }
123 128
 
124 129
     private List<LicensedComponent> createLicensedComponents() {

+ 2
- 4
src/com/dmdirc/updater/UpdaterModule.java Parādīt failu

@@ -109,10 +109,8 @@ public class UpdaterModule {
109 109
             final DMDircMBassador eventBus) {
110 110
         UpdateChecker.init(updateManager, identityController, eventBus);
111 111
 
112
-        if (commandLineParser.getLauncherVersion() != null) {
113
-            LauncherComponent.setLauncherInfo(updateManager,
114
-                    commandLineParser.getLauncherVersion());
115
-        }
112
+        commandLineParser.getLauncherVersion().ifPresent(version ->
113
+                LauncherComponent.setLauncherInfo(updateManager, version));
116 114
 
117 115
         return updateManager;
118 116
     }

+ 7
- 2
test/com/dmdirc/ui/core/about/CoreAboutDialogModelTest.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.ui.core.about;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26
+import com.dmdirc.commandline.CommandLineParser;
26 27
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
27 28
 import com.dmdirc.plugins.PluginInfo;
28 29
 import com.dmdirc.plugins.PluginManager;
@@ -34,6 +35,7 @@ import com.google.common.collect.Lists;
34 35
 
35 36
 import java.nio.file.Path;
36 37
 import java.util.List;
38
+import java.util.Optional;
37 39
 
38 40
 import org.junit.Before;
39 41
 import org.junit.Test;
@@ -57,6 +59,7 @@ public class CoreAboutDialogModelTest {
57 59
     @Mock private PluginMetaData pluginMetaData2;
58 60
     @Mock private PluginInfo pluginInfo1;
59 61
     @Mock private PluginInfo pluginInfo2;
62
+    @Mock private CommandLineParser commandLineParser;
60 63
     private CoreAboutDialogModel instance;
61 64
 
62 65
     @Before
@@ -74,7 +77,9 @@ public class CoreAboutDialogModelTest {
74 77
         when(pluginInfo2.getMetaData()).thenReturn(pluginMetaData2);
75 78
         when(pluginMetaData1.getFriendlyName()).thenReturn("Plugin1");
76 79
         when(pluginMetaData2.getFriendlyName()).thenReturn("Plugin2");
77
-        instance = new CoreAboutDialogModel(globalConfig, path, clientInfo, eventBus, pluginManager);
80
+        when(commandLineParser.getLauncherVersion()).thenReturn(Optional.of("Unknown"));
81
+        instance = new CoreAboutDialogModel(globalConfig, path, clientInfo, eventBus,
82
+                pluginManager, commandLineParser);
78 83
         instance.load();
79 84
     }
80 85
 
@@ -109,7 +114,7 @@ public class CoreAboutDialogModelTest {
109 114
 
110 115
     @Test
111 116
     public void testGetInfo() throws Exception {
112
-        assertEquals(6, instance.getInfo().size());
117
+        assertEquals(7, instance.getInfo().size());
113 118
     }
114 119
 
115 120
     @Test

Notiek ielāde…
Atcelt
Saglabāt