Browse Source

Added option to change a torrent's storage location from the details screen. Fixed #8.

pull/13/merge
Eric Kok 11 years ago
parent
commit
6b928e4ca4
  1. BIN
      core/res/drawable-hdpi/ic_action_save_dark.png
  2. BIN
      core/res/drawable-hdpi/ic_action_save_light.png
  3. BIN
      core/res/drawable-mdpi/ic_action_save_dark.png
  4. BIN
      core/res/drawable-mdpi/ic_action_save_light.png
  5. BIN
      core/res/drawable-xhdpi/ic_action_save_dark.png
  6. BIN
      core/res/drawable-xhdpi/ic_action_save_light.png
  7. BIN
      core/res/drawable-xxhdpi/ic_action_save_dark.png
  8. BIN
      core/res/drawable-xxhdpi/ic_action_save_light.png
  9. 29
      core/res/layout/dialog_storagelocation.xml
  10. 6
      core/res/menu/fragment_details.xml
  11. 1
      core/res/values/attrs.xml
  12. 1
      core/res/values/changelog.xml
  13. 2
      core/res/values/strings.xml
  14. 2
      core/res/values/styles.xml
  15. 24
      core/src/org/transdroid/core/gui/DetailsFragment.java
  16. 92
      core/src/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java

BIN
core/res/drawable-hdpi/ic_action_save_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

BIN
core/res/drawable-hdpi/ic_action_save_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

BIN
core/res/drawable-mdpi/ic_action_save_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

BIN
core/res/drawable-mdpi/ic_action_save_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

BIN
core/res/drawable-xhdpi/ic_action_save_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

BIN
core/res/drawable-xhdpi/ic_action_save_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

BIN
core/res/drawable-xxhdpi/ic_action_save_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

BIN
core/res/drawable-xxhdpi/ic_action_save_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

29
core/res/layout/dialog_storagelocation.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2013 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/margin_half" >
<EditText
android:id="@+id/location_edit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textUri" />
</FrameLayout>

6
core/res/menu/fragment_details.xml

@ -68,5 +68,11 @@
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_updatetrackers" android:title="@string/action_updatetrackers"
android:orderInCategory="206" /> android:orderInCategory="206" />
<item
android:id="@+id/action_changelocation"
android:icon="?attr/ic_action_save"
android:showAsAction="ifRoom"
android:title="@string/action_changelocation"
android:orderInCategory="207" />
</menu> </menu>

1
core/res/values/attrs.xml

@ -35,6 +35,7 @@
<attr name="ic_action_remove" format="reference"/> <attr name="ic_action_remove" format="reference"/>
<attr name="ic_action_resume" format="reference"/> <attr name="ic_action_resume" format="reference"/>
<attr name="ic_action_rss" format="reference"/> <attr name="ic_action_rss" format="reference"/>
<attr name="ic_action_save" format="reference"/>
<attr name="ic_action_search" format="reference"/> <attr name="ic_action_search" format="reference"/>
<attr name="ic_action_sort_by_size" format="reference"/> <attr name="ic_action_sort_by_size" format="reference"/>
<attr name="ic_action_start" format="reference"/> <attr name="ic_action_start" format="reference"/>

1
core/res/values/changelog.xml

@ -18,6 +18,7 @@
<resources> <resources>
<string name="system_changelog"> <string name="system_changelog">
Transdroid 2.0.0\n Transdroid 2.0.0\n
- Allow changing of storage location (Deluge and Transmission)\n
- UI improvements for Lite version\n - UI improvements for Lite version\n
\n \n
Transdroid 2.0.0-alpha4\n Transdroid 2.0.0-alpha4\n

2
core/res/values/strings.xml

@ -48,6 +48,7 @@
<string name="action_remove_withdata">Remove and delete data</string> <string name="action_remove_withdata">Remove and delete data</string>
<string name="action_setlabel">Set label</string> <string name="action_setlabel">Set label</string>
<string name="action_updatetrackers">Update trackers</string> <string name="action_updatetrackers">Update trackers</string>
<string name="action_changelocation">Change storage location</string>
<string name="action_priority_off">Off</string> <string name="action_priority_off">Off</string>
<string name="action_priority_low">Low</string> <string name="action_priority_low">Low</string>
<string name="action_priority_normal">Normal</string> <string name="action_priority_normal">Normal</string>
@ -354,6 +355,7 @@
<string name="error_cant_write_settings_file">Can\'t write to the settings file</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> <string name="error_notanumber">Please enter a positive number</string>
<string name="error_notalabel">Please enter a valid label or pick from the list</string> <string name="error_notalabel">Please enter a valid label or pick from the list</string>
<string name="error_stillloadingdetails">Please wait until the torrent details have been loaded</string>
<string name="update_app_newversion">New Transdroid version available</string> <string name="update_app_newversion">New Transdroid version available</string>
<string name="update_search_newversion">New Transdroid search module available</string> <string name="update_search_newversion">New Transdroid search module available</string>

