forked from I2P_Developers/i2p.i2p
Util: Number formatting tweaks (ticket #1913)
This commit is contained in:
@ -1555,7 +1555,7 @@ public class DataHelper {
|
||||
case 6: return str + "Ei";
|
||||
case 7: return str + "Zi";
|
||||
case 8: return str + "Yi";
|
||||
default: return bytes + "";
|
||||
default: return Long.toString(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1589,6 +1589,9 @@ public class DataHelper {
|
||||
* @since 0.9.31
|
||||
*/
|
||||
public static String formatSize2(long bytes, boolean nonBreaking) {
|
||||
String space = nonBreaking ? " " : " ";
|
||||
if (bytes < 1024)
|
||||
return bytes + space;
|
||||
double val = bytes;
|
||||
int scale = 0;
|
||||
while (val >= 1024) {
|
||||
@ -1597,10 +1600,14 @@ public class DataHelper {
|
||||
}
|
||||
|
||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
||||
if (val >= 200) {
|
||||
fmt.setMaximumFractionDigits(0);
|
||||
} else if (val >= 20) {
|
||||
fmt.setMaximumFractionDigits(1);
|
||||
}
|
||||
|
||||
// Replace with thin non-breaking space   (more consistent/predictable width between fonts & point sizes)
|
||||
|
||||
String space = nonBreaking ? " " : " ";
|
||||
String str = fmt.format(val) + space;
|
||||
switch (scale) {
|
||||
case 1: return str + "Ki";
|
||||
@ -1643,6 +1650,9 @@ public class DataHelper {
|
||||
* @since 0.9.34
|
||||
*/
|
||||
public static String formatSize2Decimal(long bytes, boolean nonBreaking) {
|
||||
String space = nonBreaking ? " " : " ";
|
||||
if (bytes < 1000)
|
||||
return bytes + space;
|
||||
double val = bytes;
|
||||
int scale = 0;
|
||||
while (val >= 1000) {
|
||||
@ -1650,7 +1660,11 @@ public class DataHelper {
|
||||
val /= 1000;
|
||||
}
|
||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
||||
String space = nonBreaking ? " " : " ";
|
||||
if (val >= 200) {
|
||||
fmt.setMaximumFractionDigits(0);
|
||||
} else if (val >= 20) {
|
||||
fmt.setMaximumFractionDigits(1);
|
||||
}
|
||||
String str = fmt.format(val) + space;
|
||||
switch (scale) {
|
||||
case 1: return str + "K";
|
||||
|
14
history.txt
14
history.txt
@ -1,3 +1,17 @@
|
||||
2018-02-11 zzz
|
||||
* Util: Number formatting tweaks (ticket #1913)
|
||||
|
||||
2018-02-09 zzz
|
||||
* SusiMail:
|
||||
- Don't collapse spaces in email display (ticket #2156)
|
||||
- Constant URL for attachments
|
||||
- Fixes when no subject is present
|
||||
- Filename encoding fixes
|
||||
- Handle lower case in Q-P decode
|
||||
- Don't show the no-charset warning
|
||||
- Thread loading mail from disk
|
||||
- More error handling fixes
|
||||
|
||||
2018-02-08 zzz
|
||||
* SusiMail:
|
||||
- Error handling fixes
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 3;
|
||||
public final static long BUILD = 4;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
Reference in New Issue
Block a user