diff --git a/README b/README
index 7ab734cd..34a2037d 100644
--- a/README
+++ b/README
@@ -33,6 +33,10 @@ Some code/libraries are used in the project:
Idea: Cyril Mottier
Apache License, Version 2.0
https://github.com/keyboardsurfer/Crouton
+ BetterPickers
+ Derek Brameyer
+ Apache License, Version 2.0
+ https://github.com/derekbrameyer/android-betterpickers
Base16Encoder
Marc Prud'hommeaux
Apache OpenJPA
diff --git a/core/AndroidManifest.xml b/core/AndroidManifest.xml
index d905a57a..6f69f60e 100644
--- a/core/AndroidManifest.xml
+++ b/core/AndroidManifest.xml
@@ -6,6 +6,6 @@
+ android:targetSdkVersion="18" />
\ No newline at end of file
diff --git a/core/project.properties b/core/project.properties
index 0a043162..0ca2ebd5 100644
--- a/core/project.properties
+++ b/core/project.properties
@@ -11,7 +11,7 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-17
+target=android-18
android.library.reference.1=../external/JakeWharton-ActionBarSherlock/library
android.library.reference.2=../external/ColorPickerPreference
android.library=true
diff --git a/core/res/layout/dialog_transferrates.xml b/core/res/layout/dialog_transferrates.xml
new file mode 100644
index 00000000..9bdf34d3
--- /dev/null
+++ b/core/res/layout/dialog_transferrates.xml
@@ -0,0 +1,293 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/res/values-v16/styles.xml b/core/res/values-v16/styles.xml
index b3cef559..fcfa28db 100644
--- a/core/res/values-v16/styles.xml
+++ b/core/res/values-v16/styles.xml
@@ -37,4 +37,11 @@
- sans-serif-condensed
+
+
\ No newline at end of file
diff --git a/core/res/values/changelog.xml b/core/res/values/changelog.xml
index 66fd568e..16aa4560 100644
--- a/core/res/values/changelog.xml
+++ b/core/res/values/changelog.xml
@@ -1,6 +1,10 @@
+Transdroid 2.0.0-alpha3\n
+- Added torrent search\n
+- Setting of max. up/down speeds\n
+\n
Transdroid 2.0.0-alpha2\n
- Fixed Transmission adapter folder setting\n
- Fixed RSS feed screens\n
diff --git a/core/res/values/strings.xml b/core/res/values/strings.xml
index 7a1b46c4..a3f4749d 100644
--- a/core/res/values/strings.xml
+++ b/core/res/values/strings.xml
@@ -94,6 +94,11 @@
TRACKERS
ERRORS
FILES
+ Maximum transfer speeds
+ MAX DOWNLOAD
+ MAX UPLOAD
+ KB/S
+ Reset
All labels
Unlabeled
@@ -115,6 +120,7 @@
Label set to \'%1$s\'
Torrent moved to \'%1$s\'
File priorities updated
+ Maximum transfer speeds set
Torrent search
Search for torrents
@@ -305,6 +311,7 @@
File does not seem to contain Transdroid settings
The settings file could not be found
Can\'t write to the settings file
+ Please enter a positive number
Transdroid
\u00A9 Eric Kok, 2312 development
diff --git a/core/res/values/styles.xml b/core/res/values/styles.xml
index 3122d416..7a37be80 100644
--- a/core/res/values/styles.xml
+++ b/core/res/values/styles.xml
@@ -82,4 +82,10 @@
- 2dip
+
+
\ No newline at end of file
diff --git a/core/src/org/transdroid/core/gui/ServerStatusView.java b/core/src/org/transdroid/core/gui/ServerStatusView.java
index 8bbda367..b74cb42e 100644
--- a/core/src/org/transdroid/core/gui/ServerStatusView.java
+++ b/core/src/org/transdroid/core/gui/ServerStatusView.java
@@ -4,31 +4,43 @@ import java.util.List;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
+import org.transdroid.core.R;
+import org.transdroid.core.gui.navigation.NavigationHelper;
+import org.transdroid.core.gui.navigation.SetTransferRatesDialog;
+import org.transdroid.core.gui.navigation.SetTransferRatesDialog.OnRatesPickedListener;
import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentStatus;
import org.transdroid.daemon.util.FileSizeConverter;
+import de.keyboardsurfer.android.widget.crouton.Crouton;
+
import android.content.Context;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
-@EViewGroup(resName="actionbar_serverstatus")
-public class ServerStatusView extends RelativeLayout {
+@EViewGroup(resName = "actionbar_serverstatus")
+public class ServerStatusView extends RelativeLayout implements OnRatesPickedListener {
@ViewById
protected TextView downcountText, upcountText, downcountSign, upcountSign, downspeedText, upspeedText;
-
+ private TorrentsActivity activity;
+
public ServerStatusView(Context context) {
super(context);
}
+ public ServerStatusView(TorrentsActivity activity) {
+ super(activity);
+ this.activity = activity;
+ }
+
/**
* Updates the statistics as shown in the action bar through this server status view.
* @param torrents The most recently received list of torrents
*/
public void update(List torrents) {
-
+
if (torrents == null) {
downcountText.setText(null);
upcountText.setText(null);
@@ -36,11 +48,12 @@ public class ServerStatusView extends RelativeLayout {
upspeedText.setText(null);
downcountSign.setVisibility(View.INVISIBLE);
upcountSign.setVisibility(View.INVISIBLE);
+ setClickListener(null);
}
-
+
int downcount = 0, upcount = 0, downspeed = 0, upspeed = 0;
for (Torrent torrent : torrents) {
-
+
// Downloading torrents count towards downloads and uploads, seeding torrents towards uploads
if (torrent.getStatusCode() == TorrentStatus.Downloading) {
downcount++;
@@ -50,7 +63,7 @@ public class ServerStatusView extends RelativeLayout {
}
downspeed += torrent.getRateDownload();
upspeed += torrent.getRateUpload();
-
+
}
downcountText.setText(Integer.toString(downcount));
@@ -59,7 +72,39 @@ public class ServerStatusView extends RelativeLayout {
upspeedText.setText(FileSizeConverter.getSize(upspeed));
downcountSign.setVisibility(View.VISIBLE);
upcountSign.setVisibility(View.VISIBLE);
-
+ setClickListener(onStartDownPickerClicked);
+
+ }
+
+ private void setClickListener(OnClickListener onClick) {
+ downcountText.setOnClickListener(onClick);
+ upcountText.setOnClickListener(onClick);
+ downspeedText.setOnClickListener(onClick);
+ upspeedText.setOnClickListener(onClick);
+ downcountSign.setOnClickListener(onClick);
+ upcountSign.setOnClickListener(onClick);
+ }
+
+ private OnClickListener onStartDownPickerClicked = new OnClickListener() {
+ public void onClick(View v) {
+ new SetTransferRatesDialog().setOnRatesPicked(ServerStatusView.this).show(
+ activity.getSupportFragmentManager(), "SetTransferRatesDialog");
+ }
+ };
+
+ @Override
+ public void onRatesPicked(int maxDownloadSpeed, int maxUploadSpeed) {
+ activity.updateMaxSpeeds(maxDownloadSpeed, maxUploadSpeed);
}
-
+
+ @Override
+ public void resetRates() {
+ activity.updateMaxSpeeds(null, null);
+ }
+
+ @Override
+ public void onInvalidNumber() {
+ Crouton.showText(activity, R.string.error_notanumber, NavigationHelper.CROUTON_ERROR_STYLE);
+ }
+
}
diff --git a/core/src/org/transdroid/core/gui/TorrentsActivity.java b/core/src/org/transdroid/core/gui/TorrentsActivity.java
index b52bb65b..e954ead3 100644
--- a/core/src/org/transdroid/core/gui/TorrentsActivity.java
+++ b/core/src/org/transdroid/core/gui/TorrentsActivity.java
@@ -28,9 +28,7 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.transdroid.core.R;
-import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.*;
-import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.log.*;
@@ -69,6 +67,7 @@ import org.transdroid.daemon.task.SetDownloadLocationTask;
import org.transdroid.daemon.task.SetFilePriorityTask;
import org.transdroid.daemon.task.SetLabelTask;
import org.transdroid.daemon.task.SetTrackersTask;
+import org.transdroid.daemon.task.SetTransferRatesTask;
import org.transdroid.daemon.task.StartTask;
import org.transdroid.daemon.task.StopTask;
import org.transdroid.daemon.util.DLog;
@@ -859,6 +858,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
}
+ @Background
+ public void updateMaxSpeeds(Integer maxDownloadSpeed, Integer maxUploadSpeed) {
+ DaemonTaskResult result = SetTransferRatesTask.create(currentConnection, maxUploadSpeed, maxDownloadSpeed)
+ .execute();
+ if (result instanceof DaemonTaskResult) {
+ onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_maxspeedsset));
+ } else {
+ onCommunicationError((DaemonTaskFailureResult) result, false);
+ }
+ }
+
@UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// Refresh the screen as well
diff --git a/core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java b/core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java
new file mode 100644
index 00000000..e96f7912
--- /dev/null
+++ b/core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java
@@ -0,0 +1,103 @@
+package org.transdroid.core.gui.navigation;
+
+import org.transdroid.core.R;
+
+import android.annotation.TargetApi;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+/**
+ * A dialog fragment that allow picking of maximum download and upload transfer rates as well as the resetting of these
+ * values.
+ * @author Eric Kok
+ */
+public class SetTransferRatesDialog extends DialogFragment {
+
+ private OnRatesPickedListener onRatesPicked;
+ private TextView maxSpeedDown, maxSpeedUp;
+
+ public SetTransferRatesDialog() {
+ setRetainInstance(true);
+ }
+
+ /**
+ * Sets the callback for results in this dialog (with newly selected values or a reset).
+ * @param onRatesPicked The event listener to this dialog
+ * @return This dialog, for method chaining
+ */
+ public SetTransferRatesDialog setOnRatesPicked(OnRatesPickedListener onRatesPicked) {
+ this.onRatesPicked = onRatesPicked;
+ return this;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final View transferRatesContent = getActivity().getLayoutInflater().inflate(R.layout.dialog_transferrates,
+ null, false);
+ maxSpeedDown = (TextView) transferRatesContent.findViewById(R.id.maxspeeddown_text);
+ maxSpeedUp = (TextView) transferRatesContent.findViewById(R.id.maxspeedup_text);
+ bindButtons(transferRatesContent, maxSpeedDown, R.id.down1Button, R.id.down2Button, R.id.down3Button,
+ R.id.down4Button, R.id.down5Button, R.id.down6Button, R.id.down7Button, R.id.down8Button,
+ R.id.down9Button, R.id.down0Button);
+ bindButtons(transferRatesContent, maxSpeedUp, R.id.up1Button, R.id.up2Button, R.id.up3Button, R.id.up4Button,
+ R.id.up5Button, R.id.up6Button, R.id.up7Button, R.id.up8Button, R.id.up9Button, R.id.up0Button);
+ return new AlertDialog.Builder(getActivity()).setTitle(R.string.status_maxspeed).setView(transferRatesContent)
+ .setPositiveButton(android.R.string.ok, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ int maxDown = -1, maxUp = -1;
+ try {
+ maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
+ maxUp = Integer.parseInt(maxSpeedUp.getText().toString());
+ } catch (NumberFormatException e) {
+ }
+ if (maxDown <= 0 || maxUp <= 0) {
+ onRatesPicked.onInvalidNumber();
+ }
+ onRatesPicked.onRatesPicked(maxDown, maxUp);
+ }
+ }).setNeutralButton(R.string.status_maxspeed_reset, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ onRatesPicked.resetRates();
+ }
+ }).setNegativeButton(android.R.string.cancel, null).create();
+ }
+
+ private void bindButtons(View transferRatesContent, View numberView, int... buttonResource) {
+ for (int i : buttonResource) {
+ // Keep the relevant number as reference in the view tag and bind the click listerner
+ transferRatesContent.findViewById(i).setTag(numberView);
+ transferRatesContent.findViewById(i).setOnClickListener(onNumberClicked);
+ }
+ }
+
+ private android.view.View.OnClickListener onNumberClicked = new android.view.View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // Append the text contents of the button itself as text to the current number (as reference in the view's
+ // tag)
+ TextView numberView = (TextView) v.getTag();
+ if (numberView.getText().equals("-"))
+ numberView.setText("");
+ numberView.setText(numberView.getText().toString() + ((Button) v).getText().toString());
+ }
+ };
+
+ /**
+ * Listener interface to the user having picked or wanting to resets the current maximum transfer speeds;
+ */
+ public interface OnRatesPickedListener {
+ public void onRatesPicked(int maxDownloadSpeed, int maxUploadSpeed);
+ public void resetRates();
+ public void onInvalidNumber();
+ }
+
+}
diff --git a/external/ColorPickerPreference/project.properties b/external/ColorPickerPreference/project.properties
index 616f300c..6905bdf0 100644
--- a/external/ColorPickerPreference/project.properties
+++ b/external/ColorPickerPreference/project.properties
@@ -9,4 +9,4 @@
android.library=true
# Project target.
-target=android-16
+target=android-18
diff --git a/external/Crouton/library/project.properties b/external/Crouton/library/project.properties
index 225879d4..bbe5c21a 100644
--- a/external/Crouton/library/project.properties
+++ b/external/Crouton/library/project.properties
@@ -12,6 +12,6 @@
# Project target.
-target=android-17
+target=android-18
android.library=true
android.library.reference.1=../../JakeWharton-ActionBarSherlock/library
diff --git a/external/JakeWharton-ActionBarSherlock/library/AndroidManifest.xml b/external/JakeWharton-ActionBarSherlock/library/AndroidManifest.xml
index 7b8a8482..bd9d22d1 100644
--- a/external/JakeWharton-ActionBarSherlock/library/AndroidManifest.xml
+++ b/external/JakeWharton-ActionBarSherlock/library/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/external/JakeWharton-ActionBarSherlock/library/project.properties b/external/JakeWharton-ActionBarSherlock/library/project.properties
index 0e58ae1c..6905bdf0 100644
--- a/external/JakeWharton-ActionBarSherlock/library/project.properties
+++ b/external/JakeWharton-ActionBarSherlock/library/project.properties
@@ -9,4 +9,4 @@
android.library=true
# Project target.
-target=android-17
+target=android-18
diff --git a/full/AndroidManifest.xml b/full/AndroidManifest.xml
index 6ac1d2f4..81243c33 100644
--- a/full/AndroidManifest.xml
+++ b/full/AndroidManifest.xml
@@ -6,7 +6,7 @@
+ android:targetSdkVersion="18" />
-
+
diff --git a/lite/AndroidManifest.xml b/lite/AndroidManifest.xml
index 068fd8dd..055e0598 100644
--- a/lite/AndroidManifest.xml
+++ b/lite/AndroidManifest.xml
@@ -6,7 +6,7 @@
+ android:targetSdkVersion="18" />