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. 15
      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 @@
--> -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.transdroid.core" package="org.transdroid.core"
android:versionCode="214" android:versionCode="215"
android:versionName="2.2.0" > android:versionName="2.2.0" >
<uses-sdk <uses-sdk

4
core/res/menu/fragment_details_cab.xml

@ -40,5 +40,9 @@
android:id="@+id/action_download" android:id="@+id/action_download"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_download" /> android:title="@string/action_download" />
<item
android:id="@+id/action_copytoclipboard"
android:showAsAction="never"
android:title="@string/action_copytoclipboard" />
</menu> </menu>

15
core/res/menu/fragment_rssitems_cab.xml

@ -20,24 +20,25 @@
android:id="@+id/action_addall" android:id="@+id/action_addall"
android:icon="?attr/ic_action_new" android:icon="?attr/ic_action_new"
android:showAsAction="always" android:showAsAction="always"
android:title="@string/action_addall" /> android:title="@string/action_addall"/>
<item <item
android:id="@+id/action_showdetails" android:id="@+id/action_showdetails"
android:icon="?attr/ic_action_info" android:icon="?attr/ic_action_info"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_showdetails" /> android:title="@string/action_showdetails"/>
<item <item
android:id="@+id/action_openwebsite" android:id="@+id/action_openwebsite"
android:icon="?attr/ic_action_website" android:icon="?attr/ic_action_website"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_openwebsite" /> android:title="@string/action_openwebsite"/>
<item <item
android:id="@+id/action_useassearch" android:id="@+id/action_useassearch"
android:icon="?attr/ic_action_search" android:icon="?attr/ic_action_search"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_useassearch" /> android:title="@string/action_useassearch"/>
<item
android:id="@+id/action_copytoclipboard"
android:showAsAction="never"
android:title="@string/action_copytoclipboard"/>
</menu> </menu>

1
core/res/values/strings.xml

@ -61,6 +61,7 @@
<string name="action_priority_high">High</string> <string name="action_priority_high">High</string>
<string name="action_remoteplay">Remote play in VLC</string> <string name="action_remoteplay">Remote play in VLC</string>
<string name="action_download">Download using FTP(S)</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_showdetails">Show details</string>
<string name="action_openwebsite">Open website</string> <string name="action_openwebsite">Open website</string>
<string name="action_useassearch">Use as new search</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;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Fragment; import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.view.ActionMode; import android.view.ActionMode;
@ -472,6 +475,20 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
mode.finish(); mode.finish();
return true; 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 { } else {
Priority priority = Priority.Off; Priority priority = Priority.Off;
if (itemId == R.id.action_priority_low) 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;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.app.Fragment; import android.app.Fragment;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -146,6 +149,7 @@ public class RssitemsFragment extends Fragment {
int itemId = item.getItemId(); int itemId = item.getItemId();
if (itemId == R.id.action_addall) { if (itemId == R.id.action_addall) {
// Start an Intent that adds multiple items at once, by supplying the urls and titles as string array // 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 // extras and setting the Intent action to ADD_MULTIPLE
Intent intent = new Intent("org.transdroid.ADD_MULTIPLE"); Intent intent = new Intent("org.transdroid.ADD_MULTIPLE");
@ -160,7 +164,23 @@ public class RssitemsFragment extends Fragment {
startActivity(intent); startActivity(intent);
mode.finish(); mode.finish();
return true; 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 { } else {
// The other items only operate on one (the first) selected item // The other items only operate on one (the first) selected item
if (checked.size() < 1) if (checked.size() < 1)
return false; return false;
@ -190,7 +210,9 @@ public class RssitemsFragment extends Fragment {
search.putExtra(SearchManager.QUERY, first.getTitle()); search.putExtra(SearchManager.QUERY, first.getTitle());
startActivity(search); startActivity(search);
} }
return false; mode.finish();
return true;
} }
} }

2
full/AndroidManifest.xml

@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="org.transdroid.full" package="org.transdroid.full"
android:versionCode="214" android:versionCode="215"
android:versionName="2.2.0" > android:versionName="2.2.0" >
<uses-sdk <uses-sdk

2
lite/AndroidManifest.xml

@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="org.transdroid.lite" package="org.transdroid.lite"
android:versionCode="214" android:versionCode="215"
android:versionName="2.2.0" > android:versionName="2.2.0" >
<uses-sdk <uses-sdk

Loading…
Cancel
Save