mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
@@ -722,7 +722,18 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
if (session != null) {
|
if (session != null) {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, session.getEmulator().getScreen().getTranscriptText().trim());
|
String transcriptText = session.getEmulator().getScreen().getTranscriptText().trim();
|
||||||
|
// See https://github.com/termux/termux-app/issues/1166.
|
||||||
|
final int MAX_LENGTH = 100_000;
|
||||||
|
if (transcriptText.length() > MAX_LENGTH) {
|
||||||
|
int cutOffIndex = transcriptText.length() - MAX_LENGTH;
|
||||||
|
int nextNewlineIndex = transcriptText.indexOf('\n', cutOffIndex);
|
||||||
|
if (nextNewlineIndex != -1 && nextNewlineIndex != transcriptText.length() - 1) {
|
||||||
|
cutOffIndex = nextNewlineIndex + 1;
|
||||||
|
}
|
||||||
|
transcriptText = transcriptText.substring(cutOffIndex).trim();
|
||||||
|
}
|
||||||
|
intent.putExtra(Intent.EXTRA_TEXT, transcriptText);
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_transcript_title));
|
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_transcript_title));
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.share_transcript_chooser_title)));
|
startActivity(Intent.createChooser(intent, getString(R.string.share_transcript_chooser_title)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user