Browse Source

Fix qBittorrent version parsing for beta version (like 3.0.0-alpha5).

pull/11/head
Eric Kok 12 years ago
parent
commit
8f20708bea
  1. 15
      android/res/values/changelog.xml
  2. 35
      lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

15
android/res/values/changelog.xml

@ -1,6 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="changes"> <string name="changes">
Transdroid 1.1.13\n
- Fix crash on pre-Android 2.3 devices\n
- Sort 'no eta' torrents as last instead of first\n
- qBittorrent: improve version number parsing\n
\n
Transdroid 1.1.12\n
- Option to disable app update checking\n
- Transmission: support non-Western characters in directories\n
- Deluge: don\'t treat trackers errors as blocking\n
- Added Pirate Bay mirror search support\n
\n
Transdroid 1.1.11\n
- rTorrent: fix crash with creationtime and non-i8 dialect\n
- Fixed picking up local .torrent files\n
\n
Transdroid 1.1.10\n Transdroid 1.1.10\n
- Updated translations (thanks to all translators)\n - Updated translations (thanks to all translators)\n
- Special thanks Tom Briden for the following contributions:\n - Special thanks Tom Briden for the following contributions:\n

35
lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -97,19 +97,34 @@ public class QbittorrentAdapter implements IDaemonAdapter {
String aboutEndText = " (Web UI)"; String aboutEndText = " (Web UI)";
int aboutStart = about.indexOf(aboutStartText); int aboutStart = about.indexOf(aboutStartText);
int aboutEnd = about.indexOf(aboutEndText); int aboutEnd = about.indexOf(aboutEndText);
if (aboutStart >= 0 && aboutEnd > aboutStart) { try {
// String found: now parse a version like 2.9.7 as a number like 20907 (allowing 10 places for each .) if (aboutStart >= 0 && aboutEnd > aboutStart) {
String[] parts = about.substring(aboutStart + aboutStartText.length(), aboutEnd).split("\\."); // String found: now parse a version like 2.9.7 as a number like 20907 (allowing 10 places for each .)
if (parts.length > 0) { String[] parts = about.substring(aboutStart + aboutStartText.length(), aboutEnd).split("\\.");
version = Integer.parseInt(parts[0]) * 100 * 100; if (parts.length > 0) {
if (parts.length > 1) { version = Integer.parseInt(parts[0]) * 100 * 100;
version += Integer.parseInt(parts[1]) * 100; if (parts.length > 1) {
if (parts.length > 2) { version += Integer.parseInt(parts[1]) * 100;
version += Integer.parseInt(parts[2]); if (parts.length > 2) {
return; // For the last part only read until a non-numeric character is read
// For example version 3.0.0-alpha5 is read as version code 30000
String numbers = "";
for (char c : parts[2].toCharArray()) {
if (Character.isDigit(c))
// Still a number; add it to the numbers string
numbers += Character.toString(c);
else {
// No longer reading numbers; stop reading
break;
}
}
version += Integer.parseInt(numbers);
return;
}
} }
} }
} }
} catch (NumberFormatException e) {
} }
// Unable to establish version number; assume an old version by setting it to version 1 // Unable to establish version number; assume an old version by setting it to version 1
version = 10000; version = 10000;

Loading…
Cancel
Save