aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java16
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java18
3 files changed, 43 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d84f6aa..536c42a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-04-19 Jiri Vanek <[email protected]>
+
+ Splashscreen now strip commit id from released versions
+ * netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java:
+ (stripCommitFromVersion) new method responsible for cutting
+ (drawBase) now using stripCommitFromVersion before printing drawing version
+ to splashscreen
+ * tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java:
+ (stripCommitFromVersion) new test for
+
+
2013-04-24 Adam Domurad <[email protected]>
* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java:
diff --git a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java
index 8bef868..2b14085 100644
--- a/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java
+++ b/netx/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainter.java
@@ -371,6 +371,17 @@ public class BasePainter implements Observer {
return tt;
}
+ static String stripCommitFromVersion(String version) {
+ if (version.contains("pre+")) {
+ return version;
+ }
+ int i = version.indexOf("+");
+ if (i < 0) {
+ return version;
+ }
+ return version.substring(0, version.indexOf("+"));
+ }
+
private final class MovingTextRunner extends Observable implements Runnable {
private static final int MAX_ANIMATION_VALUE = 10000;
@@ -499,11 +510,12 @@ public class BasePainter implements Observer {
g2d.setColor(plainTextColor);
FontMetrics fm = g2d.getFontMetrics();
if (version != null) {
- int y = master.getSplashWidth() - fm.stringWidth(version + " ");
+ String niceVersion=stripCommitFromVersion(version);
+ int y = master.getSplashWidth() - fm.stringWidth(niceVersion + " ");
if (y < 0) {
y = 0;
}
- g2d.drawString(version, y, fm.getHeight());
+ g2d.drawString(niceVersion, y, fm.getHeight());
}
return fm;
}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java
index 53d499a..ec4b97a 100644
--- a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java
@@ -105,4 +105,22 @@ public class BasePainterTest {
}
+
+ @Test
+ public void stripCommitFromVersion() {
+ Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4"));
+ Assert.assertEquals("1.4.2", BasePainter.stripCommitFromVersion("1.4.2"));
+ Assert.assertEquals("1.4pre", BasePainter.stripCommitFromVersion("1.4pre"));
+ Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+657tgkhyu4iy5"));
+ Assert.assertEquals("1.4.2", BasePainter.stripCommitFromVersion("1.4.2+887tgjh07tftvhjj"));
+ Assert.assertEquals("1.4pre+0977tyugg", BasePainter.stripCommitFromVersion("1.4pre+0977tyugg"));
+
+ Assert.assertEquals("1.4pre+", BasePainter.stripCommitFromVersion("1.4pre+"));
+ Assert.assertEquals("1.4pre+foo+", BasePainter.stripCommitFromVersion("1.4pre+foo+"));
+ Assert.assertEquals("1.4pre+foo+bar", BasePainter.stripCommitFromVersion("1.4pre+foo+bar"));
+
+ Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+"));
+ Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+foo+"));
+ Assert.assertEquals("1.4", BasePainter.stripCommitFromVersion("1.4+foo+bar"));
+ }
}