This source file includes following definitions.
- setClipboard
- ownsClipboard
- clipboardExists
- getClipboard
- getClipboardTargets
- getClipboardData
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.gnu.emacs;
21
22
23
24
25 import android.text.*;
26
27 import android.content.Context;
28 import android.util.Log;
29
30 import java.io.UnsupportedEncodingException;
31
32
33
34
35 @SuppressWarnings ("deprecation")
36 public final class EmacsSdk8Clipboard extends EmacsClipboard
37 {
38 private static final String TAG = "EmacsSdk8Clipboard";
39 private ClipboardManager manager;
40
41 public
42 EmacsSdk8Clipboard ()
43 {
44 String what;
45 Context context;
46
47 what = Context.CLIPBOARD_SERVICE;
48 context = EmacsService.SERVICE;
49 manager
50 = (ClipboardManager) context.getSystemService (what);
51 }
52
53
54
55
56 @Override
57 public void
58 setClipboard (byte[] bytes)
59 {
60 try
61 {
62 manager.setText (new String (bytes, "UTF-8"));
63 }
64 catch (UnsupportedEncodingException exception)
65 {
66 Log.w (TAG, "setClipboard: " + exception);
67 }
68 }
69
70
71
72
73
74 @Override
75 public int
76 ownsClipboard ()
77 {
78 return -1;
79 }
80
81
82
83 @Override
84 public boolean
85 clipboardExists ()
86 {
87 return manager.hasText ();
88 }
89
90
91
92
93 @Override
94 public byte[]
95 getClipboard ()
96 {
97 String string;
98 CharSequence text;
99
100 text = manager.getText ();
101
102 if (text == null)
103 return null;
104
105 string = text.toString ();
106
107 try
108 {
109 return string.getBytes ("UTF-8");
110 }
111 catch (UnsupportedEncodingException exception)
112 {
113 Log.w (TAG, "getClipboard: " + exception);
114 }
115
116 return null;
117 }
118
119
120
121
122 @Override
123 public byte[][]
124 getClipboardTargets ()
125 {
126 return null;
127 }
128
129
130
131
132
133
134
135
136
137
138
139
140
141 @Override
142 public long[]
143 getClipboardData (byte[] target)
144 {
145 return null;
146 }
147 };