add the Properties cab

This commit is contained in:
tibbi 2016-11-19 19:45:38 +01:00
parent e635be89db
commit f1c5699fe6
2 changed files with 21 additions and 45 deletions

View file

@ -355,17 +355,6 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
}
}
private fun showProperties() {
/*val selectedMedia = getSelectedMedia()
if (selectedMedia.size == 1) {
PropertiesDialog(this, selectedMedia[0].path, false)
} else {
val paths = ArrayList<String>(selectedMedia.size)
selectedMedia.mapTo(paths) { it.path }
PropertiesDialog(this, paths, false)
}*/
}
private fun isSetWallpaperIntent() = intent.getBooleanExtra(Constants.SET_WALLPAPER_INTENT, false)
private fun displayCopyDialog() {
@ -412,7 +401,7 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
WallpaperManager.getInstance(applicationContext).setBitmap(bitmap)
setResult(Activity.RESULT_OK)
} catch (e: IOException) {
Log.e(TAG, "item click " + e.message)
Log.e(TAG, "item click $e")
}
finish()
@ -432,35 +421,8 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
}
}
/*override fun onItemCheckedStateChanged(mode: ActionMode, position: Int, id: Long, checked: Boolean) {
if (checked) {
mSelectedItemsCnt++
} else {
mSelectedItemsCnt--
}
if (mSelectedItemsCnt > 0)
mode.title = mSelectedItemsCnt.toString()
mode.invalidate()
}
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
val inflater = mode.menuInflater
inflater.inflate(R.menu.cab_media, menu)
return true
}
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
return false
}
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
/*override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
when (item.itemId) {
R.id.cab_properties -> {
showProperties()
return true
}
R.id.cab_share -> {
shareMedia()
return true
@ -476,10 +438,6 @@ class MediaActivity : SimpleActivity(), AdapterView.OnItemClickListener, View.On
}
else -> return false
}
}
override fun onDestroyActionMode(mode: ActionMode) {
mSelectedItemsCnt = 0
}*/
override fun onTouch(v: View, event: MotionEvent): Boolean {

View file

@ -10,6 +10,7 @@ import com.bignerdranch.android.multiselector.SwappingHolder
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.signature.StringSignature
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog
import com.simplemobiletools.gallery.Config
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity
@ -39,7 +40,13 @@ class MediaAdapter(val activity: SimpleActivity, val media: MutableList<Medium>,
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
return false
return when (item.itemId) {
R.id.cab_properties -> {
showProperties()
true
}
else -> false
}
}
override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean {
@ -57,6 +64,17 @@ class MediaAdapter(val activity: SimpleActivity, val media: MutableList<Medium>,
}
}
private fun showProperties() {
val selections = multiSelector.selectedPositions
if (selections.size <= 1) {
PropertiesDialog(activity, media[selections[0]].path, config.showHiddenFolders)
} else {
val paths = ArrayList<String>()
selections.forEach { paths.add(media[it].path) }
PropertiesDialog(activity, paths, config.showHiddenFolders)
}
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
views.add(holder.bindView(activity, multiSelectorMode, multiSelector, media[position]))
}