Skip to content

Commit

Permalink
Remove adding torrent by barcode scanner, as not free adn token-less …
Browse files Browse the repository at this point in the history
…web search API seems to exist that can help us get a product name from upc code. Closes #449.
  • Loading branch information
erickok committed Oct 4, 2018
1 parent c2faf75 commit e171266
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 180 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Transdroid

<img src="http://2312.nl/images/screenshot_transdroid_main.png" alt="Screen shot of the main torrents listing screen" width="280" />

Manage your torrents from your Android device with Transdroid. All popular clients are supported: µTorrent, Transmission, rTorrent, Vuze, Deluge, BitTorrent 6, qBittorrent and many more. You can view and manage the running torrents and individual files. Adding is easy via the integrated search, RSS feeds or the barcode scanner (full version required). Monitor progress using the home screen widget or background alarm service.

Manage your torrents from your Android device with Transdroid. All popular clients are supported: µTorrent, Transmission, rTorrent, Vuze, Deluge, BitTorrent 6, qBittorrent and many more. You can view and manage the running torrents and individual files. Adding is easy via the integrated search or RSS feeds (full version required). Monitor progress using the home screen widget or background alarm service.

Contributions
=============
Expand All @@ -27,7 +28,7 @@ Please respect the coding standards for easier merging. master contains the curr
Code structure
==============

Starting with version 2.3.0, Transdroid is developed in Android Studio, fully integrating with the Gradle build system. It is (since version 2.5.0) compiled against Android 5.1 (API level 22) and (since version 2.2.0) supporting ICS (API level 15) and up only. To support lite (Transdrone, specially for the Play Store) and full (Transdroid) versions of the app, build flavours are defined in gradle, which contain version-specific resources. Dependencies are managed via JCentral in the app's build.gradle file.
Starting with version 2.3.0, Transdroid is developed in Android Studio, fully integrating with the Gradle build system. It is (since version 2.5.0) compiled against Android 5.1 (API level 22) and (since version 2.2.0) supporting ICS (API level 15) and up only. To support lite (Transdrone, specially for the Play Store) and full (Transdroid) versions of the app, build flavours are defined in gradle, which contain version-specific resources. Dependencies are managed via JCentral et al. in the app's build.gradle file.

Developed By
============
Expand All @@ -37,7 +38,7 @@ Designed and developed by [Eric Kok](eric@2312.nl) of [2312 development](http://
License
=======

Copyright 2010-2017 Eric Kok et al.
Copyright 2010-2018 Eric Kok et al.

Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down

This file was deleted.

33 changes: 0 additions & 33 deletions app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -85,7 +84,6 @@
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.remoterss.RemoteRssActivity_;
import org.transdroid.core.gui.rss.RssfeedsActivity_;
import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog;
import org.transdroid.core.gui.settings.MainSettingsActivity_;
Expand Down Expand Up @@ -791,37 +789,6 @@ public void onFilePicked(int resultCode, Intent data) {
}
}

@Click(R.id.addmenu_barcode_button)
protected void startBarcodeScanner() {
addmenuButton.collapse();
BarcodeHelper.startBarcodeScanner(this, BarcodeHelper.ACTIVITY_BARCODE_ADDTORRENT);
}

@Background
@OnActivityResult(BarcodeHelper.ACTIVITY_BARCODE_ADDTORRENT)
public void onBarcodeScanned(int resultCode, Intent data) {
if (data != null) {
// We receive from the helper either a URL (as string) or a query we can start a search for
String query = BarcodeHelper.handleScanResult(resultCode, data, navigationHelper.enableSearchUi());
onBarcodeScanHandled(data.getStringExtra("SCAN_RESULT"), query);
}
}

@UiThread
protected void onBarcodeScanHandled(String barcode, String result) {
log.d(this, "Scanned barcode " + barcode + " and got " + result);
if (TextUtils.isEmpty(result)) {
SnackbarManager.show(Snackbar.with(this).text(R.string.error_noproductforcode).colorResource(R.color.red).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);
}
}

