use the FileProperties dialog from bintray

This commit is contained in:
tibbi 2016-11-03 21:53:39 +01:00
parent 0757bf209b
commit c3a2aba66a
4 changed files with 9 additions and 128 deletions

View File

@ -27,6 +27,10 @@ android {
}
}
packagingOptions {
exclude 'META-INF/library-compileDebugKotlin.kotlin_module'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
@ -40,6 +44,7 @@ dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.simplemobiletools:filepicker:1.3.6@aar'
compile 'com.simplemobiletools:fileproperties:1.0.2@aar'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
apt 'com.jakewharton:butterknife-compiler:8.0.1'

View File

@ -32,9 +32,9 @@ import com.simplemobiletools.filemanager.adapters.ItemsAdapter;
import com.simplemobiletools.filemanager.asynctasks.CopyTask;
import com.simplemobiletools.filemanager.dialogs.CopyDialog;
import com.simplemobiletools.filemanager.dialogs.CreateNewItemDialog;
import com.simplemobiletools.filemanager.dialogs.PropertiesDialog;
import com.simplemobiletools.filemanager.dialogs.RenameItemDialog;
import com.simplemobiletools.filepicker.models.FileDirItem;
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog;
import java.io.File;
import java.io.FileFilter;
@ -332,7 +332,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
if (item == null)
return;
new PropertiesDialog(getContext(), item.getPath(), mConfig.getShowHidden());
new PropertiesDialog(getActivity(), item.getPath(), mConfig.getShowHidden());
}
private void showMultipleItemProperties(List<Integer> itemIndexes) {
@ -340,7 +340,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
for (int i : itemIndexes) {
paths.add(mItems.get(i).getPath());
}
new PropertiesDialog(getContext(), paths, mConfig.getShowHidden());
new PropertiesDialog(getActivity(), paths, mConfig.getShowHidden());
}
private void displayRenameDialog() {

View File

@ -46,7 +46,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
}
private fun openPath(path: String) {
breadcrumbs.setBreadcrumb(path, mBasePath)
breadcrumbs.setBreadcrumb(path)
val bundle = Bundle()
bundle.putString(Constants.PATH, path)

View File

@ -1,124 +0,0 @@
package com.simplemobiletools.filemanager.dialogs
import android.content.Context
import android.content.res.Resources
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.ViewGroup
import com.simplemobiletools.filemanager.Config
import com.simplemobiletools.filemanager.R
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
lateinit var mInflater: LayoutInflater
lateinit var mPropertyView: ViewGroup
lateinit var mResources: Resources
private var mCountHiddenItems = false
private var mFilesCnt = 0
constructor(context: Context, path: String, countHiddenItems: Boolean = false) : this() {
mContext = context
mCountHiddenItems = countHiddenItems
mInflater = LayoutInflater.from(context)
mResources = mContext.resources
mPropertyView = mInflater.inflate(R.layout.item_properties, null) as ViewGroup
val file = File(path)
addProperty(R.string.name, file.name)
addProperty(R.string.path, file.parent)
addProperty(R.string.size, getItemSize(file).formatSize())
addProperty(R.string.last_modified, file.lastModified().formatLastModified())
if (file.isDirectory) {
addProperty(R.string.files_count, mFilesCnt.toString())
} else if (file.isImage()) {
addProperty(R.string.resolution, file.getImageResolution())
} else if (file.isAudio()) {
addProperty(R.string.duration, file.getDuration())
addProperty(R.string.artist, file.getArtist())
addProperty(R.string.album, file.getAlbum())
} else if (file.isVideo()) {
addProperty(R.string.duration, file.getDuration())
addProperty(R.string.resolution, file.getVideoResolution())
addProperty(R.string.artist, file.getArtist())
addProperty(R.string.album, file.getAlbum())
}
AlertDialog.Builder(context)
.setTitle(mResources.getString(R.string.properties))
.setView(mPropertyView)
.setPositiveButton(R.string.ok, null)
.create()
.show()
}
constructor(context: Context, paths: List<String>, countHiddenItems: Boolean = false) : this() {
mContext = context
mCountHiddenItems = countHiddenItems
mInflater = LayoutInflater.from(context)
mResources = mContext.resources
mPropertyView = mInflater.inflate(R.layout.item_properties, null) as ViewGroup
val files = ArrayList<File>(paths.size)
paths.forEach { files.add(File(it)) }
addProperty(R.string.path, files[0].parent)
addProperty(R.string.size, getItemsSize(files).formatSize())
addProperty(R.string.files_count, mFilesCnt.toString())
AlertDialog.Builder(context)
.setTitle(mResources.getString(R.string.properties))
.setView(mPropertyView)
.setPositiveButton(R.string.ok, null)
.create()
.show()
}
private fun addProperty(labelId: Int, value: String?) {
if (value == null)
return
val view = mInflater.inflate(R.layout.property_item, mPropertyView, false)
view.property_label.text = mResources.getString(labelId)
view.property_value.text = value
mPropertyView.properties_holder.addView(view)
}
private fun getItemsSize(files: ArrayList<File>): Long {
var size = 0L
files.forEach { size += getItemSize(it) }
return size
}
private fun getItemSize(file: File): Long {
if (file.isDirectory) {
mCountHiddenItems = Config.newInstance(mContext).showHidden
return getDirectorySize(File(file.path))
}
mFilesCnt++
return file.length()
}
private fun getDirectorySize(dir: File): Long {
var size = 0L
if (dir.exists()) {
val files = dir.listFiles()
for (i in files.indices) {
if (files[i].isDirectory) {
size += getDirectorySize(files[i])
} else if (!files[i].isHidden && !dir.isHidden || mCountHiddenItems) {
mFilesCnt++
size += files[i].length()
}
}
}
return size
}
}