├── .gitignore
├── LICENSE
├── README.md
├── default.properties
├── pom.xml
└── src
└── main
├── .DS_Store
├── AndroidManifest.xml
├── java
└── ca
│ └── zgrs
│ └── clipper
│ ├── ClipboardService.java
│ ├── ClipperReceiver.java
│ └── Main.java
└── res
├── drawable-hdpi
└── icon.png
├── drawable-ldpi
└── icon.png
├── drawable-mdpi
└── icon.png
├── layout
└── main.xml
└── values
└── strings.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2012 Majid Valipour
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Clipper
2 | Simple app to interact with Android system clipboard service via adb shell one liners.
3 |
4 | # Installation
5 | Download the [application apk](https://github.com/majido/clipper/releases/download/v1.2.1/clipper.apk) and manually install application on your android device.
6 |
7 | # Usage
8 | Assuming you have already installed the app, connect to your emulator or phone using adb shell.
9 | First start the service. You can do this either by opening the application or using the following commands on ADB shell
10 | $ adb shell
11 | # am startservice ca.zgrs.clipper/.ClipboardService
12 |
13 |
14 | Once service is started you can invoke clipper service by broadcasting intents.
15 | The intent's *Action* can be either "get" or "set". When setting the clipboard value, pass your string as an *Extra* parameter.
16 |
17 | * Supported actions
18 | 1. **get**: print the value in clipboard into logs (TODO: print the value on standard output)
19 | 2. **set**: sets the clipboard content to the string passed via extra parameter "text"
20 | * Supported extras
21 | 1. **text**: The text that you want to be copied in the clipboard
22 |
23 | Usage example using broadcast intent:
24 |
25 | # am broadcast -a clipper.set -e text "this can be pasted now"
26 | # am broadcast -a clipper.get
27 |
28 | # Building
29 | Build using maven
30 |
31 | 1. update pom.xml and set ANDROID_HOME in enviroment.
32 | 2. build: `mvn package`
33 | 3. deploy: `mvn android:deploy`
34 |
35 |
--------------------------------------------------------------------------------
/default.properties:
--------------------------------------------------------------------------------
1 | # File used by Eclipse to determine the target system
2 | # Project target.
3 | target=android-10
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | ca.zgrs.clipper
6 | clipboard-service
7 | 1.2
8 | apk
9 | clipboard-service
10 |
11 |
12 | 2.3.3
13 | 10
14 | ${env.ANDROID_HOME}
15 |
16 |
17 |
18 |
19 | com.google.android
20 | android
21 | ${platform.version}
22 | provided
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | com.simpligility.maven.plugins
31 | android-maven-plugin
32 | 4.0.0
33 | true
34 |
35 |
36 |
37 |
38 |
39 | com.simpligility.maven.plugins
40 | android-maven-plugin
41 |
42 |
43 | ${android.sdk.version}
44 |
45 | true
46 |
47 | true
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/majido/clipper/628b06b2e1bf4f36701d86f3ef14ca8927fb5612/src/main/.DS_Store
--------------------------------------------------------------------------------
/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/main/java/ca/zgrs/clipper/ClipboardService.java:
--------------------------------------------------------------------------------
1 | package ca.zgrs.clipper;
2 |
3 | import android.app.IntentService;
4 | import android.content.Intent;
5 |
6 | import android.util.Log;
7 |
8 | public class ClipboardService extends IntentService {
9 | private static String TAG = "ClipboardService";
10 |
11 | public ClipboardService() {
12 | super("ClipboardService");
13 | }
14 |
15 | /* Define service as sticky so that it stays in background */
16 | @Override
17 | public int onStartCommand(Intent intent, int flags, int startId) {
18 | super.onStartCommand(intent, flags, startId);
19 | return START_STICKY;
20 | }
21 |
22 | @Override
23 | public void onCreate() {
24 | super.onCreate();
25 | // start itself to ensure our broadcast receiver is active
26 | Log.d(TAG, "Start clipboard service.");
27 | startService(new Intent(getApplicationContext(), ClipboardService.class));
28 | }
29 |
30 | /**
31 | * The IntentService calls this method from the default worker thread with
32 | * the intent that started the service. When this method returns, IntentService
33 | * stops the service, as appropriate.
34 | */
35 | @Override
36 | protected void onHandleIntent(Intent intent) {
37 | }
38 | }
--------------------------------------------------------------------------------
/src/main/java/ca/zgrs/clipper/ClipperReceiver.java:
--------------------------------------------------------------------------------
1 | package ca.zgrs.clipper;
2 |
3 | import android.app.Activity;
4 | import android.text.ClipboardManager;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.BroadcastReceiver;
8 |
9 | import android.util.Log;
10 |
11 | /*
12 | * Receives broadcast commands and controls clipboard accordingly.
13 | * The broadcast receiver is active only as long as the application, or its service is active.
14 | */
15 | public class ClipperReceiver extends BroadcastReceiver {
16 | private static String TAG = "ClipboardReceiver";
17 |
18 | public static String ACTION_GET = "clipper.get";
19 | public static String ACTION_GET_SHORT = "get";
20 | public static String ACTION_SET = "clipper.set";
21 | public static String ACTION_SET_SHORT = "set";
22 | public static String EXTRA_TEXT = "text";
23 |
24 | public static boolean isActionGet(final String action) {
25 | return ACTION_GET.equals(action) || ACTION_GET_SHORT.equals(action);
26 | }
27 |
28 | public static boolean isActionSet(final String action) {
29 | return ACTION_SET.equals(action) || ACTION_SET_SHORT.equals(action);
30 | }
31 |
32 | @Override
33 | public void onReceive(Context context, Intent intent) {
34 | ClipboardManager cb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
35 | if (isActionSet(intent.getAction())) {
36 | Log.d(TAG, "Setting text into clipboard");
37 | String text = intent.getStringExtra(EXTRA_TEXT);
38 | if (text != null) {
39 | cb.setText(text);
40 | setResultCode(Activity.RESULT_OK);
41 | setResultData("Text is copied into clipboard.");
42 | } else {
43 | setResultCode(Activity.RESULT_CANCELED);
44 | setResultData("No text is provided. Use -e text \"text to be pasted\"");
45 | }
46 | } else if (isActionGet(intent.getAction())) {
47 | Log.d(TAG, "Getting text from clipboard");
48 | CharSequence clip = cb.getText();
49 | if (clip != null) {
50 | Log.d(TAG, String.format("Clipboard text: %s", clip));
51 | setResultCode(Activity.RESULT_OK);
52 | setResultData(clip.toString());
53 | } else {
54 | setResultCode(Activity.RESULT_CANCELED);
55 | setResultData("");
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/main/java/ca/zgrs/clipper/Main.java:
--------------------------------------------------------------------------------
1 | package ca.zgrs.clipper;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 |
8 | public class Main extends Activity {
9 | @Override
10 | public void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 |
13 | setContentView(R.layout.main);
14 |
15 | // start clipboard service
16 | Intent serviceIntent = new Intent(this, ClipboardService.class);
17 | startService(serviceIntent);
18 | }
19 | }
--------------------------------------------------------------------------------
/src/main/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/majido/clipper/628b06b2e1bf4f36701d86f3ef14ca8927fb5612/src/main/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/src/main/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/majido/clipper/628b06b2e1bf4f36701d86f3ef14ca8927fb5612/src/main/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/src/main/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/majido/clipper/628b06b2e1bf4f36701d86f3ef14ca8927fb5612/src/main/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/src/main/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
18 |
19 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Clipper service is started.
4 |
5 | You can now copy to or paste from clipboard using the
6 | following commands in adb shell:\n \n
7 | 1. am broadcast -a clipper.set -e text \'This may be pasted now\' \n
8 | 2. am broadcast -a clipper.get
9 |
10 | Clipper
11 |
12 |
--------------------------------------------------------------------------------