Support creating local folder
This commit is contained in:
parent
c98171418b
commit
f5fd914d23
18
README.md
18
README.md
|
@ -4,12 +4,24 @@
|
|||
|
||||
ADB file manager
|
||||
|
||||
## Missing features
|
||||
|
||||
This application is missing a few features before its initial release:
|
||||
|
||||
- Display a confirmation dialog before overwriting a file
|
||||
- Recursive upload/download (only single file upload/download is currently supported)
|
||||
|
||||
## Download
|
||||
|
||||
adbfm is written in [Go](https://golang.org). Run the following command to
|
||||
download and build adbfm from source.
|
||||
|
||||
```bash
|
||||
go get gitlab.com/tslocum/adbfm
|
||||
```
|
||||
|
||||
The resulting binary is available as `~/go/bin/adbfm`.
|
||||
|
||||
## Usage
|
||||
|
||||
adbfm may be used with a keyboard or mouse.
|
||||
|
@ -18,6 +30,12 @@ adbfm may be used with a keyboard or mouse.
|
|||
- Open context menu: Alt+Enter
|
||||
- Enter directory: Enter
|
||||
|
||||
Launch with `--connect` to connect to a device over a network connection.
|
||||
|
||||
```bash
|
||||
adb --connect=192.168.8.100
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Please share issues and suggestions [here](https://gitlab.com/tslocum/adbfm/issues).
|
||||
|
|
42
gui.go
42
gui.go
|
@ -40,6 +40,8 @@ var (
|
|||
currentFocus = 0
|
||||
currentMode = modeNormal
|
||||
|
||||
newFolderRemote bool
|
||||
|
||||
clipboardRemote bool
|
||||
clipboardPath string
|
||||
clipboardCut bool
|
||||
|
@ -85,6 +87,7 @@ func acceptRename(buttonIndex int, buttonLabel string) {
|
|||
if buttonIndex >= 0 {
|
||||
go func() {
|
||||
browseRemote(remotePath)
|
||||
focusUpdated()
|
||||
app.Draw()
|
||||
}()
|
||||
return
|
||||
|
@ -94,10 +97,18 @@ func acceptRename(buttonIndex int, buttonLabel string) {
|
|||
}
|
||||
|
||||
func acceptNewFolder(buttonIndex int, buttonLabel string) {
|
||||
if buttonIndex >= 0 {
|
||||
err := bridge.newDirectory(path.Join(remotePath, newFolderField.GetText()))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
folderName := newFolderField.GetText()
|
||||
if buttonIndex >= 0 && folderName != "" {
|
||||
if newFolderRemote {
|
||||
err := bridge.newDirectory(path.Join(remotePath, folderName))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
err := os.Mkdir(path.Join(localPath, folderName), 0655)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +116,12 @@ func acceptNewFolder(buttonIndex int, buttonLabel string) {
|
|||
|
||||
if buttonIndex >= 0 {
|
||||
go func() {
|
||||
browseRemote(remotePath)
|
||||
if newFolderRemote {
|
||||
browseRemote(remotePath)
|
||||
} else {
|
||||
browseLocal(localPath)
|
||||
}
|
||||
focusUpdated()
|
||||
app.Draw()
|
||||
}()
|
||||
}
|
||||
|
@ -315,7 +331,22 @@ func initTUI() {
|
|||
})
|
||||
localBuffer.AddContextItem("", 0, nil)
|
||||
localBuffer.AddContextItem("New folder", 'f', func(index int) {
|
||||
newFolderField.SetLabel("Folder name")
|
||||
|
||||
modalPopup.SetDoneFunc(acceptNewFolder)
|
||||
|
||||
modalPopup.SetText("Create new folder")
|
||||
modalPopup.GetForm().Clear(true)
|
||||
modalPopup.GetForm().AddFormItem(newFolderField)
|
||||
modalPopup.GetForm().AddButton("Create", func() {
|
||||
acceptNewFolder(0, "")
|
||||
})
|
||||
|
||||
newFolderRemote = false
|
||||
newFolderItem = index
|
||||
setMode(modeNewFolder)
|
||||
|
||||
app.Draw()
|
||||
})
|
||||
|
||||
localBuffer.SetSelectedFunc(func(i int, item *cview.ListItem) {
|
||||
|
@ -526,6 +557,7 @@ func initTUI() {
|
|||
acceptNewFolder(0, "")
|
||||
})
|
||||
|
||||
newFolderRemote = true
|
||||
newFolderItem = index
|
||||
setMode(modeNewFolder)
|
||||
|
||||
|
|
Loading…
Reference in New Issue