From ee824238d05197df50e4befd95b7b8be96573415 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 8 Mar 2013 18:56:39 +0100 Subject: [PATCH] Fixing the details fragment to show and with a proper layout of headers.\nStarting task execution. --- lite/res/layout/list_item_filter.xml | 4 +- lite/res/layout/list_item_separator.xml | 2 + lite/res/menu/fragment_details.xml | 2 +- lite/res/values/strings.xml | 14 ++++ lite/res/xml/pref_system.xml | 3 +- .../transdroid/core/gui/DetailsFragment.java | 42 ++++++++++ .../transdroid/core/gui/TorrentsActivity.java | 84 ++++++++++++++++++- .../transdroid/core/gui/TorrentsFragment.java | 7 ++ .../core/gui/lists/DetailsAdapter.java | 15 +++- .../core/gui/lists/TorrentDetailsView.java | 12 +++ .../gui/navigation/FilterSeparatorView.java | 7 +- .../gui/settings/SystemSettingsActivity.java | 2 +- 12 files changed, 178 insertions(+), 16 deletions(-) diff --git a/lite/res/layout/list_item_filter.xml b/lite/res/layout/list_item_filter.xml index 5dff7d2f..66f6ae72 100644 --- a/lite/res/layout/list_item_filter.xml +++ b/lite/res/layout/list_item_filter.xml @@ -2,8 +2,8 @@ diff --git a/lite/res/layout/list_item_separator.xml b/lite/res/layout/list_item_separator.xml index 8a48e729..65389da3 100644 --- a/lite/res/layout/list_item_separator.xml +++ b/lite/res/layout/list_item_separator.xml @@ -2,6 +2,8 @@ \ No newline at end of file diff --git a/lite/res/values/strings.xml b/lite/res/values/strings.xml index ccd9f810..43c447a3 100644 --- a/lite/res/values/strings.xml +++ b/lite/res/values/strings.xml @@ -84,6 +84,20 @@ New label Setting a label is not supported by your client + Torrent added (refreshing) + %1$s removed + %1$s removed and data deleted + %1$s resumed (refreshing) + %1$s stopped + %1$s started (refreshing) + %1$s paused + Torrents paused + Torrents resumed (refreshing) + Torrents stopped + Torrents started (refreshing) + Trackers updated + Torrent moved to \'%1$s\' + Torrent search Search for torrents diff --git a/lite/res/xml/pref_system.xml b/lite/res/xml/pref_system.xml index b186a063..8968dc62 100644 --- a/lite/res/xml/pref_system.xml +++ b/lite/res/xml/pref_system.xml @@ -10,8 +10,7 @@ - + android:summary="@string/pref_sendlog_info" /> torrents) { + // TODO Auto-generated method stub + + } + + @Override + public void pauseTorrents(List torrents) { + // TODO Auto-generated method stub + + } + + @Override + public void removeTorrents(List torrents, boolean withData) { + // TODO Auto-generated method stub + + } + + @Override + public void setLabels(List torrents) { + // TODO Auto-generated method stub + + } + } diff --git a/lite/src/org/transdroid/core/gui/TorrentsFragment.java b/lite/src/org/transdroid/core/gui/TorrentsFragment.java index 25ef7d28..afaba547 100644 --- a/lite/src/org/transdroid/core/gui/TorrentsFragment.java +++ b/lite/src/org/transdroid/core/gui/TorrentsFragment.java @@ -146,4 +146,11 @@ public class TorrentsFragment extends SherlockFragment { // TODO: Implement action } + public interface TorrentsTasksExecutor { + void resumeTorrents(List torrents); + void pauseTorrents(List torrents); + void removeTorrents(List torrents, boolean withData); + void setLabels(List torrents); + } + } diff --git a/lite/src/org/transdroid/core/gui/lists/DetailsAdapter.java b/lite/src/org/transdroid/core/gui/lists/DetailsAdapter.java index 11f8e986..ba60ee43 100644 --- a/lite/src/org/transdroid/core/gui/lists/DetailsAdapter.java +++ b/lite/src/org/transdroid/core/gui/lists/DetailsAdapter.java @@ -81,7 +81,7 @@ public class DetailsAdapter extends MergeAdapter { torrentFilesSeparatorView.setVisibility(View.GONE); } else { torrentFilesAdapter.update(torrentFiles); - torrentFilesSeparatorView.setVisibility(View.GONE); + torrentFilesSeparatorView.setVisibility(View.VISIBLE); } } @@ -95,7 +95,7 @@ public class DetailsAdapter extends MergeAdapter { trackersSeparatorView.setVisibility(View.GONE); } else { trackersAdapter.update(trackers); - trackersSeparatorView.setVisibility(View.GONE); + trackersSeparatorView.setVisibility(View.VISIBLE); } } @@ -109,10 +109,19 @@ public class DetailsAdapter extends MergeAdapter { errorsSeparatorView.setVisibility(View.GONE); } else { errorsAdapter.update(errors); - errorsSeparatorView.setVisibility(View.GONE); + errorsSeparatorView.setVisibility(View.VISIBLE); } } + /** + * The details adapter is empty if it is not showing any torrent (regardless of errors, trackers and files) + */ + @Override + public boolean isEmpty() { + //return torrentDetailsView.isBound(); + return false; + } + /** * Clear currently visible torrent, including header and shown lists */ diff --git a/lite/src/org/transdroid/core/gui/lists/TorrentDetailsView.java b/lite/src/org/transdroid/core/gui/lists/TorrentDetailsView.java index c2975105..2245e4b7 100644 --- a/lite/src/org/transdroid/core/gui/lists/TorrentDetailsView.java +++ b/lite/src/org/transdroid/core/gui/lists/TorrentDetailsView.java @@ -21,6 +21,8 @@ import android.widget.TextView; @EViewGroup(R.layout.fragment_details_header) public class TorrentDetailsView extends RelativeLayout { + private boolean isShowingData = false; + @ViewById protected TextView labelText, dateaddedText, uploadedText, uploadedunitText, ratioText, upspeedText, seedersText, downloadedunitText, downloadedText, totalsizeText, downspeedText, leechersText, statusText; @@ -35,6 +37,12 @@ public class TorrentDetailsView extends RelativeLayout { */ public void update(Torrent torrent) { + if (torrent == null) { + isShowingData = false; + return; + } + + isShowingData = true; LocalTorrent local = LocalTorrent.fromTorrent(torrent); // Set label text @@ -82,4 +90,8 @@ public class TorrentDetailsView extends RelativeLayout { } + public boolean isBound() { + return isShowingData ; + } + } diff --git a/lite/src/org/transdroid/core/gui/navigation/FilterSeparatorView.java b/lite/src/org/transdroid/core/gui/navigation/FilterSeparatorView.java index 9ea2a411..a26516dc 100644 --- a/lite/src/org/transdroid/core/gui/navigation/FilterSeparatorView.java +++ b/lite/src/org/transdroid/core/gui/navigation/FilterSeparatorView.java @@ -3,7 +3,6 @@ package org.transdroid.core.gui.navigation; import org.androidannotations.annotations.EViewGroup; import org.androidannotations.annotations.ViewById; import org.transdroid.core.R; -import org.transdroid.core.gui.lists.SimpleListItem; import android.content.Context; import android.widget.LinearLayout; @@ -26,17 +25,13 @@ public class FilterSeparatorView extends LinearLayout { super(context); } - public void bind(SimpleListItem filterItem) { - separatorText.setText(text); - } - /** * Sets the text that will be shown in this separator (sub header) * @param text The new text to show * @return Itself, for convenience of method chaining */ public FilterSeparatorView setText(String text) { - this.text = text; + separatorText.setText(text); return this; } diff --git a/lite/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java b/lite/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java index 20a9d611..7f697f93 100644 --- a/lite/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java +++ b/lite/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java @@ -27,7 +27,7 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { super.onCreate(savedInstanceState); // Just load the system-related preferences from XML - addPreferencesFromResource(R.xml.pref_notifications); + addPreferencesFromResource(R.xml.pref_system); // Handle outgoing links findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick);