Browse Source

Support scanning of QR codes with embedded magnet link. Fixes #196.

pull/222/merge v2.5.0
Eric Kok 10 years ago
parent
commit
45d2d594a5
  1. 2
      app/build.gradle
  2. 3
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  3. 9
      app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java

2
app/build.gradle

@ -9,7 +9,7 @@ android {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 22 targetSdkVersion 22
versionCode 218 versionCode 218
versionName '2.5.0-SNAPSHOT' versionName '2.5.0-beta1'
} }
buildTypes { buildTypes {
release { release {

3
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)); .type(SnackbarType.MULTI_LINE));
} else if (result.startsWith("http") || result.startsWith("https")) { } else if (result.startsWith("http") || result.startsWith("https")) {
addTorrentByUrl(result, "QR code result"); // No torrent title known 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()) { } else if (navigationHelper.enableSearchUi()) {
startSearch(result, false, null, false); startSearch(result, false, null, false);
} }

9
app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java

@ -106,6 +106,9 @@ public class SearchActivity extends ActionBarActivity implements ActionBar.OnNav
@AfterViews @AfterViews
protected void init() { protected void init() {
setSupportActionBar(searchToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Get the user query, as coming from the standard SearchManager // Get the user query, as coming from the standard SearchManager
handleIntent(getIntent()); 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 // Allow site selection via list (on large screens) or action bar spinner
setSupportActionBar(searchToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (searchsitesList != null) { if (searchsitesList != null) {
// The current layout has a dedicated list view to select the search site // The current layout has a dedicated list view to select the search site
SearchSitesAdapter searchSitesAdapter = SearchSitesAdapter_.getInstance_(this); SearchSitesAdapter searchSitesAdapter = SearchSitesAdapter_.getInstance_(this);
searchSitesAdapter.update(searchSites); searchSitesAdapter.update(searchSites);
searchsitesList.setAdapter(searchSitesAdapter); searchsitesList.setAdapter(searchSitesAdapter);
searchsitesList.setOnItemClickListener(onSearchSiteClicked); 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) { if (lastUsedPosition >= 0) {
searchsitesList.setItemChecked(lastUsedPosition, true); searchsitesList.setItemChecked(lastUsedPosition, true);
lastUsedSite = searchSites.get(lastUsedPosition);
refreshSearch();
} }
} else { } else {
// Use the action bar spinner to select sites // Use the action bar spinner to select sites

Loading…
Cancel
Save