@ -45,18 +45,28 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie ;
import org.apache.http.impl.cookie.BasicClientCookie ;
import org.transdroid.core.R ;
import org.transdroid.core.R ;
import org.transdroid.core.app.settings.ApplicationSettings ;
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.app.settings.WebsearchSetting ;
import org.transdroid.core.gui.lists.LocalTorrent ;
import org.transdroid.core.gui.lists.LocalTorrent ;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer ;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer ;
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.Log ;
import org.transdroid.core.gui.navigation.* ;
import org.transdroid.core.gui.log.Log_ ;
import org.transdroid.core.gui.rss.* ;
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.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 ;
import org.transdroid.core.gui.settings.* ;
import org.transdroid.core.gui.settings.MainSettingsActivity_ ;
import org.transdroid.core.service.BootReceiver ;
import org.transdroid.core.service.BootReceiver ;
import org.transdroid.core.service.ConnectivityHelper ;
import org.transdroid.core.service.ConnectivityHelper ;
import org.transdroid.core.widget.WidgetProvider ;
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.DaemonTaskFailureResult ;
import org.transdroid.daemon.task.DaemonTaskResult ;
import org.transdroid.daemon.task.DaemonTaskResult ;
import org.transdroid.daemon.task.DaemonTaskSuccessResult ;
import org.transdroid.daemon.task.DaemonTaskSuccessResult ;
import org.transdroid.daemon.task.ForceRecheckTask ;
import org.transdroid.daemon.task.GetFileListTask ;
import org.transdroid.daemon.task.GetFileListTask ;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult ;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult ;
import org.transdroid.daemon.task.GetStatsTask ;
import org.transdroid.daemon.task.GetStatsTask ;
@ -280,7 +291,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
return ;
return ;
}
}
// If we had no connection before, establish it now; otherwise js ut reload the settings
// If we had no connection before, establish it now; otherwise jus t reload the settings
if ( currentConnection = = null )
if ( currentConnection = = null )
filterSelected ( lastUsed , true ) ;
filterSelected ( lastUsed , true ) ;
else
else
@ -289,9 +300,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@OnActivityResult ( RESULT_DETAILS )
@OnActivityResult ( RESULT_DETAILS )
protected void onDetailsScreenResult ( Intent result ) {
protected void onDetailsScreenResult ( Intent result ) {
// If the details activity returns whether the torrent was removed, refresh the screen
// If the details activity returns whether the torrent was removed or updated, update the torrents list as well
if ( result ! = null & & result . getBooleanExtra ( "torrent_removed" , false ) )
// (the details fragment is the source, so no need to update that)
refreshScreen ( ) ;
if ( result ! = null & & result . hasExtra ( "affected_torrent" ) ) {
Torrent affected = result . getParcelableExtra ( "affected_torrent" ) ;
fragmentTorrents . quickUpdateTorrent ( affected , result . getBooleanExtra ( "torrent_removed" , false ) ) ;
}
}
}
@Override
@Override
@ -701,7 +715,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if ( fragmentDetails ! = null ) {
if ( fragmentDetails ! = null ) {
fragmentDetails . updateTorrent ( torrent ) ;
fragmentDetails . updateTorrent ( torrent ) ;
} else {
} 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 ) {
public void resumeTorrent ( Torrent torrent ) {
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 DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_resumed , torrent . getName ( ) ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_resumed , torrent . getName ( ) ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -894,7 +909,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void pauseTorrent ( Torrent torrent ) {
public void pauseTorrent ( Torrent torrent ) {
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 DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_paused , torrent . getName ( ) ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_paused , torrent . getName ( ) ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -906,7 +921,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void startTorrent ( Torrent torrent , boolean forced ) {
public void startTorrent ( Torrent torrent , boolean forced ) {
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 DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_started , torrent . getName ( ) ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_started , torrent . getName ( ) ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -918,7 +933,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void stopTorrent ( Torrent torrent ) {
public void stopTorrent ( Torrent torrent ) {
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 DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_stopped , torrent . getName ( ) ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_stopped , torrent . getName ( ) ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -944,7 +959,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent . mimicNewLabel ( newLabel ) ;
torrent . mimicNewLabel ( newLabel ) ;
DaemonTaskResult result = SetLabelTask . create ( currentConnection , torrent , newLabel = = null ? "" : newLabel )
DaemonTaskResult result = SetLabelTask . create ( currentConnection , torrent , newLabel = = null ? "" : newLabel )
. execute ( ) ;
. execute ( ) ;
if ( result instanceof DaemonTaskResult ) {
if ( result instanceof DaemonTaskSuccess Result ) {
onTaskSucceeded (
onTaskSucceeded (
( DaemonTaskSuccessResult ) result ,
( DaemonTaskSuccessResult ) result ,
newLabel = = null ? getString ( R . string . result_labelremoved ) : getString ( R . string . result_labelset ,
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
@Background
@Override
@Override
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 DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_trackersupdated ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_trackersupdated ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -969,7 +997,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override
@Override
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 DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_locationset , newLocation ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_locationset , newLocation ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -981,7 +1009,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updatePriority ( Torrent torrent , List < TorrentFile > files , Priority priority ) {
public void updatePriority ( Torrent torrent , List < TorrentFile > files , Priority priority ) {
DaemonTaskResult result = SetFilePriorityTask . create ( currentConnection , torrent , priority ,
DaemonTaskResult result = SetFilePriorityTask . create ( currentConnection , torrent , priority ,
new ArrayList < TorrentFile > ( files ) ) . execute ( ) ;
new ArrayList < TorrentFile > ( files ) ) . execute ( ) ;
if ( result instanceof DaemonTaskResult ) {
if ( result instanceof DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_priotitiesset ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_priotitiesset ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
@ -992,7 +1020,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updateMaxSpeeds ( Integer maxDownloadSpeed , Integer maxUploadSpeed ) {
public void updateMaxSpeeds ( Integer maxDownloadSpeed , Integer maxUploadSpeed ) {
DaemonTaskResult result = SetTransferRatesTask . create ( currentConnection , maxUploadSpeed , maxDownloadSpeed )
DaemonTaskResult result = SetTransferRatesTask . create ( currentConnection , maxUploadSpeed , maxDownloadSpeed )
. execute ( ) ;
. execute ( ) ;
if ( result instanceof DaemonTaskResult ) {
if ( result instanceof DaemonTaskSuccess Result ) {
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_maxspeedsset ) ) ;
onTaskSucceeded ( ( DaemonTaskSuccessResult ) result , getString ( R . string . result_maxspeedsset ) ) ;
} else {
} else {
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;
onCommunicationError ( ( DaemonTaskFailureResult ) result , false ) ;