From 45d2d594a5301542ae60ddd8201d3821fed28117 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 1 Jun 2015 15:17:27 +0200 Subject: [PATCH] Support scanning of QR codes with embedded magnet link. Fixes #196. --- app/build.gradle | 2 +- .../java/org/transdroid/core/gui/TorrentsActivity.java | 3 +++ .../org/transdroid/core/gui/search/SearchActivity.java | 9 ++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 043473d8..3d7fbd01 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion 15 targetSdkVersion 22 versionCode 218 - versionName '2.5.0-SNAPSHOT' + versionName '2.5.0-beta1' } buildTypes { release { diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java index 65c257e6..1c7205b5 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -787,6 +787,9 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE .type(SnackbarType.MULTI_LINE)); } else if (result.startsWith("http") || result.startsWith("https")) { addTorrentByUrl(result, "QR code result"); // No torrent title known + } else if (result.startsWith("magnet")) { + String title = NavigationHelper.extractNameFromUri(Uri.parse(result)); + addTorrentByMagnetUrl(result, title); } else if (navigationHelper.enableSearchUi()) { startSearch(result, false, null, false); } diff --git a/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java b/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java index 0a065933..e59279c7 100644 --- a/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java @@ -106,6 +106,9 @@ public class SearchActivity extends ActionBarActivity implements ActionBar.OnNav @AfterViews protected void init() { + setSupportActionBar(searchToolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + // Get the user query, as coming from the standard SearchManager handleIntent(getIntent()); @@ -128,17 +131,17 @@ public class SearchActivity extends ActionBarActivity implements ActionBar.OnNav } // Allow site selection via list (on large screens) or action bar spinner - setSupportActionBar(searchToolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (searchsitesList != null) { // The current layout has a dedicated list view to select the search site SearchSitesAdapter searchSitesAdapter = SearchSitesAdapter_.getInstance_(this); searchSitesAdapter.update(searchSites); searchsitesList.setAdapter(searchSitesAdapter); searchsitesList.setOnItemClickListener(onSearchSiteClicked); - // Select the last used site; this also starts the search! + // Select the last used site and start the search if (lastUsedPosition >= 0) { searchsitesList.setItemChecked(lastUsedPosition, true); + lastUsedSite = searchSites.get(lastUsedPosition); + refreshSearch(); } } else { // Use the action bar spinner to select sites