1
0
mirror of https://github.com/danog/termux-api.git synced 2024-11-30 04:19:20 +01:00

Do not trim input when setting clipboard content

See #195.
This commit is contained in:
Fredrik Fornwall 2018-08-28 02:59:57 +02:00
parent 6b7b98179b
commit 75c48ad6d5
2 changed files with 12 additions and 2 deletions

View File

@ -24,7 +24,12 @@ public class ClipboardAPI {
if (set) {
ResultReturner.returnData(apiReceiver, intent, new ResultReturner.WithStringInput() {
@Override
public void writeResult(PrintWriter out) throws Exception {
protected boolean trimInput() {
return false;
}
@Override
public void writeResult(PrintWriter out) {
clipboard.setPrimaryClip(ClipData.newPlainText("", inputString));
}
});

View File

@ -49,6 +49,10 @@ public abstract class ResultReturner {
public static abstract class WithStringInput extends WithInput {
protected String inputString;
protected boolean trimInput() {
return true;
}
@Override
public final void setInput(InputStream inputStream) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -57,7 +61,8 @@ public abstract class ResultReturner {
while ((l = inputStream.read(buffer)) > 0) {
baos.write(buffer, 0, l);
}
inputString = new String(baos.toByteArray(), StandardCharsets.UTF_8).trim();
inputString = new String(baos.toByteArray(), StandardCharsets.UTF_8);
if (trimInput()) inputString = inputString.trim();
}
}