Browse Source

Merge remote-tracking branch 'remotes/origin/master' into combine_rss_feed_views

pull/526/head
Twig N 4 years ago
parent
commit
7584c77271
  1. 6
      app/build.gradle
  2. 34
      app/src/main/java/org/transdroid/core/gui/DetailsActivity.java
  3. 29
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  4. 4
      app/src/main/java/org/transdroid/core/gui/TorrentTasksExecutor.java
  5. 26
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  6. 32
      app/src/main/java/org/transdroid/core/gui/lists/DetailsAdapter.java
  7. 3
      app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java
  8. 150
      app/src/main/java/org/transdroid/core/gui/lists/PiecesMapView.java
  9. 18
      app/src/main/java/org/transdroid/daemon/Daemon.java
  10. 4
      app/src/main/java/org/transdroid/daemon/DaemonMethod.java
  11. 1473
      app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java
  12. 23
      app/src/main/java/org/transdroid/daemon/Torrent.java
  13. 27
      app/src/main/java/org/transdroid/daemon/TorrentDetails.java
  14. 31
      app/src/main/java/org/transdroid/daemon/task/ToggleFirstLastPieceDownloadTask.java
  15. 31
      app/src/main/java/org/transdroid/daemon/task/ToggleSequentialDownloadTask.java
  16. 31
      app/src/main/res/menu/fragment_details.xml
  17. 9
      app/src/main/res/values-ru/strings.xml
  18. 5
      app/src/main/res/values/changelog.xml
  19. 10
      app/src/main/res/values/strings.xml
  20. 2
      latest-app.html

6
app/build.gradle

@ -7,9 +7,9 @@ android { @@ -7,9 +7,9 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 236
versionName '2.5.16'
targetSdkVersion 29
versionCode 237
versionName '2.5.17'
javaCompileOptions {
annotationProcessorOptions {

34
app/src/main/java/org/transdroid/core/gui/DetailsActivity.java

@ -56,6 +56,8 @@ import org.transdroid.daemon.TorrentFile; @@ -56,6 +56,8 @@ import org.transdroid.daemon.TorrentFile;
import org.transdroid.daemon.task.DaemonTaskFailureResult;
import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import org.transdroid.daemon.task.ToggleSequentialDownloadTask;
import org.transdroid.daemon.task.ToggleFirstLastPieceDownloadTask;
import org.transdroid.daemon.task.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
@ -278,6 +280,36 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -278,6 +280,36 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
}
}
@Background
@Override
public void toggleSequentialDownload(Torrent torrent, boolean sequentialState) {
torrent.mimicSequentialDownload(sequentialState);
String onState = getString(R.string.result_togglesequential_onstate);
String offState = getString(R.string.result_togglesequential_offstate);
String stateString = sequentialState ? onState : offState;
DaemonTaskResult result = ToggleSequentialDownloadTask.create(currentConnection, torrent).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_togglesequential, torrent.getName(), stateString));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@Background
@Override
public void toggleFirstLastPieceDownload(Torrent torrent, boolean firstLastPieceState) {
torrent.mimicFirstLastPieceDownload(firstLastPieceState);
String onState = getString(R.string.result_togglefirstlastpiece_onstate);
String offState = getString(R.string.result_togglefirstlastpiece_offstate);
String stateString = firstLastPieceState ? onState : offState;
DaemonTaskResult result = ToggleFirstLastPieceDownloadTask.create(currentConnection, torrent).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_togglefirstlastpiece, torrent.getName(), stateString));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@Background
@Override
public void forceRecheckTorrent(Torrent torrent) {
@ -330,7 +362,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -330,7 +362,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
// Refresh the screen as well
refreshTorrent();
refreshTorrentDetails(torrent);
SnackbarManager.show(Snackbar.with(this).text(successMessage));
SnackbarManager.show(Snackbar.with(this).text(successMessage).duration(Snackbar.SnackbarDuration.LENGTH_SHORT));
}
@UiThread

29
app/src/main/java/org/transdroid/core/gui/DetailsFragment.java

