Browse Source

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.
pull/176/head
Uranium235 10 years ago
parent
commit
4b08d32ac4
  1. 10
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java

10
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("")) if (urlBase == null || urlBase.equals(""))
urlBase = "ftp://" + currentServerSettings.getAddress(); urlBase = "ftp://" + currentServerSettings.getAddress();
if (!urlBase.endsWith("/")) if (!urlBase.endsWith("/"))
urlBase = urlBase + "/"; urlBase += "/";
Uri urlBaseUri = Uri.parse(urlBase); Uri urlBaseUri = Uri.parse(urlBase);
urlBaseUri = urlBaseUri.normalizeScheme(); urlBaseUri = urlBaseUri.normalizeScheme();
String basePath = urlBaseUri.getPath(); String basePath = urlBaseUri.getPath();
@ -445,7 +445,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
andftpStart.putExtra("command_type", "download"); andftpStart.putExtra("command_type", "download");
andftpStart.putExtra("ftp_pasv", "true"); andftpStart.putExtra("ftp_pasv", "true");
if (urlBaseUri.getUserInfo() != null) if (urlBaseUri.getUserInfo() != null)
andftpStart.putExtra("ftp_username", Uri.parse(urlBase).getUserInfo()); andftpStart.putExtra("ftp_username", urlBaseUri.getUserInfo());
else else
andftpStart.putExtra("ftp_username", currentServerSettings.getUsername()); andftpStart.putExtra("ftp_username", currentServerSettings.getUsername());
if (currentServerSettings.getFtpPassword() != null if (currentServerSettings.getFtpPassword() != null
@ -473,7 +473,11 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
} }
// Try using a VIEW intent given an ftp:// scheme URI // 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)) Intent simpleStart = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (simpleStart.resolveActivity(getActivity().getPackageManager()) != null) { if (simpleStart.resolveActivity(getActivity().getPackageManager()) != null) {

Loading…
Cancel
Save