Browse Source

Fixed file priorities and added appropriate action bar icons.

pull/11/head
Eric Kok 12 years ago
parent
commit
4056ddf497
  1. BIN
      core/res/drawable-hdpi/ic_action_priority_high_dark.png
  2. BIN
      core/res/drawable-hdpi/ic_action_priority_high_light.png
  3. BIN
      core/res/drawable-hdpi/ic_action_priority_low_dark.png
  4. BIN
      core/res/drawable-hdpi/ic_action_priority_low_light.png
  5. BIN
      core/res/drawable-hdpi/ic_action_priority_normal_dark.png
  6. BIN
      core/res/drawable-hdpi/ic_action_priority_normal_light.png
  7. BIN
      core/res/drawable-hdpi/ic_action_priority_off_dark.png
  8. BIN
      core/res/drawable-hdpi/ic_action_priority_off_light.png
  9. BIN
      core/res/drawable-hdpi/ic_action_trackers_dark.png
  10. BIN
      core/res/drawable-hdpi/ic_action_trackers_light.png
  11. BIN
      core/res/drawable-mdpi/ic_action_priority_high_dark.png
  12. BIN
      core/res/drawable-mdpi/ic_action_priority_high_light.png
  13. BIN
      core/res/drawable-mdpi/ic_action_priority_low_dark.png
  14. BIN
      core/res/drawable-mdpi/ic_action_priority_low_light.png
  15. BIN
      core/res/drawable-mdpi/ic_action_priority_normal_dark.png
  16. BIN
      core/res/drawable-mdpi/ic_action_priority_normal_light.png
  17. BIN
      core/res/drawable-mdpi/ic_action_priority_off_dark.png
  18. BIN
      core/res/drawable-mdpi/ic_action_priority_off_light.png
  19. BIN
      core/res/drawable-mdpi/ic_action_trackers_dark.png
  20. BIN
      core/res/drawable-mdpi/ic_action_trackers_light.png
  21. BIN
      core/res/drawable-xhdpi/ic_action_priority_high_dark.png
  22. BIN
      core/res/drawable-xhdpi/ic_action_priority_high_light.png
  23. BIN
      core/res/drawable-xhdpi/ic_action_priority_low_dark.png
  24. BIN
      core/res/drawable-xhdpi/ic_action_priority_low_light.png
  25. BIN
      core/res/drawable-xhdpi/ic_action_priority_normal_dark.png
  26. BIN
      core/res/drawable-xhdpi/ic_action_priority_normal_light.png
  27. BIN
      core/res/drawable-xhdpi/ic_action_priority_off_dark.png
  28. BIN
      core/res/drawable-xhdpi/ic_action_priority_off_light.png
  29. BIN
      core/res/drawable-xhdpi/ic_action_trackers_dark.png
  30. BIN
      core/res/drawable-xhdpi/ic_action_trackers_light.png
  31. 1
      core/res/menu/fragment_details.xml
  32. 4
      core/res/menu/fragment_details_file.xml
  33. 5
      core/res/values/attrs.xml
  34. 10
      core/res/values/styles.xml
  35. 6
      core/src/org/transdroid/core/gui/DetailsFragment.java
  36. 4
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  37. 12
      core/src/org/transdroid/core/gui/TorrentsFragment.java
  38. 18
      core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java
  39. 13
      core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java
  40. 2
      lib/src/org/transdroid/daemon/Daemon.java

BIN
core/res/drawable-hdpi/ic_action_priority_high_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

BIN
core/res/drawable-hdpi/ic_action_priority_high_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

BIN
core/res/drawable-hdpi/ic_action_priority_low_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

BIN
core/res/drawable-hdpi/ic_action_priority_low_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
core/res/drawable-hdpi/ic_action_priority_normal_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 B

BIN
core/res/drawable-hdpi/ic_action_priority_normal_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

BIN
core/res/drawable-hdpi/ic_action_priority_off_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

