Feature/theme review section#47
Conversation
WalkthroughAdds per-meal enable/disable switches persisted via SharedPreferences, updates SettingsActivity UI and logic to manage temporary switch states, adjusts MainActivity.setAlarm() to cancel all alarms then schedule only enabled meals, and converts app themes/colors to Material DayNight palette. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SettingsActivity
participant Mess
participant SharedPreferences
participant MainActivity
participant AlarmManager
User->>SettingsActivity: Toggle meal switch
SettingsActivity->>SettingsActivity: update tempStates
SettingsActivity->>SettingsActivity: update UI state (alpha/isEnabled)
User->>SettingsActivity: Tap "Done"
SettingsActivity->>Mess: setMealEnabled(mealKey, value)
Mess->>SharedPreferences: write boolean flag
SettingsActivity->>User: show "Settings Updated" toast
Note over MainActivity,Mess: Later when alarms are (re)scheduled
MainActivity->>Mess: isMealEnabled(mealKey)
Mess->>SharedPreferences: read boolean (default true)
Mess-->>MainActivity: return enabled status
MainActivity->>AlarmManager: cancelAllAlarms(index)
alt enabled == true
MainActivity->>AlarmManager: scheduleAlarm(index, time, intent)
else enabled == false
MainActivity->>MainActivity: skip scheduling
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/res/layout/fragment_review.xml (1)
16-20:⚠️ Potential issue | 🟡 MinorRemove redundant Toolbar title color attribute.
Line 16 sets
app:titleTextColor="?attr/colorOnPrimary", but Line 20 also setsandroid:titleTextColor="@color/white". In AppCompat Toolbar, theapp:namespace attribute takes precedence, making theandroid:attribute ignored. Remove the redundantandroid:titleTextColorto maintain a single, theme-driven source of truth. Theapp:titleTextColorwith a theme attribute is the correct approach for dark-mode support.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/res/layout/fragment_review.xml` around lines 16 - 20, Remove the redundant android:titleTextColor attribute from the Toolbar definition so only the theme-driven app:titleTextColor="?attr/colorOnPrimary" remains; locate the Toolbar entry in fragment_review.xml and delete the android:titleTextColor="@color/white" line to ensure dark-mode uses the app: attribute as the single source of truth.
🧹 Nitpick comments (1)
app/src/main/java/com/theayushyadav11/MessEase/ui/more/SettingsActivity.kt (1)
31-38: Consolidate meal-key handling to one source of truth.The same four keys are repeated in initialization and persistence paths; this is easy to desync during future edits. Consider driving both blocks from one meal-config list.
Also applies to: 91-94
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/com/theayushyadav11/MessEase/ui/more/SettingsActivity.kt` around lines 31 - 38, The code repeats the four meal keys in multiple places; create a single source of truth (e.g., a List or array named mealKeys = listOf("bt_enabled","lt_enabled","st_enabled","dt_enabled")) and replace the duplicated literals by iterating that list when calling setupToggle (use the existing setupToggle function and binding references mapped by index or a small map of key->views) and when initializing tempStates with mess.isMealEnabled; also update the corresponding persistence/update block referenced around lines 91-94 to iterate the same mealKeys list so all meal-key handling is driven from that single collection.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/res/layout/activity_settings.xml`:
- Around line 78-85: Add descriptive accessibility labels to each meal Switch so
screen readers announce the meal context: for Switch elements like
switchBreakfast (and the other meal switches referenced at the other locations),
set android:contentDescription to a meaningful string resource (e.g.,
`@string/switch_breakfast`) and add corresponding strings in strings.xml (e.g.,
"Breakfast notifications switch") so the switch announces the meal name; update
each Switch (ids: switchBreakfast and the other meal switch ids at the ranges
you flagged) to use contentDescription rather than leaving them unlabeled.
In `@app/src/main/res/values-night/themes.xml`:
- Line 3: The Night theme currently sets <style name="Theme.MyApplication"
parent="Theme.MaterialComponents.Light.NoActionBar"> which forces light colors
in dark mode; update the parent to a DayNight or dark parent (for example use
Theme.MaterialComponents.DayNight.NoActionBar or a dark-specific parent) so
"Theme.MyApplication" inherits proper dark-mode styles in
res/values-night/themes.xml and restores correct contrast for night mode.
---
Outside diff comments:
In `@app/src/main/res/layout/fragment_review.xml`:
- Around line 16-20: Remove the redundant android:titleTextColor attribute from
the Toolbar definition so only the theme-driven
app:titleTextColor="?attr/colorOnPrimary" remains; locate the Toolbar entry in
fragment_review.xml and delete the android:titleTextColor="@color/white" line to
ensure dark-mode uses the app: attribute as the single source of truth.
---
Nitpick comments:
In `@app/src/main/java/com/theayushyadav11/MessEase/ui/more/SettingsActivity.kt`:
- Around line 31-38: The code repeats the four meal keys in multiple places;
create a single source of truth (e.g., a List or array named mealKeys =
listOf("bt_enabled","lt_enabled","st_enabled","dt_enabled")) and replace the
duplicated literals by iterating that list when calling setupToggle (use the
existing setupToggle function and binding references mapped by index or a small
map of key->views) and when initializing tempStates with mess.isMealEnabled;
also update the corresponding persistence/update block referenced around lines
91-94 to iterate the same mealKeys list so all meal-key handling is driven from
that single collection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c3333505-3cc5-4d7f-9668-24887a65d181
📒 Files selected for processing (9)
app/src/main/java/com/theayushyadav11/MessEase/MainActivity.ktapp/src/main/java/com/theayushyadav11/MessEase/ui/more/SettingsActivity.ktapp/src/main/java/com/theayushyadav11/MessEase/utils/Mess.ktapp/src/main/res/layout/activity_settings.xmlapp/src/main/res/layout/fragment_review.xmlapp/src/main/res/values-night/colors.xmlapp/src/main/res/values-night/themes.xmlapp/src/main/res/values/colors.xmlapp/src/main/res/values/themes.xml
| <Switch | ||
| android:id="@+id/switchBreakfast" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| app:layout_constraintEnd_toStartOf="@id/pickb" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| android:layout_marginEnd="8dp"/> |
There was a problem hiding this comment.
Add accessibility labels for the new meal switches.
These switches are currently unlabeled for screen readers, so assistive tech users may hear generic controls without meal context.
♿ Suggested fix
<Switch
android:id="@+id/switchBreakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:contentDescription="@string/cd_toggle_breakfast_reminder"
app:layout_constraintEnd_toStartOf="@id/pickb"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>
<Switch
android:id="@+id/switchLunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:contentDescription="@string/cd_toggle_lunch_reminder"
app:layout_constraintEnd_toStartOf="@id/pickl"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>
<Switch
android:id="@+id/switchSnacks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:contentDescription="@string/cd_toggle_snacks_reminder"
app:layout_constraintEnd_toStartOf="@id/picks"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>
<Switch
android:id="@+id/switchDinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:contentDescription="@string/cd_toggle_dinner_reminder"
app:layout_constraintEnd_toStartOf="@id/pickd"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>Also applies to: 148-155, 220-227, 294-301
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/src/main/res/layout/activity_settings.xml` around lines 78 - 85, Add
descriptive accessibility labels to each meal Switch so screen readers announce
the meal context: for Switch elements like switchBreakfast (and the other meal
switches referenced at the other locations), set android:contentDescription to a
meaningful string resource (e.g., `@string/switch_breakfast`) and add
corresponding strings in strings.xml (e.g., "Breakfast notifications switch") so
the switch announces the meal name; update each Switch (ids: switchBreakfast and
the other meal switch ids at the ranges you flagged) to use contentDescription
rather than leaving them unlabeled.
|
/unassign |
2 similar comments
|
/unassign |
|
/unassign |
Resolves #18
Description
Fix
night\Themes.xmlLive Demo (if any)
darknighttoggle.mp4
Checkout
Summary by CodeRabbit
New Features
Design & Theme