Skip to content

Commit

Permalink
Merge pull request #3299 from deltachat/adb/issue-3289
Browse files Browse the repository at this point in the history
avoid android.view.WindowManager$BadTokenException in maybeShowConfigurationError
  • Loading branch information
adbenitez committed Sep 17, 2024
2 parents 5c9afb9 + be4bc82 commit 0bd2c2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private void progressUpdate(int progress) {

private void progressError(String data2) {
progressDialog.dismiss();
maybeShowConfigurationError(this, data2);
WelcomeActivity.maybeShowConfigurationError(this, data2);
}

private void progressSuccess() {
Expand All @@ -416,22 +416,6 @@ private void progressSuccess() {
finishAffinity();
}

public static void maybeShowConfigurationError(Activity activity, String data2) {
if (data2 != null && !data2.isEmpty()) {
AlertDialog d = new AlertDialog.Builder(activity)
.setMessage(data2)
.setPositiveButton(android.R.string.ok, null)
.create();
d.show();
try {
//noinspection ConstantConditions
Linkify.addLinks((TextView) d.findViewById(android.R.id.message), Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
} catch(NullPointerException e) {
Log.e(TAG, "Linkify failed", e);
}
}
}

@SuppressLint("StaticFieldLeak")
private void createProfile() {
if (TextUtils.isEmpty(this.name.getText())) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/thoughtcrime/securesms/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ private void progressSuccess() {
}

public static void maybeShowConfigurationError(Activity activity, String data2) {
if (activity.isFinishing()) return; // avoid android.view.WindowManager$BadTokenException

if (data2 != null && !data2.isEmpty()) {
AlertDialog d = new AlertDialog.Builder(activity)
.setMessage(data2)
Expand Down

0 comments on commit 0bd2c2f

Please sign in to comment.