medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.

Home Page:https://communityhealthtoolkit.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blank screen when launching external apps from CHT Android app

IreneAchola opened this issue · comments

Describe the bug
Opening links to external applications does not work when launched from the android application (no application selector) but works when launched from the browser.

To Reproduce
Steps to reproduce the behavior:

  1. Install CHT CHA Learning Care application from here
  2. Login as CHW
  3. Select any task in the tasks tab
  4. Click Open Oppia Mobile button
  5. See a blank white screen

Expected behavior
User should be able to see an application popup to select which application to open the link with

Screenshots

Application screenshots

20200921_154909

Browser screenshots

20200921_154657

Environment

  • Instance: cht-covid.dev.medicmobile.org
  • Browser: Worked in both Firefox and Chrome
  • Client platform: Android OS, Linux
  • App: webapp
  • Version: 3.10.0, observed in previous version as well (CIHA Rapid Pro version)

Additional context
Following steps 2 to 4 using the browsers on the phone prompts user to select an application to open the link with

@IreneAchola Can you share the configuration you're using?

@garethbowen Config available on this branch

This might be relevant: https://github.com/medic/medic-android/blob/master/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java#L383

We're hooking into a crosswalk feature that intercepts page loads and we block loading external pages. This would explain the white screen.

I'm thinking crosswalk has some thing that blocks standard android activity popups, otherwise they'd show up when clicking any link in the loaded app.

Yup it looks like that might be the case:
crosswalk-project/crosswalk#4000 <- see the solution provided here, where the problem is that crosswalk was opening in-app urls in the default browser instead of the crosswalk browser instance:

xDemo.setResourceClient(new XWalkResourceClient(xDemo) {
    @Override
    public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
        view.loadUrl(url);
        return true;
    }
}); 

We're also using the same hook
We could be blocking activities for any URL that is not a tel or sms https://github.com/medic/medic-android/blob/master/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java#L371 ?

I think the correct solution would be to change this code to launch activities for external URLs as well, and use the same URL matching as we do in the other function.

Thanks for confirming Diana. I've put this in 3.11.0 as it's blocking the Oppia integration project.

Great to see this investigated and prioritized so quickly, thank you!

Ready for AT in 6648-enable-outside-links

Just a small addendum that this is a medic-android issue, the branch above is in medic-android: https://github.com/medic/medic-android/tree/6648-enable-outside-links

To test, you'd need to add some config (a form maybe) that has an external link that you can click in the android app.
Also, please make sure that the "call" button from the contact profile still works.

I think this is ready to go @dianabarsan.

Tested with the CHA app not installed. This navigates us to the webpage.
Tested with the CHA app installed and used the form to navigate to the app.
Navigates back to our app as expected.
Tested the phone with no internet and navigate to the CHA app.
I was able to use the call function and get to the dialer app. I don't know if we have a way to go directly to the messaging app installed so I couldn't test that.

Thanks @newtewt ! Merged to master.