Browse Source

Trial with more compact torrent list layout and colour-based status indicator.

pull/11/head
Eric Kok 12 years ago
parent
commit
21f90ab761
  1. 1
      core/res/values/dimens.xml
  2. 12
      core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java
  3. 30
      core/src/org/transdroid/core/gui/lists/TorrentView.java

1
core/res/values/dimens.xml

@ -2,5 +2,6 @@ @@ -2,5 +2,6 @@
<dimen name="margin_default">16dp</dimen>
<dimen name="margin_half">8dp</dimen>
<dimen name="margin_torrentlistleft">16dp</dimen>
</resources>

12
core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java

@ -66,12 +66,12 @@ public class TorrentProgressBar extends View { @@ -66,12 +66,12 @@ public class TorrentProgressBar extends View {
}
private void initPaints() {
notdonePaint.setColor(0xFFEEEEEE);
inactiveDonePaint.setColor(0xFFA759D4);
inactivePaint.setColor(0xFF9E9E9E);
progressPaint.setColor(0xFF42A8FA);
donePaint.setColor(0xFF8CCF29);
errorPaint.setColor(0xFFDE3939);
notdonePaint.setColor(0xFFEEEEEE); // Light grey
inactiveDonePaint.setColor(0xFFA759D4); // Purple
inactivePaint.setColor(0xFF9E9E9E); // Grey
progressPaint.setColor(0xFF42A8FA); // Blue
donePaint.setColor(0xFF8CCF29); // Green
errorPaint.setColor(0xFFDE3939); // Red
}
@Override

30
core/src/org/transdroid/core/gui/lists/TorrentView.java

@ -9,14 +9,13 @@ import android.content.Context; @@ -9,14 +9,13 @@ import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import fr.marvinlabs.widget.CheckableRelativeLayout;
/**
* View that represents some {@link Torrent} object and displays progress, status, speeds, etc.
* @author Eric Kok
*/
@EViewGroup(resName="list_item_torrent")
public class TorrentView extends CheckableRelativeLayout {
@EViewGroup(resName = "list_item_torrent2")
public class TorrentView extends TorrentStatusLayout {
@ViewById
protected ImageView priorityImage;
@ -31,16 +30,29 @@ public class TorrentView extends CheckableRelativeLayout { @@ -31,16 +30,29 @@ public class TorrentView extends CheckableRelativeLayout {
public void bind(Torrent torrent) {
LocalTorrent local = LocalTorrent.fromTorrent(torrent);
setStatus(torrent.getStatusCode());
nameText.setText(torrent.getName());
ratioText.setText(local.getProgressEtaRatioText(getResources()));
progressText.setText(local.getProgressSizeText(getResources(), false));
speedText.setText(local.getProgressSpeedText(getResources()));
peersText.setText(local.getProgressConnectionText(getResources()));
torrentProgressbar.setProgress((int) (torrent.getDownloadedPercentage() * 100));
torrentProgressbar.setActive(torrent.canPause());;
torrentProgressbar.setError(torrent.getStatusCode() == TorrentStatus.Error);
ratioText.setText(local.getProgressEtaRatioText(getResources()));
// TODO: Implement per-torrent priority and set priorityImage
priorityImage.setVisibility(View.INVISIBLE);
// Only show status bar, peers and speed fields if relevant, i.e. when downloading or actively seeding
if (torrent.getStatusCode() == TorrentStatus.Downloading
|| (torrent.getStatusCode() == TorrentStatus.Seeding && torrent.getRateUpload() > 0)) {
torrentProgressbar.setVisibility(View.VISIBLE);
torrentProgressbar.setProgress((int) (torrent.getDownloadedPercentage() * 100));
torrentProgressbar.setActive(torrent.canPause());
torrentProgressbar.setError(torrent.getStatusCode() == TorrentStatus.Error);
peersText.setVisibility(View.VISIBLE);
peersText.setText(local.getProgressConnectionText(getResources()));
speedText.setVisibility(View.VISIBLE);
speedText.setText(local.getProgressSpeedText(getResources()));
} else {
torrentProgressbar.setVisibility(View.GONE);
peersText.setVisibility(View.GONE);
speedText.setVisibility(View.GONE);
}
}
}

Loading…
Cancel
Save