diff --git a/src/androidTest/java/com/nutomic/syncthingandroid/test/syncthing/RestApiTest.java b/src/androidTest/java/com/nutomic/syncthingandroid/test/syncthing/RestApiTest.java index 39860cbc..927cfaa3 100644 --- a/src/androidTest/java/com/nutomic/syncthingandroid/test/syncthing/RestApiTest.java +++ b/src/androidTest/java/com/nutomic/syncthingandroid/test/syncthing/RestApiTest.java @@ -87,8 +87,8 @@ public class RestApiTest extends AndroidTestCase { @SmallTest public void testGetReadableTransferRate() { - assertEquals("1 Mib/s", RestApi.readableTransferRate(getContext(), 1048576)); - assertEquals("1 Gib/s", RestApi.readableTransferRate(getContext(), 1073741824)); + assertEquals("1 MiB/s", RestApi.readableTransferRate(getContext(), 8388608L)); + assertEquals("1 GiB/s", RestApi.readableTransferRate(getContext(), 8589934592L)); } @MediumTest diff --git a/src/androidTest/java/com/nutomic/syncthingandroid/test/util/DevicesAdapterTest.java b/src/androidTest/java/com/nutomic/syncthingandroid/test/util/DevicesAdapterTest.java index cf87797f..ec5ab68e 100644 --- a/src/androidTest/java/com/nutomic/syncthingandroid/test/util/DevicesAdapterTest.java +++ b/src/androidTest/java/com/nutomic/syncthingandroid/test/util/DevicesAdapterTest.java @@ -30,8 +30,8 @@ public class DevicesAdapterTest extends AndroidTestCase { mDevice.deviceID = "123-456-789"; mConnection.completion = 100; - mConnection.inBits = 1048576; - mConnection.outBits = 1073741824; + mConnection.inBits = 8388608L; + mConnection.outBits = 8589934592L; } @@ -57,8 +57,8 @@ public class DevicesAdapterTest extends AndroidTestCase { assertEquals(getContext().getString(R.string.device_up_to_date), ((TextView) v.findViewById(R.id.status)).getText().toString()); - assertEquals("1 Mib/s", ((TextView) v.findViewById(R.id.download)).getText().toString()); - assertEquals("1 Gib/s", ((TextView) v.findViewById(R.id.upload)).getText().toString()); + assertEquals("1 MiB/s", ((TextView) v.findViewById(R.id.download)).getText().toString()); + assertEquals("1 GiB/s", ((TextView) v.findViewById(R.id.upload)).getText().toString()); } } diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index 3b2d26d8..48085d2b 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -577,9 +577,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, public static String readableTransferRate(Context context, long bits) { final String[] units = context.getResources().getStringArray(R.array.transfer_rate_units); if (bits <= 0) return "0 " + units[0]; - int digitGroups = (int) (Math.log10(bits) / Math.log10(1024)); + long bytes = bits / 8; + int digitGroups = (int) (Math.log10(bytes) / Math.log10(1024)); return new DecimalFormat("#,##0.#") - .format(bits / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; + .format(bytes / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; } /** diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 95b80aae..a2054f45 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -425,11 +425,11 @@ Please report any problems you encounter via Github. - b/s - Kib/s - Mib/s - Gib/s - Tib/s + B/s + KiB/s + MiB/s + GiB/s + TiB/s