add copy button for jvm crash

This commit is contained in:
ShirosakiMio 2024-05-08 18:40:30 +08:00
parent 5dab4531a4
commit c959759509
2 changed files with 27 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import static com.tungsten.fclcore.util.Logging.LOG;
import static com.tungsten.fclcore.util.Pair.pair;
import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@ -11,6 +13,7 @@ import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ScrollView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
@ -27,6 +30,7 @@ import com.tungsten.fcllibrary.component.FCLActivity;
import com.tungsten.fcllibrary.component.view.FCLButton;
import com.tungsten.fcllibrary.component.view.FCLProgressBar;
import com.tungsten.fcllibrary.component.view.FCLTextView;
import com.tungsten.fcllibrary.crash.CrashReporter;
import java.io.File;
import java.io.IOException;
@ -51,6 +55,7 @@ public class JVMCrashActivity extends FCLActivity implements View.OnClickListene
private FCLButton restart;
private FCLButton close;
private FCLButton copy;
private FCLButton share;
private FCLTextView title;
@ -67,10 +72,12 @@ public class JVMCrashActivity extends FCLActivity implements View.OnClickListene
restart = findViewById(R.id.restart);
close = findViewById(R.id.close);
copy = findViewById(R.id.copy);
share = findViewById(R.id.share);
restart.setOnClickListener(this);
close.setOnClickListener(this);
copy.setOnClickListener(this);
share.setOnClickListener(this);
title = findViewById(R.id.title);
@ -257,6 +264,14 @@ public class JVMCrashActivity extends FCLActivity implements View.OnClickListene
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(10);
}
if (v == copy) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clipboard != null) {
ClipData clip = ClipData.newPlainText(null, error.getText().toString());
clipboard.setPrimaryClip(clip);
Toast.makeText(this, com.tungsten.fcllibrary.R.string.crash_reporter_toast, Toast.LENGTH_SHORT).show();
}
}
if (v == share) {
try {
Intent intent = new Intent(Intent.ACTION_SEND);

View File

@ -119,7 +119,18 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toTopOf="@+id/share"
app:layout_constraintBottom_toTopOf="@+id/copy"
app:layout_constraintStart_toEndOf="@+id/split"
app:layout_constraintEnd_toEndOf="parent"/>
<com.tungsten.fcllibrary.component.view.FCLButton
android:id="@+id/copy"
android:text="@string/crash_reporter_copy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toTopOf="@id/share"
app:layout_constraintStart_toEndOf="@+id/split"
app:layout_constraintEnd_toEndOf="parent"/>