Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android 11+] Correctly open URLs in browser and fix opening downloads and external players #9850

Merged
merged 4 commits into from
Feb 25, 2023

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Feb 23, 2023

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • [Android 11+] Cannot open downloads from the app ("No app installed to play this file" toast) #9771 was caused by a misconfiguration of the queries field in the manifest. I thought I could use http|https|market to specify three schemas at once, but actually it's not possible. Hence, the permission was not actually given by the Android system and getDefaultAppPackageName would not work. Now I removed https and market as we never actually query those packages, but we only query http in openUrlInBrowser.
  • Instead of passing a boolean parameter to openUrlInBrowser, now there are two functions:
    • openUrlInBrowser, which enforces the opened app is a browser
      • Remove getDefaultAppPackageName and just hardcode the one important line of code inside openUrlInBrowser. This is to make sure that function is not used by accident anywhere else, since we don't want resolveActivity checks anywhere (tryOpenIntentInApp should be used instead, which uses a try catch instead).
    • openUrlInApp, which allows any app to be opened
  • Instead of passing a boolean parameter to decide whether openIntentInApp should show a toast, now there are two functions: openIntentInApp and tryOpenIntentInApp
  • Move all the "Kore"-related code into KoreUtils and deduplicate code for trying to open a Kore intent and showing a failure toast.
  • Remove the toast_no_player string ("No app installed to play this file"), because it was basically a duplicate of no_app_to_open_intent ("No app on your device can open this").

For more info check out the javadocs in ShareUtils

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@Stypox Stypox force-pushed the fix-api33-links-again3 branch from 88b6c1d to f329b32 Compare February 23, 2023 22:54
@AudricV AudricV changed the title Correctly open urls in browser on Android 11+ [Android 11+] Correctly open URLs in browser and fix opening downloads and external players Feb 24, 2023
Copy link
Member

@AudricV AudricV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good overall to me, except the following ones which needs to be solved.

Please split the sentences in Javadocs into "visible" multiple lines, i.e. lines that can be seen in the Javadoc preview, especially in the ones you changed in ShareUtils. This would make their reading a lot better.

Could you also reword your commit message to summarize better what you have done here, so we are not really forced to look at the pull request in the future to understand better your changes? Thanks in advance!

- Fix misconfiguration in manifest ('http|https|market' is not valid)
- Split ShareUtils functions taking a boolean parameter into pairs of functions with better names and less runtime checks
- Move all Kore-related functions to KoreUtils
- Remove the toast_no_player string
@Stypox Stypox force-pushed the fix-api33-links-again3 branch from f329b32 to 5972e50 Compare February 25, 2023 08:16
@Stypox
Copy link
Member Author

Stypox commented Feb 25, 2023

@AudricV done, thanks for the review :-)

@Stypox Stypox force-pushed the fix-api33-links-again3 branch from 5972e50 to be4f3d9 Compare February 25, 2023 12:14
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
2 participants