BIN
core/res/drawable-hdpi/ic_action_priority_off_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
core/res/drawable-hdpi/ic_action_trackers_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
core/res/drawable-hdpi/ic_action_trackers_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
core/res/drawable-mdpi/ic_action_priority_high_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

BIN
core/res/drawable-mdpi/ic_action_priority_high_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

BIN
core/res/drawable-mdpi/ic_action_priority_low_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

BIN
core/res/drawable-mdpi/ic_action_priority_low_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

BIN
core/res/drawable-mdpi/ic_action_priority_normal_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

BIN
core/res/drawable-mdpi/ic_action_priority_normal_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

BIN
core/res/drawable-mdpi/ic_action_priority_off_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

BIN
core/res/drawable-mdpi/ic_action_priority_off_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
core/res/drawable-mdpi/ic_action_trackers_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
core/res/drawable-mdpi/ic_action_trackers_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_high_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_high_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_low_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_low_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_normal_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_normal_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_off_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
core/res/drawable-xhdpi/ic_action_priority_off_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
core/res/drawable-xhdpi/ic_action_trackers_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
core/res/drawable-xhdpi/ic_action_trackers_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

1
core/res/menu/fragment_details.xml

@ -42,6 +42,7 @@
android:title="@string/action_setlabel" /> android:title="@string/action_setlabel" />
<item <item
android:id="@+id/action_updatetrackers" android:id="@+id/action_updatetrackers"
android:icon="?attr/ic_action_trackers"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_updatetrackers" /> android:title="@string/action_updatetrackers" />

4
core/res/menu/fragment_details_file.xml

@ -2,18 +2,22 @@
<item <item
android:id="@+id/action_priority_off" android:id="@+id/action_priority_off"
android:icon="?attr/ic_action_priority_off"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_priority_off" /> android:title="@string/action_priority_off" />
<item <item
android:id="@+id/action_priority_low" android:id="@+id/action_priority_low"
android:icon="?attr/ic_action_priority_low"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_priority_low" /> android:title="@string/action_priority_low" />
<item <item
android:id="@+id/action_priority_normal" android:id="@+id/action_priority_normal"
android:icon="?attr/ic_action_priority_normal"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_priority_normal" /> android:title="@string/action_priority_normal" />
<item <item
android:id="@+id/action_priority_high" android:id="@+id/action_priority_high"
android:icon="?attr/ic_action_priority_high"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_priority_high" /> android:title="@string/action_priority_high" />
<item <item

5
core/res/values/attrs.xml

@ -10,6 +10,10 @@
<attr name="ic_action_labels" format="reference"/> <attr name="ic_action_labels" format="reference"/>
<attr name="ic_action_new" format="reference"/> <attr name="ic_action_new" format="reference"/>
<attr name="ic_action_pause" format="reference"/> <attr name="ic_action_pause" format="reference"/>
<attr name="ic_action_priority_off" format="reference"/>
<attr name="ic_action_priority_low" format="reference"/>
<attr name="ic_action_priority_normal" format="reference"/>
<attr name="ic_action_priority_high" format="reference"/>
<attr name="ic_action_refresh" format="reference"/> <attr name="ic_action_refresh" format="reference"/>
<attr name="ic_action_remove" format="reference"/> <attr name="ic_action_remove" format="reference"/>
<attr name="ic_action_resume" format="reference"/> <attr name="ic_action_resume" format="reference"/>
@ -18,6 +22,7 @@
<attr name="ic_action_sort_by_size" format="reference"/> <attr name="ic_action_sort_by_size" format="reference"/>
<attr name="ic_action_start" format="reference"/> <attr name="ic_action_start" format="reference"/>
<attr name="ic_action_stop" format="reference"/> <attr name="ic_action_stop" format="reference"/>
<attr name="ic_action_trackers" format="reference"/>
<attr name="ic_action_website" format="reference"/> <attr name="ic_action_website" format="reference"/>
<attr name="loading_progress" format="reference"/> <attr name="loading_progress" format="reference"/>
<attr name="selectable_background_transdroid" format="reference"/> <attr name="selectable_background_transdroid" format="reference"/>

