|
|
@ -44,18 +44,31 @@ import org.apache.http.client.methods.HttpGet; |
|
|
|
import org.apache.http.impl.client.DefaultHttpClient; |
|
|
|
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.search.*; |
|
|
|
import org.transdroid.core.app.search.SearchHelper_; |
|
|
|
import org.transdroid.core.app.settings.*; |
|
|
|
import org.transdroid.core.app.settings.ApplicationSettings; |
|
|
|
|
|
|
|
import org.transdroid.core.app.settings.ServerSetting; |
|
|
|
|
|
|
|
import org.transdroid.core.app.settings.SystemSettings; |
|
|
|
|
|
|
|
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.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.ListWidgetProvider; |
|
|
|
import org.transdroid.core.widget.ListWidgetProvider; |
|
|
@ -163,6 +176,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
@InstanceState |
|
|
|
@InstanceState |
|
|
|
protected NavigationFilter currentFilter = null; |
|
|
|
protected NavigationFilter currentFilter = null; |
|
|
|
@InstanceState |
|
|
|
@InstanceState |
|
|
|
|
|
|
|
protected String preselectNavigationFilter = null; |
|
|
|
|
|
|
|
@InstanceState |
|
|
|
protected boolean turleModeEnabled = false; |
|
|
|
protected boolean turleModeEnabled = false; |
|
|
|
@InstanceState |
|
|
|
@InstanceState |
|
|
|
protected ArrayList<Label> lastNavigationLabels; |
|
|
|
protected ArrayList<Label> lastNavigationLabels; |
|
|
@ -220,7 +235,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
// Add an empty labels list (which will be updated later, but the adapter needs to be created now)
|
|
|
|
// Add an empty labels list (which will be updated later, but the adapter needs to be created now)
|
|
|
|
navigationSpinnerAdapter.updateLabels(new ArrayList<Label>()); |
|
|
|
navigationSpinnerAdapter.updateLabels(new ArrayList<Label>()); |
|
|
|
} |
|
|
|
} |
|
|
|
// Now that all items (or at least their adapters) have been added
|
|
|
|
// Now that all items (or at least their adapters) have been added, ensure a filter is selected
|
|
|
|
|
|
|
|
// NOTE When this is a fresh start, it might override the filter later (based on the last user selection)
|
|
|
|
if (currentFilter == null) { |
|
|
|
if (currentFilter == null) { |
|
|
|
currentFilter = StatusType.getShowAllType(this); |
|
|
|
currentFilter = StatusType.getShowAllType(this); |
|
|
|
} |
|
|
|
} |
|
|
@ -258,6 +274,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
if (firstStart) { |
|
|
|
if (firstStart) { |
|
|
|
// Force first torrents refresh
|
|
|
|
// Force first torrents refresh
|
|
|
|
filterSelected(lastUsed, true); |
|
|
|
filterSelected(lastUsed, true); |
|
|
|
|
|
|
|
// Perhaps we can select the last used navigation filter, but only after a first refresh was completed
|
|
|
|
|
|
|
|
preselectNavigationFilter = applicationSettings.getLastUsedNavigationFilter(); |
|
|
|
// Handle any start up intents
|
|
|
|
// Handle any start up intents
|
|
|
|
if (openTorrent != null) { |
|
|
|
if (openTorrent != null) { |
|
|
|
openDetails(openTorrent); |
|
|
|
openDetails(openTorrent); |
|
|
@ -313,7 +331,6 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
|
|
|
public void startAutoRefresh() { |
|
|
|
public void startAutoRefresh() { |
|
|
|
// Check if already running
|
|
|
|
// Check if already running
|
|
|
@ -479,6 +496,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void filterSelected(SimpleListItem item, boolean forceNewConnection) { |
|
|
|
protected void filterSelected(SimpleListItem item, boolean forceNewConnection) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// No longer apply the last used filter (on a fresh application start), if we still needed to
|
|
|
|
|
|
|
|
preselectNavigationFilter = null; |
|
|
|
|
|
|
|
|
|
|
|
// Server selection
|
|
|
|
// Server selection
|
|
|
|
if (item instanceof ServerSetting) { |
|
|
|
if (item instanceof ServerSetting) { |
|
|
|
ServerSetting server = (ServerSetting) item; |
|
|
|
ServerSetting server = (ServerSetting) item; |
|
|
@ -512,9 +532,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
|
|
|
|
|
|
|
|
// Status type or label selection - both of which are navigation filters
|
|
|
|
// Status type or label selection - both of which are navigation filters
|
|
|
|
if (item instanceof NavigationFilter) { |
|
|
|
if (item instanceof NavigationFilter) { |
|
|
|
|
|
|
|
// Set new filter
|
|
|
|
currentFilter = (NavigationFilter) item; |
|
|
|
currentFilter = (NavigationFilter) item; |
|
|
|
fragmentTorrents.applyNavigationFilter(currentFilter); |
|
|
|
fragmentTorrents.applyNavigationFilter(currentFilter); |
|
|
|
navigationSpinnerAdapter.updateCurrentFilter(currentFilter); |
|
|
|
navigationSpinnerAdapter.updateCurrentFilter(currentFilter); |
|
|
|
|
|
|
|
// Remember that the user last selected this
|
|
|
|
|
|
|
|
applicationSettings.setLastUsedNavigationFilter(currentFilter); |
|
|
|
// Clear the details view
|
|
|
|
// Clear the details view
|
|
|
|
if (fragmentDetails != null) { |
|
|
|
if (fragmentDetails != null) { |
|
|
|
fragmentDetails.updateIsLoading(false, null); |
|
|
|
fragmentDetails.updateIsLoading(false, null); |
|
|
@ -1203,6 +1226,25 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
if (fragmentDetails != null) |
|
|
|
if (fragmentDetails != null) |
|
|
|
fragmentDetails.updateLabels(lastNavigationLabels); |
|
|
|
fragmentDetails.updateLabels(lastNavigationLabels); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Perhaps we were still waiting to preselect the last used filter (on a fresh application start)
|
|
|
|
|
|
|
|
if (preselectNavigationFilter != null) { |
|
|
|
|
|
|
|
FilterListAdapter adapter = navigationListAdapter != null ? navigationListAdapter |
|
|
|
|
|
|
|
: navigationSpinnerAdapter; |
|
|
|
|
|
|
|
for (int i = 0; i < adapter.getCount(); i++) { |
|
|
|
|
|
|
|
// Regardless of the navigation style (side list or action bar spinner), we can look up the navigation
|
|
|
|
|
|
|
|
// filter item, which is represented as simple list item (and might not exist any more, such as with a
|
|
|
|
|
|
|
|
// label that is deleted on the server)
|
|
|
|
|
|
|
|
Object item = adapter.getItem(i); |
|
|
|
|
|
|
|
if (item instanceof SimpleListItem && item instanceof NavigationFilter |
|
|
|
|
|
|
|
&& ((NavigationFilter) item).getCode().equals(preselectNavigationFilter)) { |
|
|
|
|
|
|
|
filterSelected((SimpleListItem) item, false); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Only preselect after the first update we receive (even if the filter wasn't found any more)
|
|
|
|
|
|
|
|
preselectNavigationFilter = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Update the server status (counts and speeds) in the action bar
|
|
|
|
// Update the server status (counts and speeds) in the action bar
|
|
|
|
serverStatusView.update(torrents, systemSettings.treatDormantAsInactive()); |
|
|
|
serverStatusView.update(torrents, systemSettings.treatDormantAsInactive()); |
|
|
|
|
|
|
|
|
|
|
|