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. 15
      core/res/menu/fragment_rssitems_cab.xml
  14. 5
      core/res/values/strings.xml
  15. 7
      core/res/xml/pref_main.xml
  16. 60
      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. 74
      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. 19
      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:// @@ -37,7 +37,7 @@ Designed and developed by [Eric Kok](eric@2312.nl) of [2312 development](http://
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
it under the terms of the GNU General Public License as published by

2
core/AndroidManifest.xml

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

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

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

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

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

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

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

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

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

2
core/res/layout/activity_details.xml

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

2
core/res/layout/activity_rssfeeds.xml

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

2
core/res/layout/activity_rssitems.xml

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

2
core/res/layout/activity_search.xml

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

2
core/res/layout/activity_torrents.xml

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

4
core/res/menu/fragment_details_cab.xml

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

15
core/res/menu/fragment_rssitems_cab.xml

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

5
core/res/values/strings.xml

@ -61,6 +61,7 @@ @@ -61,6 +61,7 @@
<string name="action_priority_high">High</string>
<string name="action_remoteplay">Remote play in VLC</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_openwebsite">Open website</string>
<string name="action_useassearch">Use as new search</string>
@ -90,6 +91,7 @@ @@ -90,6 +91,7 @@
<string name="navigation_selectall">Select all</string>
<string name="navigation_selectfinished">Select finished</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_waiting">Waiting to check&#8230;</string>
@ -216,6 +218,9 @@ @@ -216,6 +218,9 @@
<string name="pref_servers">Servers</string>
<string name="pref_addserver">Add new server</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_setsearchsite">Set default site</string>
<string name="pref_addwebsearch">Add web search site</string>

7
core/res/xml/pref_main.xml

@ -24,7 +24,12 @@ @@ -24,7 +24,12 @@
<org.transdroid.core.gui.settings.OverflowPreference
android:key="header_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

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