10
core/res/values/styles.xml

@ -9,6 +9,10 @@
<item name="ic_action_labels">@drawable/ic_action_labels_light</item> <item name="ic_action_labels">@drawable/ic_action_labels_light</item>
<item name="ic_action_new">@drawable/ic_action_new_light</item> <item name="ic_action_new">@drawable/ic_action_new_light</item>
<item name="ic_action_pause">@drawable/ic_action_pause_light</item> <item name="ic_action_pause">@drawable/ic_action_pause_light</item>
<item name="ic_action_priority_off">@drawable/ic_action_priority_off_light</item>
<item name="ic_action_priority_low">@drawable/ic_action_priority_low_light</item>
<item name="ic_action_priority_normal">@drawable/ic_action_priority_normal_light</item>
<item name="ic_action_priority_high">@drawable/ic_action_priority_high_light</item>
<item name="ic_action_refresh">@drawable/ic_action_refresh_light</item> <item name="ic_action_refresh">@drawable/ic_action_refresh_light</item>
<item name="ic_action_remove">@drawable/ic_action_remove_light</item> <item name="ic_action_remove">@drawable/ic_action_remove_light</item>
<item name="ic_action_resume">@drawable/ic_action_resume_light</item> <item name="ic_action_resume">@drawable/ic_action_resume_light</item>
@ -17,6 +21,7 @@
<item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_light</item> <item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_light</item>
<item name="ic_action_start">@drawable/ic_action_start_light</item> <item name="ic_action_start">@drawable/ic_action_start_light</item>
<item name="ic_action_stop">@drawable/ic_action_stop_light</item> <item name="ic_action_stop">@drawable/ic_action_stop_light</item>
<item name="ic_action_trackers">@drawable/ic_action_trackers_light</item>
<item name="ic_action_website">@drawable/ic_action_website_light</item> <item name="ic_action_website">@drawable/ic_action_website_light</item>
<item name="loading_progress">@drawable/loading_progress_light</item> <item name="loading_progress">@drawable/loading_progress_light</item>
<item name="selectable_background_transdroid">@drawable/selectable_background_transdroid2</item> <item name="selectable_background_transdroid">@drawable/selectable_background_transdroid2</item>
@ -33,6 +38,10 @@
<item name="ic_action_labels">@drawable/ic_action_labels_dark</item> <item name="ic_action_labels">@drawable/ic_action_labels_dark</item>
<item name="ic_action_new">@drawable/ic_action_new_dark</item> <item name="ic_action_new">@drawable/ic_action_new_dark</item>
<item name="ic_action_pause">@drawable/ic_action_pause_dark</item> <item name="ic_action_pause">@drawable/ic_action_pause_dark</item>
<item name="ic_action_priority_off">@drawable/ic_action_priority_off_dark</item>
<item name="ic_action_priority_low">@drawable/ic_action_priority_low_dark</item>
<item name="ic_action_priority_normal">@drawable/ic_action_priority_normal_dark</item>
<item name="ic_action_priority_high">@drawable/ic_action_priority_high_dark</item>
<item name="ic_action_refresh">@drawable/ic_action_refresh_dark</item> <item name="ic_action_refresh">@drawable/ic_action_refresh_dark</item>
<item name="ic_action_remove">@drawable/ic_action_remove_dark</item> <item name="ic_action_remove">@drawable/ic_action_remove_dark</item>
<item name="ic_action_resume">@drawable/ic_action_resume_dark</item> <item name="ic_action_resume">@drawable/ic_action_resume_dark</item>
@ -41,6 +50,7 @@
<item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_dark</item> <item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_dark</item>
<item name="ic_action_start">@drawable/ic_action_start_dark</item> <item name="ic_action_start">@drawable/ic_action_start_dark</item>
<item name="ic_action_stop">@drawable/ic_action_stop_dark</item> <item name="ic_action_stop">@drawable/ic_action_stop_dark</item>
<item name="ic_action_trackers">@drawable/ic_action_trackers_dark</item>
<item name="ic_action_website">@drawable/ic_action_website_dark</item> <item name="ic_action_website">@drawable/ic_action_website_dark</item>
<item name="loading_progress">@drawable/loading_progress_light</item> <item name="loading_progress">@drawable/loading_progress_light</item>
<item name="selectable_background_transdroid">@drawable/selectable_background_transdroid</item> <item name="selectable_background_transdroid">@drawable/selectable_background_transdroid</item>

