|
|
@ -20,16 +20,11 @@ import org.androidannotations.annotations.SystemService; |
|
|
|
import org.androidannotations.annotations.UiThread; |
|
|
|
import org.androidannotations.annotations.UiThread; |
|
|
|
import org.androidannotations.annotations.ViewById; |
|
|
|
import org.androidannotations.annotations.ViewById; |
|
|
|
import org.transdroid.core.R; |
|
|
|
import org.transdroid.core.R; |
|
|
|
import org.transdroid.core.app.settings.ApplicationSettings; |
|
|
|
|
|
|
|
import org.transdroid.core.app.settings.*; |
|
|
|
import org.transdroid.core.app.settings.*; |
|
|
|
import org.transdroid.core.gui.lists.LocalTorrent; |
|
|
|
import org.transdroid.core.gui.lists.LocalTorrent; |
|
|
|
import org.transdroid.core.gui.lists.SimpleListItem; |
|
|
|
import org.transdroid.core.gui.lists.SimpleListItem; |
|
|
|
import org.transdroid.core.gui.log.*; |
|
|
|
import org.transdroid.core.gui.log.*; |
|
|
|
import org.transdroid.core.gui.navigation.*; |
|
|
|
import org.transdroid.core.gui.navigation.*; |
|
|
|
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.StatusType; |
|
|
|
|
|
|
|
import org.transdroid.core.gui.search.BarcodeHelper; |
|
|
|
import org.transdroid.core.gui.search.BarcodeHelper; |
|
|
|
import org.transdroid.core.gui.search.FilePickerHelper; |
|
|
|
import org.transdroid.core.gui.search.FilePickerHelper; |
|
|
|
import org.transdroid.core.gui.search.UrlEntryDialog; |
|
|
|
import org.transdroid.core.gui.search.UrlEntryDialog; |
|
|
@ -584,7 +579,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
public void addTorrentByUrl(String url, String title) { |
|
|
|
public void addTorrentByUrl(String url, String title) { |
|
|
|
DaemonTaskResult result = AddByUrlTask.create(currentConnection, url, title).execute(); |
|
|
|
DaemonTaskResult result = AddByUrlTask.create(currentConnection, url, title).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_added, title); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, title)); |
|
|
|
refreshTorrents(); |
|
|
|
refreshTorrents(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
@ -595,7 +590,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
protected void addTorrentByMagnetUrl(String url) { |
|
|
|
protected void addTorrentByMagnetUrl(String url) { |
|
|
|
DaemonTaskResult result = AddByMagnetUrlTask.create(currentConnection, url).execute(); |
|
|
|
DaemonTaskResult result = AddByMagnetUrlTask.create(currentConnection, url).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_added, "Torrent"); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, "Torrent")); |
|
|
|
refreshTorrents(); |
|
|
|
refreshTorrents(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
@ -606,7 +601,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
protected void addTorrentByFile(String localFile, String title) { |
|
|
|
protected void addTorrentByFile(String localFile, String title) { |
|
|
|
DaemonTaskResult result = AddByFileTask.create(currentConnection, localFile).execute(); |
|
|
|
DaemonTaskResult result = AddByFileTask.create(currentConnection, localFile).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_added, title); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, title)); |
|
|
|
refreshTorrents(); |
|
|
|
refreshTorrents(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
@ -656,7 +651,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
torrent.mimicResume(); |
|
|
|
torrent.mimicResume(); |
|
|
|
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute(); |
|
|
|
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_resumed); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName())); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -668,7 +663,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
torrent.mimicPause(); |
|
|
|
torrent.mimicPause(); |
|
|
|
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute(); |
|
|
|
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_paused); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName())); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -680,7 +675,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
torrent.mimicStart(); |
|
|
|
torrent.mimicStart(); |
|
|
|
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute(); |
|
|
|
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_started); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -692,7 +687,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
torrent.mimicStop(); |
|
|
|
torrent.mimicStop(); |
|
|
|
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute(); |
|
|
|
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_stopped); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -703,8 +698,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
public void removeTorrent(Torrent torrent, boolean withData) { |
|
|
|
public void removeTorrent(Torrent torrent, boolean withData) { |
|
|
|
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, 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)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -716,7 +711,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
torrent.mimicNewLabel(newLabel); |
|
|
|
torrent.mimicNewLabel(newLabel); |
|
|
|
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel).execute(); |
|
|
|
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_labelset, newLabel); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -727,7 +722,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
public void updateTrackers(Torrent torrent, List<String> newTrackers) { |
|
|
|
public void updateTrackers(Torrent torrent, List<String> newTrackers) { |
|
|
|
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute(); |
|
|
|
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_trackersupdated); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -738,16 +733,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
public void updateLocation(Torrent torrent, String newLocation) { |
|
|
|
public void updateLocation(Torrent torrent, String newLocation) { |
|
|
|
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute(); |
|
|
|
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute(); |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
if (result instanceof DaemonTaskResult) { |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_locationset, newLocation); |
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
onCommunicationError((DaemonTaskFailureResult) result, false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@UiThread |
|
|
|
@UiThread |
|
|
|
protected void onTaskSucceeded(DaemonTaskSuccessResult result, int successMessageId, String... messageParams) { |
|
|
|
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) { |
|
|
|
Crouton.showText(this, getString(successMessageId, (Object[]) messageParams), |
|
|
|
// Refresh the screen as well
|
|
|
|
navigationHelper.CROUTON_INFO_STYLE); |
|
|
|
refreshScreen(); |
|
|
|
|
|
|
|
Crouton.showText(this, successMessage, navigationHelper.CROUTON_INFO_STYLE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@UiThread |
|
|
|
@UiThread |
|
|
|