From 21f90ab761469ed704adf592b32f58a5b7b3744f Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Tue, 11 Jun 2013 22:20:26 +0200 Subject: [PATCH] Trial with more compact torrent list layout and colour-based status indicator. --- core/res/values/dimens.xml | 1 + .../core/gui/lists/TorrentProgressBar.java | 12 ++++---- .../core/gui/lists/TorrentView.java | 30 +++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/core/res/values/dimens.xml b/core/res/values/dimens.xml index e6f730d4..5cb23510 100644 --- a/core/res/values/dimens.xml +++ b/core/res/values/dimens.xml @@ -2,5 +2,6 @@ 16dp 8dp + 16dp \ No newline at end of file diff --git a/core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java b/core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java index c6347cee..392f3724 100644 --- a/core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java +++ b/core/src/org/transdroid/core/gui/lists/TorrentProgressBar.java @@ -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 diff --git a/core/src/org/transdroid/core/gui/lists/TorrentView.java b/core/src/org/transdroid/core/gui/lists/TorrentView.java index 6c87f478..7f958b48 100644 --- a/core/src/org/transdroid/core/gui/lists/TorrentView.java +++ b/core/src/org/transdroid/core/gui/lists/TorrentView.java @@ -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 { 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); + } } }