@OptionsItem(R.id.action_refresh)
public void refreshScreen() {
fragmentTorrents.updateIsLoading(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,21 @@
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

import org.transdroid.R;
import org.transdroid.core.app.search.GoogleWebSearchBarcodeResolver;

public class BarcodeHelper {

public static final int ACTIVITY_BARCODE_ADDTORRENT = 0x0000c0de;
// A 'random' ID to identify torrent adding scan intents
public static final int ACTIVITY_BARCODE_QRSETTINGS = 0x0000c0df;
// A 'random' ID to identify QR-encoded settings scan intents
public static final Uri SCANNER_MARKET_URI = Uri.parse("market://search?q=pname:com.google.zxing.client.android");
public static final int ACTIVITY_BARCODE_QRSETTINGS = 0x0000c0df;
private static final Uri SCANNER_MARKET_URI = Uri.parse("market://search?q=pname:com.google.zxing.client.android");

/**
* Call this to start a bar code scanner intent. The calling activity will receive an Intent result with ID {@link
* #ACTIVITY_BARCODE_ADDTORRENT} or {@link #ACTIVITY_BARCODE_QRSETTINGS}. From there {@link #handleScanResult(int,
* android.content.Intent, boolean)} can be called to parse the result into a search query, in case of {@link
* #ACTIVITY_BARCODE_ADDTORRENT} scans.
* Call this to start a bar code scanner intent. The calling activity will receive an Intent result with the given
* request code.
* @param activity The calling activity, to which the result is returned or a dialog is bound that asks to install
* the bar code scanner
* @param requestCode {@link #ACTIVITY_BARCODE_ADDTORRENT} or {@link #ACTIVITY_BARCODE_QRSETTINGS
* @param requestCode {@link #ACTIVITY_BARCODE_QRSETTINGS}
*/
public static void startBarcodeScanner(final Activity activity, int requestCode) {
// Start a bar code scanner that can handle the SCAN intent (specifically ZXing)
Expand Down Expand Up @@ -82,42 +76,12 @@ public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
.setPositiveButton(android.R.string.yes, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (activity != null) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, SCANNER_MARKET_URI));
}
activity.startActivity(new Intent(Intent.ACTION_VIEW, SCANNER_MARKET_URI));
}
}).setNegativeButton(android.R.string.no, null).create();
}

;
}.show(activity.getFragmentManager(), "installscanner");
}
}

/**
* The activity that called {@link #startBarcodeScanner(android.app.Activity, int)} with {@link
* #ACTIVITY_BARCODE_ADDTORRENT} should call this after the scan result was returned. This will parse the scan data
* and return a query search query appropriate to the bar code.
* @param resultCode The raw result code as returned by the bar code scanner
* @param data The raw data as returned from the bar code scanner
* @param supportsSearch Whether the application has the search UI enabled, such that it can use the scanned barcode
* to find torrents
* @return A String that can be used as new search query, or null if the bar code could not be scanned or no query
* can be constructed for it
*/
public static String handleScanResult(int resultCode, Intent data, boolean supportsSearch) {
String contents = data != null ? data.getStringExtra("SCAN_RESULT") : null;
String formatName = data != null ? data.getStringExtra("SCAN_RESULT_FORMAT") : null;
if (formatName != null && formatName.equals("QR_CODE")) {
// Scanned barcode was a QR code: return the contents directly
return contents;
} else {
if (TextUtils.isEmpty(contents) || !supportsSearch) {
return null;
}
// Get a meaningful search query based on a Google Search product lookup
return GoogleWebSearchBarcodeResolver.resolveBarcode(contents);
}
}

}
Binary file removed app/src/main/res/drawable-hdpi/ic_action_barcode.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 0 additions & 9 deletions app/src/main/res/layout/actionbar_addbutton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,5 @@
app:fab_colorPressed="@color/green_dark"
app:fab_icon="@drawable/ic_action_link" />

<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/addmenu_barcode_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="@color/green"
app:fab_colorPressed="@color/green_dark"
app:fab_icon="@drawable/ic_action_barcode" />

</com.getbase.floatingactionbutton.FloatingActionsMenu>


0 comments on commit e171266

Please sign in to comment.