Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
erickok committed Oct 16, 2013
2 parents 5ca8afc + 1ed644e commit 2f00afd
Show file tree
Hide file tree
Showing 93 changed files with 3,629 additions and 41 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Some code/libraries/resources are used in the project:
* [AndroidAnnotations](http://androidannotations.org/)
Pierre-Yves Ricau (eBusinessInformations) et al.
Apache License, Version 2.0
* [ActionBar-PullToRefresh](https://github.com/chrisbanes/ActionBar-PullToRefresh)
Chris Banes
Apache License, Version 2.0
* [Crouton](https://github.com/keyboardsurfer/Crouton)
Code: Benjamin Weiss (Neofonie Mobile Gmbh) et al.
Idea: Cyril Mottier
Expand Down
4 changes: 2 additions & 2 deletions core/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.transdroid.core"
android:versionCode="6"
android:versionName="2.0" >
android:versionCode="7"
android:versionName="2.0.1" >

<uses-sdk
android:minSdkVersion="7"
Expand Down
2 changes: 2 additions & 0 deletions core/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ android.library.reference.1=../external/JakeWharton-ActionBarSherlock/library
android.library.reference.2=../external/ColorPickerPreference
android.library=true
android.library.reference.3=../external/Crouton/library
android.library.reference.4=../external/ActionBar-PullToRefresh-actionbarsherlock
android.library.reference.5=../external/ActionBar-PullToRefresh
1 change: 0 additions & 1 deletion core/res/layout/fragment_torrents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:text="@string/navigation_nosettings"
android:textIsSelectable="false"
android:visibility="gone" />

Expand Down
323 changes: 323 additions & 0 deletions core/res/values-nl/strings.xml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions core/res/values/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
-->
<resources>
<string name="system_changelog">
Transdroid 2.0.1\n
- Support for pull to refresh\n
- First Google Play release of the lite version as Transdrone\n
- First release as auto-update (now checked only once a day)\n
\n
Transdroid 2.0.0\n
- Scrollable home screen widget (Android 3+)\n
- Allow changing of storage location (Deluge and Transmission)\n
Expand Down
17 changes: 8 additions & 9 deletions core/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<string name="action_search">Search</string>
<string name="action_refresh">Refresh</string>
<string name="action_rss">RSS</string>
<string name="action_enableturtle">Enable turle mode</string>
<string name="action_disableturtle">Disable turle mode</string>
<string name="action_enableturtle">Enable turtle mode</string>
<string name="action_disableturtle">Disable turtle mode</string>
<string name="action_sort">Sort list</string>
<string name="action_sort_alpha">Name</string>
<string name="action_sort_status">Status</string>
Expand Down Expand Up @@ -59,7 +59,7 @@
<string name="action_removesettings">Remove settings</string>
<string name="action_visitwebsite">Visit transdroid.org</string>

<string name="navigation_nosettings">Transdroid allows you to monitor and manage the torrent client you run at home or on your seedbox. Setting things up can be a bit tricky, but we offer step-by-step guides and promise it\'ll be worth it!</string>
<string name="navigation_nosettings">%1$s allows you to monitor and manage the torrent client you run at home or on your seedbox. Setting things up can be a bit tricky, but we offer step-by-step guides and promise it\'ll be worth it!</string>
<string name="navigation_emptytorrents">Connected, but no torrent are active within the current filter</string>
<string name="navigation_emptydetails">Select a torrent to view its details</string>
<string name="navigation_servers">SERVERS</string>
Expand Down Expand Up @@ -270,17 +270,17 @@
<string name="pref_usedarktheme">Use dark UI theme</string>
<string name="pref_usedarktheme_info">Requires a restart to take effect</string>
<string name="pref_import">Import settings</string>
<string name="pref_import_dialog">Transdroid will try to import server, web search, RSS and system settings from: %1$s</string>
<string name="pref_import_dialog">%1$s will try to import server, web search, RSS and system settings from: %2$s</string>
<string name="pref_import_success">Settings successfully imported</string>
<string name="pref_export">Export settings</string>
<string name="pref_export_dialog">Transdroid will export server (including passwords), web search, RSS and system settings to the following plain text JSON file: %1$s</string>
<string name="pref_export_dialog">%1$s will export server (including passwords), web search, RSS and system settings to the following plain text JSON file: %2$s</string>
<string name="pref_export_success">Settings successfully exported</string>
<string name="pref_sendlog">Send error log</string>
<string name="pref_sendlog_info">Get support or report a bug</string>
<string name="pref_installhelp">View install guides</string>
<string name="pref_installhelp_info">Available at transdroid.org/download</string>
<string name="pref_changelog">Recent changes</string>
<string name="pref_about">About Transdroid</string>
<string name="pref_about">About %1$s</string>
<string-array name="pref_daemon_types" translatable="false">
<item>BitComet</item>
<item>Bitflu 1.2+</item>
Expand Down Expand Up @@ -359,7 +359,7 @@
<string name="error_no_link">The RSS feed item does not provide a link to browse to</string>
<string name="error_norssfeed">URL is not a (valid) RSS feed</string>
<string name="error_media_not_available">SD card not available to read/write</string>
<string name="error_no_valid_settings_file">File does not seem to contain Transdroid settings</string>
<string name="error_no_valid_settings_file">File does not seem to contain %1$s settings</string>
<string name="error_file_not_found">The settings file could not be found</string>
<string name="error_cant_write_settings_file">Can\'t write to the settings file</string>
<string name="error_notanumber">Please enter a positive number</string>
Expand All @@ -371,11 +371,10 @@
<string name="update_search_newversion">New Transdroid search module available</string>
<string name="update_updateto">You can now update to %1$s</string>

<string name="system_name" translatable="false">Transdroid</string>
<string name="system_developer" translatable="false">\u00A9 Eric Kok, 2312 development</string>
<string name="system_license" translatable="false">Published under GNU General Public License v3</string>
<string name="system_librarieslabel">Some code/libraries are used in the project:</string>
<string name="system_libraries" translatable="false">ActionBarSherlock\n \u00A0 http://actionbarsherlock.com/\n \u00A0 Jake Wharton \n \u00A0 Apache License, Version 2.0\nAndroidAnnotations\n \u00A0 http://androidannotations.org/\n \u00A0 Pierre-Yves Ricau (eBusinessInformations) et al. \n \u00A0 Apache License, Version 2.0\nCrouton\n \u00A0 https://github.com/keyboardsurfer/Crouton\n \u00A0 Code: Benjamin Weiss (Neofonie Mobile Gmbh) et al. \n \u00A0 Idea: Cyril Mottier \n \u00A0 Apache License, Version 2.0\nBase16Encoder\n \u00A0 http://openjpa.apache.org/\n \u00A0 Marc Prud\'hommeaux \n \u00A0 Apache OpenJPA\n MultipartEntity \n \u00A0 Apache Software Foundation \n \u00A0 Apache License, Version 2.0\nRssParser (learning-android)\n \u00A0 http://github.com/digitalspaghetti/learning-android\n \u00A0 Tane Piper \n \u00A0 Public Domain\nBase64\n \u00A0 http://iharder.net/base64\n \u00A0 Robert Harder \n \u00A0 Public Domain\nandroid-xmlrpc\n \u00A0 http://code.google.com/p/android-xmlrpc/\n \u00A0 pskink et al. \n \u00A0 Apache License, Version 2.0\nandroid-ColorPickerPreference\n \u00A0 https://github.com/attenzione/android-ColorPickerPreference\n \u00A0 Daniel Nilsson and Sergey Margaritov \n \u00A0 Apache License, Version 2.0\nCheckableRelativeLayout\n \u00A0 http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/\n \u00A0 Cédric Caron (MarvinLabs)\n \u00A0 Public Domain\nFunnel icon\n \u00A0 http://thenounproject.com/noun/funnel/#icon-No5608\n \u00A0 Naomi Atkinson from The Noun Project\n \u00A0 Creative Commons Attribution 3.0</string>
<string name="system_libraries" translatable="false">ActionBarSherlock\n \u00A0 http://actionbarsherlock.com/\n \u00A0 Jake Wharton \n \u00A0 Apache License, Version 2.0\nAndroidAnnotations\n \u00A0 http://androidannotations.org/\n \u00A0 Pierre-Yves Ricau (eBusinessInformations) et al. \n \u00A0 Apache License, Version 2.0\nActionBar-PullToRefresh\n \u00A0 https://github.com/chrisbanes/ActionBar-PullToRefresh\n \u00A0 Chris Banes \n \u00A0 Apache License, Version 2.0\nCrouton\n \u00A0 https://github.com/keyboardsurfer/Crouton\n \u00A0 Code: Benjamin Weiss (Neofonie Mobile Gmbh) et al. \n \u00A0 Idea: Cyril Mottier \n \u00A0 Apache License, Version 2.0\nBase16Encoder\n \u00A0 http://openjpa.apache.org/\n \u00A0 Marc Prud\'hommeaux \n \u00A0 Apache OpenJPA\n MultipartEntity \n \u00A0 Apache Software Foundation \n \u00A0 Apache License, Version 2.0\nRssParser (learning-android)\n \u00A0 http://github.com/digitalspaghetti/learning-android\n \u00A0 Tane Piper \n \u00A0 Public Domain\nBase64\n \u00A0 http://iharder.net/base64\n \u00A0 Robert Harder \n \u00A0 Public Domain\nandroid-xmlrpc\n \u00A0 http://code.google.com/p/android-xmlrpc/\n \u00A0 pskink et al. \n \u00A0 Apache License, Version 2.0\nandroid-ColorPickerPreference\n \u00A0 https://github.com/attenzione/android-ColorPickerPreference\n \u00A0 Daniel Nilsson and Sergey Margaritov \n \u00A0 Apache License, Version 2.0\nCheckableRelativeLayout\n \u00A0 http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/\n \u00A0 Cédric Caron (MarvinLabs)\n \u00A0 Public Domain\nFunnel icon\n \u00A0 http://thenounproject.com/noun/funnel/#icon-No5608\n \u00A0 Naomi Atkinson from The Noun Project\n \u00A0 Creative Commons Attribution 3.0</string>
<string name="system_description">Manage your torrents from your Android device</string>

</resources>
3 changes: 1 addition & 2 deletions core/res/xml/pref_system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
android:title="@string/pref_changelog" />

<Preference
android:key="system_about"
android:title="@string/pref_about" />
android:key="system_about" />

</PreferenceScreen>
33 changes: 31 additions & 2 deletions core/src/org/transdroid/core/app/settings/SystemSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
*/
package org.transdroid.core.app.settings;

import java.util.Date;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.androidannotations.annotations.EBean.Scope;
import org.transdroid.core.service.AppUpdateService;

import android.content.Context;
import android.content.SharedPreferences;
Expand All @@ -34,7 +37,7 @@ public class SystemSettings {
@RootContext
protected Context context;
private SharedPreferences prefs;

protected SystemSettings(Context context) {
prefs = PreferenceManager.getDefaultSharedPreferences(context);
}
Expand All @@ -46,5 +49,31 @@ public boolean checkForUpdates() {
public boolean useDarkTheme() {
return prefs.getBoolean("system_usedarktheme", false);
}


/**
* Returns the date when we last checked transdroid.org for the latest app version.
* @return The date/time when the {@link AppUpdateService} checked on the server for updates
*/
public Date getLastCheckedForAppUpdates() {
long lastChecked = prefs.getLong("system_lastappupdatecheck", -1L);
return lastChecked == -1 ? null : new Date(lastChecked);
}

/**
* Stores the date at which was last successfully, fully checked for new updates to the app.
* @param lastChecked The date/time at which the {@link AppUpdateService} last checked the server for updates
*/
public void setLastCheckedForAppUpdates(Date lastChecked) {
prefs.edit().putLong("system_lastappupdatecheck", lastChecked == null ? -1L : lastChecked.getTime()).commit();
}

/**
* Whether the custom app update checker should be used to check for new app and search module versions.
* @return True if it should be checked against transdroid.org if there are app updates (as opposed to using the
* Play Store for updates), false otherwise
*/
public static boolean enableUpdateChecker(Context context) {
return !context.getPackageName().equals("org.transdroid.lite");
}

}
31 changes: 30 additions & 1 deletion core/src/org/transdroid/core/gui/DetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.transdroid.core.R;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationHelper;
Expand Down Expand Up @@ -62,10 +63,15 @@
import org.transdroid.daemon.task.StartTask;
import org.transdroid.daemon.task.StopTask;

import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefreshListener;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.Options;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.actionbarsherlock.app.SherlockFragmentActivity;
Expand Down Expand Up @@ -97,6 +103,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@Bean
protected ApplicationSettings applicationSettings;
private IDaemonAdapter currentConnection = null;
private PullToRefreshAttacher pullToRefreshAttacher = null;

// Details view components
@FragmentById(resName = "torrent_details")
Expand Down Expand Up @@ -148,6 +155,28 @@ protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}

/**
* Attaches some view (perhaps contained in a fragment) to this activity's pull to refresh support
* @param view The view to attach
*/
@Override
public void addRefreshableView(View view) {
if (pullToRefreshAttacher == null) {
// Still need to initialise the PullToRefreshAttacher
Options options = new PullToRefreshAttacher.Options();
options.headerTransformer = new NoProgressHeaderTransformer();
pullToRefreshAttacher = PullToRefreshAttacher.get(this, options);
}
pullToRefreshAttacher.addRefreshableView(view, new OnRefreshListener() {
@Override
public void onRefreshStarted(View view) {
// Just refresh the full screen, now that the user has pulled to refresh
pullToRefreshAttacher.setRefreshComplete();
refreshScreen();
}
});
}

@OptionsItem(resName = "action_refresh")
public void refreshScreen() {
fragmentDetails.updateIsLoading(true, null);
Expand Down Expand Up @@ -330,7 +359,7 @@ protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torren
protected void onCommunicationError(DaemonTaskFailureResult result, boolean isCritical) {
Log.i(this, result.getException().toString());
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
fragmentDetails.updateIsLoading(false, isCritical? error: null);
fragmentDetails.updateIsLoading(false, isCritical ? error : null);
Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())),
NavigationHelper.CROUTON_ERROR_STYLE);
}
Expand Down
5 changes: 5 additions & 0 deletions core/src/org/transdroid/core/gui/DetailsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ protected void init() {
detailsList.setAdapter(new DetailsAdapter(getActivity()));
detailsList.setMultiChoiceModeListener(onDetailsSelected);
detailsList.setFastScrollEnabled(true);
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).addRefreshableView(detailsList);
}

