mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Housekeeping around androidselect.c
* java/org/gnu/emacs/EmacsClipboard.java (setClipboard) (getClipboard): * java/org/gnu/emacs/EmacsSdk11Clipboard.java (setClipboard) (getClipboard): * java/org/gnu/emacs/EmacsSdk8Clipboard.java (setClipboard) (getClipboard): Save and return Strings rather than byte arrays. * src/androidselect.c (android_init_emacs_clipboard) (Fandroid_set_clipboard, Fandroid_get_clipboard): Adjust to match.
This commit is contained in:
parent
5ec4c1a7d3
commit
8dc00dc222
4 changed files with 48 additions and 86 deletions
|
|
@ -27,10 +27,10 @@ import android.os.Build;
|
|||
|
||||
public abstract class EmacsClipboard
|
||||
{
|
||||
public abstract void setClipboard (byte[] bytes);
|
||||
public abstract void setClipboard (String string);
|
||||
public abstract int ownsClipboard ();
|
||||
public abstract boolean clipboardExists ();
|
||||
public abstract byte[] getClipboard ();
|
||||
public abstract String getClipboard ();
|
||||
|
||||
public abstract String[] getClipboardTargets ();
|
||||
public abstract AssetFileDescriptor getClipboardData (String target);
|
||||
|
|
|
|||
|
|
@ -86,32 +86,23 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
|
|||
}
|
||||
}
|
||||
|
||||
/* Set the clipboard text to CLIPBOARD, a string in UTF-8
|
||||
encoding. */
|
||||
/* Save the STRING into the clipboard by way of text copied by the
|
||||
user. */
|
||||
|
||||
@Override
|
||||
public synchronized void
|
||||
setClipboard (byte[] bytes)
|
||||
setClipboard (String string)
|
||||
{
|
||||
ClipData data;
|
||||
String string;
|
||||
|
||||
try
|
||||
{
|
||||
string = new String (bytes, "UTF-8");
|
||||
data = ClipData.newPlainText ("Emacs", string);
|
||||
manager.setPrimaryClip (data);
|
||||
ownsClipboard = true;
|
||||
data = ClipData.newPlainText ("Emacs", string);
|
||||
manager.setPrimaryClip (data);
|
||||
ownsClipboard = true;
|
||||
|
||||
/* onPrimaryClipChanged will be called again. Use this
|
||||
variable to keep track of how many times the clipboard has
|
||||
been changed. */
|
||||
++clipboardChangedCount;
|
||||
}
|
||||
catch (UnsupportedEncodingException exception)
|
||||
{
|
||||
Log.w (TAG, "setClipboard: " + exception);
|
||||
}
|
||||
/* onPrimaryClipChanged will be called again. Use this
|
||||
variable to keep track of how many times the clipboard has
|
||||
been changed. */
|
||||
++clipboardChangedCount;
|
||||
}
|
||||
|
||||
/* Return whether or not Emacs owns the clipboard. Value is 1 if
|
||||
|
|
@ -141,7 +132,7 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
|
|||
NULL if no content is available. */
|
||||
|
||||
@Override
|
||||
public byte[]
|
||||
public String
|
||||
getClipboard ()
|
||||
{
|
||||
ClipData clip;
|
||||
|
|
@ -154,18 +145,8 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
|
|||
return null;
|
||||
|
||||
context = EmacsService.SERVICE;
|
||||
|
||||
try
|
||||
{
|
||||
text = clip.getItemAt (0).coerceToText (context);
|
||||
return text.toString ().getBytes ("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException exception)
|
||||
{
|
||||
Log.w (TAG, "getClipboard: " + exception);
|
||||
}
|
||||
|
||||
return null;
|
||||
text = clip.getItemAt (0).coerceToText (context);
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
/* Return an array of targets currently provided by the
|
||||
|
|
|
|||
|
|
@ -52,21 +52,14 @@ public final class EmacsSdk8Clipboard extends EmacsClipboard
|
|||
= (ClipboardManager) context.getSystemService (what);
|
||||
}
|
||||
|
||||
/* Set the clipboard text to CLIPBOARD, a string in UTF-8
|
||||
encoding. */
|
||||
/* Save the STRING into the clipboard by way of text copied by the
|
||||
user. */
|
||||
|
||||
@Override
|
||||
public void
|
||||
setClipboard (byte[] bytes)
|
||||
setClipboard (String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
manager.setText (new String (bytes, "UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException exception)
|
||||
{
|
||||
Log.w (TAG, "setClipboard: " + exception);
|
||||
}
|
||||
manager.setText (string);
|
||||
}
|
||||
|
||||
/* Return whether or not Emacs owns the clipboard. Value is 1 if
|
||||
|
|
@ -93,7 +86,7 @@ public final class EmacsSdk8Clipboard extends EmacsClipboard
|
|||
NULL if no content is available. */
|
||||
|
||||
@Override
|
||||
public byte[]
|
||||
public String
|
||||
getClipboard ()
|
||||
{
|
||||
String string;
|
||||
|
|
@ -105,17 +98,7 @@ public final class EmacsSdk8Clipboard extends EmacsClipboard
|
|||
return null;
|
||||
|
||||
string = text.toString ();
|
||||
|
||||
try
|
||||
{
|
||||
return string.getBytes ("UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException exception)
|
||||
{
|
||||
Log.w (TAG, "getClipboard: " + exception);
|
||||
}
|
||||
|
||||
return null;
|
||||
return string;
|
||||
}
|
||||
|
||||
/* Return an array of targets currently provided by the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue