|
| 1 | +# ClipboardManager plugin for Phonegap # |
| 2 | +By Omer Saatcioglu |
| 3 | + |
| 4 | +## Adding the Plugin to your project ## |
| 5 | +1. To install the plugin, move clipboardmanager.js to your project's www folder and include a reference to it in your html files. |
| 6 | +2. Create a folder called 'src/com/saatcioglu/phonegap/clipboardmanager' within your project's src folder. |
| 7 | +3. And copy ContextHolder.java and ClipboardManagerPlugin.java into that new folder. |
| 8 | + |
| 9 | +`mkdir <your_project>/src/com/saatcioglu/phonegap/clipboardmanager` |
| 10 | +`cp ./ClipboardManagerPlugin.java <your_project>/src/com/beetight/barcodescanner` |
| 11 | +`cp ./ContextHolder.java <your_project>/src/com/beetight/barcodescanner` |
| 12 | + |
| 13 | +## Using the plugin ## |
| 14 | +Before using the plugin, we need to at the following line of code before calling the `loadUrl` method in the main activity to let the |
| 15 | +ClipboardManagerPlugin use the context of the main activity. Otherwise, it wouldn't be able to reach to the Clipboard Service |
| 16 | + |
| 17 | + ContextHolder.set(this); |
| 18 | + |
| 19 | +The plugin creates the object `window.plugins.clipboardManager` with the methods |
| 20 | + |
| 21 | +`copy(str, success, fail)` that copies the given string |
| 22 | +`paste(success, fail)` that returns the text from the Clipboard |
| 23 | + |
| 24 | +`success` and `fail` are callback functions. |
| 25 | + |
| 26 | +An example for copy: |
| 27 | + |
| 28 | + window.plugins.clipboardManager.copy( |
| 29 | + "the text to copy", |
| 30 | + function(r){alert("copy is successful")}, |
| 31 | + function(e){alert(e)} |
| 32 | + ); |
| 33 | + |
| 34 | +An example for paste: |
| 35 | + |
| 36 | + window.plugins.clipboardManager.paste( |
| 37 | + function(r){alert("The text in the clipboard is " + r)}, |
| 38 | + function(e){alert(e)} |
| 39 | + ); |
| 40 | + |
| 41 | + |
| 42 | +## BUGS AND CONTRIBUTIONS ## |
| 43 | +The latest version is available [at GitHub](https://github.com/osaatcioglu/phonegap-plugins/tree/master/Android) |
| 44 | +If you have a patch, fork my repo baby and send me a pull request. Submit bug reports on GitHub, please. |
| 45 | + |
| 46 | +## Licence ## |
| 47 | +The MIT License |
| 48 | + |
| 49 | +Copyright (c) 2010 Matt Kane |
| 50 | + |
| 51 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 52 | +of this software and associated documentation files (the "Software"), to deal |
| 53 | +in the Software without restriction, including without limitation the rights |
| 54 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 55 | +copies of the Software, and to permit persons to whom the Software is |
| 56 | +furnished to do so, subject to the following conditions: |
| 57 | + |
| 58 | +The above copyright notice and this permission notice shall be included in |
| 59 | +all copies or substantial portions of the Software. |
| 60 | + |
| 61 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 62 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 63 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 64 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 65 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 66 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 67 | +THE SOFTWARE. |
0 commit comments