-
Notifications
You must be signed in to change notification settings - Fork 72
Open url via navigation menu #3780
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.0%) is below the target coverage (60.0%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3780 +/- ##
=========================================
- Coverage 30.0% 25.3% -4.8%
+ Complexity 915 815 -100
=========================================
Files 287 297 +10
Lines 15409 16086 +677
Branches 2703 2812 +109
=========================================
- Hits 4628 4071 -557
- Misses 10215 11502 +1287
+ Partials 566 513 -53
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds functionality to open URLs via navigation menu items by implementing a new OPEN_URL workflow. The implementation allows configurable navigation menu items to open external URLs in the system browser or appropriate applications.
- Added
OPEN_URLworkflow type toApplicationWorkflowenum - Implemented URL opening functionality in
ConfigExtensions.ktusing Android intents - Added a "Feedback" navigation menu item as an example usage
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ConfigExtensions.kt | Implements the OPEN_URL workflow handler with intent-based URL opening |
| navigation_config.json | Adds example feedback menu item using the new OPEN_URL workflow |
| ic_feedback.xml | Adds feedback icon resource for the navigation menu item |
| ApplicationWorkflow.kt | Defines the new OPEN_URL workflow enum value |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
| ContextCompat.startActivity(navController.context, intent, null) | ||
| } catch (e: Exception) { | ||
| context?.showToast("Unable to open url ${e.message}", Toast.LENGTH_SHORT) |
Copilot
AI
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message exposes the raw exception message to users, which may contain technical details that are confusing. Consider using a more user-friendly message like 'Unable to open the URL. Please check the link and try again.'
| context?.showToast("Unable to open url ${e.message}", Toast.LENGTH_SHORT) | |
| context?.showToast("Unable to open the URL. Please check the link and try again.", Toast.LENGTH_SHORT) |
| try { | ||
| val intent = Intent(Intent.ACTION_VIEW, url.toUri()) | ||
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
| ContextCompat.startActivity(navController.context, intent, null) | ||
| } catch (e: Exception) { | ||
| context?.showToast("Unable to open url ${e.message}", Toast.LENGTH_SHORT) |
Copilot
AI
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL is not validated before being passed to the intent. This could allow malicious URLs to be opened. Consider validating the URL scheme (e.g., only allow http/https) or implementing a URL whitelist to prevent potential security issues.
| try { | |
| val intent = Intent(Intent.ACTION_VIEW, url.toUri()) | |
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | |
| ContextCompat.startActivity(navController.context, intent, null) | |
| } catch (e: Exception) { | |
| context?.showToast("Unable to open url ${e.message}", Toast.LENGTH_SHORT) | |
| val uri = Uri.parse(url) | |
| val scheme = uri.scheme?.lowercase() | |
| if (scheme == "http" || scheme == "https") { | |
| try { | |
| val intent = Intent(Intent.ACTION_VIEW, uri) | |
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | |
| ContextCompat.startActivity(navController.context, intent, null) | |
| } catch (e: Exception) { | |
| context?.showToast("Unable to open url ${e.message}", Toast.LENGTH_SHORT) | |
| } | |
| } else { | |
| context?.showToast("Invalid or unsupported URL scheme", Toast.LENGTH_SHORT) |
IMPORTANT: Where possible all PRs must be linked to a Github issue
Fixes #3779
Engineer Checklist
strings.xmlfile./gradlew spotlessApplyand./gradlew spotlessCheckto check my code follows the project's style guideCode Reviewer Checklist
strings.xmlfile