Skip to content

Feature/theme review section#47

Open
siddhigupta075 wants to merge 6 commits into
iiitl:masterfrom
siddhigupta075:feature/theme-review-section
Open

Feature/theme review section#47
siddhigupta075 wants to merge 6 commits into
iiitl:masterfrom
siddhigupta075:feature/theme-review-section

Conversation

@siddhigupta075
Copy link
Copy Markdown
Contributor

@siddhigupta075 siddhigupta075 commented Apr 11, 2026

Resolves #18

Description

This PR fixes the problem of write review section where it was not changing the color theme and was not in sync with the rest of the app.

Fix

  • Replaced some hardcoded colours
  • App was using Light-only theme, ignoring Dark Mode
  • Replaced the poor contrast
  • Changed the parent theme of night\Themes.xml

Live Demo (if any)

darknighttoggle.mp4

Checkout

  • I have read all the contributor guidelines for the repo.

Summary by CodeRabbit

  • New Features

    • Added toggles in Settings to enable/disable individual meals (breakfast, lunch, snacks, dinner).
    • Alarms now only schedule for enabled meals, skipping disabled ones.
  • Design & Theme

    • Updated color scheme and theme styling with improved dark mode support.
    • Enhanced UI consistency across the app using theme attributes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2026

Walkthrough

Adds 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

Cohort / File(s) Summary
Meal toggle logic
app/src/main/java/com/theayushyadav11/MessEase/ui/more/SettingsActivity.kt, app/src/main/java/com/theayushyadav11/MessEase/utils/Mess.kt, app/src/main/java/com/theayushyadav11/MessEase/MainActivity.kt
Add per-meal switches and tempStates in SettingsActivity; add setMealEnabled(key, Boolean) and isMealEnabled(key) in Mess; MainActivity.setAlarm() now cancels all alarms then schedules only meals where isMealEnabled is true.
Settings layout
app/src/main/res/layout/activity_settings.xml
Add four Switch views: @+id/switchBreakfast, @+id/switchLunch, @+id/switchSnacks, @+id/switchDinner placed in respective meal cards.
Review fragment theming
app/src/main/res/layout/fragment_review.xml
Replace hardcoded colors with theme attributes (e.g., ?attr/colorPrimary, ?attr/colorOnPrimary, ?attr/colorSurface) and add toolbar elevation.
Theme styles (DayNight)
app/src/main/res/values/themes.xml, app/src/main/res/values-night/themes.xml
Switch app theme parent to Theme.MaterialComponents.DayNight.NoActionBar; remap color items to new Material palette and background/surface/text attributes; rename/adjust night theme style.
Color resources
app/src/main/res/values/colors.xml, app/src/main/res/values-night/colors.xml
Add/adjust palette colors (primary, primary_variant, accent, accent_soft, surface, text_primary, text_secondary, divider, error) and update bg values for light and night.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes substantial out-of-scope changes: meal enable/disable toggles in SettingsActivity, alarm scheduling logic in MainActivity, and new Mess.kt methods unrelated to the Write Review theme fix. Remove changes to MainActivity.kt, SettingsActivity.kt, Mess.kt, activity_settings.xml, and colors.xml/themes.xml entries unrelated to the Write Review section to keep the PR focused on issue #18.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feature/theme review section' is overly vague and does not clearly describe the main changes; it lacks specificity about what was actually modified. Use a more descriptive title like 'Fix theme support in Write Review section' or 'Apply Dark/Light theme to Write Review section' to clearly convey the purpose of the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses issue #18 by applying Dark/Light theme support to the Write Review section through updated themes.xml, colors.xml, and fragment_review.xml layout changes.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Remove redundant Toolbar title color attribute.

Line 16 sets app:titleTextColor="?attr/colorOnPrimary", but Line 20 also sets android:titleTextColor="@color/white". In AppCompat Toolbar, the app: namespace attribute takes precedence, making the android: attribute ignored. Remove the redundant android:titleTextColor to maintain a single, theme-driven source of truth. The app:titleTextColor with 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

📥 Commits

Reviewing files that changed from the base of the PR and between 70fdeb4 and 153eb68.

📒 Files selected for processing (9)
  • app/src/main/java/com/theayushyadav11/MessEase/MainActivity.kt
  • app/src/main/java/com/theayushyadav11/MessEase/ui/more/SettingsActivity.kt
  • app/src/main/java/com/theayushyadav11/MessEase/utils/Mess.kt
  • app/src/main/res/layout/activity_settings.xml
  • app/src/main/res/layout/fragment_review.xml
  • app/src/main/res/values-night/colors.xml
  • app/src/main/res/values-night/themes.xml
  • app/src/main/res/values/colors.xml
  • app/src/main/res/values/themes.xml

Comment on lines +78 to +85
<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"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

Comment thread app/src/main/res/values-night/themes.xml Outdated
@siddhigupta075
Copy link
Copy Markdown
Contributor Author

/unassign

2 similar comments
@siddhigupta075
Copy link
Copy Markdown
Contributor Author

/unassign

@siddhigupta075
Copy link
Copy Markdown
Contributor Author

/unassign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix]: Applying the Dark/Light theme in the Write Review section.

2 participants