2
core/res/values/styles.xml

@ -34,6 +34,7 @@
<item name="ic_action_remove">@drawable/ic_action_remove_light</item> <item name="ic_action_remove">@drawable/ic_action_remove_light</item>
<item name="ic_action_resume">@drawable/ic_action_resume_light</item> <item name="ic_action_resume">@drawable/ic_action_resume_light</item>
<item name="ic_action_rss">@drawable/ic_action_rss_light</item> <item name="ic_action_rss">@drawable/ic_action_rss_light</item>
<item name="ic_action_save">@drawable/ic_action_save_light</item>
<item name="ic_action_search">@drawable/ic_action_search_light</item> <item name="ic_action_search">@drawable/ic_action_search_light</item>
<item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_light</item> <item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_light</item>
<item name="ic_action_start">@drawable/ic_action_start_light</item> <item name="ic_action_start">@drawable/ic_action_start_light</item>
@ -64,6 +65,7 @@
<item name="ic_action_remove">@drawable/ic_action_remove_dark</item> <item name="ic_action_remove">@drawable/ic_action_remove_dark</item>
<item name="ic_action_resume">@drawable/ic_action_resume_dark</item> <item name="ic_action_resume">@drawable/ic_action_resume_dark</item>
<item name="ic_action_rss">@drawable/ic_action_rss_dark</item> <item name="ic_action_rss">@drawable/ic_action_rss_dark</item>
<item name="ic_action_save">@drawable/ic_action_save_dark</item>
<item name="ic_action_search">@drawable/ic_action_search_dark</item> <item name="ic_action_search">@drawable/ic_action_search_dark</item>
<item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_dark</item> <item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_dark</item>
<item name="ic_action_start">@drawable/ic_action_start_dark</item> <item name="ic_action_start">@drawable/ic_action_start_dark</item>

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

