Browse Source

Added copy to clipboard option for file names (from CAB) and RSS items (from CAB). Fixes #145 and (partially) fixes #126.

pull/173/head
Eric Kok 10 years ago
parent
commit
8b5ec92f0f
  1. 2
      core/AndroidManifest.xml
  2. 4
      core/res/menu/fragment_details_cab.xml
  3. 7
      core/res/menu/fragment_rssitems_cab.xml
  4. 1
      core/res/values/strings.xml
  5. 17
      core/src/org/transdroid/core/gui/DetailsFragment.java
  6. 24
      core/src/org/transdroid/core/gui/rss/RssitemsFragment.java
  7. 2
      full/AndroidManifest.xml
  8. 2
      lite/AndroidManifest.xml

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

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>

7
core/res/menu/fragment_rssitems_cab.xml

@ -21,23 +21,24 @@ @@ -21,23 +21,24 @@
android:icon="?attr/ic_action_new"
android:showAsAction="always"
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"/>
<item
android:id="@+id/action_openwebsite"
android:icon="?attr/ic_action_website"
android:showAsAction="ifRoom"
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"/>
<item
android:id="@+id/action_copytoclipboard"
android:showAsAction="never"
android:title="@string/action_copytoclipboard"/>
</menu>

1
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>

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;
@ -472,6 +475,20 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -472,6 +475,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)

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;
}
}

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