@ -51,6 +51,9 @@ import android.preference.PreferenceManager; @@ -51,6 +51,9 @@ import android.preference.PreferenceManager;
@EBean(scope = Scope.Singleton)
public class ApplicationSettings {
public static final int DEFAULTSERVER_LASTUSED = -2;
public static final int DEFAULTSERVER_ASKONADD = -1;
@RootContext
protected Context context;
private SharedPreferences prefs;
@ -244,10 +247,67 @@ public class ApplicationSettings { @@ -244,10 +247,67 @@ public class ApplicationSettings {
edit.remove("server_timeout_" + 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();
}
/**
* 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
* 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 @@ -104,7 +104,7 @@ public class DetailsActivity extends Activity implements TorrentTasksExecutor, R
private PullToRefreshAttacher pullToRefreshAttacher = null;
// Details view components
@FragmentById(resName = "torrent_details")
@FragmentById(resName = "torrentdetails_fragment")
protected DetailsFragment fragmentDetails;
@Override

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

@ -52,6 +52,9 @@ import org.transdroid.daemon.TorrentFile; @@ -52,6 +52,9 @@ import org.transdroid.daemon.TorrentFile;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.ActionMode;
@ -475,6 +478,20 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -475,6 +478,20 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
mode.finish();
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 {
Priority priority = Priority.Off;
if (itemId == R.id.action_priority_low)

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

@ -0,0 +1,41 @@ @@ -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");
}
}

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

@ -51,11 +51,6 @@ import org.transdroid.core.gui.lists.NoProgressHeaderTransformer; @@ -51,11 +51,6 @@ 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.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.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper;
@ -173,9 +168,9 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -173,9 +168,9 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
protected ArrayList<Label> lastNavigationLabels;
// Contained torrent and details fragments
@FragmentById(resName = "torrent_list")
@FragmentById(resName = "torrents_fragment")
protected TorrentsFragment fragmentTorrents;
@FragmentById(resName = "torrent_details")
@FragmentById(resName = "torrentdetails_fragment")
protected DetailsFragment fragmentDetails;
// Auto refresh task
@ -236,10 +231,10 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -236,10 +231,10 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Log messages from the server daemons using our singleton logger
DLog.setLogger(Log_.getInstance_(this));
// Load the last used server or a server that was explicitly supplied in the starting intent
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
if (lastUsed == null) {
// No server settings yet;
// Load the default server or a server that was explicitly supplied in the starting intent
ServerSetting defaultServer = applicationSettings.getDefaultServer();
if (defaultServer == null) {
// No server settings yet
return;
}
Torrent openTorrent = null;
@ -251,7 +246,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -251,7 +246,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
Log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId
+ " is not an existing server order id");
} else {
lastUsed = applicationSettings.getServerSetting(serverId);
defaultServer = applicationSettings.getServerSetting(serverId);
if (getIntent().hasExtra(ListWidgetProvider.EXTRA_TORRENT))
openTorrent = getIntent().getParcelableExtra(ListWidgetProvider.EXTRA_TORRENT);
}
@ -259,12 +254,12 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -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
// 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
if (firstStart) {
// 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
preselectNavigationFilter = applicationSettings.getLastUsedNavigationFilter();
// Handle any start up intents
@ -276,6 +271,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -276,6 +271,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
}
} else {
// 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);
navigationSpinnerAdapter.updateCurrentServer(currentConnection);
navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
@ -368,14 +364,12 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -368,14 +364,12 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
super.onDestroy();
}
@TargetApi(Build.VERSION_CODES.FROYO)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
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);
if (android.os.Build.VERSION.SDK_INT >= 8) {
SearchView searchView = new SearchView(this);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true);
@ -387,7 +381,6 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -387,7 +381,6 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
stopAutoRefresh();
}
});
// NOTE ABS's OnCloseListener is not working, hence using an OnActionExpandListener
item.setOnActionExpandListener(new OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
@ -404,7 +397,6 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -404,7 +397,6 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
item.setActionView(searchView);
searchMenu = item;
}
}
return true;
}
@ -510,7 +502,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -510,7 +502,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true);
if (fragmentDetails != null && fragmentDetails.getActivity() != null) {
if (fragmentDetails != null && fragmentDetails.isAdded() && fragmentDetails.getActivity() != null) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear();
fragmentDetails.setCurrentServerSettings(server);
@ -530,7 +522,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -530,7 +522,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Remember that the user last selected this
applicationSettings.setLastUsedNavigationFilter(currentFilter);
// Clear the details view
if (fragmentDetails != null) {
if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear();
}
@ -545,7 +537,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -545,7 +537,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
private void updateFragmentVisibility(boolean hasServerSettings) {
if (filtersList != null)
filtersList.setVisibility(hasServerSettings ? View.VISIBLE : View.GONE);
if (fragmentDetails != null) {
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (hasServerSettings)
getFragmentManager().beginTransaction().show(fragmentDetails).commit();
else
@ -560,11 +552,31 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -560,11 +552,31 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
handleStartIntent();
}
/**
* If required, add torrents, switch to a specific server, etc.
*/
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();
Uri dataUri = intent.getData();
String data = intent.getDataString();
@ -818,7 +830,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -818,7 +830,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
* @param torrent The torrent to show detailed statistics for
*/
public void openDetails(Torrent torrent) {
if (fragmentDetails != null) {
if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateTorrent(torrent);
} else {
DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels)
@ -1186,7 +1198,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -1186,7 +1198,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.updateIsLoading(false);
if (isCritical) {
fragmentTorrents.updateError(error);
if (fragmentDetails != null)
if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateIsLoading(false, error);
}
}
@ -1202,7 +1214,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -1202,7 +1214,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.updateTorrents(new ArrayList<Torrent>(torrents), lastNavigationLabels);
// 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);
}
@ -1214,7 +1226,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener, @@ -1214,7 +1226,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Labels are shown in the action bar spinner
navigationSpinnerAdapter.updateLabels(lastNavigationLabels);
}
if (fragmentDetails != null)
if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateLabels(lastNavigationLabels);
// 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, @@ -1244,14 +1256,14 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
@UiThread
protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// 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);
}
@UiThread
protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// 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));
}

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

