Skip to content

Commit

Permalink
Changes per PR feedback
Browse files Browse the repository at this point in the history
- use ErrorInfo.comparePackageInfo() too in ErrorActivity.startErrorActivity() since BuildConfig.APPLICATION_ID may not be available during build, and may cause build failures
- Fix ErrorActivity.reportError() an intentional trap to trigger check during test
  • Loading branch information
TranceLove committed Jun 26, 2021
1 parent 058fc06 commit 045fa94
Showing 1 changed file with 67 additions and 67 deletions.
134 changes: 67 additions & 67 deletions app/src/main/java/com/amaze/filemanager/crashreport/ErrorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static void reportError(

private static void startErrorActivity(
final Context context, final ErrorInfo errorInfo, final List<Throwable> el) {
if (context.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
if (ErrorInfo.comparePackageInfo(context.getPackageName()) < 1) {
final Intent intent = new Intent(context, ErrorActivity.class);
intent.putExtra(ERROR_INFO, errorInfo);
intent.putExtra(ERROR_LIST, elToSl(el));
Expand All @@ -147,11 +147,11 @@ public static void reportError(

public static void reportError(
final Context context, final CrashReportData report, final ErrorInfo errorInfo) {
System.out.println("ErrorActivity reportError");
Log.d(TAG, "ErrorActivity reportError");
final String[] el = new String[] {report.getString(ReportField.STACK_TRACE)};

final Intent intent = new Intent(context, ErrorActivity.class);
intent.setPackage("context.getPackageName()");
intent.setPackage(context.getPackageName());
intent.putExtra(ERROR_INFO, errorInfo);
intent.putExtra(ERROR_LIST, el);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Expand Down Expand Up @@ -180,74 +180,74 @@ public void onCreate(final Bundle savedInstanceState) {
final Intent intent = getIntent();
if (ErrorInfo.comparePackageInfo(intent.getPackage()) != 0) {
finish();
} else {
setContentView(R.layout.activity_error);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.error_report_title);
actionBar.setDisplayShowTitleEnabled(true);
}
return;
}
setContentView(R.layout.activity_error);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.error_report_title);
actionBar.setDisplayShowTitleEnabled(true);
}

final Button reportEmailButton = findViewById(R.id.errorReportEmailButton);
final Button reportTelegramButton = findViewById(R.id.errorReportTelegramButton);
final Button copyButton = findViewById(R.id.errorReportCopyButton);
final Button reportGithubButton = findViewById(R.id.errorReportGitHubButton);

userCommentBox = findViewById(R.id.errorCommentBox);
final TextView errorView = findViewById(R.id.errorView);
final TextView errorMessageView = findViewById(R.id.errorMessageView);

returnActivity = MainActivity.class;
errorInfo = intent.getParcelableExtra(ERROR_INFO);
errorList = intent.getStringArrayExtra(ERROR_LIST);

// important add guru meditation
addGuruMeditation();
currentTimeStamp = getCurrentTimeStamp();

reportEmailButton.setOnClickListener((View v) -> sendReportEmail());

reportTelegramButton.setOnClickListener(
(View v) -> {
FileUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show();
Utils.openTelegramURL(this);
});

copyButton.setOnClickListener(
(View v) -> {
FileUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show();
});

reportGithubButton.setOnClickListener(
(View v) -> {
FileUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show();
Utils.openURL(ERROR_GITHUB_ISSUE_URL, this);
});

// normal bugreport
buildInfo(errorInfo);
if (errorInfo.message != 0) {
errorMessageView.setText(errorInfo.message);
} else {
errorMessageView.setVisibility(View.GONE);
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE);
}
final Button reportEmailButton = findViewById(R.id.errorReportEmailButton);
final Button reportTelegramButton = findViewById(R.id.errorReportTelegramButton);
final Button copyButton = findViewById(R.id.errorReportCopyButton);
final Button reportGithubButton = findViewById(R.id.errorReportGitHubButton);

userCommentBox = findViewById(R.id.errorCommentBox);
final TextView errorView = findViewById(R.id.errorView);
final TextView errorMessageView = findViewById(R.id.errorMessageView);

returnActivity = MainActivity.class;
errorInfo = intent.getParcelableExtra(ERROR_INFO);
errorList = intent.getStringArrayExtra(ERROR_LIST);

// important add guru meditation
addGuruMeditation();
currentTimeStamp = getCurrentTimeStamp();

reportEmailButton.setOnClickListener((View v) -> sendReportEmail());

reportTelegramButton.setOnClickListener(
(View v) -> {
FileUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show();
Utils.openTelegramURL(this);
});

copyButton.setOnClickListener(
(View v) -> {
FileUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show();
});

reportGithubButton.setOnClickListener(
(View v) -> {
FileUtils.copyToClipboard(this, buildMarkdown());
Toast.makeText(this, R.string.crash_report_copied, Toast.LENGTH_SHORT).show();
Utils.openURL(ERROR_GITHUB_ISSUE_URL, this);
});

// normal bugreport
buildInfo(errorInfo);
if (errorInfo.message != 0) {
errorMessageView.setText(errorInfo.message);
} else {
errorMessageView.setVisibility(View.GONE);
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE);
}

errorView.setText(formErrorText(errorList));
errorView.setText(formErrorText(errorList));

// print stack trace once again for debugging:
for (final String e : errorList) {
Log.e(TAG, e);
}
initStatusBarResources(findViewById(R.id.parent_view));
// print stack trace once again for debugging:
for (final String e : errorList) {
Log.e(TAG, e);
}
initStatusBarResources(findViewById(R.id.parent_view));
}

@Override
Expand Down

0 comments on commit 045fa94

Please sign in to comment.