From b45e526fa7f5a2501f8b8326d1cb380f6a88b3fe Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Oct 2016 16:19:34 +0200 Subject: [PATCH] display image resolution at the properties dialog --- .../filemanager/dialogs/PropertiesDialog.kt | 4 +++- app/src/main/res/layout/item_properties.xml | 17 +++++++++++++++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-pt-rPT/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + .../filepicker/models/FileDirItem.kt | 13 ++++++++++++- 9 files changed, 38 insertions(+), 2 deletions(-) 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 bbc2d4c4..fc2e324c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/PropertiesDialog.kt @@ -41,7 +41,9 @@ class PropertiesDialog : DialogFragment() { properties_files_count.visibility = View.VISIBLE properties_files_count.text = mFilesCnt.toString() } else if (mItem.isImage()) { - + properties_resolution_label.visibility = View.VISIBLE + properties_resolution.visibility = View.VISIBLE + properties_resolution.text = mItem.resolution } val file = File(mItem.path) diff --git a/app/src/main/res/layout/item_properties.xml b/app/src/main/res/layout/item_properties.xml index aba3547a..0c6fe29a 100644 --- a/app/src/main/res/layout/item_properties.xml +++ b/app/src/main/res/layout/item_properties.xml @@ -85,4 +85,21 @@ android:textColor="@android:color/black" android:visibility="gone"/> + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 3743473e..0d948d0b 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -44,6 +44,7 @@ Size Last modified Files inside + Resolution 1 Datei/Ordner gelöscht diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index c39891b4..5f4c1ef5 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -44,6 +44,7 @@ Dimensione Ultima modifica File contenuti + Resolution 1 elemento eliminato diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 363a1bed..3888caf1 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -44,6 +44,7 @@ Size Last modified Files inside + Resolution 1 アイテムを削除しました diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 035459d4..fbc44630 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -44,6 +44,7 @@ Tamanho Última modificação Ficheiros no interior + Resolution 1 item eliminado diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 16b869c0..7f1787f5 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -44,6 +44,7 @@ Size Last modified Files inside + Resolution 1 objekt borttagen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0baec469..2ade1d30 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,6 +44,7 @@ Size Last modified Files inside + Resolution 1 item deleted diff --git a/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt b/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt index e0eaf3b3..d3e0c8bb 100644 --- a/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt +++ b/library/src/main/kotlin/com/simplemobiletools/filepicker/models/FileDirItem.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.filepicker.models +import android.graphics.Bitmap import android.graphics.BitmapFactory class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, val children: Int, val size: Long) : @@ -22,6 +23,16 @@ class FileDirItem(val path: String, val name: String, val isDirectory: Boolean, fun isImage(): Boolean { val options = BitmapFactory.Options() options.inJustDecodeBounds = true - return options.outWidth !== -1 && options.outHeight !== -1 + BitmapFactory.decodeFile(path, options) + return options.outWidth != -1 && options.outHeight != -1 } + + val resolution: String + get () { + val bitmap: Bitmap? = BitmapFactory.decodeFile(path) + if (bitmap == null) + return "" + + return "${bitmap.width} x ${bitmap.height}" + } }