Repository navigation
Update from task ee42c794-bbdb-4ba0-8b66-fc4c6c31295c - #8
Conversation
…, and Arabic localization Key features implemented: - Created comprehensive TODO.md tracking development progress and immediate next steps - Implemented AndroidManifest.xml with extensive permissions for storage, P2P sharing, and networking - Added medical.db and medical_arabic.db with emergency protocols in both languages - Created launcher icons and theme resources for consistent UI appearance - Developed PeerSharingService.kt enabling APK and asset sharing via Bluetooth/WiFi - Built SharingScreen.kt with UI for sharing app, database, or all assets - Implemented generate_cheat_sheets.py to create print-ready PDF emergency guides - Extended SettingsScreen.kt with sharing and print navigation options - Added proguard-rules.pro for proper code obfuscation - Created database population script with Arabic protocol translations The application now includes complete build configuration, core assets, P2P sharing capabilities, print-ready emergency guides, and Arabic localization support while maintaining offline functionality for crisis zones.
|
Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideIntroduce proper Android app scaffolding, localization, and distribution tooling for Hayat AI, plus enrich the README with full product and architecture documentation. Sequence diagram for Hayat AI P2P sharing flow from settingssequenceDiagram
actor User
participant SettingsScreen
participant SharingScreen
participant SharingViewModel
participant PeerSharingService
participant AndroidShareIntent
User->>SettingsScreen: tap Distribution menu item
SettingsScreen->>SharingScreen: onNavigateToSharing()
User->>SharingScreen: select SharingOption
SharingScreen->>SharingViewModel: option.action()
alt Share APK
SharingViewModel->>PeerSharingService: shareApk()
PeerSharingService-->>SharingViewModel: Result<Uri>
SharingViewModel->>AndroidShareIntent: createShareIntent(apkUri)
else Share Database
SharingViewModel->>PeerSharingService: shareDatabase()
PeerSharingService-->>SharingViewModel: Result<Uri>
SharingViewModel->>AndroidShareIntent: createShareIntent(dbUri)
else Share All Assets
SharingViewModel->>PeerSharingService: shareAllAssets()
PeerSharingService-->>SharingViewModel: Result<List<Uri>>
SharingViewModel->>AndroidShareIntent: createMultiShareIntent(uris, mimeType)
end
AndroidShareIntent-->>User: system chooser to send files
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Hey - I've found 5 issues, and left some high level feedback:
- The new SettingsScreen uses Color(0xFF1565C0) without importing androidx.compose.ui.graphics.Color, and PeerSharingService references FileNotFoundException without importing java.io.FileNotFoundException; these missing imports will break the build and should be added.
- AndroidManifest currently requests MANAGE_EXTERNAL_STORAGE and legacy READ/WRITE_EXTERNAL_STORAGE, which are very broad and problematic on recent Android versions; consider scoping file access to app-specific directories or Storage Access Framework instead of these permissions.
- The language selection in SettingsScreen is tracked locally via selectedLanguage but does not propagate to an app-wide locale or configuration change; wiring this setting into a central localization mechanism would make the language toggle effective throughout the app.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new SettingsScreen uses Color(0xFF1565C0) without importing androidx.compose.ui.graphics.Color, and PeerSharingService references FileNotFoundException without importing java.io.FileNotFoundException; these missing imports will break the build and should be added.
- AndroidManifest currently requests MANAGE_EXTERNAL_STORAGE and legacy READ/WRITE_EXTERNAL_STORAGE, which are very broad and problematic on recent Android versions; consider scoping file access to app-specific directories or Storage Access Framework instead of these permissions.
- The language selection in SettingsScreen is tracked locally via selectedLanguage but does not propagate to an app-wide locale or configuration change; wiring this setting into a central localization mechanism would make the language toggle effective throughout the app.
## Individual Comments
### Comment 1
<location path="app/src/main/java/com/hayat/ui/screens/SharingScreen.kt" line_range="274-282" />
<code_context>
+
+ private val sharingService = PeerSharingService(context)
+
+ suspend fun shareApk(context: android.content.Context): Result<android.net.Uri> {
+ return sharingService.shareApk()
+ }
+
+ suspend fun shareDatabase(context: android.content.Context): Result<android.net.Uri> {
+ return sharingService.shareDatabase()
+ }
+
+ suspend fun shareAllAssets(context: android.content.Context): Result<List<android.net.Uri>> {
+ return sharingService.shareAllAssets()
+ }
</code_context>
<issue_to_address>
**suggestion:** The context parameters on SharingViewModel methods are unused and redundant.
`shareApk`, `shareDatabase`, and `shareAllAssets` all ignore their `context` parameter and only use the `sharingService` field. This makes the API misleading. Please either remove these parameters or refactor to use the passed-in `context` consistently.
Suggested implementation:
```
class SharingViewModel(private val context: android.content.Context) : androidx.lifecycle.ViewModel() {
private val sharingService = PeerSharingService(context)
suspend fun shareApk(): Result<android.net.Uri> {
return sharingService.shareApk()
}
suspend fun shareDatabase(): Result<android.net.Uri> {
return sharingService.shareDatabase()
}
suspend fun shareAllAssets(): Result<List<android.net.Uri>> {
return sharingService.shareAllAssets()
}
```
1. Update all call sites that currently invoke `shareApk(context)`, `shareDatabase(context)`, or `shareAllAssets(context)` to drop the `context` argument and call the parameterless versions instead (e.g. `viewModel.shareApk()`).
2. If these methods are referenced as `action: suspend () -> Result<Any>`, you may need to adjust the generics or cast the specific `Result<android.net.Uri>` / `Result<List<android.net.Uri>>` to `Result<Any>` where appropriate, depending on how `action` is consumed.
3. Remove any now-unused imports related to passing `android.content.Context` into these methods.
</issue_to_address>
### Comment 2
<location path="app/src/main/java/com/hayat/ui/screens/SharingScreen.kt" line_range="93-94" />
<code_context>
+ scope.launch {
+ isSharing = true
+ shareMessage = ""
+ val result = option.action()
+ result.fold(
+ onSuccess = {
+ showSuccess = true
</code_context>
<issue_to_address>
**issue (bug_risk):** Sharing flow prepares URIs but doesn’t actually launch a share intent.
On success you only update `shareMessage` / `showSuccess` and never launch a share intent. The flow should call `startActivity(PeerSharingService.createShareIntent(...)` or `createMultiShareIntent(...)` in the success branch so the user actually gets a chooser to send the files.
</issue_to_address>
### Comment 3
<location path="scripts/generate_cheat_sheets.py" line_range="22-31" />
<code_context>
+MEDICAL_PROTOCOLS = [
+ {
+ "title_en": "Severe Bleeding Control",
+ "title_ar": "التحكم في النزيف الحاد",
+ "steps_en": [
+ "Apply direct pressure to the wound with a clean cloth",
+ "If bleeding continues, apply a tourniquet 2-3 inches above wound",
+ "Note the time of tourniquet application",
+ "Do not remove the tourniquet once applied",
+ "Seek medical help immediately"
+ ],
+ "steps_ar": [
+ "اضغط مباشرة على الجرح بقطعة قماش نظيفة",
+ "إذا استمر النزيف، ضع عاصبة على بعد 2-3 بوصات فوق الجرح",
+ "دوّن وقت وضع العاصبة",
+ "لا تزل العاصبة بمجرد وضعها",
+ "اطلب المساعدة الطبية فوراً"
+ ],
+ "warning_en": "⚠️ Tourniquets only for life-threatening limb bleeding",
+ "warning_ar": "⚠️ العاصبة فقط للنزيف الذي يهدد الحياة في الأطراف"
+ },
+ {
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Arabic content is generated without any RTL / font handling, which may render poorly.
ReportLab doesn’t support Arabic shaping or RTL layout by default, and this code doesn’t set an Arabic-capable font or right-to-left alignment. As a result, the generated Arabic text may appear disconnected or misaligned and be difficult to read. If Arabic output is a requirement, integrate an Arabic text shaping/RTL solution and register a suitable TTF font with right-aligned paragraphs before generating these PDFs.
Suggested implementation:
```python
from reportlab.lib.units import inch, cm
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
# Arabic / RTL text support
try:
import arabic_reshaper
from bidi.algorithm import get_display
except ImportError:
arabic_reshaper = None
get_display = None
ARABIC_FONT_NAME = "Arabic-Regular"
def register_arabic_font():
"""
Register a TTF font that supports Arabic glyphs.
The path should point to a font file that:
- Supports Arabic script
- Is bundled with the project or available on the deployment environment
"""
try:
# Adjust the path if your font is located elsewhere in the project
pdfmetrics.registerFont(TTFont(ARABIC_FONT_NAME, "fonts/Arabic-Regular.ttf"))
except Exception:
# Fallback: do not register if font is missing; Arabic output may be degraded
pass
def shape_arabic_text(text: str) -> str:
"""
Apply Arabic shaping and bidi reordering so ReportLab can render connected RTL text.
If the shaping libraries are not available, the original text is returned.
"""
if not text:
return ""
if arabic_reshaper is None or get_display is None:
return text
reshaped = arabic_reshaper.reshape(text)
return get_display(reshaped)
# Ensure the Arabic-capable font is registered before any Paragraphs are built
register_arabic_font()
# Medical protocols data
MEDICAL_PROTOCOLS = [
```
1. Wherever Arabic text (`title_ar`, `steps_ar`, `warning_ar`, etc.) is passed into a `Paragraph`, wrap the text with `shape_arabic_text(...)` before constructing the `Paragraph`, e.g.:
- `Paragraph(shape_arabic_text(protocol["title_ar"]), arabic_title_style)`
- `Paragraph(shape_arabic_text(step), arabic_body_style)`
2. Define dedicated `ParagraphStyle` instances for Arabic content with:
- `fontName=ARABIC_FONT_NAME`
- `alignment=TA_RIGHT`
- Appropriate `leading` and `fontSize` consistent with the rest of the cheat sheet.
3. Ensure any tables or multi-column layouts that include Arabic text either:
- Use right alignment for the Arabic column, or
- Use separate left/right aligned styles per language.
4. Confirm that `fonts/Arabic-Regular.ttf` (or your chosen Arabic-capable TTF, e.g. Amiri, Noto Naskh Arabic) is added to the repository and available in production. If the font is located elsewhere, update the path in `register_arabic_font()` accordingly.
</issue_to_address>
### Comment 4
<location path="app/src/main/java/com/hayat/ui/screens/SettingsScreen.kt" line_range="29" />
<code_context>
) {
var modelPathState by remember { mutableStateOf(modelPath) }
var dbPathState by remember { mutableStateOf(dbPath) }
+ var selectedLanguage by remember { mutableStateOf("en") }
+
+ val menuItems = listOf(
</code_context>
<issue_to_address>
**question:** The language selection state is currently not connected to any localization mechanism.
`selectedLanguage` only affects chip selection and doesn’t feed into `Locale`, configuration, or any persistence. If language switching is intended to be functional, propagate this state through a shared settings/localization mechanism so it actually drives app localization.
</issue_to_address>
### Comment 5
<location path="README.md" line_range="35" />
<code_context>
+
+### Safety Features
+- **Triple-Check Validation**: All responses validated against medical database
+- **Clear Disclaimers**: Every response includes medical disclaimer
+- **Source Attribution**: Shows which protocol each answer comes from
+- **Refusal Messages**: Gracefully declines queries outside medical scope
</code_context>
<issue_to_address>
**nitpick (typo):** Add an article before "medical disclaimer" for correct grammar.
Change this bullet to: "Every response includes a medical disclaimer."
```suggestion
- **Clear Disclaimers**: Every response includes a medical disclaimer
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| suspend fun shareApk(context: android.content.Context): Result<android.net.Uri> { | ||
| return sharingService.shareApk() | ||
| } | ||
|
|
||
| suspend fun shareDatabase(context: android.content.Context): Result<android.net.Uri> { | ||
| return sharingService.shareDatabase() | ||
| } | ||
|
|
||
| suspend fun shareAllAssets(context: android.content.Context): Result<List<android.net.Uri>> { |
There was a problem hiding this comment.
suggestion: The context parameters on SharingViewModel methods are unused and redundant.
shareApk, shareDatabase, and shareAllAssets all ignore their context parameter and only use the sharingService field. This makes the API misleading. Please either remove these parameters or refactor to use the passed-in context consistently.
Suggested implementation:
class SharingViewModel(private val context: android.content.Context) : androidx.lifecycle.ViewModel() {
private val sharingService = PeerSharingService(context)
suspend fun shareApk(): Result<android.net.Uri> {
return sharingService.shareApk()
}
suspend fun shareDatabase(): Result<android.net.Uri> {
return sharingService.shareDatabase()
}
suspend fun shareAllAssets(): Result<List<android.net.Uri>> {
return sharingService.shareAllAssets()
}
- Update all call sites that currently invoke
shareApk(context),shareDatabase(context), orshareAllAssets(context)to drop thecontextargument and call the parameterless versions instead (e.g.viewModel.shareApk()). - If these methods are referenced as
action: suspend () -> Result<Any>, you may need to adjust the generics or cast the specificResult<android.net.Uri>/Result<List<android.net.Uri>>toResult<Any>where appropriate, depending on howactionis consumed. - Remove any now-unused imports related to passing
android.content.Contextinto these methods.
| val result = option.action() | ||
| result.fold( |
There was a problem hiding this comment.
issue (bug_risk): Sharing flow prepares URIs but doesn’t actually launch a share intent.
On success you only update shareMessage / showSuccess and never launch a share intent. The flow should call startActivity(PeerSharingService.createShareIntent(...) or createMultiShareIntent(...) in the success branch so the user actually gets a chooser to send the files.
| "title_ar": "التحكم في النزيف الحاد", | ||
| "steps_en": [ | ||
| "Apply direct pressure to the wound with a clean cloth", | ||
| "If bleeding continues, apply a tourniquet 2-3 inches above wound", | ||
| "Note the time of tourniquet application", | ||
| "Do not remove the tourniquet once applied", | ||
| "Seek medical help immediately" | ||
| ], | ||
| "steps_ar": [ | ||
| "اضغط مباشرة على الجرح بقطعة قماش نظيفة", |
There was a problem hiding this comment.
suggestion (bug_risk): Arabic content is generated without any RTL / font handling, which may render poorly.
ReportLab doesn’t support Arabic shaping or RTL layout by default, and this code doesn’t set an Arabic-capable font or right-to-left alignment. As a result, the generated Arabic text may appear disconnected or misaligned and be difficult to read. If Arabic output is a requirement, integrate an Arabic text shaping/RTL solution and register a suitable TTF font with right-aligned paragraphs before generating these PDFs.
Suggested implementation:
from reportlab.lib.units import inch, cm
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
# Arabic / RTL text support
try:
import arabic_reshaper
from bidi.algorithm import get_display
except ImportError:
arabic_reshaper = None
get_display = None
ARABIC_FONT_NAME = "Arabic-Regular"
def register_arabic_font():
"""
Register a TTF font that supports Arabic glyphs.
The path should point to a font file that:
- Supports Arabic script
- Is bundled with the project or available on the deployment environment
"""
try:
# Adjust the path if your font is located elsewhere in the project
pdfmetrics.registerFont(TTFont(ARABIC_FONT_NAME, "fonts/Arabic-Regular.ttf"))
except Exception:
# Fallback: do not register if font is missing; Arabic output may be degraded
pass
def shape_arabic_text(text: str) -> str:
"""
Apply Arabic shaping and bidi reordering so ReportLab can render connected RTL text.
If the shaping libraries are not available, the original text is returned.
"""
if not text:
return ""
if arabic_reshaper is None or get_display is None:
return text
reshaped = arabic_reshaper.reshape(text)
return get_display(reshaped)
# Ensure the Arabic-capable font is registered before any Paragraphs are built
register_arabic_font()
# Medical protocols data
MEDICAL_PROTOCOLS = [- Wherever Arabic text (
title_ar,steps_ar,warning_ar, etc.) is passed into aParagraph, wrap the text withshape_arabic_text(...)before constructing theParagraph, e.g.:Paragraph(shape_arabic_text(protocol["title_ar"]), arabic_title_style)Paragraph(shape_arabic_text(step), arabic_body_style)
- Define dedicated
ParagraphStyleinstances for Arabic content with:fontName=ARABIC_FONT_NAMEalignment=TA_RIGHT- Appropriate
leadingandfontSizeconsistent with the rest of the cheat sheet.
- Ensure any tables or multi-column layouts that include Arabic text either:
- Use right alignment for the Arabic column, or
- Use separate left/right aligned styles per language.
- Confirm that
fonts/Arabic-Regular.ttf(or your chosen Arabic-capable TTF, e.g. Amiri, Noto Naskh Arabic) is added to the repository and available in production. If the font is located elsewhere, update the path inregister_arabic_font()accordingly.
| ) { | ||
| var modelPathState by remember { mutableStateOf(modelPath) } | ||
| var dbPathState by remember { mutableStateOf(dbPath) } | ||
| var selectedLanguage by remember { mutableStateOf("en") } |
There was a problem hiding this comment.
question: The language selection state is currently not connected to any localization mechanism.
selectedLanguage only affects chip selection and doesn’t feed into Locale, configuration, or any persistence. If language switching is intended to be functional, propagate this state through a shared settings/localization mechanism so it actually drives app localization.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Code Review Roast 🔥Verdict: 3 Issues Found | Recommendation: Address as follow-up (PR is already merged)
Overview
Issue Details (click to expand)
🏆 Best part: The README/SETUP docs are genuinely thorough and the Compose UI structure is clean and readable for AI-generated code — I was bracing for a dumpster fire and got a tidy campfire instead. 💀 Worst part: The single headline P2P feature (sharing the app itself) is fundamentally non-functional because 📊 Overall: Like a beautifully packaged first-aid kit with the scissors glued shut — looks ready for a crisis, but squeeze the handle and nothing comes out. Files Reviewed
Fix these issues in Kilo Cloud Reviewed by hy3:free · Input: 115.6K · Output: 36.1K · Cached: 1.4M |
This PR was created by qwen-chat coder for task ee42c794-bbdb-4ba0-8b66-fc4c6c31295c.
Summary by Sourcery
Introduce a more detailed, deployment-focused README and supporting setup documentation for Hayat AI, while adding sharing, localization, and printing capabilities to the Android app and wiring up basic build/config assets.
New Features:
Enhancements:
Build:
Documentation: