forked from hardcoresushi/DroidFS
Prefill text field with current name when renaming a volume
This commit is contained in:
parent
53f28e9475
commit
55b0ac0daa
@ -411,7 +411,7 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
|
||||
}
|
||||
|
||||
private fun renameVolume(volume: Volume, position: Int) {
|
||||
EditTextDialog(this, R.string.new_volume_name) { newName ->
|
||||
with (EditTextDialog(this, R.string.new_volume_name) { newName ->
|
||||
val srcPath = File(volume.getFullPath(filesDir.path))
|
||||
val dstPath = File(srcPath.parent, newName).canonicalFile
|
||||
val newDBName: String
|
||||
@ -440,7 +440,10 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
|
||||
} else {
|
||||
Toast.makeText(this, R.string.volume_rename_failed, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}.show()
|
||||
}) {
|
||||
setSelectedText(volume.shortName)
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi") // fingerprintProtector is non-null only when SDK_INT >= 23
|
||||
|
@ -1,5 +1,6 @@
|
||||
package sushi.hardcore.droidfs.adapters
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -66,9 +67,11 @@ class VolumeAdapter(
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun refresh() {
|
||||
reloadVolumes()
|
||||
unSelectAll(true)
|
||||
unSelectAll(false)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
inner class VolumeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
@ -417,10 +417,7 @@ open class BaseExplorerActivity : BaseActivity(), ExplorerElementAdapter.Listene
|
||||
}
|
||||
checkPathOverwrite(items, dstDirectoryPath, callback)
|
||||
}) {
|
||||
with (binding.dialogEditText) {
|
||||
setText(items[i].explorerElement.name)
|
||||
selectAll()
|
||||
}
|
||||
setSelectedText(items[i].explorerElement.name)
|
||||
setOnCancelListener{
|
||||
callback(null)
|
||||
}
|
||||
@ -558,10 +555,7 @@ open class BaseExplorerActivity : BaseActivity(), ExplorerElementAdapter.Listene
|
||||
with(EditTextDialog(this, R.string.rename_title) {
|
||||
rename(oldName, it)
|
||||
}) {
|
||||
with(binding.dialogEditText) {
|
||||
setText(oldName)
|
||||
selectAll()
|
||||
}
|
||||
setSelectedText(oldName)
|
||||
show()
|
||||
}
|
||||
true
|
||||
|
@ -13,6 +13,13 @@ class EditTextDialog(
|
||||
): CustomAlertDialogBuilder(activity, activity.themeValue) {
|
||||
val binding = DialogEditTextBinding.inflate(activity.layoutInflater)
|
||||
|
||||
fun setSelectedText(text: CharSequence) {
|
||||
with (binding.dialogEditText) {
|
||||
setText(text)
|
||||
selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
override fun create(): AlertDialog {
|
||||
setTitle(titleId)
|
||||
setView(binding.root)
|
||||
|
Loading…
Reference in New Issue
Block a user