6
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -274,9 +274,13 @@ public class DetailsFragment extends SherlockFragment {
mode.finish(); mode.finish();
return true; return true;
} else { } else {
Priority priority = Priority.Normal; Priority priority = Priority.Off;
if (itemId == R.id.action_priority_low) if (itemId == R.id.action_priority_low)
priority = Priority.Low; priority = Priority.Low;
if (itemId == R.id.action_priority_normal)
priority = Priority.Normal;
if (itemId == R.id.action_priority_high)
priority = Priority.High;
getTasksExecutor().updatePriority(torrent, checked, priority); getTasksExecutor().updatePriority(torrent, checked, priority);
mode.finish(); mode.finish();
return true; return true;

4
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -305,7 +305,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
navigationSpinnerAdapter.updateCurrentFilter(currentFilter); navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
// Clear the currently shown list of torrents and perhaps the details // Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(); fragmentTorrents.clear(true);
if (fragmentDetails != null && fragmentDetails.getActivity() != null) { if (fragmentDetails != null && fragmentDetails.getActivity() != null) {
fragmentDetails.clear(); fragmentDetails.clear();
} }
@ -701,7 +701,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute(); DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(withData ? R.string.result_removed_with_data onTaskSucceeded((DaemonTaskSuccessResult) result, getString(withData ? R.string.result_removed_with_data
: R.string.result_removed)); : R.string.result_removed, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
} }

