diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt index f7e4f5c3..1ef3a74f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt @@ -3,7 +3,6 @@ package com.simplemobiletools.filemanager.dialogs import android.content.Context import android.content.res.Resources import android.support.v7.app.AlertDialog -import android.text.format.DateFormat import android.view.LayoutInflater import android.view.ViewGroup import com.simplemobiletools.filemanager.Config @@ -12,7 +11,6 @@ import com.simplemobiletools.filemanager.extensions.* import kotlinx.android.synthetic.main.item_properties.view.* import kotlinx.android.synthetic.main.property_item.view.* import java.io.File -import java.util.* class PropertiesDialog() { lateinit var mContext: Context @@ -36,7 +34,7 @@ class PropertiesDialog() { addProperty(R.string.name, file.name) addProperty(R.string.path, file.parent) addProperty(R.string.size, getItemSize(file)) - addProperty(R.string.last_modified, formatLastModified(file.lastModified())) + addProperty(R.string.last_modified, file.lastModified().formatLastModified()) if (file.isDirectory) { addProperty(R.string.files_count, mFilesCnt.toString()) @@ -73,12 +71,6 @@ class PropertiesDialog() { return file.length().formatSize() } - private fun formatLastModified(ts: Long): String { - val cal = Calendar.getInstance(Locale.ENGLISH) - cal.timeInMillis = ts - return DateFormat.format("dd.MM.yyyy HH:mm", cal).toString() - } - private fun getDirectorySize(dir: File): Long { var size = 0L if (dir.exists()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt index 3fcceb29..31cafe25 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/extensions/long.kt @@ -1,6 +1,8 @@ package com.simplemobiletools.filemanager.extensions +import android.text.format.DateFormat import java.text.DecimalFormat +import java.util.* fun Long.formatSize(): String { if (this <= 0) @@ -10,3 +12,9 @@ fun Long.formatSize(): String { val digitGroups = (Math.log10(toDouble()) / Math.log10(1024.0)).toInt() return DecimalFormat("#,##0.#").format(this / Math.pow(1024.0, digitGroups.toDouble())) + " " + units[digitGroups] } + +fun Long.formatLastModified(): String { + val cal = Calendar.getInstance(Locale.ENGLISH) + cal.timeInMillis = this + return DateFormat.format("dd.MM.yyyy HH:mm", cal).toString() +}