// Restore the fragment state (on orientation changes et al.)
if (torrent != null)
updateTorrent(torrent);
if (torrentDetails != null)
Expand Down
28 changes: 28 additions & 0 deletions core/src/org/transdroid/core/gui/TorrentsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.transdroid.core.R;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.lists.LocalTorrent;
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.*;
Expand Down Expand Up @@ -92,6 +93,10 @@
import org.transdroid.daemon.util.DLog;
import org.transdroid.daemon.util.HttpHelper;

import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshAttacher;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.OnRefreshListener;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshAttacher.Options;

import android.annotation.TargetApi;
import android.app.SearchManager;
import android.content.ContentResolver;
Expand Down Expand Up @@ -138,6 +143,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@SystemService
protected SearchManager searchManager;
private MenuItem searchMenu = null;
private PullToRefreshAttacher pullToRefreshAttacher = null;

// Settings
@Bean
Expand Down Expand Up @@ -571,6 +577,28 @@ public void onBarcodeScanned(int resultCode, Intent data) {
startSearch(query, false, null, false);
}

/**
* Attaches some view (perhaps contained in a fragment) to this activity's pull to refresh support
* @param view The view to attach
*/
@Override
public void addRefreshableView(View view) {
if (pullToRefreshAttacher == null) {
// Still need to initialise the PullToRefreshAttacher
Options options = new PullToRefreshAttacher.Options();
options.headerTransformer = new NoProgressHeaderTransformer();
pullToRefreshAttacher = PullToRefreshAttacher.get(this, options);
}
pullToRefreshAttacher.addRefreshableView(view, new OnRefreshListener() {
@Override
public void onRefreshStarted(View view) {
// Just refresh the full screen, now that the user has pulled to refresh
pullToRefreshAttacher.setRefreshComplete();
refreshScreen();
}
});
}

