Skip to content

Update UnifiedAboutActivity.kt - #23154

Closed
OneBitSailor wants to merge 2 commits into
wordpress-mobile:trunkfrom
OneBitSailor:check-about-activity
Closed

Update UnifiedAboutActivity.kt#23154
OneBitSailor wants to merge 2 commits into
wordpress-mobile:trunkfrom
OneBitSailor:check-about-activity

Conversation

@OneBitSailor

Copy link
Copy Markdown

Fixed lifecycle and possible injection issues in UnifiedAboutActivity along side with implementing safe check for possible invalid URLs or missing external web browsers.

Description

  • Safe Dependency Injection: Ensured Dagger injection occurs before super.onCreate to prevent lifecycle race conditions where the framework might try to restore state or fragments using fields before they are injected.

  • Safe URL Interaction: Encapsulated the external URL launcher in a explicit try-catch block capturing ActivityNotFoundException. This guarantees the app will not crash on low-end or highly restricted devices lacking a default web browser or when processed an invalid deep-link structure.

Testing instructions

Test Case 1: Standard navigation and external link launching

  1. Clicking upon blog button in about.
  2. The link will be redirected to URLs upon action.
  • Verify that the external web browser opens immediately to the correct URL.
  1. Rotate the device while the browser is open or right after returning to the app.
  • Verify that the app does not repeatedly attempt to launch the browser or crash due to configuration changes.

Test Case 2: Error handling on missing browser or invalid URL

  1. (Optional/Simulated) Use a device/emulator with no default web browser installed, or temporarily disable your system browser.
  2. Trigger the action that calls openExternalBlogUrl with an invalid link schema or restricted destination.
  • Verify that the app does not crash.
  • Verify that a Toast message appears displaying "Invalid URL or external activity!".
    Use numbered lists for action steps and checkboxes for verifications.
    Organise by test case title when there are multiple scenarios.

Self-Testing Checklist

  • Compatibility with WordPress.com sites and self-hosted Jetpack sites: Verified that the UnifiedAboutActivity correctly resolves config settings provided by the UnifiedAboutViewModel regardless of whether the active authenticated user profile belongs to a WordPress.com account or a self-hosted Jetpack site.

Added check for possible invalid URLs or missing web browsers.
@nbradbury
nbradbury self-requested a review July 31, 2026 17:36
@nbradbury

nbradbury commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for taking the time to put this together, @OneBitSailor! Unfortunately I don’t think we can merge this one, and I wanted to explain why.

The try/catch is already handled upstream. ActivityLauncher.openUrlExternal catches ActivityNotFoundException itself and shows a localized toast (ActivityLauncher.java#L1676):

} catch (ActivityNotFoundException e) {
    ToastUtils.showToast(context, context.getString(R.string.cant_open_url), Duration.LONG);
    AppLog.e(AppLog.T.UTILS, "No default app available on the device to open the link: " + url, e);
}

Since the exception never reaches the caller, the new catch block can’t be hit. Devices without a browser are already covered.

The Dagger change isn’t in the diff. The description mentions moving injection before super.onCreate, but the code still calls super.onCreate first. That’s also our convention across the app, so no change is needed there.

One thing for future PRs: user-facing strings need to come from strings.xml (a hardcoded literal won’t be translated).

Going to close this, but thanks again for the interest in the project! 🙇

@nbradbury nbradbury closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants