mirror of
https://github.com/danog/termux-api.git
synced 2024-11-30 04:19:20 +01:00
parent
6b7b98179b
commit
75c48ad6d5
@ -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));
|
||||
}
|
||||
});
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user