@ -203,6 +203,8 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@@ -203,6 +203,8 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@ -301,6 +303,12 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@@ -301,6 +303,12 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
caseR.id.action_stop:
stopTorrent();
returntrue;
caseR.id.action_toggle_sequential:
toggleSequentialDownload(menuItem);
returntrue;
caseR.id.action_toggle_firstlastpiece:
toggleFirstLastPieceDownload(menuItem);
returntrue;
caseR.id.action_forcerecheck:
setForceRecheck();
returntrue;
@ -359,6 +367,15 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@@ -359,6 +367,15 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@ -421,6 +438,18 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@@ -421,6 +438,18 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
@ -70,35 +90,28 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -70,35 +90,28 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Format is something like 'qBittorrent v2.9.7 (Web UI)' or 'qBittorrent v3.0.0-alpha5 (Web UI)'
}catch(Exceptione2){
// Legacy mode; format is something like 'qBittorrent v2.9.7 (Web UI)' or 'qBittorrent v3.0.0-alpha5 (Web UI)'
Stringabout=makeRequest(log,"/about.html");
StringaboutStartText="qBittorrent v";
StringaboutEndText=" (Web UI)";
@ -108,8 +121,20 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -108,8 +121,20 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Unable to establish version number; assume an old version by setting it to version 1
version=10000;
}
}
privateintparseVersionNumber(StringversionText){
// String found: now parse a version like 2.9.7 as a number like 20907 (allowing 10 places for each .)
intversion=-1;
String[]parts=versionText.split("\\.");
if(parts.length>0){
version=Integer.parseInt(parts[0])*100*100;
@ -129,64 +154,71 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -129,64 +154,71 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
}
version+=Integer.parseInt(numbers);
return;
}
}
}
}catch(Exceptione){
// Unable to establish version number; assume an old version by setting it to version 1
@ -194,77 +226,145 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -194,77 +226,145 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -281,21 +381,59 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -281,21 +381,59 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
// We have to make a separate request per file, it seems
@ -303,7 +441,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -303,7 +441,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -311,18 +454,33 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -311,18 +454,33 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -333,7 +491,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -333,7 +491,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -352,7 +515,9 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -352,7 +515,9 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -384,15 +549,14 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -384,15 +549,14 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -413,21 +577,30 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -413,21 +577,30 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -439,7 +612,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -439,7 +612,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -455,8 +628,15 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -455,8 +628,15 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
}
ArrayList<Integer>pieces=newArrayList<>();
if(pieceStates.length()>0){
for(inti=0;i<pieceStates.length();i++){
pieces.add(pieceStates.getInt(i));
}
}
// Return the list
returnnewTorrentDetails(trackers,errors);
returnnewTorrentDetails(trackers,errors,pieces);
}
@ -466,7 +646,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -466,7 +646,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
Map<String,Label>labels=newHashMap<>();
for(inti=0;i<response.length();i++){
JSONObjecttor=response.getJSONObject(i);
if(apiVersion>=2){
if(version>=40100){
Stringlabel=tor.optString("category");
if(label!=null&&label.length()>0){
finalLabellabelObject=labels.get(label);
@ -492,11 +672,13 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -492,11 +672,13 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -507,6 +689,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -507,6 +689,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
ratio=tor.getDouble("ratio");
dlspeed=tor.getInt("dlspeed");
upspeed=tor.getInt("upspeed");
if(tor.has("seq_dl")){
dlseq=tor.getBoolean("seq_dl");
}
if(tor.has("f_l_piece_prio")){
dlflp=tor.getBoolean("f_l_piece_prio");
}
if(tor.has("uploaded")){
uploaded=tor.getLong("uploaded");
}else{
@ -535,7 +723,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -535,7 +723,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
eta=(long)(size-(size*progress))/dlspeed;
// Add the parsed torrent to the list
// @formatter:off
torrents.add(newTorrent(
Torrenttorrent=newTorrent(
(long)i,
tor.getString("hash"),
tor.getString("name"),
@ -557,7 +745,10 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -557,7 +745,10 @@ public class QbittorrentAdapter implements IDaemonAdapter {
addedOn,
completionOn,
null,
settings.getType()));
settings.getType());
torrent.mimicSequentialDownload(dlseq);
torrent.mimicFirstLastPieceDownload(dlflp);
torrents.add(torrent);
// @formatter:on
}
@ -679,7 +870,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -679,7 +870,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -49,6 +49,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -49,6 +49,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
finalprivatefloatpartDone;
finalprivatefloatavailable;
privateStringlabel;
privatebooleansequentialDownload;
privatebooleanfirstLastPieceDownload;
finalprivateDatedateAdded;
finalprivateDatedateDone;
@ -76,6 +78,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -76,6 +78,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@ -109,6 +113,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -109,6 +113,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
this.partDone=partDone;
this.available=available;
this.label=label;
this.sequentialDownload=false;
this.firstLastPieceDownload=false;
this.dateAdded=dateAdded;
if(realDateDone!=null){
@ -197,6 +203,13 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -197,6 +203,13 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
returnlabel;
}
publicbooleanisSequentiallyDownloading(){
returnsequentialDownload;
}
publicbooleanisDownloadingFirstLastPieceFirst(){
returnfirstLastPieceDownload;
}
publicDategetDateAdded(){
returndateAdded;
}
@ -342,6 +355,14 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -342,6 +355,14 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@ -399,6 +420,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@@ -399,6 +420,8 @@ public final class Torrent implements Parcelable, Comparable<Torrent>, Finishabl
@ -32,15 +33,29 @@ public final class TorrentDetails implements Parcelable {
@@ -32,15 +33,29 @@ public final class TorrentDetails implements Parcelable {
@ -77,6 +92,10 @@ public final class TorrentDetails implements Parcelable {
@@ -77,6 +92,10 @@ public final class TorrentDetails implements Parcelable {
@ -96,6 +115,14 @@ public final class TorrentDetails implements Parcelable {
@@ -96,6 +115,14 @@ public final class TorrentDetails implements Parcelable {