From f74e066521bd6929ca08fa3de937bc610b8198cb Mon Sep 17 00:00:00 2001 From: Micdu70 Date: Sat, 10 Nov 2018 14:04:04 +0100 Subject: [PATCH] Fix AndFTP files download --- .../java/org/transdroid/core/gui/DetailsFragment.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java b/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java index 456e297e..d11755d1 100644 --- a/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java @@ -550,6 +550,14 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen if (urlBase == null || urlBase.equals("")) { urlBase = "ftp://" + currentServerSettings.getAddress() + "/"; } + String rootDir = ""; + if (urlBase.matches("(ftps?|scp|sftp)://.+/.+")) { + String[] split = urlBase.split("/", 4); + rootDir = "/" + split[3]; + if (!rootDir.endsWith("/")) { + rootDir = rootDir + "/"; + } + } // Try using AndFTP intents Intent andftpStart = new Intent(Intent.ACTION_PICK); @@ -578,7 +586,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen if (file.startsWith("/") && file.indexOf("/", 1) < 0) { file = file.substring(1); } - andftpStart.putExtra("remote_file" + (f + 1), file); + andftpStart.putExtra("remote_file" + (f + 1), rootDir + file); } } if (andftpStart.resolveActivity(getActivity().getPackageManager()) != null) {