Browse Source

Added editing of trackers from torrent details view.

pull/11/head
Eric Kok 11 years ago
parent
commit
65e28f5638
  1. 1
      core/res/values/strings.xml
  2. 16
      core/src/org/transdroid/core/gui/DetailsFragment.java
  3. 2
      core/src/org/transdroid/core/gui/ServerStatusView.java
  4. 22
      core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java

1
core/res/values/strings.xml

@ -99,6 +99,7 @@ @@ -99,6 +99,7 @@
<string name="status_maxspeed_up">MAX UPLOAD</string>
<string name="status_maxspeed_unit">KB/S</string>
<string name="status_maxspeed_reset">Reset</string>
<string name="status_update">Update</string>
<string name="labels_showall">All labels</string>
<string name="labels_unlabeled">Unlabeled</string>

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

@ -18,6 +18,8 @@ import org.transdroid.core.gui.lists.SimpleListItemAdapter; @@ -18,6 +18,8 @@ import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.navigation.SetTrackersDialog;
import org.transdroid.core.gui.navigation.SetTrackersDialog.OnTrackersUpdatedListener;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.Priority;
import org.transdroid.daemon.Torrent;
@ -45,7 +47,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -45,7 +47,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/
@EFragment(resName = "fragment_details")
@OptionsMenu(resName = "fragment_details")
public class DetailsFragment extends SherlockFragment {
public class DetailsFragment extends SherlockFragment implements OnTrackersUpdatedListener {
// Local data
@InstanceState
@ -78,7 +80,7 @@ public class DetailsFragment extends SherlockFragment { @@ -78,7 +80,7 @@ public class DetailsFragment extends SherlockFragment {
detailsList.setBackgroundResource(R.drawable.details_list_background_light);
}
}
// Set up details adapter (itself containing the actual lists to show), which allows multi-select and fast
// scrolling
detailsList.setAdapter(new DetailsAdapter(getActivity()));
@ -256,13 +258,19 @@ public class DetailsFragment extends SherlockFragment { @@ -256,13 +258,19 @@ public class DetailsFragment extends SherlockFragment {
@OptionsItem(resName = "action_updatetrackers")
protected void updateTrackers() {
// TODO: Show trackers edit dialog
new SetTrackersDialog().setOnTrackersUpdated(this).setCurrentTrackers(torrentDetails.getTrackersText())
.show(getActivity().getSupportFragmentManager(), "SetTrackersDialog");
}
@Override
public void onTrackersUpdated(List<String> updatedTrackers) {
getTasksExecutor().updateTrackers(torrent, updatedTrackers);
}
private MultiChoiceModeListenerCompat onDetailsSelected = new MultiChoiceModeListenerCompat() {
SelectionManagerMode selectionManagerMode;
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Show contextual action bar to start/stop/remove/etc. torrents in batch mode

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

@ -87,7 +87,7 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis @@ -87,7 +87,7 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis
private OnClickListener onStartDownPickerClicked = new OnClickListener() {
public void onClick(View v) {
new SetTransferRatesDialog().setOnRatesPicked(ServerStatusView.this).show(
new SetTransferRatesDialog().setOnRatesPickedListener(ServerStatusView.this).show(
activity.getSupportFragmentManager(), "SetTransferRatesDialog");
}
};

22
core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
package org.transdroid.core.gui.navigation;
import java.security.InvalidParameterException;
import org.transdroid.core.R;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
@ -20,7 +21,7 @@ import android.widget.TextView; @@ -20,7 +21,7 @@ import android.widget.TextView;
*/
public class SetTransferRatesDialog extends DialogFragment {
private OnRatesPickedListener onRatesPicked;
private OnRatesPickedListener onRatesPickedListener = null;
private TextView maxSpeedDown, maxSpeedUp;
public SetTransferRatesDialog() {
@ -29,16 +30,19 @@ public class SetTransferRatesDialog extends DialogFragment { @@ -29,16 +30,19 @@ public class SetTransferRatesDialog extends DialogFragment {
/**
* Sets the callback for results in this dialog (with newly selected values or a reset).
* @param onRatesPicked The event listener to this dialog
* @param onRatesPickedListener The event listener to this dialog
* @return This dialog, for method chaining
*/
public SetTransferRatesDialog setOnRatesPicked(OnRatesPickedListener onRatesPicked) {
this.onRatesPicked = onRatesPicked;
public SetTransferRatesDialog setOnRatesPickedListener(OnRatesPickedListener onRatesPickedListener) {
this.onRatesPickedListener = onRatesPickedListener;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (onRatesPickedListener == null)
throw new InvalidParameterException(
"Please first set the callback listener using setOnRatesPickedListener before opening the dialog.");
final View transferRatesContent = getActivity().getLayoutInflater().inflate(R.layout.dialog_transferrates,
null, false);
maxSpeedDown = (TextView) transferRatesContent.findViewById(R.id.maxspeeddown_text);
@ -59,14 +63,14 @@ public class SetTransferRatesDialog extends DialogFragment { @@ -59,14 +63,14 @@ public class SetTransferRatesDialog extends DialogFragment {
} catch (NumberFormatException e) {
}
if (maxDown <= 0 || maxUp <= 0) {
onRatesPicked.onInvalidNumber();
onRatesPickedListener.onInvalidNumber();
}
onRatesPicked.onRatesPicked(maxDown, maxUp);
onRatesPickedListener.onRatesPicked(maxDown, maxUp);
}
}).setNeutralButton(R.string.status_maxspeed_reset, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onRatesPicked.resetRates();
onRatesPickedListener.resetRates();
}
}).setNegativeButton(android.R.string.cancel, null).create();
}
@ -96,7 +100,9 @@ public class SetTransferRatesDialog extends DialogFragment { @@ -96,7 +100,9 @@ public class SetTransferRatesDialog extends DialogFragment {
*/
public interface OnRatesPickedListener {
public void onRatesPicked(int maxDownloadSpeed, int maxUploadSpeed);
public void resetRates();
public void onInvalidNumber();
}

Loading…
Cancel
Save