show an empty dialog at pressing Properties with multiple items selected

This commit is contained in:
tibbi
2016-10-16 22:19:48 +02:00
parent 1b4ff76566
commit 592b9c1f70
2 changed files with 23 additions and 5 deletions

View File

@ -392,7 +392,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
if (itemIndexes.size() == 1) { if (itemIndexes.size() == 1) {
showOneItemProperties(); showOneItemProperties();
} else { } else {
showMultipleItemProperties(); showMultipleItemProperties(itemIndexes);
} }
} }
@ -404,8 +404,12 @@ public class ItemsFragment extends android.support.v4.app.Fragment
new PropertiesDialog(getContext(), item.getPath(), mConfig.getShowHidden()); new PropertiesDialog(getContext(), item.getPath(), mConfig.getShowHidden());
} }
private void showMultipleItemProperties() { private void showMultipleItemProperties(List<Integer> itemIndexes) {
final List<String> paths = new ArrayList<>(itemIndexes.size());
for (int i : itemIndexes) {
paths.add(mItems.get(i).getPath());
}
new PropertiesDialog(getContext(), paths, mConfig.getShowHidden());
} }
private void displayRenameDialog() { private void displayRenameDialog() {

View File

@ -26,10 +26,9 @@ class PropertiesDialog() {
mCountHiddenItems = countHiddenItems mCountHiddenItems = countHiddenItems
mInflater = LayoutInflater.from(context) mInflater = LayoutInflater.from(context)
mResources = mContext.resources mResources = mContext.resources
val file = File(path)
mPropertyView = mInflater.inflate(R.layout.item_properties, null) as ViewGroup mPropertyView = mInflater.inflate(R.layout.item_properties, null) as ViewGroup
val file = File(path)
addProperty(R.string.name, file.name) addProperty(R.string.name, file.name)
addProperty(R.string.path, file.parent) addProperty(R.string.path, file.parent)
addProperty(R.string.size, getItemSize(file)) addProperty(R.string.size, getItemSize(file))
@ -54,6 +53,21 @@ class PropertiesDialog() {
.show() .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
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) { private fun addProperty(labelId: Int, value: String) {
val view = mInflater.inflate(R.layout.property_item, mPropertyView, false) val view = mInflater.inflate(R.layout.property_item, mPropertyView, false)
view.property_label.text = mResources.getString(labelId) view.property_label.text = mResources.getString(labelId)