@ -36,6 +36,8 @@ import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.navigation.SetLabelDialog; import org.transdroid.core.gui.navigation.SetLabelDialog;
import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener; import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener;
import org.transdroid.core.gui.navigation.SetStorageLocationDialog;
import org.transdroid.core.gui.navigation.SetStorageLocationDialog.OnStorageLocationUpdatedListener;
import org.transdroid.core.gui.navigation.SetTrackersDialog; import org.transdroid.core.gui.navigation.SetTrackersDialog;
import org.transdroid.core.gui.navigation.SetTrackersDialog.OnTrackersUpdatedListener; import org.transdroid.core.gui.navigation.SetTrackersDialog.OnTrackersUpdatedListener;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Daemon;
@ -65,7 +67,8 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/ */
@EFragment(resName = "fragment_details") @EFragment(resName = "fragment_details")
@OptionsMenu(resName = "fragment_details") @OptionsMenu(resName = "fragment_details")
public class DetailsFragment extends SherlockFragment implements OnTrackersUpdatedListener, OnLabelPickedListener { public class DetailsFragment extends SherlockFragment implements OnTrackersUpdatedListener, OnLabelPickedListener,
OnStorageLocationUpdatedListener {
// Local data // Local data
@InstanceState @InstanceState
@ -187,7 +190,7 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
* @param currentLabels The list of known server labels * @param currentLabels The list of known server labels
*/ */
public void updateLabels(ArrayList<Label> currentLabels) { public void updateLabels(ArrayList<Label> currentLabels) {
this.currentLabels = currentLabels == null? null: new ArrayList<Label>(currentLabels); this.currentLabels = currentLabels == null ? null : new ArrayList<Label>(currentLabels);
} }
/** /**
@ -241,6 +244,8 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
menu.findItem(R.id.action_setlabel).setVisible(setLabel); menu.findItem(R.id.action_setlabel).setVisible(setLabel);
boolean setTrackers = Daemon.supportsSetTrackers(torrent.getDaemon()); boolean setTrackers = Daemon.supportsSetTrackers(torrent.getDaemon());
menu.findItem(R.id.action_updatetrackers).setVisible(setTrackers); menu.findItem(R.id.action_updatetrackers).setVisible(setTrackers);
boolean setLocation = Daemon.supportsSetDownloadLocation(torrent.getDaemon());
menu.findItem(R.id.action_changelocation).setVisible(setLocation);
} }
@ -287,10 +292,20 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
@OptionsItem(resName = "action_updatetrackers") @OptionsItem(resName = "action_updatetrackers")
protected void updateTrackers() { protected void updateTrackers() {
if (torrentDetails == null) {
Crouton.showText(getActivity(), R.string.error_stillloadingdetails, NavigationHelper.CROUTON_INFO_STYLE);
return;
}
new SetTrackersDialog().setOnTrackersUpdated(this).setCurrentTrackers(torrentDetails.getTrackersText()) new SetTrackersDialog().setOnTrackersUpdated(this).setCurrentTrackers(torrentDetails.getTrackersText())
.show(getFragmentManager(), "SetTrackersDialog"); .show(getFragmentManager(), "SetTrackersDialog");
} }
@OptionsItem(resName = "action_changelocation")
protected void changeStorageLocation() {
new SetStorageLocationDialog().setOnStorageLocationUpdated(this).setCurrentLocation(torrent.getLocationDir())
.show(getFragmentManager(), "SetStorageLocationDialog");
}
@Override @Override
public void onLabelPicked(String newLabel) { public void onLabelPicked(String newLabel) {
getTasksExecutor().updateLabel(torrent, newLabel); getTasksExecutor().updateLabel(torrent, newLabel);
@ -301,6 +316,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
getTasksExecutor().updateTrackers(torrent, updatedTrackers); getTasksExecutor().updateTrackers(torrent, updatedTrackers);
} }
@Override
public void onStorageLocationUpdated(String newLocation) {
getTasksExecutor().updateLocation(torrent, newLocation);
}
private MultiChoiceModeListenerCompat onDetailsSelected = new MultiChoiceModeListenerCompat() { private MultiChoiceModeListenerCompat onDetailsSelected = new MultiChoiceModeListenerCompat() {
SelectionManagerMode selectionManagerMode; SelectionManagerMode selectionManagerMode;

92
core/src/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java

@ -0,0 +1,92 @@
/*
* Copyright 2010-2013 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.navigation;
import java.security.InvalidParameterException;
import org.transdroid.core.R;
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.EditText;
/**
* A dialog fragment that allows changing of the storage location by editing the path text directly.
* @author Eric Kok
*/
public class SetStorageLocationDialog extends DialogFragment {
private OnStorageLocationUpdatedListener onStorageLocationUpdatedListener = null;
private String currentLocation = null;
public SetStorageLocationDialog() {
setRetainInstance(true);
}
/**
* Sets the callback for when the user is done updating the storage location.
* @param onStorageLocationUpdatedListener The event listener to this dialog
* @return This dialog, for method chaining
*/
public SetStorageLocationDialog setOnStorageLocationUpdated(
OnStorageLocationUpdatedListener onStorageLocationUpdatedListener) {
this.onStorageLocationUpdatedListener = onStorageLocationUpdatedListener;
return this;
}
/**
* Sets the current storage location that will be available to the user to edit
* @param currentLocation The current storage location path as text
* @return This dialog, for method chaining
*/
public SetStorageLocationDialog setCurrentLocation(String currentLocation) {
this.currentLocation = currentLocation;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (currentLocation == null)
throw new InvalidParameterException(
"Please first set the current trackers text using setCurrentLocation before opening the dialog.");
if (onStorageLocationUpdatedListener == null)
throw new InvalidParameterException(
"Please first set the callback listener using setOnStorageLocationUpdated before opening the dialog.");
final View locationFrame = getActivity().getLayoutInflater().inflate(R.layout.dialog_storagelocation, null,
false);
final EditText locationText = (EditText) locationFrame.findViewById(R.id.location_edit);
locationText.setText(currentLocation);
return new AlertDialog.Builder(getActivity()).setView(locationFrame)
.setPositiveButton(R.string.status_update, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// User is done editing and requested to update given the text input
onStorageLocationUpdatedListener.onStorageLocationUpdated(locationText.getText().toString());
}
}).setNegativeButton(android.R.string.cancel, null).show();
}
public interface OnStorageLocationUpdatedListener {
public void onStorageLocationUpdated(String newLocation);
}
}
Loading…
Cancel
Save