Browse Source

Merge branch 'dev'

pull/159/head v2.2.0
Eric Kok 10 years ago
parent
commit
fef815720e
  1. 2
      README.md
  2. 2
      core/AndroidManifest.xml
  3. 2
      core/res/layout-w600dp/activity_search.xml
  4. 2
      core/res/layout-w600dp/activity_torrents.xml
  5. 4
      core/res/layout-w900dp/activity_rssfeeds.xml
  6. 4
      core/res/layout-w900dp/activity_torrents.xml
  7. 2
      core/res/layout/activity_details.xml
  8. 2
      core/res/layout/activity_rssfeeds.xml
  9. 2
      core/res/layout/activity_rssitems.xml
  10. 2
      core/res/layout/activity_search.xml
  11. 2
      core/res/layout/activity_torrents.xml
  12. 4
      core/res/menu/fragment_details_cab.xml
  13. 19
      core/res/menu/fragment_rssitems_cab.xml
  14. 5
      core/res/values/strings.xml
  15. 7
      core/res/xml/pref_main.xml
  16. 66
      core/src/org/transdroid/core/app/settings/ApplicationSettings.java
  17. 2
      core/src/org/transdroid/core/gui/DetailsActivity.java
  18. 17
      core/src/org/transdroid/core/gui/DetailsFragment.java
  19. 41
      core/src/org/transdroid/core/gui/ServerPickerDialog.java
  20. 124
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  21. 6
      core/src/org/transdroid/core/gui/rss/RssfeedsActivity.java
  22. 2
      core/src/org/transdroid/core/gui/rss/RssitemsActivity.java
  23. 24
      core/src/org/transdroid/core/gui/rss/RssitemsFragment.java
  24. 31
      core/src/org/transdroid/core/gui/search/SearchActivity.java
  25. 22
      core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java
  26. 2
      full/AndroidManifest.xml
  27. 2
      lite/AndroidManifest.xml

2
README.md

@ -37,7 +37,7 @@ Designed and developed by [Eric Kok](eric@2312.nl) of [2312 development](http://
License License
======= =======
Copyright 2010-2013 Eric Kok et al. Copyright 2010-2014 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

2
core/AndroidManifest.xml

@ -17,7 +17,7 @@
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.transdroid.core" package="org.transdroid.core"
android:versionCode="214" android:versionCode="215"
android:versionName="2.2.0" > android:versionName="2.2.0" >
<uses-sdk <uses-sdk

2
core/res/layout-w600dp/activity_search.xml

@ -32,7 +32,7 @@
android:listSelector="?attr/selectable_background_transdroid" /> android:listSelector="?attr/selectable_background_transdroid" />
<fragment <fragment
android:id="@+id/searchresults_list" android:id="@+id/searchresults_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"

2
core/res/layout-w600dp/activity_torrents.xml

@ -17,7 +17,7 @@
android:listSelector="?attr/selectable_background_transdroid" /> android:listSelector="?attr/selectable_background_transdroid" />
<fragment <fragment
android:id="@+id/torrent_list" android:id="@+id/torrents_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="3"

4
core/res/layout-w900dp/activity_rssfeeds.xml

@ -24,7 +24,7 @@
tools:context=".RssfeedsActivity" > tools:context=".RssfeedsActivity" >
<fragment <fragment
android:id="@+id/rssfeeds_list" android:id="@+id/rssfeeds_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"
@ -32,7 +32,7 @@
tools:layout="@layout/fragment_rssfeeds" /> tools:layout="@layout/fragment_rssfeeds" />
<fragment <fragment
android:id="@+id/rssitems_list" android:id="@+id/rssitems_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="3"

4
core/res/layout-w900dp/activity_torrents.xml

@ -17,7 +17,7 @@
android:listSelector="?attr/selectable_background_transdroid" /> android:listSelector="?attr/selectable_background_transdroid" />
<fragment <fragment
android:id="@+id/torrent_list" android:id="@+id/torrents_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"
@ -25,7 +25,7 @@
tools:layout="@layout/fragment_torrents" /> tools:layout="@layout/fragment_torrents" />
<fragment <fragment
android:id="@+id/torrent_details" android:id="@+id/torrentdetails_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"

2
core/res/layout/activity_details.xml

@ -7,7 +7,7 @@
tools:context=".DetailsActivity" > tools:context=".DetailsActivity" >
<fragment <fragment
android:id="@+id/torrent_details" android:id="@+id/torrentdetails_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.DetailsFragment_" class="org.transdroid.core.gui.DetailsFragment_"

2
core/res/layout/activity_rssfeeds.xml

@ -22,7 +22,7 @@
tools:context=".RssfeedsActivity" > tools:context=".RssfeedsActivity" >
<fragment <fragment
android:id="@+id/rssfeeds_list" android:id="@+id/rssfeeds_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.rss.RssfeedsFragment_" class="org.transdroid.core.gui.rss.RssfeedsFragment_"

2
core/res/layout/activity_rssitems.xml

@ -22,7 +22,7 @@
tools:context=".RssItemsActivity" > tools:context=".RssItemsActivity" >
<fragment <fragment
android:id="@+id/rssitems_list" android:id="@+id/rssitems_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.rss.RssitemsFragment_" class="org.transdroid.core.gui.rss.RssitemsFragment_"

2
core/res/layout/activity_search.xml

@ -22,7 +22,7 @@
tools:context=".SearchActivity" > tools:context=".SearchActivity" >
<fragment <fragment
android:id="@+id/searchresults_list" android:id="@+id/searchresults_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.search.SearchResultsFragment_" class="org.transdroid.core.gui.search.SearchResultsFragment_"

2
core/res/layout/activity_torrents.xml

@ -7,7 +7,7 @@
tools:context=".TorrentsActivity" > tools:context=".TorrentsActivity" >
<fragment <fragment
android:id="@+id/torrent_list" android:id="@+id/torrents_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.TorrentsFragment_" class="org.transdroid.core.gui.TorrentsFragment_"

4
core/res/menu/fragment_details_cab.xml

@ -40,5 +40,9 @@
android:id="@+id/action_download" android:id="@+id/action_download"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_download" /> android:title="@string/action_download" />
<item
android:id="@+id/action_copytoclipboard"
android:showAsAction="never"
android:title="@string/action_copytoclipboard" />
</menu> </menu>

19
core/res/menu/fragment_rssitems_cab.xml

@ -20,24 +20,25 @@
android:id="@+id/action_addall" android:id="@+id/action_addall"
android:icon="?attr/ic_action_new" android:icon="?attr/ic_action_new"
android:showAsAction="always" android:showAsAction="always"
android:title="@string/action_addall" /> android:title="@string/action_addall"/>
<item <item
android:id="@+id/action_showdetails" android:id="@+id/action_showdetails"
android:icon="?attr/ic_action_info" android:icon="?attr/ic_action_info"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_showdetails" /> android:title="@string/action_showdetails"/>
<item <item
android:id="@+id/action_openwebsite" android:id="@+id/action_openwebsite"
android:icon="?attr/ic_action_website" android:icon="?attr/ic_action_website"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_openwebsite" /> android:title="@string/action_openwebsite"/>
<item <item
android:id="@+id/action_useassearch" android:id="@+id/action_useassearch"
android:icon="?attr/ic_action_search" android:icon="?attr/ic_action_search"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_useassearch" /> android:title="@string/action_useassearch"/>
<item
</menu> android:id="@+id/action_copytoclipboard"
android:showAsAction="never"
android:title="@string/action_copytoclipboard"/>
</menu>

5
core/res/values/strings.xml

@ -61,6 +61,7 @@
<string name="action_priority_high">High</string> <string name="action_priority_high">High</string>
<string name="action_remoteplay">Remote play in VLC</string> <string name="action_remoteplay">Remote play in VLC</string>
<string name="action_download">Download using FTP(S)</string> <string name="action_download">Download using FTP(S)</string>
<string name="action_copytoclipboard">Copy to clipboard</string>
<string name="action_showdetails">Show details</string> <string name="action_showdetails">Show details</string>
<string name="action_openwebsite">Open website</string> <string name="action_openwebsite">Open website</string>
<string name="action_useassearch">Use as new search</string> <string name="action_useassearch">Use as new search</string>
@ -90,6 +91,7 @@
<string name="navigation_selectall">Select all</string> <string name="navigation_selectall">Select all</string>
<string name="navigation_selectfinished">Select finished</string> <string name="navigation_selectfinished">Select finished</string>
<string name="navigation_invertselection">Invert selection</string> <string name="navigation_invertselection">Invert selection</string>
<string name="navigation_pickserver">Add torrent to&#8230;</string>
<string name="status_status">STATUS: %1$s</string> <string name="status_status">STATUS: %1$s</string>
<string name="status_waiting">Waiting to check&#8230;</string> <string name="status_waiting">Waiting to check&#8230;</string>
@ -216,6 +218,9 @@
<string name="pref_servers">Servers</string> <string name="pref_servers">Servers</string>
<string name="pref_addserver">Add new server</string> <string name="pref_addserver">Add new server</string>
<string name="pref_addseedbox">Add seedbox</string> <string name="pref_addseedbox">Add seedbox</string>
<string name="pref_defaultserver">Default server</string>
<string name="pref_defaultserver_lastused">Last used</string>
<string name="pref_defaultserver_askonadd">Ask when adding torrent</string>
<string name="pref_searchsites">Search sites</string> <string name="pref_searchsites">Search sites</string>
<string name="pref_setsearchsite">Set default site</string> <string name="pref_setsearchsite">Set default site</string>
<string name="pref_addwebsearch">Add web search site</string> <string name="pref_addwebsearch">Add web search site</string>

7
core/res/xml/pref_main.xml

@ -24,7 +24,12 @@
<org.transdroid.core.gui.settings.OverflowPreference <org.transdroid.core.gui.settings.OverflowPreference
android:key="header_addserver" android:key="header_addserver"
android:title="@string/pref_addserver" android:title="@string/pref_addserver"
android:order="99" /> android:order="98" />
<ListPreference
android:key="header_defaultserver"
android:title="@string/pref_defaultserver"
android:order="99"
android:defaultValue="-2" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory

66
core/src/org/transdroid/core/app/settings/ApplicationSettings.java

@ -51,6 +51,9 @@ import android.preference.PreferenceManager;
@EBean(scope = Scope.Singleton) @EBean(scope = Scope.Singleton)
public class ApplicationSettings { public class ApplicationSettings {
public static final int DEFAULTSERVER_LASTUSED = -2;
public static final int DEFAULTSERVER_ASKONADD = -1;
@RootContext @RootContext
protected Context context; protected Context context;
private SharedPreferences prefs; private SharedPreferences prefs;
@ -85,9 +88,9 @@ public class ApplicationSettings {
} }
return max; return max;
} }
/** /**
* Returns the server settings for either a normal or a seedbox server as the user configured. WARNING: This method * Returns the server settings for either a normal or a seedbox server as the user configured. WARNING: This method
* does not check if the settings actually exist and may reply on empty default if called for a non-existing server. * does not check if the settings actually exist and may reply on empty default if called for a non-existing server.
* @param order The order number/identifying key of the server's settings to retrieve, where the normal servers are * @param order The order number/identifying key of the server's settings to retrieve, where the normal servers are
* first and the seedboxes are numbers thereafter onwards * first and the seedboxes are numbers thereafter onwards
@ -132,7 +135,7 @@ public class ApplicationSettings {
} }
/** /**
* Returns the user-specified server settings for a normal (non-seedbox) server. WARNING: This method does not check * Returns the user-specified server settings for a normal (non-seedbox) server. WARNING: This method does not check
* if the settings actually exist and may rely on empty defaults if called for a non-existing server. * if the settings actually exist and may rely on empty defaults if called for a non-existing server.
* @param order The order number/identifying key of the normal server's settings to retrieve * @param order The order number/identifying key of the normal server's settings to retrieve
* @return The server settings object, loaded from shared preferences * @return The server settings object, loaded from shared preferences
@ -244,10 +247,67 @@ public class ApplicationSettings {
edit.remove("server_timeout_" + max); edit.remove("server_timeout_" + max);
edit.remove("server_alarmfinished_" + max); edit.remove("server_alarmfinished_" + max);
edit.remove("server_alarmfinished_" + max); edit.remove("server_alarmfinished_" + max);
// Perhaps we should also update the default server to match the server's new id or remove the default selection
// in case it was this server that was removed
int defaultServer = getDefaultServerKey();
if (defaultServer == order) {
edit.remove("header_defaultserver");
} else if (defaultServer > order) {
// Move 'up' one place to account for the removed server setting
edit.putInt("header_defaultserver", --order);
}
edit.commit(); edit.commit();
} }
/**
* Returns the settings of the server that was explicitly selected by the user to select as default or, when no
* specific default server was selected, the last used server settings. As opposed to getDefaultServerKey(int), this
* method checks whether the particular server still exists (and returns the first server if not). If no servers are
* configured, null is returned.
* @return A server settings object of the server to use by default, or null if no server is yet configured
*/
public ServerSetting getDefaultServer() {
int defaultServer = getDefaultServerKey();
if (defaultServer == DEFAULTSERVER_LASTUSED || defaultServer == DEFAULTSERVER_ASKONADD) {
return getLastUsedServer();
}
// Use the explicitly selected default server
int max = getMaxOfAllServers(); // Zero-based index, so with max == 0 there is 1 server
if (max < 0) {
// No servers configured
return null;
}
if (defaultServer < 0 || defaultServer > max) {
// Last server was never set or no longer exists
return getServerSetting(0);
}
return getServerSetting(defaultServer);
}
/**
* Returns the unique key of the server setting that the user selected as their default server, or code indicating
* that the last used server should be selected by default; use with getDefaultServer directly. WARNING: the
* returned string may no longer refer to a known server setting key.
* @return An integer; if it is 0 or higher it represents the unique key of a configured server setting, -2 means
* the last used server should be selected as default instead and -1 means the last used server should be
* selected by default for viewing yet it should always ask when adding a new torrent
*/
public int getDefaultServerKey() {
String defaultServer = prefs.getString("header_defaultserver", Integer.toString(DEFAULTSERVER_LASTUSED));
try {
return Integer.parseInt(defaultServer);
} catch (NumberFormatException e) {
// This should NEVER happen but if the setting somehow is not a number, return the default
return DEFAULTSERVER_LASTUSED;
}
}
/** /**
* Returns the settings of the server that was last used by the user. As opposed to getLastUsedServerKey(int), this * Returns the settings of the server that was last used by the user. As opposed to getLastUsedServerKey(int), this
* method checks whether a server was already registered as being last used and check whether the server still * method checks whether a server was already registered as being last used and check whether the server still

2
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -104,7 +104,7 @@ public class DetailsActivity extends Activity implements TorrentTasksExecutor, R
private PullToRefreshAttacher pullToRefreshAttacher = null; private PullToRefreshAttacher pullToRefreshAttacher = null;
// Details view components // Details view components
@FragmentById(resName = "torrent_details") @FragmentById(resName = "torrentdetails_fragment")
protected DetailsFragment fragmentDetails; protected DetailsFragment fragmentDetails;
@Override @Override

17
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -52,6 +52,9 @@ import org.transdroid.daemon.TorrentFile;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Fragment; import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.view.ActionMode; import android.view.ActionMode;
@ -475,6 +478,20 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
mode.finish(); mode.finish();
return true; return true;
} else if (itemId == R.id.action_copytoclipboard) {
StringBuilder names = new StringBuilder();
for (int f = 0; f < checked.size(); f++) {
if (f != 0)
names.append("\n");
names.append(checked.get(f).getName());
}
ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(
Context.CLIPBOARD_SERVICE);
clipboardManager.setPrimaryClip(ClipData.newPlainText("Transdroid", names.toString()));
mode.finish();
return true;
} else { } else {
Priority priority = Priority.Off; Priority priority = Priority.Off;
if (itemId == R.id.action_priority_low) if (itemId == R.id.action_priority_low)

41
core/src/org/transdroid/core/gui/ServerPickerDialog.java

@ -0,0 +1,41 @@
package org.transdroid.core.gui;
import java.util.List;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ServerSetting;
import android.app.AlertDialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
public class ServerPickerDialog {
/**
* Opens a dialog that allows the selection of a configured server (manual or seedbox). The calling activity will
* receive a callback on its switchServerAndAddFromIntent(int) method.
* @param activity The torrents activity from which the picker is started (and which received the callback)
* @param serverSettings The list of all available servers, of which their names will be offered to the user to pick
* from (and its position in the list is returned to the activity)
*/
public static void startServerPicker(final TorrentsActivity activity, List<ServerSetting> serverSettings) {
final String[] serverNames = new String[serverSettings.size()];
for (int i = 0; i < serverSettings.size(); i++) {
serverNames[i] = serverSettings.get(i).getName();
}
new DialogFragment() {
public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
return new AlertDialog.Builder(activity).setTitle(R.string.navigation_pickserver)
.setItems(serverNames, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (activity != null)
activity.switchServerAndAddFromIntent(which);
}
}).create();
};
}.show(activity.getFragmentManager(), "serverpicker");
}
}

124
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -51,11 +51,6 @@ 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.*;
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.RefreshableActivity;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.rss.*; import org.transdroid.core.gui.rss.*;
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;
@ -173,9 +168,9 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
protected ArrayList<Label> lastNavigationLabels; protected ArrayList<Label> lastNavigationLabels;
// Contained torrent and details fragments // Contained torrent and details fragments
@FragmentById(resName = "torrent_list") @FragmentById(resName = "torrents_fragment")
protected TorrentsFragment fragmentTorrents; protected TorrentsFragment fragmentTorrents;
@FragmentById(resName = "torrent_details") @FragmentById(resName = "torrentdetails_fragment")
protected DetailsFragment fragmentDetails; protected DetailsFragment fragmentDetails;
// Auto refresh task // Auto refresh task
@ -236,10 +231,10 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Log messages from the server daemons using our singleton logger // Log messages from the server daemons using our singleton logger
DLog.setLogger(Log_.getInstance_(this)); DLog.setLogger(Log_.getInstance_(this));
// Load the last used server or a server that was explicitly supplied in the starting intent // Load the default server or a server that was explicitly supplied in the starting intent
ServerSetting lastUsed = applicationSettings.getLastUsedServer(); ServerSetting defaultServer = applicationSettings.getDefaultServer();
if (lastUsed == null) { if (defaultServer == null) {
// No server settings yet; // No server settings yet
return; return;
} }
Torrent openTorrent = null; Torrent openTorrent = null;
@ -251,7 +246,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
Log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId Log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId
+ " is not an existing server order id"); + " is not an existing server order id");
} else { } else {
lastUsed = applicationSettings.getServerSetting(serverId); defaultServer = applicationSettings.getServerSetting(serverId);
if (getIntent().hasExtra(ListWidgetProvider.EXTRA_TORRENT)) if (getIntent().hasExtra(ListWidgetProvider.EXTRA_TORRENT))
openTorrent = getIntent().getParcelableExtra(ListWidgetProvider.EXTRA_TORRENT); openTorrent = getIntent().getParcelableExtra(ListWidgetProvider.EXTRA_TORRENT);
} }
@ -259,12 +254,12 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Set this as selection in the action bar spinner; we can use the server setting key since we have stable ids // Set this as selection in the action bar spinner; we can use the server setting key since we have stable ids
// Note: skipNextOnNavigationItemSelectedCalls is used to prevent this event from triggering filterSelected // Note: skipNextOnNavigationItemSelectedCalls is used to prevent this event from triggering filterSelected
actionBar.setSelectedNavigationItem(lastUsed.getOrder() + 1); actionBar.setSelectedNavigationItem(defaultServer.getOrder() + 1);
// Connect to the last used server or a server that was explicitly supplied in the starting intent // Connect to the last used server or a server that was explicitly supplied in the starting intent
if (firstStart) { if (firstStart) {
// Force first torrents refresh // Force first torrents refresh
filterSelected(lastUsed, true); filterSelected(defaultServer, true);
// Perhaps we can select the last used navigation filter, but only after a first refresh was completed // Perhaps we can select the last used navigation filter, but only after a first refresh was completed
preselectNavigationFilter = applicationSettings.getLastUsedNavigationFilter(); preselectNavigationFilter = applicationSettings.getLastUsedNavigationFilter();
// Handle any start up intents // Handle any start up intents
@ -276,6 +271,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
} }
} else { } else {
// Resume after instead of fully loading the torrents list; create connection and set action bar title // Resume after instead of fully loading the torrents list; create connection and set action bar title
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this); currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
navigationSpinnerAdapter.updateCurrentServer(currentConnection); navigationSpinnerAdapter.updateCurrentServer(currentConnection);
navigationSpinnerAdapter.updateCurrentFilter(currentFilter); navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
@ -368,42 +364,38 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
super.onDestroy(); super.onDestroy();
} }
@TargetApi(Build.VERSION_CODES.FROYO)
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
if (navigationHelper.enableSearchUi()) { if (navigationHelper.enableSearchUi()) {
// For Android 2.1+, add an expandable SearchView to the action bar // Add an expandable SearchView to the action bar
MenuItem item = menu.findItem(R.id.action_search); MenuItem item = menu.findItem(R.id.action_search);
if (android.os.Build.VERSION.SDK_INT >= 8) { SearchView searchView = new SearchView(this);
SearchView searchView = new SearchView(this); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true);
searchView.setQueryRefinementEnabled(true); searchView.setOnSearchClickListener(new OnClickListener() {
searchView.setOnSearchClickListener(new OnClickListener() { @Override
@Override public void onClick(View v) {
public void onClick(View v) { // Pause autorefresh
// Pause autorefresh stopRefresh = true;
stopRefresh = true; stopAutoRefresh();
stopAutoRefresh(); }
} });
}); item.setOnActionExpandListener(new OnActionExpandListener() {
// NOTE ABS's OnCloseListener is not working, hence using an OnActionExpandListener @Override
item.setOnActionExpandListener(new OnActionExpandListener() { public boolean onMenuItemActionExpand(MenuItem item) {
@Override return true;
public boolean onMenuItemActionExpand(MenuItem item) { }
return true;
}
@Override @Override
public boolean onMenuItemActionCollapse(MenuItem item) { public boolean onMenuItemActionCollapse(MenuItem item) {
stopRefresh = false; stopRefresh = false;
startAutoRefresh(); startAutoRefresh();
return true; return true;
} }
}); });
item.setActionView(searchView); item.setActionView(searchView);
searchMenu = item; searchMenu = item;
}
} }
return true; return true;
} }
@ -510,7 +502,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Clear the currently shown list of torrents and perhaps the details // Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true); fragmentTorrents.clear(true, true);
if (fragmentDetails != null && fragmentDetails.getActivity() != null) { if (fragmentDetails != null && fragmentDetails.isAdded() && fragmentDetails.getActivity() != null) {
fragmentDetails.updateIsLoading(false, null); fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear(); fragmentDetails.clear();
fragmentDetails.setCurrentServerSettings(server); fragmentDetails.setCurrentServerSettings(server);
@ -530,7 +522,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Remember that the user last selected this // Remember that the user last selected this
applicationSettings.setLastUsedNavigationFilter(currentFilter); applicationSettings.setLastUsedNavigationFilter(currentFilter);
// Clear the details view // Clear the details view
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateIsLoading(false, null); fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear(); fragmentDetails.clear();
} }
@ -545,7 +537,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
private void updateFragmentVisibility(boolean hasServerSettings) { private void updateFragmentVisibility(boolean hasServerSettings) {
if (filtersList != null) if (filtersList != null)
filtersList.setVisibility(hasServerSettings ? View.VISIBLE : View.GONE); filtersList.setVisibility(hasServerSettings ? View.VISIBLE : View.GONE);
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (hasServerSettings) if (hasServerSettings)
getFragmentManager().beginTransaction().show(fragmentDetails).commit(); getFragmentManager().beginTransaction().show(fragmentDetails).commit();
else else
@ -560,11 +552,31 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
handleStartIntent(); handleStartIntent();
} }
/**
* If required, add torrents, switch to a specific server, etc.
*/
protected void handleStartIntent() { protected void handleStartIntent() {
// For intents that come from out of the application, perhaps we can not directly add them
if (applicationSettings.getDefaultServerKey() == ApplicationSettings.DEFAULTSERVER_ASKONADD
&& getIntent().getData() != null) {
// First ask which server to use before adding any intent from the extras
ServerPickerDialog.startServerPicker(this, applicationSettings.getAllServerSettings());
return;
}
addFromIntent();
}
public void switchServerAndAddFromIntent(int position) {
// Callback from the ServerPickerDialog; force a connection before selecting it (in the navigation)
// Note: we can just use the list position as we have stable server setting ids
ServerSetting selectedServer = applicationSettings.getAllServerSettings().get(position);
filterSelected(selectedServer, false);
addFromIntent();
skipNextOnNavigationItemSelectedCalls++; // Prevent this selection from launching filterSelected() again
getActionBar().setSelectedNavigationItem(position + 1);
}
/**
* If required, add torrents from the supplied intent extras.
*/
protected void addFromIntent() {
Intent intent = getIntent(); Intent intent = getIntent();
Uri dataUri = intent.getData(); Uri dataUri = intent.getData();
String data = intent.getDataString(); String data = intent.getDataString();
@ -818,7 +830,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
* @param torrent The torrent to show detailed statistics for * @param torrent The torrent to show detailed statistics for
*/ */
public void openDetails(Torrent torrent) { public void openDetails(Torrent torrent) {
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateTorrent(torrent); fragmentDetails.updateTorrent(torrent);
} else { } else {
DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels) DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels)
@ -1186,7 +1198,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.updateIsLoading(false); fragmentTorrents.updateIsLoading(false);
if (isCritical) { if (isCritical) {
fragmentTorrents.updateError(error); fragmentTorrents.updateError(error);
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateIsLoading(false, error); fragmentDetails.updateIsLoading(false, error);
} }
} }
@ -1202,7 +1214,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.updateTorrents(new ArrayList<Torrent>(torrents), lastNavigationLabels); fragmentTorrents.updateTorrents(new ArrayList<Torrent>(torrents), lastNavigationLabels);
// Update the details fragment if the currently shown torrent is in the newly retrieved list // Update the details fragment if the currently shown torrent is in the newly retrieved list
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.perhapsUpdateTorrent(torrents); fragmentDetails.perhapsUpdateTorrent(torrents);
} }
@ -1214,7 +1226,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Labels are shown in the action bar spinner // Labels are shown in the action bar spinner
navigationSpinnerAdapter.updateLabels(lastNavigationLabels); navigationSpinnerAdapter.updateLabels(lastNavigationLabels);
} }
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateLabels(lastNavigationLabels); fragmentDetails.updateLabels(lastNavigationLabels);
// Perhaps we were still waiting to preselect the last used filter (on a fresh application start) // Perhaps we were still waiting to preselect the last used filter (on a fresh application start)
@ -1244,14 +1256,14 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
@UiThread @UiThread
protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) { protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// Update the details fragment with the new fine details for the shown torrent // Update the details fragment with the new fine details for the shown torrent
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateTorrentDetails(torrent, torrentDetails); fragmentDetails.updateTorrentDetails(torrent, torrentDetails);
} }
@UiThread @UiThread
protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) { protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// Update the details fragment with the newly retrieved list of files // Update the details fragment with the newly retrieved list of files
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateTorrentFiles(torrent, new ArrayList<TorrentFile>(torrentFiles)); fragmentDetails.updateTorrentFiles(torrent, new ArrayList<TorrentFile>(torrentFiles));
} }

