From 4b08d32ac4d784cb85bbe6d23bdf92efa2d5ed95 Mon Sep 17 00:00:00 2001 From: Uranium235 Date: Tue, 18 Nov 2014 22:02:33 +0100 Subject: [PATCH] Reuse already parsed URL Reuse the already parsed URL for Username. Make sure url for VIEW intents with ftp scheme are constructed the same way as for AndFTP. --- .../org/transdroid/core/gui/DetailsFragment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 101e0752..acd480c7 100644 --- a/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java @@ -433,7 +433,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen if (urlBase == null || urlBase.equals("")) urlBase = "ftp://" + currentServerSettings.getAddress(); if (!urlBase.endsWith("/")) - urlBase = urlBase + "/"; + urlBase += "/"; Uri urlBaseUri = Uri.parse(urlBase); urlBaseUri = urlBaseUri.normalizeScheme(); String basePath = urlBaseUri.getPath(); @@ -445,7 +445,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen andftpStart.putExtra("command_type", "download"); andftpStart.putExtra("ftp_pasv", "true"); if (urlBaseUri.getUserInfo() != null) - andftpStart.putExtra("ftp_username", Uri.parse(urlBase).getUserInfo()); + andftpStart.putExtra("ftp_username", urlBaseUri.getUserInfo()); else andftpStart.putExtra("ftp_username", currentServerSettings.getUsername()); if (currentServerSettings.getFtpPassword() != null @@ -463,7 +463,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen if (file != null) { if (file.startsWith("/")) file = file.substring(1); - andftpStart.putExtra("remote_file" + (f + 1), basePath + file); + andftpStart.putExtra("remote_file" + (f + 1), basePath + file); } } if (andftpStart.resolveActivity(getActivity().getPackageManager()) != null) { @@ -473,7 +473,11 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen } // Try using a VIEW intent given an ftp:// scheme URI - String url = urlBase + checked.get(0).getRelativePath(); + String file = checked.get(0).getRelativePath(); + if (file != null) { + if (file.startsWith("/")) + file = file.substring(1); + String url = urlBase + file; Intent simpleStart = new Intent(Intent.ACTION_VIEW, Uri.parse(url)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (simpleStart.resolveActivity(getActivity().getPackageManager()) != null) {