simply the properties dialog

This commit is contained in:
tibbi 2016-10-16 15:48:31 +02:00
parent 93f3fafd58
commit 424ca7dfb5
1 changed files with 20 additions and 19 deletions

View File

@ -6,11 +6,11 @@ import android.support.v4.app.DialogFragment
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.text.format.DateFormat import android.text.format.DateFormat
import android.view.View import android.view.View
import android.widget.TextView
import com.simplemobiletools.filemanager.Config import com.simplemobiletools.filemanager.Config
import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.extensions.formatSize import com.simplemobiletools.filemanager.extensions.formatSize
import com.simplemobiletools.filepicker.models.FileDirItem import com.simplemobiletools.filepicker.models.FileDirItem
import kotlinx.android.synthetic.main.item_properties.view.*
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -28,33 +28,34 @@ class PropertiesDialog : DialogFragment() {
} }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
mShowHidden = Config.newInstance(context).showHidden
val title = if (mItem.isDirectory) R.string.directory_properties else R.string.file_properties val title = if (mItem.isDirectory) R.string.directory_properties else R.string.file_properties
val infoView = activity.layoutInflater.inflate(R.layout.item_properties, null) val infoView = activity.layoutInflater.inflate(R.layout.item_properties, null)
(infoView.findViewById(R.id.properties_name) as TextView).text = mItem.name
(infoView.findViewById(R.id.properties_path) as TextView).text = mItem.path
(infoView.findViewById(R.id.properties_size) as TextView).text = getItemSize()
if (mItem.isDirectory) { infoView.apply {
infoView.findViewById(R.id.properties_files_count_label).visibility = View.VISIBLE properties_name.text = mItem.name
infoView.findViewById(R.id.properties_files_count).visibility = View.VISIBLE properties_path.text = mItem.path
(infoView.findViewById(R.id.properties_files_count) as TextView).text = mFilesCnt.toString() properties_size.text = getItemSize()
if (mItem.isDirectory) {
properties_files_count_label.visibility = View.VISIBLE
properties_files_count.visibility = View.VISIBLE
properties_files_count.text = mFilesCnt.toString()
}
val file = File(mItem.path)
properties_last_modified.text = formatLastModified(file.lastModified())
} }
val file = File(mItem.path) return AlertDialog.Builder(context)
(infoView.findViewById(R.id.properties_last_modified) as TextView).text = formatLastModified(file.lastModified()) .setTitle(resources.getString(title))
.setView(infoView)
val builder = AlertDialog.Builder(context) .setPositiveButton(R.string.ok, null)
builder.setTitle(resources.getString(title)) .create()
builder.setView(infoView)
builder.setPositiveButton(R.string.ok, null)
return builder.create()
} }
fun getItemSize(): String { fun getItemSize(): String {
if (mItem.isDirectory) { if (mItem.isDirectory) {
mShowHidden = Config.newInstance(context).showHidden
return getDirectorySize(File(mItem.path)).formatSize() return getDirectorySize(File(mItem.path)).formatSize()
} }