diff --git a/lib/src/main/java/at/bitfire/vcard4android/Utils.kt b/lib/src/main/java/at/bitfire/vcard4android/Utils.kt index ea8e073..24bbee8 100644 --- a/lib/src/main/java/at/bitfire/vcard4android/Utils.kt +++ b/lib/src/main/java/at/bitfire/vcard4android/Utils.kt @@ -21,22 +21,6 @@ object Utils { return values } - fun Long.byteCountToDisplaySize(): String { - val gb = this / 1_073_741_824 // 2^30 - if (gb > 0) { - return "$gb GB" - } - val mb = this / 1_048_576 // 2^20 - if (mb > 0) { - return "$mb MB" - } - val kb = this / 1024 // 2^10 - if (kb > 0) { - return "$kb KB" - } - return "$this B" - } - fun String.capitalize(): String = split(' ').joinToString(" ") { word -> word.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() diff --git a/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoBuilder.kt b/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoBuilder.kt index 7f0f62c..368bb02 100644 --- a/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoBuilder.kt +++ b/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoBuilder.kt @@ -16,7 +16,6 @@ import at.bitfire.vcard4android.BatchOperation import at.bitfire.vcard4android.Constants import at.bitfire.vcard4android.Contact import at.bitfire.vcard4android.Utils.asSyncAdapter -import at.bitfire.vcard4android.Utils.byteCountToDisplaySize import java.io.IOException import java.util.logging.Level @@ -56,7 +55,7 @@ class PhotoBuilder(dataRowUri: Uri, rawContactId: Long?, contact: Contact, readO .appendPath(rawContactId.toString()) .appendPath(RawContacts.DisplayPhoto.CONTENT_DIRECTORY) .build() - Constants.log.log(Level.FINE, "Writing photo to $uri (${data.size.toLong().byteCountToDisplaySize()})") + Constants.log.log(Level.FINE, "Writing photo to $uri (${data.size} bytes)") provider.openAssetFile(uri, "w")?.use { fd -> try { fd.createOutputStream()?.use { os -> diff --git a/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt b/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt index 4033b48..1daef1d 100644 --- a/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt +++ b/lib/src/main/java/at/bitfire/vcard4android/contactrow/PhotoHandler.kt @@ -13,7 +13,6 @@ import android.provider.ContactsContract import android.provider.ContactsContract.CommonDataKinds.Photo import at.bitfire.vcard4android.Constants import at.bitfire.vcard4android.Contact -import at.bitfire.vcard4android.Utils.byteCountToDisplaySize import java.io.ByteArrayOutputStream import java.io.IOException import java.util.logging.Level @@ -73,7 +72,7 @@ class PhotoHandler(val provider: ContentProviderClient?): DataRowHandler() { file.createInputStream().use { // Samsung Android 12 bug: they return a PNG image with MIME type image/jpeg convertToJpeg(it.readBytes(), 75)?.let { jpeg -> - Constants.log.log(Level.FINE, "Got high-res contact photo (${jpeg.size.toLong().byteCountToDisplaySize()})") + Constants.log.log(Level.FINE, "Got high-res contact photo (${jpeg.size} bytes)") contact.photo = jpeg } } @@ -87,7 +86,7 @@ class PhotoHandler(val provider: ContentProviderClient?): DataRowHandler() { values.getAsByteArray(Photo.PHOTO)?.let { thumbnail -> // Samsung Android 12 bug: even the thumbnail is a PNG image convertToJpeg(thumbnail, 95)?.let { jpeg -> - Constants.log.log(Level.FINE, "Got contact photo thumbnail (${jpeg.size.toLong().byteCountToDisplaySize()})") + Constants.log.log(Level.FINE, "Got contact photo thumbnail (${jpeg.size} bytes)") contact.photo = jpeg } }