6
core/src/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -53,9 +53,9 @@ public class RssfeedsActivity extends Activity {
protected List<RssfeedLoader> loaders; protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments // Contained feeds and items fragments
@FragmentById(resName = "rssfeeds_list") @FragmentById(resName = "rssfeeds_fragment")
protected RssfeedsFragment fragmentFeeds; protected RssfeedsFragment fragmentFeeds;
@FragmentById(resName = "rssitems_list") @FragmentById(resName = "rssitems_fragment")
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@Override @Override
@ -145,7 +145,7 @@ public class RssfeedsActivity extends Activity {
public void openRssfeed(RssfeedLoader loader, boolean markAsViewedNow) { public void openRssfeed(RssfeedLoader loader, boolean markAsViewedNow) {
// The RSS feed content was loaded and can now be shown in the dedicated fragment or a new activity // The RSS feed content was loaded and can now be shown in the dedicated fragment or a new activity
if (fragmentItems != null) { if (fragmentItems != null && fragmentItems.isAdded()) {
// If desired, update the lastViewedDate and lastViewedItemUrl of this feed in the user setting; this won't // If desired, update the lastViewedDate and lastViewedItemUrl of this feed in the user setting; this won't
// be loaded until the RSS feeds screen in opened again. // be loaded until the RSS feeds screen in opened again.

2
core/src/org/transdroid/core/gui/rss/RssitemsActivity.java

@ -41,7 +41,7 @@ public class RssitemsActivity extends Activity {
@Extra @Extra
protected String rssfeedName; protected String rssfeedName;
@FragmentById(resName = "rssitems_list") @FragmentById(resName = "rssitems_fragment")
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@Override @Override

24
core/src/org/transdroid/core/gui/rss/RssitemsFragment.java

@ -38,6 +38,9 @@ import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.Fragment; import android.app.Fragment;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -146,6 +149,7 @@ public class RssitemsFragment extends Fragment {
int itemId = item.getItemId(); int itemId = item.getItemId();
if (itemId == R.id.action_addall) { if (itemId == R.id.action_addall) {
// Start an Intent that adds multiple items at once, by supplying the urls and titles as string array // Start an Intent that adds multiple items at once, by supplying the urls and titles as string array
// extras and setting the Intent action to ADD_MULTIPLE // extras and setting the Intent action to ADD_MULTIPLE
Intent intent = new Intent("org.transdroid.ADD_MULTIPLE"); Intent intent = new Intent("org.transdroid.ADD_MULTIPLE");
@ -160,7 +164,23 @@ public class RssitemsFragment extends Fragment {
startActivity(intent); startActivity(intent);
mode.finish(); mode.finish();
return true; return true;
} else if (itemId == R.id.action_copytoclipboard) {
StringBuilder names = new StringBuilder();
for (int f = 0; f < checked.size(); f++) {
if (f != 0)
names.append("\n");
names.append(checked.get(f).getTitle());
}
ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(
Context.CLIPBOARD_SERVICE);
clipboardManager.setPrimaryClip(ClipData.newPlainText("Transdroid", names.toString()));
mode.finish();
return true;
} else { } else {
// The other items only operate on one (the first) selected item // The other items only operate on one (the first) selected item
if (checked.size() < 1) if (checked.size() < 1)
return false; return false;
@ -190,7 +210,9 @@ public class RssitemsFragment extends Fragment {
search.putExtra(SearchManager.QUERY, first.getTitle()); search.putExtra(SearchManager.QUERY, first.getTitle());
startActivity(search); startActivity(search);
} }
return false; mode.finish();
return true;
} }
} }

31
core/src/org/transdroid/core/gui/search/SearchActivity.java

@ -29,8 +29,10 @@ import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.search.SearchHelper; import org.transdroid.core.app.search.SearchHelper;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.gui.*; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -62,7 +64,7 @@ import android.widget.TextView;
@OptionsMenu(resName = "activity_search") @OptionsMenu(resName = "activity_search")
public class SearchActivity extends Activity implements OnNavigationListener { public class SearchActivity extends Activity implements OnNavigationListener {
@FragmentById(resName = "searchresults_list") @FragmentById(resName = "searchresults_fragment")
protected SearchResultsFragment fragmentResults; protected SearchResultsFragment fragmentResults;
@ViewById @ViewById
protected ListView searchsitesList; protected ListView searchsitesList;
@ -141,20 +143,17 @@ public class SearchActivity extends Activity implements OnNavigationListener {
} }
@TargetApi(Build.VERSION_CODES.FROYO)
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
if (navigationHelper.enableSearchUi()) { if (navigationHelper.enableSearchUi()) {
// For Android 2.1+, add an expandable SearchView to the action bar // Add an expandable SearchView to the action bar
MenuItem item = menu.findItem(R.id.action_search); MenuItem item = menu.findItem(R.id.action_search);
if (android.os.Build.VERSION.SDK_INT >= 8) { final SearchView searchView = new SearchView(this);
final SearchView searchView = new SearchView(this); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true);
searchView.setQueryRefinementEnabled(true); item.setActionView(searchView);
item.setActionView(searchView); searchMenu = item;
searchMenu = item;
}
} }
return true; return true;
} }
@ -185,13 +184,17 @@ public class SearchActivity extends Activity implements OnNavigationListener {
} }
private void handleIntent(Intent intent) { private void handleIntent(Intent intent) {
lastUsedQuery = parseQuery(intent);
lastUsedQuery = parseQuery(intent);
// Is this actually a full HTTP URL? Then redirect this request to add the URL directly // Is this actually a full HTTP URL? Then redirect this request to add the URL directly
if (lastUsedQuery != null if (lastUsedQuery != null
&& (lastUsedQuery.startsWith("http") || lastUsedQuery.startsWith("https") && (lastUsedQuery.startsWith("http") || lastUsedQuery.startsWith("https")
|| lastUsedQuery.startsWith("magnet") || lastUsedQuery.startsWith("file"))) { || lastUsedQuery.startsWith("magnet") || lastUsedQuery.startsWith("file"))) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(lastUsedQuery))); // Don't broadcast this intent; we can safely assume this is intended for Transdroid only
Intent i = TorrentsActivity_.intent(this).get();
i.setData(Uri.parse(lastUsedQuery));
startActivity(i);
finish(); finish();
return; return;
} }

22
core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -29,7 +29,7 @@ import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.RssfeedSetting; import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.WebsearchSetting; import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.*; import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.settings.OverflowPreference.OnOverflowClicked; import org.transdroid.core.gui.settings.OverflowPreference.OnOverflowClicked;
import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener; import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener;
@ -108,12 +108,24 @@ public class MainSettingsActivity extends PreferenceActivity {
findPreference("header_system").setOnPreferenceClickListener(onSystemSettings); findPreference("header_system").setOnPreferenceClickListener(onSystemSettings);
findPreference("header_help").setOnPreferenceClickListener(onHelpSettings); findPreference("header_help").setOnPreferenceClickListener(onHelpSettings);
// Keep a list of the server codes and names (for default server selection)
List<String> serverCodes = new ArrayList<String>();
List<String> serverNames = new ArrayList<String>();
serverCodes.add(Integer.toString(ApplicationSettings.DEFAULTSERVER_LASTUSED));
serverCodes.add(Integer.toString(ApplicationSettings.DEFAULTSERVER_ASKONADD));
serverNames.add(getString(R.string.pref_defaultserver_lastused));
serverNames.add(getString(R.string.pref_defaultserver_askonadd));
// Add existing servers // Add existing servers
List<ServerSetting> servers = applicationSettings.getNormalServerSettings(); List<ServerSetting> servers = applicationSettings.getNormalServerSettings();
for (ServerSetting serverSetting : servers) { for (ServerSetting serverSetting : servers) {
getPreferenceScreen().addPreference( getPreferenceScreen().addPreference(
new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener( new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener(
onServerClicked)); onServerClicked));
if (serverSetting.getUniqueIdentifier() != null) {
serverCodes.add(Integer.toString(serverSetting.getOrder()));
serverNames.add(serverSetting.getName());
}
} }
// Add seedboxes; serversOffset keeps an int to have all ServerSettings with unique ids, seedboxOffset is unique // Add seedboxes; serversOffset keeps an int to have all ServerSettings with unique ids, seedboxOffset is unique
// only per seedbox type // only per seedbox type
@ -126,8 +138,16 @@ public class MainSettingsActivity extends PreferenceActivity {
.setOnSeedboxClickedListener(onSeedboxClicked, seedboxOffset)); .setOnSeedboxClickedListener(onSeedboxClicked, seedboxOffset));
orderOffset++; orderOffset++;
seedboxOffset++; seedboxOffset++;
if (seedbox.getUniqueIdentifier() != null) {
serverCodes.add(Integer.toString(seedbox.getOrder()));
serverNames.add(seedbox.getName());
}
} }
} }
// Allow selection of the default server
ListPreference defaultServerPreference = (ListPreference) findPreference("header_defaultserver");
defaultServerPreference.setEntries(serverNames.toArray(new String[serverNames.size()]));
defaultServerPreference.setEntryValues(serverCodes.toArray(new String[serverCodes.size()]));
// Add existing RSS feeds // Add existing RSS feeds
if (!enableRssUi) { if (!enableRssUi) {

2
full/AndroidManifest.xml

@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="org.transdroid.full" package="org.transdroid.full"
android:versionCode="214" android:versionCode="215"
android:versionName="2.2.0" > android:versionName="2.2.0" >
<uses-sdk <uses-sdk

2
lite/AndroidManifest.xml

@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="org.transdroid.lite" package="org.transdroid.lite"
android:versionCode="214" android:versionCode="215"
android:versionName="2.2.0" > android:versionName="2.2.0" >
<uses-sdk <uses-sdk

Loading…
Cancel
Save