diff --git a/core/.classpath b/core/.classpath
index 1931bb1c..340040a3 100644
--- a/core/.classpath
+++ b/core/.classpath
@@ -10,5 +10,6 @@
+
diff --git a/core/libs/transdroid-connect.jar b/core/libs/transdroid-connect.jar
deleted file mode 100644
index 42191a8f..00000000
Binary files a/core/libs/transdroid-connect.jar and /dev/null differ
diff --git a/core/res/drawable-hdpi/ic_action_forcerecheck_dark.png b/core/res/drawable-hdpi/ic_action_forcerecheck_dark.png
new file mode 100755
index 00000000..66c441b4
Binary files /dev/null and b/core/res/drawable-hdpi/ic_action_forcerecheck_dark.png differ
diff --git a/core/res/drawable-hdpi/ic_action_forcerecheck_light.png b/core/res/drawable-hdpi/ic_action_forcerecheck_light.png
new file mode 100755
index 00000000..a7e8db88
Binary files /dev/null and b/core/res/drawable-hdpi/ic_action_forcerecheck_light.png differ
diff --git a/core/res/drawable-mdpi/ic_action_forcerecheck_dark.png b/core/res/drawable-mdpi/ic_action_forcerecheck_dark.png
new file mode 100755
index 00000000..bf1a6d4d
Binary files /dev/null and b/core/res/drawable-mdpi/ic_action_forcerecheck_dark.png differ
diff --git a/core/res/drawable-mdpi/ic_action_forcerecheck_light.png b/core/res/drawable-mdpi/ic_action_forcerecheck_light.png
new file mode 100755
index 00000000..d62250f6
Binary files /dev/null and b/core/res/drawable-mdpi/ic_action_forcerecheck_light.png differ
diff --git a/core/res/drawable-xhdpi/ic_action_forcerecheck_dark.png b/core/res/drawable-xhdpi/ic_action_forcerecheck_dark.png
new file mode 100755
index 00000000..07ee5e42
Binary files /dev/null and b/core/res/drawable-xhdpi/ic_action_forcerecheck_dark.png differ
diff --git a/core/res/drawable-xhdpi/ic_action_forcerecheck_light.png b/core/res/drawable-xhdpi/ic_action_forcerecheck_light.png
new file mode 100755
index 00000000..a58fa96d
Binary files /dev/null and b/core/res/drawable-xhdpi/ic_action_forcerecheck_light.png differ
diff --git a/core/res/drawable-xxhdpi/ic_action_forcerecheck_dark.png b/core/res/drawable-xxhdpi/ic_action_forcerecheck_dark.png
new file mode 100755
index 00000000..a1106388
Binary files /dev/null and b/core/res/drawable-xxhdpi/ic_action_forcerecheck_dark.png differ
diff --git a/core/res/drawable-xxhdpi/ic_action_forcerecheck_light.png b/core/res/drawable-xxhdpi/ic_action_forcerecheck_light.png
new file mode 100644
index 00000000..08fa9c84
Binary files /dev/null and b/core/res/drawable-xxhdpi/ic_action_forcerecheck_light.png differ
diff --git a/core/res/menu/fragment_details.xml b/core/res/menu/fragment_details.xml
index 294912ce..e5c1e1f4 100644
--- a/core/res/menu/fragment_details.xml
+++ b/core/res/menu/fragment_details.xml
@@ -62,17 +62,23 @@
android:showAsAction="ifRoom"
android:title="@string/action_setlabel"
android:orderInCategory="205" />
+
+ android:orderInCategory="207" />
+ android:orderInCategory="208" />
diff --git a/core/res/values-nl/strings.xml b/core/res/values-nl/strings.xml
index 8d3bfc05..f0aaeff9 100644
--- a/core/res/values-nl/strings.xml
+++ b/core/res/values-nl/strings.xml
@@ -49,6 +49,7 @@ along with Transdroid. If not, see .
Label toewijzen
Trackers updaten
Opslaglocatie wijzigen
+Forceer dataintegriteitscontrole
Uit
Laag
Normaal
@@ -151,6 +152,7 @@ along with Transdroid. If not, see .
Trackers geüpdatet
Label \'%1$s\' toegewezen
Label verwijderd
+%1$s wordt gecontroleerd
Torrent verplaatst naar \'%1$s\'
Bestandsprioriteiten geüpdatet
Maximale snelheden ingesteld
diff --git a/core/res/values/attrs.xml b/core/res/values/attrs.xml
index 78e1bb1e..820371c5 100644
--- a/core/res/values/attrs.xml
+++ b/core/res/values/attrs.xml
@@ -36,6 +36,7 @@
+
diff --git a/core/res/values/strings.xml b/core/res/values/strings.xml
index 736d1ca3..9a7e3bff 100644
--- a/core/res/values/strings.xml
+++ b/core/res/values/strings.xml
@@ -49,6 +49,7 @@
Set label
Update trackers
Change storage location
+ Force data recheck
Off
Low
Normal
@@ -154,6 +155,7 @@
Trackers updated
Label set to \'%1$s\'
Label removed
+ Checking %1$s data
Torrent moved to \'%1$s\'
File priorities updated
Maximum transfer speeds set
diff --git a/core/res/values/styles.xml b/core/res/values/styles.xml
index 0a3b3561..2090c90e 100644
--- a/core/res/values/styles.xml
+++ b/core/res/values/styles.xml
@@ -36,6 +36,7 @@
- @drawable/ic_action_resume_light
- @drawable/ic_action_rss_light
- @drawable/ic_action_save_light
+ - @drawable/ic_action_forcerecheck_light
- @drawable/ic_action_search_light
- @drawable/ic_action_sort_by_size_light
- @drawable/ic_action_start_light
@@ -69,6 +70,7 @@
- @drawable/ic_action_resume_dark
- @drawable/ic_action_rss_dark
- @drawable/ic_action_save_dark
+ - @drawable/ic_action_forcerecheck_dark
- @drawable/ic_action_search_dark
- @drawable/ic_action_sort_by_size_dark
- @drawable/ic_action_start_dark
diff --git a/core/src/org/transdroid/core/gui/DetailsActivity.java b/core/src/org/transdroid/core/gui/DetailsActivity.java
index bc9c9b54..5d384d27 100644
--- a/core/src/org/transdroid/core/gui/DetailsActivity.java
+++ b/core/src/org/transdroid/core/gui/DetailsActivity.java
@@ -47,6 +47,7 @@ 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.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetTorrentDetailsTask;
@@ -225,7 +226,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void resumeTorrent(Torrent torrent) {
torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -237,7 +238,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void pauseTorrent(Torrent torrent) {
torrent.mimicPause();
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -249,7 +250,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void startTorrent(Torrent torrent, boolean forced) {
torrent.mimicStart();
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -261,7 +262,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void stopTorrent(Torrent torrent) {
torrent.mimicStop();
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -272,7 +273,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@Override
public void removeTorrent(Torrent torrent, boolean withData) {
DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
// Close the details activity (as the torrent is now removed)
closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed,
torrent.getName()));
@@ -283,8 +284,8 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread
protected void closeActivity(String closeText) {
- // The activity result RESULT_CANCELED means that the torrent no longer exists
- setResult(RESULT_OK, new Intent().putExtra("torrent_removed", true));
+ setResult(RESULT_OK,
+ new Intent().putExtra("torrent_removed", true).putExtra("affected_torrent", torrent));
finish();
if (closeText != null)
Toast.makeText(this, closeText, Toast.LENGTH_LONG).show();
@@ -296,18 +297,31 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel)
.execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
+ @Background
+ @Override
+ public void forceRecheckTorrent(Torrent torrent) {
+ torrent.mimicCheckingStatus();
+ DaemonTaskResult result = ForceRecheckTask.create(currentConnection, torrent).execute();
+ if (result instanceof DaemonTaskSuccessResult) {
+ onTaskSucceeded((DaemonTaskSuccessResult) result,
+ getString(R.string.result_recheckedstarted, torrent.getName()));
+ } else {
+ onCommunicationError((DaemonTaskFailureResult) result, false);
+ }
+ }
+
@Background
@Override
public void updateTrackers(Torrent torrent, List newTrackers) {
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -318,7 +332,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@Override
public void updateLocation(Torrent torrent, String newLocation) {
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -330,7 +344,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void updatePriority(Torrent torrent, List files, Priority priority) {
DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority,
new ArrayList(files)).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -339,6 +353,9 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
+ // Set the activity result so the calling activity knows it needs to update its view
+ setResult(RESULT_OK,
+ new Intent().putExtra("torrent_updated", true).putExtra("affected_torrent", torrent));
// Refresh the screen as well
refreshTorrent();
refreshTorrentDetails(torrent);
diff --git a/core/src/org/transdroid/core/gui/DetailsFragment.java b/core/src/org/transdroid/core/gui/DetailsFragment.java
index 29de8d05..33cca123 100644
--- a/core/src/org/transdroid/core/gui/DetailsFragment.java
+++ b/core/src/org/transdroid/core/gui/DetailsFragment.java
@@ -318,6 +318,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
.show(getFragmentManager(), "SetLabelDialog");
}
+ @OptionsItem(resName = "action_forcerecheck")
+ protected void setForceRecheck() {
+ getTasksExecutor().forceRecheckTorrent(torrent);
+ }
+
@OptionsItem(resName = "action_updatetrackers")
protected void updateTrackers() {
if (torrentDetails == null) {
diff --git a/core/src/org/transdroid/core/gui/TorrentTasksExecutor.java b/core/src/org/transdroid/core/gui/TorrentTasksExecutor.java
index c8011e3b..4d5f3b9f 100644
--- a/core/src/org/transdroid/core/gui/TorrentTasksExecutor.java
+++ b/core/src/org/transdroid/core/gui/TorrentTasksExecutor.java
@@ -33,6 +33,7 @@ public interface TorrentTasksExecutor {
void startTorrent(Torrent torrent, boolean forced);
void stopTorrent(Torrent torrent);
void removeTorrent(Torrent torrent, boolean withData);
+ void forceRecheckTorrent(Torrent torrent);
void updateLabel(Torrent torrent, String newLabel);
void updateTrackers(Torrent torrent, List newTrackers);
void updateLocation(Torrent torrent, String newLocation);
diff --git a/core/src/org/transdroid/core/gui/TorrentsActivity.java b/core/src/org/transdroid/core/gui/TorrentsActivity.java
index 73521a51..b61ec905 100644
--- a/core/src/org/transdroid/core/gui/TorrentsActivity.java
+++ b/core/src/org/transdroid/core/gui/TorrentsActivity.java
@@ -45,18 +45,28 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings;
-import org.transdroid.core.app.settings.*;
+import org.transdroid.core.app.settings.ServerSetting;
+import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer;
import org.transdroid.core.gui.lists.SimpleListItem;
-import org.transdroid.core.gui.log.*;
-import org.transdroid.core.gui.navigation.*;
-import org.transdroid.core.gui.rss.*;
+import org.transdroid.core.gui.log.Log;
+import org.transdroid.core.gui.log.Log_;
+import org.transdroid.core.gui.navigation.FilterListAdapter;
+import org.transdroid.core.gui.navigation.FilterListAdapter_;
+import org.transdroid.core.gui.navigation.FilterListDropDownAdapter;
+import org.transdroid.core.gui.navigation.FilterListDropDownAdapter_;
+import org.transdroid.core.gui.navigation.Label;
+import org.transdroid.core.gui.navigation.NavigationFilter;
+import org.transdroid.core.gui.navigation.NavigationHelper;
+import org.transdroid.core.gui.navigation.RefreshableActivity;
+import org.transdroid.core.gui.navigation.StatusType;
+import org.transdroid.core.gui.rss.RssfeedsActivity_;
import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog;
-import org.transdroid.core.gui.settings.*;
+import org.transdroid.core.gui.settings.MainSettingsActivity_;
import org.transdroid.core.service.BootReceiver;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.core.widget.WidgetProvider;
@@ -73,6 +83,7 @@ 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.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetStatsTask;
@@ -132,7 +143,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
RefreshableActivity {
private static final int RESULT_DETAILS = 0;
-
+
// Navigation components
@Bean
protected NavigationHelper navigationHelper;
@@ -279,8 +290,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
updateFragmentVisibility(false);
return;
}
-
- // If we had no connection before, establish it now; otherwise jsut reload the settings
+
+ // If we had no connection before, establish it now; otherwise just reload the settings
if (currentConnection == null)
filterSelected(lastUsed, true);
else
@@ -289,11 +300,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@OnActivityResult(RESULT_DETAILS)
protected void onDetailsScreenResult(Intent result) {
- // If the details activity returns whether the torrent was removed, refresh the screen
- if (result != null && result.getBooleanExtra("torrent_removed", false))
- refreshScreen();
+ // If the details activity returns whether the torrent was removed or updated, update the torrents list as well
+ // (the details fragment is the source, so no need to update that)
+ if (result != null && result.hasExtra("affected_torrent")) {
+ Torrent affected = result.getParcelableExtra("affected_torrent");
+ fragmentTorrents.quickUpdateTorrent(affected, result.getBooleanExtra("torrent_removed", false));
+ }
}
-
+
@Override
protected void onDestroy() {
Crouton.cancelAllCroutons();
@@ -457,7 +471,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
supportInvalidateOptionsMenu();
}
-
+
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
@@ -549,7 +563,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
searchMenu.collapseActionView();
super.onPause();
}
-
+
@Override
public boolean onSearchRequested() {
if (searchMenu != null) {
@@ -615,7 +629,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
});
}
-
+
@OptionsItem(resName = "action_refresh")
public void refreshScreen() {
fragmentTorrents.updateIsLoading(true);
@@ -701,7 +715,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if (fragmentDetails != null) {
fragmentDetails.updateTorrent(torrent);
} else {
- DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels).startForResult(RESULT_DETAILS);
+ DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels)
+ .startForResult(RESULT_DETAILS);
}
}
@@ -882,7 +897,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void resumeTorrent(Torrent torrent) {
torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -894,7 +909,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void pauseTorrent(Torrent torrent) {
torrent.mimicPause();
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -906,7 +921,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void startTorrent(Torrent torrent, boolean forced) {
torrent.mimicStart();
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -918,7 +933,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void stopTorrent(Torrent torrent) {
torrent.mimicStop();
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -944,7 +959,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel)
.execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded(
(DaemonTaskSuccessResult) result,
newLabel == null ? getString(R.string.result_labelremoved) : getString(R.string.result_labelset,
@@ -954,11 +969,24 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
}
+ @Background
+ @Override
+ public void forceRecheckTorrent(Torrent torrent) {
+ torrent.mimicCheckingStatus();
+ DaemonTaskResult result = ForceRecheckTask.create(currentConnection, torrent).execute();
+ if (result instanceof DaemonTaskSuccessResult) {
+ onTaskSucceeded((DaemonTaskSuccessResult) result,
+ getString(R.string.result_recheckedstarted, torrent.getName()));
+ } else {
+ onCommunicationError((DaemonTaskFailureResult) result, false);
+ }
+ }
+
@Background
@Override
public void updateTrackers(Torrent torrent, List newTrackers) {
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -969,7 +997,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override
public void updateLocation(Torrent torrent, String newLocation) {
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -981,7 +1009,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updatePriority(Torrent torrent, List files, Priority priority) {
DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority,
new ArrayList(files)).execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@@ -992,7 +1020,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updateMaxSpeeds(Integer maxDownloadSpeed, Integer maxUploadSpeed) {
DaemonTaskResult result = SetTransferRatesTask.create(currentConnection, maxUploadSpeed, maxDownloadSpeed)
.execute();
- if (result instanceof DaemonTaskResult) {
+ if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_maxspeedsset));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
diff --git a/core/src/org/transdroid/core/gui/TorrentsFragment.java b/core/src/org/transdroid/core/gui/TorrentsFragment.java
index 680b4068..02bff444 100644
--- a/core/src/org/transdroid/core/gui/TorrentsFragment.java
+++ b/core/src/org/transdroid/core/gui/TorrentsFragment.java
@@ -132,6 +132,28 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
applyAllFilters();
}
+ /**
+ * Just look for a specific torrent in the currently shown list (by its unique id) and update only this
+ * @param affected The affected torrent to update
+ * @param wasRemoved Whether the affected torrent was indeed removed; otherwise it was updated somehow
+ */
+ public void quickUpdateTorrent(Torrent affected, boolean wasRemoved) {
+ // Remove the old torrent object first
+ Iterator iter = this.torrents.iterator();
+ while (iter.hasNext()) {
+ Torrent torrent = iter.next();
+ if (torrent.getUniqueID().equals(affected.getUniqueID())) {
+ iter.remove();
+ break;
+ }
+ }
+ // In case it was an update, add the updated torrent object
+ if (!wasRemoved)
+ this.torrents.add(affected);
+ // Now refresh the screen
+ applyAllFilters();
+ }
+
/**
* Clears the currently visible list of torrents.
* @param b
@@ -187,9 +209,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
return;
}
- // Get the server daemon type directly form the local list of torrents, if it's not empty
- Daemon serverType = (this.torrents.size() > 0 ? this.torrents.get(0).getDaemon() : Daemon.Transmission);
-
// Filter the list of torrents to show according to navigation and text filters
ArrayList filteredTorrents = new ArrayList(torrents);
if (filteredTorrents != null && currentNavigationFilter != null) {
@@ -209,7 +228,7 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
}
// Sort the list of filtered torrents
- Collections.sort(filteredTorrents, new TorrentsComparator(serverType, this.currentSortOrder,
+ Collections.sort(filteredTorrents, new TorrentsComparator(daemonType, this.currentSortOrder,
this.currentSortDescending));
((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents);
diff --git a/lib/src/org/transdroid/daemon/Daemon.java b/lib/src/org/transdroid/daemon/Daemon.java
index 3d8dc566..2ba5847a 100644
--- a/lib/src/org/transdroid/daemon/Daemon.java
+++ b/lib/src/org/transdroid/daemon/Daemon.java
@@ -314,7 +314,7 @@ public enum Daemon {
}
public static boolean supportsLabels(Daemon type) {
- return type == uTorrent || type == BitTorrent || type == Deluge || type == BitComet || type == rTorrent || type == Dummy; // || type == Vuze
+ return type == uTorrent || type == BitTorrent || type == Deluge || type == BitComet || type == rTorrent || type == Dummy;
}
public static boolean supportsSetLabel(Daemon type) {
@@ -333,6 +333,10 @@ public enum Daemon {
return type == uTorrent || type == BitTorrent || type == Deluge || type == Dummy;
}
+ public static boolean supportsForceRecheck(Daemon type) {
+ return type == uTorrent || type == BitTorrent || type == Deluge || type == rTorrent || type == Dummy;
+ }
+
public static boolean supportsExtraPassword(Daemon type) {
return type == Deluge;
}
diff --git a/lib/src/org/transdroid/daemon/DaemonMethod.java b/lib/src/org/transdroid/daemon/DaemonMethod.java
index 12375d56..d459dcb1 100644
--- a/lib/src/org/transdroid/daemon/DaemonMethod.java
+++ b/lib/src/org/transdroid/daemon/DaemonMethod.java
@@ -43,7 +43,8 @@ public enum DaemonMethod {
GetTorrentDetails (18),
SetTrackers (19),
SetAlternativeMode (20),
- GetStats (21);
+ GetStats (21),
+ ForceRecheck (22);
private int code;
private static final Map lookup = new HashMap();
diff --git a/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java b/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java
index ffe0e53a..a5addb1a 100644
--- a/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java
+++ b/lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java
@@ -112,6 +112,7 @@ public class DelugeAdapter implements IDaemonAdapter {
//private static final String RPC_METHOD_SETOPTIONS = "core.set_torrent_options";
private static final String RPC_METHOD_MOVESTORAGE = "core.move_storage";
private static final String RPC_METHOD_SETTRACKERS = "core.set_torrent_trackers";
+ private static final String RPC_METHOD_FORCERECHECK = "core.force_recheck";
private static final String RPC_NAME = "name";
private static final String RPC_STATUS = "state";
@@ -397,6 +398,13 @@ public class DelugeAdapter implements IDaemonAdapter {
params.put(trackers);
makeRequest(buildRequest(RPC_METHOD_SETTRACKERS, params));
return new DaemonTaskSuccessResult(task);
+
+ case ForceRecheck:
+
+ // Pause a torrent
+ makeRequest(buildRequest(RPC_METHOD_FORCERECHECK,
+ ((new JSONArray()).put((new JSONArray()).put(task.getTargetTorrent().getUniqueID())))));
+ return new DaemonTaskSuccessResult(task);
default:
return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType()));
diff --git a/lib/src/org/transdroid/daemon/DummyAdapter.java b/lib/src/org/transdroid/daemon/DummyAdapter.java
index e52b133b..d2ecc06c 100644
--- a/lib/src/org/transdroid/daemon/DummyAdapter.java
+++ b/lib/src/org/transdroid/daemon/DummyAdapter.java
@@ -33,6 +33,7 @@ import org.transdroid.daemon.task.DaemonTask;
import org.transdroid.daemon.task.DaemonTaskFailureResult;
import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult;
+import org.transdroid.daemon.task.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetStatsTask;
@@ -269,6 +270,17 @@ public class DummyAdapter implements IDaemonAdapter {
trackersList = new ArrayList(((SetTrackersTask)task).getNewTrackers());
return new DaemonTaskSuccessResult(task);
+ case ForceRecheck:
+
+ ForceRecheckTask recheckTask = (ForceRecheckTask) task;
+ // Pretend we rechecked this task by pausing it (or stopping, if it is paused) so we can see the result
+ if (recheckTask.getTargetTorrent().getStatusCode() == TorrentStatus.Paused) {
+ recheckTask.getTargetTorrent().mimicStop();
+ } else {
+ recheckTask.getTargetTorrent().mimicPause();
+ }
+ return new DaemonTaskSuccessResult(task);
+
case SetDownloadLocation:
task.getTargetTorrent().mimicNewLocation(((SetDownloadLocationTask) task).getNewLocation());
diff --git a/lib/src/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java b/lib/src/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java
index 574e8eca..89f02720 100644
--- a/lib/src/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java
+++ b/lib/src/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java
@@ -225,6 +225,12 @@ public class RtorrentAdapter implements IDaemonAdapter {
makeRtorrentCall("d.set_custom1", new String[] { task.getTargetTorrent().getUniqueID(), labelTask.getNewLabel() });
return new DaemonTaskSuccessResult(task);
+ case ForceRecheck:
+
+ // Force re-check of data of a torrent
+ makeRtorrentCall("d.check_hash", new String[] { task.getTargetTorrent().getUniqueID() });
+ return new DaemonTaskSuccessResult(task);
+
default:
return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType()));
}
diff --git a/lib/src/org/transdroid/daemon/Torrent.java b/lib/src/org/transdroid/daemon/Torrent.java
index e05cb1f6..925eeb84 100644
--- a/lib/src/org/transdroid/daemon/Torrent.java
+++ b/lib/src/org/transdroid/daemon/Torrent.java
@@ -250,6 +250,10 @@ public final class Torrent implements Parcelable, Comparable {
public void mimicNewLabel(String newLabel) {
label = newLabel;
}
+
+ public void mimicCheckingStatus() {
+ statusCode = TorrentStatus.Checking;
+ }
public void mimicNewLocation(String newLocation) {
locationDir = newLocation;
diff --git a/lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java b/lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java
index 32bb6e54..12e1e797 100644
--- a/lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java
+++ b/lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java
@@ -41,12 +41,12 @@ import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.DaemonException.ExceptionType;
import org.transdroid.daemon.DaemonSettings;
import org.transdroid.daemon.IDaemonAdapter;
+import org.transdroid.daemon.Label;
import org.transdroid.daemon.Priority;
import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentDetails;
import org.transdroid.daemon.TorrentFile;
import org.transdroid.daemon.TorrentStatus;
-import org.transdroid.daemon.Label;
import org.transdroid.daemon.task.AddByFileTask;
import org.transdroid.daemon.task.AddByMagnetUrlTask;
import org.transdroid.daemon.task.AddByUrlTask;
@@ -248,7 +248,13 @@ public class UtorrentAdapter implements IDaemonAdapter {
makeUtorrentRequest("&action=setprops" + RPC_URL_HASH + trackersTask.getTargetTorrent().getUniqueID() +
"&s=trackers&v=" + URLEncoder.encode(newTrackersText, "UTF-8"));
return new DaemonTaskSuccessResult(task);
-
+
+ case ForceRecheck:
+
+ // Force re-check of data on a torrent
+ makeUtorrentRequest("&action=recheck" + RPC_URL_HASH + task.getTargetTorrent().getUniqueID());
+ return new DaemonTaskSuccessResult(task);
+
default:
return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType()));
}
diff --git a/lib/src/org/transdroid/daemon/task/ForceRecheckTask.java b/lib/src/org/transdroid/daemon/task/ForceRecheckTask.java
new file mode 100644
index 00000000..5f485403
--- /dev/null
+++ b/lib/src/org/transdroid/daemon/task/ForceRecheckTask.java
@@ -0,0 +1,31 @@
+/*
+ * This file is part of Transdroid
+ *
+ * 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 .
+ *
+ */
+ package org.transdroid.daemon.task;
+
+import org.transdroid.daemon.DaemonMethod;
+import org.transdroid.daemon.IDaemonAdapter;
+import org.transdroid.daemon.Torrent;
+
+public class ForceRecheckTask extends DaemonTask {
+ protected ForceRecheckTask(IDaemonAdapter adapter, Torrent targetTorrent) {
+ super(adapter, DaemonMethod.ForceRecheck, targetTorrent, null);
+ }
+ public static ForceRecheckTask create(IDaemonAdapter adapter, Torrent targetTorrent) {
+ return new ForceRecheckTask(adapter, targetTorrent);
+ }
+}