mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Pass error message to feedback activity
This commit is contained in:
@@ -72,7 +72,7 @@ public class HotspotErrorFragment extends BaseFragment {
|
|||||||
|
|
||||||
Button feedbackButton = v.findViewById(R.id.feedbackButton);
|
Button feedbackButton = v.findViewById(R.id.feedbackButton);
|
||||||
feedbackButton.setOnClickListener(
|
feedbackButton.setOnClickListener(
|
||||||
button -> triggerFeedback(requireContext()));
|
button -> triggerFeedback(requireContext(), errorMessage));
|
||||||
|
|
||||||
FallbackFragment fallbackFragment = new FallbackFragment();
|
FallbackFragment fallbackFragment = new FallbackFragment();
|
||||||
FragmentTransaction ta = getChildFragmentManager().beginTransaction();
|
FragmentTransaction ta = getChildFragmentManager().beginTransaction();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class BriarExceptionHandler implements UncaughtExceptionHandler {
|
|||||||
|
|
||||||
// activity runs in its own process, so we can kill the old one
|
// activity runs in its own process, so we can kill the old one
|
||||||
startDevReportActivity(app.getApplicationContext(),
|
startDevReportActivity(app.getApplicationContext(),
|
||||||
CrashReportActivity.class, e, appStartTime, logKey);
|
CrashReportActivity.class, e, appStartTime, logKey, null);
|
||||||
Process.killProcess(Process.myPid());
|
Process.killProcess(Process.myPid());
|
||||||
System.exit(10);
|
System.exit(10);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import static java.util.Objects.requireNonNull;
|
|||||||
public class CrashReportActivity extends BaseActivity
|
public class CrashReportActivity extends BaseActivity
|
||||||
implements BaseFragmentListener {
|
implements BaseFragmentListener {
|
||||||
|
|
||||||
|
public static final String EXTRA_INITIAL_COMMENT = "initialComment";
|
||||||
public static final String EXTRA_THROWABLE = "throwable";
|
public static final String EXTRA_THROWABLE = "throwable";
|
||||||
public static final String EXTRA_APP_START_TIME = "appStartTime";
|
public static final String EXTRA_APP_START_TIME = "appStartTime";
|
||||||
public static final String EXTRA_APP_LOGCAT = "logcat";
|
public static final String EXTRA_APP_LOGCAT = "logcat";
|
||||||
@@ -55,10 +56,11 @@ public class CrashReportActivity extends BaseActivity
|
|||||||
setContentView(R.layout.activity_dev_report);
|
setContentView(R.layout.activity_dev_report);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
String initialComment = intent.getStringExtra(EXTRA_INITIAL_COMMENT);
|
||||||
Throwable t = (Throwable) intent.getSerializableExtra(EXTRA_THROWABLE);
|
Throwable t = (Throwable) intent.getSerializableExtra(EXTRA_THROWABLE);
|
||||||
long appStartTime = intent.getLongExtra(EXTRA_APP_START_TIME, -1);
|
long appStartTime = intent.getLongExtra(EXTRA_APP_START_TIME, -1);
|
||||||
byte[] logKey = intent.getByteArrayExtra(EXTRA_APP_LOGCAT);
|
byte[] logKey = intent.getByteArrayExtra(EXTRA_APP_LOGCAT);
|
||||||
viewModel.init(t, appStartTime, logKey);
|
viewModel.init(t, appStartTime, logKey, initialComment);
|
||||||
viewModel.getShowReport().observeEvent(this, show -> {
|
viewModel.getShowReport().observeEvent(this, show -> {
|
||||||
if (show) displayFragment(true);
|
if (show) displayFragment(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ public class ReportFormFragment extends BaseFragment {
|
|||||||
list = v.findViewById(R.id.list);
|
list = v.findViewById(R.id.list);
|
||||||
progress = v.findViewById(R.id.progress_wheel);
|
progress = v.findViewById(R.id.progress_wheel);
|
||||||
|
|
||||||
|
if (viewModel.getInitialComment() != null)
|
||||||
|
userCommentView.setText(viewModel.getInitialComment());
|
||||||
|
|
||||||
if (viewModel.isFeedback()) {
|
if (viewModel.isFeedback()) {
|
||||||
includeDebugReport
|
includeDebugReport
|
||||||
.setText(getString(R.string.include_debug_report_feedback));
|
.setText(getString(R.string.include_debug_report_feedback));
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ class ReportViewModel extends AndroidViewModel {
|
|||||||
private final MutableLiveEvent<Integer> closeReport =
|
private final MutableLiveEvent<Integer> closeReport =
|
||||||
new MutableLiveEvent<>();
|
new MutableLiveEvent<>();
|
||||||
private boolean isFeedback;
|
private boolean isFeedback;
|
||||||
|
@Nullable
|
||||||
|
private String initialComment;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ReportViewModel(@NonNull Application application,
|
ReportViewModel(@NonNull Application application,
|
||||||
@@ -80,7 +82,8 @@ class ReportViewModel extends AndroidViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init(@Nullable Throwable t, long appStartTime,
|
void init(@Nullable Throwable t, long appStartTime,
|
||||||
@Nullable byte[] logKey) {
|
@Nullable byte[] logKey, @Nullable String initialComment) {
|
||||||
|
this.initialComment = initialComment;
|
||||||
isFeedback = t == null;
|
isFeedback = t == null;
|
||||||
if (reportData.getValue() == null) new SingleShotAndroidExecutor(() -> {
|
if (reportData.getValue() == null) new SingleShotAndroidExecutor(() -> {
|
||||||
String decryptedLogs;
|
String decryptedLogs;
|
||||||
@@ -103,6 +106,11 @@ class ReportViewModel extends AndroidViewModel {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
String getInitialComment() {
|
||||||
|
return initialComment;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isFeedback() {
|
boolean isFeedback() {
|
||||||
return isFeedback;
|
return isFeedback;
|
||||||
}
|
}
|
||||||
@@ -140,7 +148,7 @@ class ReportViewModel extends AndroidViewModel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The content of the report that will be loaded after
|
* The content of the report that will be loaded after
|
||||||
* {@link #init(Throwable, long, byte[])} was called.
|
* {@link #init(Throwable, long, byte[], String)} was called.
|
||||||
*/
|
*/
|
||||||
LiveData<ReportData> getReportData() {
|
LiveData<ReportData> getReportData() {
|
||||||
return reportData;
|
return reportData;
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ import static org.briarproject.briar.BuildConfig.APPLICATION_ID;
|
|||||||
import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE;
|
import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE;
|
||||||
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_APP_LOGCAT;
|
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_APP_LOGCAT;
|
||||||
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_APP_START_TIME;
|
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_APP_START_TIME;
|
||||||
|
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_INITIAL_COMMENT;
|
||||||
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_THROWABLE;
|
import static org.briarproject.briar.android.reporting.CrashReportActivity.EXTRA_THROWABLE;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@@ -434,17 +435,25 @@ public class UiUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void triggerFeedback(Context ctx) {
|
public static void triggerFeedback(Context ctx) {
|
||||||
startDevReportActivity(ctx, FeedbackActivity.class, null, null, null);
|
triggerFeedback(ctx, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void triggerFeedback(Context ctx,
|
||||||
|
@Nullable String initialComment) {
|
||||||
|
startDevReportActivity(ctx, FeedbackActivity.class, null, null, null,
|
||||||
|
initialComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startDevReportActivity(Context ctx,
|
public static void startDevReportActivity(Context ctx,
|
||||||
Class<? extends FragmentActivity> activity, @Nullable Throwable t,
|
Class<? extends FragmentActivity> activity, @Nullable Throwable t,
|
||||||
@Nullable Long appStartTime, @Nullable byte[] logKey) {
|
@Nullable Long appStartTime, @Nullable byte[] logKey, @Nullable
|
||||||
|
String initialComment) {
|
||||||
final Intent dialogIntent = new Intent(ctx, activity);
|
final Intent dialogIntent = new Intent(ctx, activity);
|
||||||
dialogIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
dialogIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||||
dialogIntent.putExtra(EXTRA_THROWABLE, t);
|
dialogIntent.putExtra(EXTRA_THROWABLE, t);
|
||||||
dialogIntent.putExtra(EXTRA_APP_START_TIME, appStartTime);
|
dialogIntent.putExtra(EXTRA_APP_START_TIME, appStartTime);
|
||||||
dialogIntent.putExtra(EXTRA_APP_LOGCAT, logKey);
|
dialogIntent.putExtra(EXTRA_APP_LOGCAT, logKey);
|
||||||
|
dialogIntent.putExtra(EXTRA_INITIAL_COMMENT, initialComment);
|
||||||
ctx.startActivity(dialogIntent);
|
ctx.startActivity(dialogIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user