12
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -95,10 +95,12 @@ public class TorrentsFragment extends SherlockFragment {
/** /**
* Clears the currently visible list of torrents. * Clears the currently visible list of torrents.
* @param b
*/ */
public void clear() { public void clear(boolean clearError) {
this.torrents = null; this.torrents = null;
this.connectionErrorMessage = null; if (clearError)
this.connectionErrorMessage = null;
this.currentTextFilter = null; this.currentTextFilter = null;
this.currentNavigationFilter = null; this.currentNavigationFilter = null;
applyAllFilters(); applyAllFilters();
@ -264,7 +266,7 @@ public class TorrentsFragment extends SherlockFragment {
public void updateConnectionStatus(boolean hasAConnection) { public void updateConnectionStatus(boolean hasAConnection) {
this.hasAConnection = hasAConnection; this.hasAConnection = hasAConnection;
if (!hasAConnection) { if (!hasAConnection) {
clear(); // Indirectly also calls updateViewVisibility() clear(true); // Indirectly also calls updateViewVisibility()
} else { } else {
updateViewVisibility(); updateViewVisibility();
} }
@ -278,7 +280,7 @@ public class TorrentsFragment extends SherlockFragment {
public void updateIsLoading(boolean isLoading) { public void updateIsLoading(boolean isLoading) {
this.isLoading = isLoading; this.isLoading = isLoading;
if (isLoading) { if (isLoading) {
clear(); // Indirectly also calls updateViewVisibility() clear(true); // Indirectly also calls updateViewVisibility()
} else { } else {
updateViewVisibility(); updateViewVisibility();
} }
@ -294,7 +296,7 @@ public class TorrentsFragment extends SherlockFragment {
this.connectionErrorMessage = connectionErrorMessage; this.connectionErrorMessage = connectionErrorMessage;
errorText.setText(connectionErrorMessage); errorText.setText(connectionErrorMessage);
if (connectionErrorMessage != null) { if (connectionErrorMessage != null) {
clear(); // Indirectly also calls updateViewVisibility() clear(false); // Indirectly also calls updateViewVisibility()
} else { } else {
updateViewVisibility(); updateViewVisibility();
} }

18
core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java

@ -9,10 +9,16 @@ import android.graphics.RectF;
import android.util.AttributeSet; import android.util.AttributeSet;
import fr.marvinlabs.widget.CheckableRelativeLayout; import fr.marvinlabs.widget.CheckableRelativeLayout;
/**
* A relative layout that that is checkable (to be used in a contextual action bar) and shows a coloured bar in the far
* left indicating the priority of the represented file. The darker the green, the higher the priority, while grey means
* the file isn't downloaded at all.
* @author Eric Kok
*/
public class TorrentFilePriorityLayout extends CheckableRelativeLayout { public class TorrentFilePriorityLayout extends CheckableRelativeLayout {
private final float scale = getContext().getResources().getDisplayMetrics().density; private final float scale = getContext().getResources().getDisplayMetrics().density;
private final int WIDTH = (int) (5 * scale + 0.5f); private final int WIDTH = (int) (6 * scale + 0.5f);
private Priority priority = null; private Priority priority = null;
private final Paint offPaint = new Paint(); private final Paint offPaint = new Paint();
@ -34,10 +40,10 @@ public class TorrentFilePriorityLayout extends CheckableRelativeLayout {
} }
private void initPaints() { private void initPaints() {
offPaint.setColor(0xFF9E9E9E); // Grey offPaint.setColor(0xFF9E9E9E); // Grey
lowPaint.setColor(0x778ACC12); // Very Light green lowPaint.setColor(0xFFC8E88E); // Light green
normalPaint.setColor(0xBB8ACC12); // Light green normalPaint.setColor(0xFF8ACC12); // Normal green
highPaint.setColor(0xFF8ACC12); // Green highPaint.setColor(0xFF4B6617); // Dark green
} }
public void setPriority(Priority priority) { public void setPriority(Priority priority) {
@ -56,7 +62,7 @@ public class TorrentFilePriorityLayout extends CheckableRelativeLayout {
if (priority == null) { if (priority == null) {
return; return;
} }
switch (priority) { switch (priority) {
case Low: case Low:
canvas.drawRect(fullRect, lowPaint); canvas.drawRect(fullRect, lowPaint);

13
core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java

@ -9,10 +9,16 @@ import android.graphics.RectF;
import android.util.AttributeSet; import android.util.AttributeSet;
import fr.marvinlabs.widget.CheckableRelativeLayout; import fr.marvinlabs.widget.CheckableRelativeLayout;
/**
* A relative layout that is checkable (to be used in a contextual action bar) and shows a coloured bar in the far left
* indicating the status of the represented torrent. Active downloads are blue, seeding torrents are green, errors are
* red, etc.
* @author Eric Kok
*/
public class TorrentStatusLayout extends CheckableRelativeLayout { public class TorrentStatusLayout extends CheckableRelativeLayout {
private final float scale = getContext().getResources().getDisplayMetrics().density; private final float scale = getContext().getResources().getDisplayMetrics().density;
private final int WIDTH = (int) (5 * scale + 0.5f); private final int WIDTH = (int) (6 * scale + 0.5f);
private TorrentStatus status = null; private TorrentStatus status = null;
private final Paint inactiveDonePaint = new Paint(); private final Paint inactiveDonePaint = new Paint();
@ -42,6 +48,11 @@ public class TorrentStatusLayout extends CheckableRelativeLayout {
errorPaint.setColor(0xFFDE3939); // Red errorPaint.setColor(0xFFDE3939); // Red
} }
/**
* Registers the status of the represented torrent and invalidates the view so the status colour will be updated
* accordingly.
* @param status
*/
public void setStatus(TorrentStatus status) { public void setStatus(TorrentStatus status) {
this.status = status; this.status = status;
this.invalidate(); this.invalidate();

2
lib/src/org/transdroid/daemon/Daemon.java

@ -217,7 +217,7 @@ public enum Daemon {
return 80; return 80;
} }
case Deluge: case Deluge:
return 8112; return 8112;
case Transmission: case Transmission:
return 9091; return 9091;
case Bitflu: case Bitflu:

Loading…
Cancel
Save