From ecf1d8833a20b9de972396eaaf639621a824dfdd Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 27 Oct 2014 11:07:59 +0100 Subject: [PATCH] Fixed crash on logging and correct search history provider authority to fix search suggestions. --- README.md | 1 + app/build.gradle | 3 ++- .../transdroid/core/gui/TorrentsActivity.java | 6 +++--- .../java/org/transdroid/core/gui/log/Log.java | 3 ++- .../core/gui/navigation/NavigationHelper.java | 18 +----------------- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 3f8a3cd0..f22712a4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Transdroid [www.transdroid.org](http://www.transdroid.org) [Google+](https://plus.google.com/u/0/b/106240944422491053650/106240944422491053650) - [Twitter](https://twitter.com/transdroid) - [transdroid@2312.nl](transdroid@2312.nl) - [Transdrone in Play Store](https://play.google.com/store/apps/details?id=org.transdroid.lite) + "Manage your torrents from your Android device" ![Screen shot of the main torretnts listing screen](http://2312.nl/img/portfolio-transdroid/240x400-transdroid-main.png) diff --git a/app/build.gradle b/app/build.gradle index 622a9fa6..0fce45bb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,6 @@ android { targetSdkVersion 19 versionCode 216 versionName '2.3.0' - resValue "string", "search_history_authority", applicationId + ".search.SearchHistoryProvider" } signingConfigs { release { @@ -30,9 +29,11 @@ android { productFlavors { full { applicationId 'org.transdroid.full' + resValue "string", "search_history_authority", applicationId + ".search.SearchHistoryProvider" } lite { applicationId 'org.transdroid.lite' + resValue "string", "search_history_authority", applicationId + ".search.SearchHistoryProvider" } } lintOptions { 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 5ca64ee2..09aa9b30 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -647,7 +647,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, if (match != null && match.getCookies() != null) { addTorrentFromWeb(data, match, title); } else if (privateSource != null) { - addTorrentFromPrivateSource(data.toString(), title, privateSource); + addTorrentFromPrivateSource(data, title, privateSource); } else { // Normally send the URL to the torrent client addTorrentByUrl(data, title); @@ -699,7 +699,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @OnActivityResult(FilePickerHelper.ACTIVITY_FILEPICKER) public void onFilePicked(int resultCode, Intent data) { // We should have received an Intent with a local torrent's Uri as data from the file picker - if (data != null && data.getData() != null && !data.getData().equals("")) { + if (data != null && data.getData() != null && !data.getData().toString().equals("")) { String url = data.getData().getPath(); addTorrentByFile(data.getData().toString(), url.substring(url.lastIndexOf("/"))); } @@ -715,7 +715,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, public void onBarcodeScanned(int resultCode, Intent data) { // 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); - if (query.startsWith("http")) + if (query.startsWith("http") || query.startsWith("https")) addTorrentByUrl(query, "QR code result"); // No torrent title known else startSearch(query, false, null, false); diff --git a/app/src/main/java/org/transdroid/core/gui/log/Log.java b/app/src/main/java/org/transdroid/core/gui/log/Log.java index b71ce69d..35fc537c 100644 --- a/app/src/main/java/org/transdroid/core/gui/log/Log.java +++ b/app/src/main/java/org/transdroid/core/gui/log/Log.java @@ -23,6 +23,7 @@ import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.EBean.Scope; import org.androidannotations.annotations.OrmLiteDao; +import org.transdroid.BuildConfig; import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.daemon.util.ITLogger; @@ -53,7 +54,7 @@ public class Log implements ITLogger { } protected void log(String logName, int priority, String message) { - if (navigationHelper.inDebugMode()) + if (BuildConfig.DEBUG) android.util.Log.println(priority, LOG_NAME, message); try { // Store this log message to the database diff --git a/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java b/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java index 1fd7326d..53b1584c 100644 --- a/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java +++ b/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java @@ -36,6 +36,7 @@ import com.nostra13.universalimageloader.core.assist.ImageScaleType; import org.androidannotations.annotations.EBean; import org.androidannotations.annotations.RootContext; +import org.transdroid.BuildConfig; import org.transdroid.R; import java.io.IOException; @@ -113,23 +114,6 @@ public class NavigationHelper { } } - /** - * Returns whether the application is running in debug mode, as opposed to release mode. Use to show/hide features - * in the ui based on the build mode. - * @return True if the app is compiled in/running as debug mode, false otherwise - */ - public boolean inDebugMode() { - try { - if (inDebugMode == null) { - PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); - inDebugMode = (pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; - } - return inDebugMode; - } catch (NameNotFoundException e) { - return false; - } - } - /** * Returns whether the device is considered small (i.e. a phone) rather than large (i.e. a tablet). Can, for * example, be used to determine if a dialog should be shown full screen. Currently is true if the device's smallest