@ -53,9 +53,9 @@ public class RssfeedsActivity extends Activity { @@ -53,9 +53,9 @@ public class RssfeedsActivity extends Activity {
protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments
@FragmentById(resName = "rssfeeds_list")
@FragmentById(resName = "rssfeeds_fragment")
protected RssfeedsFragment fragmentFeeds;
@FragmentById(resName = "rssitems_list")
@FragmentById(resName = "rssitems_fragment")
protected RssitemsFragment fragmentItems;
@Override
@ -145,7 +145,7 @@ public class RssfeedsActivity extends Activity { @@ -145,7 +145,7 @@ public class RssfeedsActivity extends Activity {
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
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
// 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 { @@ -41,7 +41,7 @@ public class RssitemsActivity extends Activity {
@Extra
protected String rssfeedName;
@FragmentById(resName = "rssitems_list")
@FragmentById(resName = "rssitems_fragment")
protected RssitemsFragment fragmentItems;
@Override

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

@ -38,6 +38,9 @@ import android.app.Dialog; @@ -38,6 +38,9 @@ import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.SearchManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@ -146,6 +149,7 @@ public class RssitemsFragment extends Fragment { @@ -146,6 +149,7 @@ public class RssitemsFragment extends Fragment {
int itemId = item.getItemId();
if (itemId == R.id.action_addall) {
// 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
Intent intent = new Intent("org.transdroid.ADD_MULTIPLE");
@ -160,7 +164,23 @@ public class RssitemsFragment extends Fragment { @@ -160,7 +164,23 @@ public class RssitemsFragment extends Fragment {
startActivity(intent);
mode.finish();
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 {
// The other items only operate on one (the first) selected item
if (checked.size() < 1)
return false;
@ -190,7 +210,9 @@ public class RssitemsFragment extends Fragment { @@ -190,7 +210,9 @@ public class RssitemsFragment extends Fragment {
search.putExtra(SearchManager.QUERY, first.getTitle());
startActivity(search);
}
return false;
mode.finish();
return true;
}
}

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

@ -29,8 +29,10 @@ import org.androidannotations.annotations.ViewById; @@ -29,8 +29,10 @@ import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R;
import org.transdroid.core.app.search.SearchHelper;
import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.*;
import org.transdroid.core.app.settings.ApplicationSettings;
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 android.annotation.TargetApi;
@ -62,7 +64,7 @@ import android.widget.TextView; @@ -62,7 +64,7 @@ import android.widget.TextView;
@OptionsMenu(resName = "activity_search")
public class SearchActivity extends Activity implements OnNavigationListener {
@FragmentById(resName = "searchresults_list")
@FragmentById(resName = "searchresults_fragment")
protected SearchResultsFragment fragmentResults;
@ViewById
protected ListView searchsitesList;
@ -141,21 +143,18 @@ public class SearchActivity extends Activity implements OnNavigationListener { @@ -141,21 +143,18 @@ public class SearchActivity extends Activity implements OnNavigationListener {
}
@TargetApi(Build.VERSION_CODES.FROYO)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
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);
if (android.os.Build.VERSION.SDK_INT >= 8) {
final SearchView searchView = new SearchView(this);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true);
item.setActionView(searchView);
searchMenu = item;
}
}
return true;
}
@ -185,13 +184,17 @@ public class SearchActivity extends Activity implements OnNavigationListener { @@ -185,13 +184,17 @@ public class SearchActivity extends Activity implements OnNavigationListener {
}
private void handleIntent(Intent intent) {
lastUsedQuery = parseQuery(intent);
// Is this actually a full HTTP URL? Then redirect this request to add the URL directly
if (lastUsedQuery != null
&& (lastUsedQuery.startsWith("http") || lastUsedQuery.startsWith("https")
|| 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();
return;
}

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

@ -29,7 +29,7 @@ import org.transdroid.core.app.settings.ApplicationSettings; @@ -29,7 +29,7 @@ import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.core.app.settings.ServerSetting;
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.settings.OverflowPreference.OnOverflowClicked;
import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener;
@ -108,12 +108,24 @@ public class MainSettingsActivity extends PreferenceActivity { @@ -108,12 +108,24 @@ public class MainSettingsActivity extends PreferenceActivity {
findPreference("header_system").setOnPreferenceClickListener(onSystemSettings);
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
List<ServerSetting> servers = applicationSettings.getNormalServerSettings();
for (ServerSetting serverSetting : servers) {
getPreferenceScreen().addPreference(
new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener(
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
// only per seedbox type
@ -126,8 +138,16 @@ public class MainSettingsActivity extends PreferenceActivity { @@ -126,8 +138,16 @@ public class MainSettingsActivity extends PreferenceActivity {
.setOnSeedboxClickedListener(onSeedboxClicked, seedboxOffset));
orderOffset++;
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
if (!enableRssUi) {

2
full/AndroidManifest.xml

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

2
lite/AndroidManifest.xml

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

Loading…
Cancel
Save