@ -203,6 +203,8 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -203,6 +203,8 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
.updateTrackers(SimpleListItemAdapter.SimpleStringItem.wrapStringsList(newTorrentDetails.getTrackers()));
((DetailsAdapter) detailsList.getAdapter())
.updateErrors(SimpleListItemAdapter.SimpleStringItem.wrapStringsList(newTorrentDetails.getErrors()));
((DetailsAdapter) detailsList.getAdapter())
.updatePieces(newTorrentDetails.getPieces());
}
/**
@ -301,6 +303,12 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -301,6 +303,12 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
case R.id.action_stop:
stopTorrent();
return true;
case R.id.action_toggle_sequential:
toggleSequentialDownload(menuItem);
return true;
case R.id.action_toggle_firstlastpiece:
toggleFirstLastPieceDownload(menuItem);
return true;
case R.id.action_forcerecheck:
setForceRecheck();
return true;
@ -359,6 +367,15 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -359,6 +367,15 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
detailsMenu.getMenu().findItem(R.id.action_setlabel).setVisible(setLabel);
boolean forceRecheck = Daemon.supportsForceRecheck(torrent.getDaemon());
detailsMenu.getMenu().findItem(R.id.action_forcerecheck).setVisible(forceRecheck);
boolean sequentialdl = Daemon.supportsSequentialDownload(torrent.getDaemon());
MenuItem seqMenuItem = detailsMenu.getMenu().findItem(R.id.action_toggle_sequential);
seqMenuItem.setVisible(sequentialdl);
seqMenuItem.setChecked(torrent.isSequentiallyDownloading());
boolean firstlastpiecedl = Daemon.supportsFirstLastPiece(torrent.getDaemon());
MenuItem flpMenuItem = detailsMenu.getMenu().findItem(R.id.action_toggle_firstlastpiece);
flpMenuItem.setVisible(firstlastpiecedl);
flpMenuItem.setChecked(torrent.isDownloadingFirstLastPieceFirst());
detailsMenu.getMenu().findItem(R.id.action_download_mode).setVisible(!torrent.isFinished() && (firstlastpiecedl || sequentialdl));
boolean setTrackers = Daemon.supportsSetTrackers(torrent.getDaemon());
detailsMenu.getMenu().findItem(R.id.action_updatetrackers).setVisible(setTrackers);
boolean setLocation = Daemon.supportsSetDownloadLocation(torrent.getDaemon());
@ -421,6 +438,18 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -421,6 +438,18 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
}
}
@OptionsItem(R.id.action_toggle_sequential)
protected void toggleSequentialDownload(MenuItem menuItem) {
if (getTasksExecutor() != null)
getTasksExecutor().toggleSequentialDownload(torrent, !menuItem.isChecked());
}
@OptionsItem(R.id.action_toggle_firstlastpiece)
protected void toggleFirstLastPieceDownload(MenuItem menuItem) {
if (getTasksExecutor() != null)
getTasksExecutor().toggleFirstLastPieceDownload(torrent, !menuItem.isChecked());
}
@OptionsItem(R.id.action_forcerecheck)
protected void setForceRecheck() {
if (getTasksExecutor() != null)

4
app/src/main/java/org/transdroid/core/gui/TorrentTasksExecutor.java

@ -40,6 +40,10 @@ public interface TorrentTasksExecutor { @@ -40,6 +40,10 @@ public interface TorrentTasksExecutor {
void removeTorrent(Torrent torrent, boolean withData);
void toggleSequentialDownload(Torrent torrent, boolean sequentialState);
void toggleFirstLastPieceDownload(Torrent torrent, boolean firstLastPieceState);
void forceRecheckTorrent(Torrent torrent);
void updateLabel(Torrent torrent, String newLabel);

26
app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

@ -103,6 +103,8 @@ import org.transdroid.daemon.task.AddByUrlTask; @@ -103,6 +103,8 @@ import org.transdroid.daemon.task.AddByUrlTask;
import org.transdroid.daemon.task.DaemonTaskFailureResult;
import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import org.transdroid.daemon.task.ToggleSequentialDownloadTask;
import org.transdroid.daemon.task.ToggleFirstLastPieceDownloadTask;
import org.transdroid.daemon.task.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
@ -1225,6 +1227,30 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -1225,6 +1227,30 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
}
}
@Background
@Override
public void toggleSequentialDownload(Torrent torrent, boolean sequentialState) {
torrent.mimicSequentialDownload(sequentialState);
DaemonTaskResult result = ToggleSequentialDownloadTask.create(currentConnection, torrent).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_togglesequential));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@Background
@Override
public void toggleFirstLastPieceDownload(Torrent torrent, boolean firstLastPieceState) {
torrent.mimicFirstLastPieceDownload(firstLastPieceState);
DaemonTaskResult result = ToggleFirstLastPieceDownloadTask.create(currentConnection, torrent).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.action_toggle_firstlastpiece));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@Background
@Override
public void forceRecheckTorrent(Torrent torrent) {

32
app/src/main/java/org/transdroid/core/gui/lists/DetailsAdapter.java

@ -21,6 +21,7 @@ import java.util.List; @@ -21,6 +21,7 @@ import java.util.List;
import org.transdroid.R;
import org.transdroid.core.gui.navigation.*;
import org.transdroid.core.gui.lists.PiecesMapView;
import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentFile;
@ -38,6 +39,9 @@ public class DetailsAdapter extends MergeAdapter { @@ -38,6 +39,9 @@ public class DetailsAdapter extends MergeAdapter {
private ViewHolderAdapter torrentDetailsViewAdapter = null;
private TorrentDetailsView torrentDetailsView = null;
private ViewHolderAdapter piecesSeparatorAdapter = null;
private ViewHolderAdapter piecesMapViewAdapter = null;
private PiecesMapView piecesMapView = null;
private ViewHolderAdapter trackersSeparatorAdapter = null;
private SimpleListItemAdapter trackersAdapter = null;
private ViewHolderAdapter errorsSeparatorAdapter = null;
@ -56,6 +60,18 @@ public class DetailsAdapter extends MergeAdapter { @@ -56,6 +60,18 @@ public class DetailsAdapter extends MergeAdapter {
torrentDetailsViewAdapter.setViewVisibility(View.GONE);
addAdapter(torrentDetailsViewAdapter);
// Pieces map
piecesSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText(
context.getString(R.string.status_pieces)));
piecesSeparatorAdapter.setViewEnabled(false);
piecesSeparatorAdapter.setViewVisibility(View.GONE);
addAdapter(piecesSeparatorAdapter);
piecesMapView = new PiecesMapView(context);
piecesMapViewAdapter = new ViewHolderAdapter(piecesMapView);
piecesMapViewAdapter.setViewEnabled(false);
piecesMapViewAdapter.setViewVisibility(View.GONE);
addAdapter(piecesMapViewAdapter);
// Tracker errors
errorsSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText(
context.getString(R.string.status_errors)));
@ -137,6 +153,22 @@ public class DetailsAdapter extends MergeAdapter { @@ -137,6 +153,22 @@ public class DetailsAdapter extends MergeAdapter {
}
}
public void updatePieces(List<Integer> pieces) {
if (pieces == null || pieces.isEmpty()) {
piecesSeparatorAdapter.setViewEnabled(false);
piecesSeparatorAdapter.setViewVisibility(View.GONE);
piecesMapViewAdapter.setViewEnabled(false);
piecesMapViewAdapter.setViewVisibility(View.GONE);
} else {
piecesMapView.setPieces(pieces);
piecesMapViewAdapter.setViewEnabled(true);
piecesMapViewAdapter.setViewVisibility(View.VISIBLE);
piecesSeparatorAdapter.setViewEnabled(true);
piecesSeparatorAdapter.setViewVisibility(View.VISIBLE);
}
}
/**
* Clear currently visible torrent, including header and shown lists
*/