@OptionsItem(resName = "action_refresh")
public void refreshScreen() {
fragmentTorrents.updateIsLoading(true);
Expand Down
5 changes: 5 additions & 0 deletions core/src/org/transdroid/core/gui/TorrentsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ protected void init() {
torrentsList.setFastScrollEnabled(true);
if (torrents != null)
updateTorrents(torrents, currentLabels);
// Allow pulls on the list view to refresh the torrents
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).addRefreshableView(torrentsList);
}
nosettingsText.setText(getString(R.string.navigation_nosettings, getString(R.string.app_name)));

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.transdroid.core.gui.lists;

import org.transdroid.core.R;

import android.app.Activity;
import android.view.View;
import uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.AbsDefaultHeaderTransformer;

public class NoProgressHeaderTransformer extends AbsDefaultHeaderTransformer {

@Override
public void onViewCreated(Activity activity, View headerView) {
super.onViewCreated(activity, headerView);
setProgressBarColor(activity.getResources().getColor(R.color.green));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ public static SpannableString buildCondensedFontString(String string) {
* @return A best-guess, reasonably long name for the linked torrent
*/
public static String extractNameFromUri(Uri rawTorrentUri) {

if (rawTorrentUri.getScheme() == null) {
// Probably an incorrect URI; just return the whole thing
return rawTorrentUri.toString();
}

if (rawTorrentUri.getScheme().equals("magnet")) {
// Magnet links might have a dn (display name) parameter
String dn = getQueryParameter(rawTorrentUri, "dn");
Expand All @@ -198,7 +198,7 @@ public static String extractNameFromUri(Uri rawTorrentUri) {
return path;
}
}

// No idea what to do with this; return as is
return rawTorrentUri.toString();
}
Expand All @@ -208,9 +208,9 @@ private static String getQueryParameter(Uri uri, String parameter) {
if (start >= 0) {
int begin = start + (parameter + "=").length();
int end = uri.toString().indexOf("&", begin);
return uri.toString().substring(begin, end >= 0? end: uri.toString().length());
return uri.toString().substring(begin, end >= 0 ? end : uri.toString().length());
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.transdroid.core.gui.navigation;

import android.view.View;

/**
* Interface to be implemented by any activity that allows its content to be refreshed; fragments can ask for
* user-initiated refreshes.
Expand All @@ -25,4 +27,6 @@ public interface RefreshableActivity {

public void refreshScreen();

public void addRefreshableView(View view);

}
Loading

0 comments on commit 2f00afd

Please sign in to comment.