3
app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java

@ -82,10 +82,11 @@ public class LocalTorrent { @@ -82,10 +82,11 @@ public class LocalTorrent {
switch (t.getStatusCode()) {
case Waiting:
case Checking:
case Error:
// Not downloading yet
return r.getString(R.string.status_waitingtodl, FileSizeConverter.getSize(t.getTotalSize()));
case Checking:
return r.getString(R.string.status_checking);
case Downloading:
// Downloading
return r.getString(

150
app/src/main/java/org/transdroid/core/gui/lists/PiecesMapView.java

@ -0,0 +1,150 @@ @@ -0,0 +1,150 @@
package org.transdroid.core.gui.lists;
import org.transdroid.R;
import android.content.Context;
import android.view.View;
import android.graphics.Canvas;
import android.graphics.Paint;
import java.util.ArrayList;
import java.util.List;
import java.lang.Math;
class PiecesMapView extends View {
private final float scale = getContext().getResources().getDisplayMetrics().density;
private final int MINIMUM_HEIGHT = (int) (25 * scale);
private final int MINIMUM_PIECE_WIDTH = (int) (2 * scale);
private ArrayList<Integer> pieces = null;
private final Paint downloadingPaint = new Paint();
private final Paint donePaint = new Paint();
private final Paint partialDonePaint = new Paint();
public PiecesMapView(Context context) {
super(context);
initPaints();
}
private void initPaints() {
downloadingPaint.setColor(getResources().getColor(R.color.torrent_downloading));
donePaint.setColor(getResources().getColor(R.color.torrent_seeding));
partialDonePaint.setColor(getResources().getColor(R.color.file_low));
}
public void setPieces(List<Integer> pieces) {
this.pieces = new ArrayList<Integer>(pieces);
invalidate();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int ws = MeasureSpec.getSize(widthMeasureSpec);
int hs = Math.max(getHeight(), MINIMUM_HEIGHT);
setMeasuredDimension(ws, hs);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (this.pieces == null) {
return;
}
int height = getHeight();
int width = getWidth();
// downscale
ArrayList<Integer> piecesScaled;
int pieceWidth;
pieceWidth = MINIMUM_PIECE_WIDTH;
piecesScaled = new ArrayList<Integer>();
int bucketCount = (int) Math.ceil((double) width / (double) pieceWidth);
int bucketSize = (int) Math.floor((double)this.pieces.size() / (double) bucketCount);
// loop buckets
for (int i = 0; i < bucketCount; i++) {
// Get segment of pieces that fall into bucket
int start = i * bucketSize;
// If this is the last bucket, throw the remainder of the pieces array into it
int end = (i == bucketCount-1) ? this.pieces.size() : (i+1) * bucketSize;
ArrayList<Integer> bucket = new ArrayList<Integer>(this.pieces.subList(start, end));
int doneCount = 0;
int downloadingCount = 0;
// loop pieces in bucket
for(int j = 0; j < bucket.size(); j++) {
// Count downloading pieces
if (bucket.get(j) == 1) {
downloadingCount++;
}
// Count finished pieces
else if (bucket.get(j) == 2) {
doneCount++;
}
}
int state;
// If a piece is downloading show bucket as downloading
if (downloadingCount > 0) {
state = 1;
}
// If all pieces are done, show bucket as done
else if (doneCount == bucket.size()) {
state = 2;
}
// Some done pieces, show bucket as partially done
else if (doneCount > 0) {
state = 3;
}
// bucket is not downloaded
else {
state = 0;
}
piecesScaled.add(state);
}
String scaledPiecesString = "";
for (int s : piecesScaled)
{
scaledPiecesString += s;
}
// Draw downscaled peices
for (int i = 0; i < piecesScaled.size(); i++) {
int piece = piecesScaled.get(i);
if (piece == 0) {
continue;
}
Paint paint = new Paint();
switch (piece) {
case 1:
paint = downloadingPaint;
break;
case 2:
paint = donePaint;
break;
case 3:
paint = partialDonePaint;
break;
}
int x = i * pieceWidth;
canvas.drawRect(x, 0, x + pieceWidth, height, paint);
}
}
}

18
app/src/main/java/org/transdroid/daemon/Daemon.java

@ -363,12 +363,12 @@ public enum Daemon { @@ -363,12 +363,12 @@ public enum Daemon {
public static boolean supportsAddByMagnetUrl(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Transmission || type == Synology || type == Deluge || type == DelugeRpc
|| type == Bitflu || type == KTorrent || type == rTorrent || type == qBittorrent || type == BitComet || type == Aria2
|| type == tTorrent || type == Dummy;
|| type == Deluge2Rpc || type == Bitflu || type == KTorrent || type == rTorrent || type == qBittorrent || type == BitComet
|| type == Aria2 || type == tTorrent || type == Dummy;
}
public static boolean supportsRemoveWithData(Daemon type) {
return type == uTorrent || type == Vuze || type == Transmission || type == Deluge || type == DelugeRpc
return type == uTorrent || type == Vuze || type == Transmission || type == Deluge || type == DelugeRpc || type == Deluge2Rpc
|| type == BitTorrent || type == Tfb4rt || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas
|| type == BitComet || type == rTorrent || type == Aria2 || type == tTorrent || type == Dummy;
}
@ -396,7 +396,7 @@ public enum Daemon { @@ -396,7 +396,7 @@ public enum Daemon {
}
public static boolean supportsSetDownloadLocation(Daemon type) {
return type == Transmission || type == Deluge || type == DelugeRpc || type == Deluge2Rpc|| type == qBittorrent || type == Dummy;
return type == Transmission || type == Deluge || type == DelugeRpc || type == Deluge2Rpc || type == qBittorrent || type == Dummy;
}
public static boolean supportsSetAlternativeMode(Daemon type) {
@ -404,7 +404,7 @@ public enum Daemon { @@ -404,7 +404,7 @@ public enum Daemon {
}
public static boolean supportsSetTrackers(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == Deluge2Rpc|| type == Dummy;
return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == Deluge2Rpc || type == Dummy;
}
public static boolean supportsForceRecheck(Daemon type) {
@ -412,6 +412,14 @@ public enum Daemon { @@ -412,6 +412,14 @@ public enum Daemon {
|| type == Transmission || type == Dummy || type == qBittorrent;
}
public static boolean supportsSequentialDownload(Daemon type) {
return type == qBittorrent;
}
public static boolean supportsFirstLastPiece(Daemon type) {
return type == qBittorrent;
}
public static boolean supportsExtraPassword(Daemon type) {
return type == Deluge || type == Aria2;
}

4
app/src/main/java/org/transdroid/daemon/DaemonMethod.java

@ -44,7 +44,9 @@ public enum DaemonMethod { @@ -44,7 +44,9 @@ public enum DaemonMethod {
SetTrackers (19),
SetAlternativeMode (20),
GetStats (21),
ForceRecheck (22);
ForceRecheck (22),
ToggleSequentialDownload(23),
ToggleFirstLastPieceDownload(24);
private int code;
private static final Map<Integer,DaemonMethod> lookup = new HashMap<>();

1473
app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

File diff suppressed because it is too large Load Diff

23
app/src/main/java/org/transdroid/daemon/Torrent.java

@ -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
final private float partDone;
final private float available;
private String label;
private boolean sequentialDownload;
private boolean firstLastPieceDownload;
final private Date dateAdded;
final private Date dateDone;
@ -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
this.partDone = in.readFloat();
this.available = in.readFloat();
this.label = in.readString();
this.sequentialDownload = in.readByte() != 0;
this.firstLastPieceDownload = in.readByte() != 0;
long lDateAdded = in.readLong();
this.dateAdded = (lDateAdded == -1) ? null : new Date(lDateAdded);
@ -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
return label;
}
public boolean isSequentiallyDownloading() {
return sequentialDownload;
}
public boolean isDownloadingFirstLastPieceFirst() {
return firstLastPieceDownload;
}
public Date getDateAdded() {
return dateAdded;
}
@ -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
label = newLabel;
}
public void mimicSequentialDownload(boolean sequentialDownload) {
this.sequentialDownload = sequentialDownload;
}
public void mimicFirstLastPieceDownload(boolean firstLastPieceDownload) {
this.firstLastPieceDownload = firstLastPieceDownload;
}
public void mimicCheckingStatus() {
statusCode = TorrentStatus.Checking;
}
@ -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
dest.writeFloat(partDone);
dest.writeFloat(available);
dest.writeString(label);
dest.writeByte((byte) (sequentialDownload ? 1 : 0));
dest.writeByte((byte) (firstLastPieceDownload ? 1 : 0));
dest.writeLong((dateAdded == null) ? -1 : dateAdded.getTime());
dest.writeLong((dateDone == null) ? -1 : dateDone.getTime());

27
app/src/main/java/org/transdroid/daemon/TorrentDetails.java

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
package org.transdroid.daemon;
import java.util.List;
import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;
@ -32,15 +33,29 @@ public final class TorrentDetails implements Parcelable { @@ -32,15 +33,29 @@ public final class TorrentDetails implements Parcelable {
private final List<String> trackers;
private final List<String> errors;
private final List<Integer> pieces;
public TorrentDetails(List<String> trackers, List<String> errors) {
this.trackers = trackers;
this.errors = errors;
this.pieces = null;
}
public TorrentDetails(List<String> trackers, List<String> errors, List<Integer> pieces) {
this.trackers = trackers;
this.errors = errors;
this.pieces = pieces;
}
private TorrentDetails(Parcel in) {
this.trackers = in.createStringArrayList();
this.errors = in.createStringArrayList();
int[] piecesarray = in.createIntArray();
this.pieces = new ArrayList<Integer>(piecesarray.length);
for (int i : piecesarray) {
this.pieces.add(i);
}
}
public List<String> getTrackers() {
@ -77,6 +92,10 @@ public final class TorrentDetails implements Parcelable { @@ -77,6 +92,10 @@ public final class TorrentDetails implements Parcelable {
return errorsText;
}
public List<Integer> getPieces() {
return this.pieces;
}
public static final Parcelable.Creator<TorrentDetails> CREATOR = new Parcelable.Creator<TorrentDetails>() {
public TorrentDetails createFromParcel(Parcel in) {
return new TorrentDetails(in);
@ -96,6 +115,14 @@ public final class TorrentDetails implements Parcelable { @@ -96,6 +115,14 @@ public final class TorrentDetails implements Parcelable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeStringList(trackers);
dest.writeStringList(errors);
int[] piecesarray = new int[this.pieces.size()];
for(int i = 0; i < this.pieces.size(); i++) {
if (this.pieces.get(i) != null) {
piecesarray[i] = this.pieces.get(i);
}
}
dest.writeIntArray(piecesarray);
}
}

31
app/src/main/java/org/transdroid/daemon/task/ToggleFirstLastPieceDownloadTask.java

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
/*
* This file is part of Transdroid <http://www.transdroid.org>
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.transdroid.daemon.task;
import org.transdroid.daemon.DaemonMethod;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Torrent;
public class ToggleFirstLastPieceDownloadTask extends DaemonTask {
protected ToggleFirstLastPieceDownloadTask(IDaemonAdapter adapter, Torrent targetTorrent) {
super(adapter, DaemonMethod.ToggleFirstLastPieceDownload, targetTorrent, null);
}
public static ToggleFirstLastPieceDownloadTask create(IDaemonAdapter adapter, Torrent targetTorrent) {
return new ToggleFirstLastPieceDownloadTask(adapter, targetTorrent);
}
}

31
app/src/main/java/org/transdroid/daemon/task/ToggleSequentialDownloadTask.java

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
/*
* This file is part of Transdroid <http://www.transdroid.org>
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.transdroid.daemon.task;
import org.transdroid.daemon.DaemonMethod;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Torrent;
public class ToggleSequentialDownloadTask extends DaemonTask {
protected ToggleSequentialDownloadTask(IDaemonAdapter adapter, Torrent targetTorrent) {
super(adapter, DaemonMethod.ToggleSequentialDownload, targetTorrent, null);
}
public static ToggleSequentialDownloadTask create(IDaemonAdapter adapter, Torrent targetTorrent) {
return new ToggleSequentialDownloadTask(adapter, targetTorrent);
}
}

31
app/src/main/res/menu/fragment_details.xml

@ -47,19 +47,36 @@ @@ -47,19 +47,36 @@
<item
android:id="@+id/action_start_direct"
android:icon="@drawable/ic_action_start"
android:orderInCategory="202"
android:orderInCategory="203"
android:title="@string/action_start"
app:showAsAction="always" />
<item
android:id="@+id/action_stop"
android:icon="@drawable/ic_action_stop"
android:orderInCategory="203"
android:orderInCategory="204"
android:title="@string/action_stop"
app:showAsAction="always" />
<item
android:id="@+id/action_download_mode"
android:icon="@drawable/ic_action_download"
android:orderInCategory="205"
android:title="@string/action_download_mode"
app:showAsAction="always" >
<menu>
<item
android:id="@+id/action_toggle_sequential"
android:title="@string/action_toggle_sequential"
android:checkable="true" />
<item
android:id="@+id/action_toggle_firstlastpiece"
android:title="@string/action_toggle_firstlastpiece"
android:checkable="true" />
</menu>
</item>
<item
android:id="@+id/action_remove"
android:icon="@drawable/ic_action_remove"
android:orderInCategory="204"
android:orderInCategory="206"
android:title="@string/action_remove"
app:showAsAction="always">
<menu>
@ -74,25 +91,25 @@ @@ -74,25 +91,25 @@
<item
android:id="@+id/action_setlabel"
android:icon="@drawable/ic_action_labels"
android:orderInCategory="205"
android:orderInCategory="207"
android:title="@string/action_setlabel"
app:showAsAction="always" />
<item
android:id="@+id/action_forcerecheck"
android:icon="@drawable/ic_action_force_recheck"
android:orderInCategory="206"
android:orderInCategory="208"
android:title="@string/action_forcerecheck"
app:showAsAction="always" />
<item
android:id="@+id/action_updatetrackers"
android:icon="@drawable/ic_action_trackers"
android:orderInCategory="207"
android:orderInCategory="209"
android:title="@string/action_updatetrackers"
app:showAsAction="always" />
<item
android:id="@+id/action_changelocation"
android:icon="@drawable/ic_action_save"
android:orderInCategory="208"
android:orderInCategory="210"
android:title="@string/action_changelocation"
app:showAsAction="always" />

9
app/src/main/res/values-ru/strings.xml

@ -54,6 +54,9 @@ @@ -54,6 +54,9 @@
<string name="action_remove_default">Удалить торрент-файл</string>
<string name="action_remove_withdata">Удалить вместе с данными</string>
<string name="action_setlabel">Установить метку</string>
<string name="action_download_mode">Режим скачивания</string>
<string name="action_toggle_sequential">Скачать последовательно</string>
<string name="action_toggle_firstlastpiece">Скачать начало и конец первыми</string>
<string name="action_updatetrackers">Обновить трекеры</string>
<string name="action_changelocation">Изменить место расположения</string>
<string name="action_forcerecheck">Пересчитать хэш</string>
@ -167,6 +170,12 @@ @@ -167,6 +170,12 @@
<string name="result_trackersupdated">Трекеры обновлены</string>
<string name="result_labelset">Метка установлена в \'%1$s\'</string>
<string name="result_labelremoved">Метка удалена</string>
<string name="result_togglesequential">%1$s скачивается %2$s</string>
<string name="result_togglesequential_offstate">последовательно</string>
<string name="result_togglesequential_onstate">обычным образом</string>
<string name="result_togglefirstlastpiece">%1$s имеет %2$s</string>
<string name="result_togglefirstlastpiece_onstate">приоритет первого и последнего куска</string>
<string name="result_togglefirstlastpiece_offstate">обычый приоритет кусков</string>
<string name="result_recheckedstarted">Проверка данных %1$s</string>
<string name="result_locationset">Торрент перемещен в \'%1$s\'</string>
<string name="result_priotitiesset">Приоритеты файлов обновлены</string>

5
app/src/main/res/values/changelog.xml

@ -17,6 +17,11 @@ @@ -17,6 +17,11 @@
-->
<resources>
<string name="system_changelog">
Transdroid 2.5.17\n
- qBittorrent 4.2+ support\n
- Proper label for checking status\n
- Deluge 2 RPC magnet support\n
\n
Transdroid 2.5.16\n
- Deluge 2 via RPC support\n
- Fix Transmission with digest auth\n

10
app/src/main/res/values/strings.xml

@ -56,6 +56,9 @@ @@ -56,6 +56,9 @@
<string name="action_remove_default">Remove torrent</string>
<string name="action_remove_withdata">Remove and delete data</string>
<string name="action_setlabel">Set label</string>
<string name="action_download_mode">Download mode</string>
<string name="action_toggle_sequential">Download sequentially</string>
<string name="action_toggle_firstlastpiece">Prioritize first and last piece</string>
<string name="action_updatetrackers">Update trackers</string>
<string name="action_changelocation">Change storage location</string>
<string name="action_forcerecheck">Force data recheck</string>
@ -130,6 +133,7 @@ @@ -130,6 +133,7 @@
<string name="status_priority_low">Low priority</string>
<string name="status_priority_normal">Normal priority</string>
<string name="status_priority_high">High priority</string>
<string name="status_pieces">PIECES</string>
<string name="status_trackers">TRACKERS</string>
<string name="status_errors">ERRORS</string>
<string name="status_files">FILES</string>
@ -177,6 +181,12 @@ @@ -177,6 +181,12 @@
<string name="result_trackersupdated">Trackers updated</string>
<string name="result_labelset">Label set to \'%1$s\'</string>
<string name="result_labelremoved">Label removed</string>
<string name="result_togglesequential">%1$s is downloading %2$s</string>
<string name="result_togglesequential_offstate">normally</string>
<string name="result_togglesequential_onstate">sequentially</string>
<string name="result_togglefirstlastpiece">%1$s has %2$s</string>
<string name="result_togglefirstlastpiece_onstate">first and last piece priority</string>
<string name="result_togglefirstlastpiece_offstate">normal piece priority</string>
<string name="result_recheckedstarted">Checking %1$s data</string>
<string name="result_locationset">Torrent moved to \'%1$s\'</string>
<string name="result_priotitiesset">File priorities updated</string>

2
latest-app.html

@ -1 +1 @@ @@ -1 +1 @@
235|2.5.15
237|2.5.17

Loading…
Cancel
Save