Skip to content

Correctly update action and scrollbar and reminders colors#904

Merged
Crustack merged 2 commits intomainfrom
fix/901
Mar 8, 2026
Merged

Correctly update action and scrollbar and reminders colors#904
Crustack merged 2 commits intomainfrom
fix/901

Conversation

@Crustack
Copy link
Owner

@Crustack Crustack commented Mar 8, 2026

Fixes #901

image

Summary by CodeRabbit

  • New Features
    • Added customizable color support for icon buttons and other controls for consistent theming.
    • Introduced colorized fast-scroll indicators and improved fast-scroll styling.
    • Centralized action bar color handling for more consistent toolbar theming across note editors.
  • Bug Fixes / Polish
    • Improved chip background contrast and icon tinting for better readability and visual consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2026

📝 Walkthrough

Walkthrough

Adds color propagation to UI helpers: icon buttons and fast-scrolls now accept a colorInt; FastScrollerBuilder gains a colored style path; EditActivity centralizes top-action-bar color application and callers updated to pass colors.

Changes

Cohort / File(s) Summary
UI Extension Methods
app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
Added colorInt parameter to addIconButton() and addFastScroll(), added FastScrollerBuilder.useColoredStyle(context, colorInt), added getSlightContrastColor() and updated control-color propagation and chip tinting.
Activity Color Management
app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditActivity.kt
Added protected fun setTopActionBarColor(@ColorInt color: Int) and replaced inline toolbar tinting with calls to the helper; updated callers to pass colorInt.
Activity Callsite Updates
app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditNoteActivity.kt, app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditTextPlainActivity.kt
Updated addIconButton(...) invocations to include new colorInt argument; removed an unused import.
ViewHolder Ordering
app/src/main/java/com/philkes/notallyx/presentation/view/main/BaseNoteVH.kt
Reordered color application: setColor(baseNote.color) now runs after ReminderChip binding (no signature changes).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant UI as ViewGroup (layout)
    participant Builder as FastScrollerBuilder
    participant Resources as AppCompatResources
    participant Scroll as FastScrollNestedScrollView

    UI->>UI: addIconButton(title, drawable, colorInt)
    UI->>UI: setControlsContrastColorForAllViews(colorInt)
    UI->>Builder: addFastScroll(context, colorInt)
    Builder->>Resources: load/md2_thumb_drawable (tint with colorInt)
    Builder->>Scroll: attach fast-scroller (thumb + track + popup styled)
    UI->>Scroll: make fast-scroll visible (styled)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I rubbed my paws on hues anew,
Tinted thumbs and buttons true.
Chips glow slightly, icons sing —
A colorful hop in every thing. 🎨✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main objective of the PR: updating action buttons, scrollbar, and reminder colors to adapt to note colors for better contrast in dark mode.
Linked Issues check ✅ Passed The PR addresses all requirements from issue #901: action button colors, scrollbar colors, and reminder chip colors now adapt to the note color instead of using fixed purple.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing dynamic color adaptation for UI elements mentioned in issue #901 with no unrelated modifications.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/901

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
Contributor

@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: 1

🧹 Nitpick comments (2)
app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt (2)

701-701: Remove unused variable.

The counter variable appears to be dead code that serves no purpose.

🔧 Suggested fix
-var counter = 0
-
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt` at line
701, Remove the unused top-level variable `counter` declared in UiExtensions.kt
(the `var counter = 0` line); search for any references to `counter` to confirm
it's unused and then delete the declaration (or replace with the intended
implementation if it was meant to be used), ensuring no remaining dead code or
unused imports remain in the file.

1001-1015: Inconsistent null handling for drawables.

Lines 1005-1010 safely handle a potentially null drawable with ?.let, but line 1011 uses a non-null assertion (!!) on ContextCompat.getDrawable. For consistency and defensive coding, consider using the same safe pattern.

🛡️ Suggested fix
-    setTrackDrawable(ContextCompat.getDrawable(context, R.drawable.scroll_track)!!)
+    ContextCompat.getDrawable(context, R.drawable.scroll_track)?.let { setTrackDrawable(it) }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt` around
lines 1001 - 1015, The useColoredStyle extension inconsistently force-unwraps
the track drawable with ContextCompat.getDrawable(... )!!; change it to handle
null defensively like the thumb drawable: retrieve the track with
ContextCompat.getDrawable(context, R.drawable.scroll_track) and only call
setTrackDrawable(...) when the result is non-null (e.g., using ?.let) or provide
a clear fallback drawable/resource before calling setTrackDrawable; update
FastScrollerBuilder.useColoredStyle to use that safe pattern.
🤖 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/java/com/philkes/notallyx/presentation/UiExtensions.kt`:
- Around line 726-728: Remove the unnecessary API check around
FastScrollNestedScrollView (delete the Build.VERSION.SDK_INT >= Q gating) and
prevent repeated FastScrollerBuilder rebuilds by making addFastScroll
idempotent: detect if a fast scroller is already installed (e.g., store/reuse a
builder or install marker via view.setTag or a weak map keyed by
FastScrollNestedScrollView) and skip creating/building a new FastScrollerBuilder
on subsequent calls; update setControlsColorForAllViews to call addFastScroll
without causing repeated rebuilds. Also fix useColoredStyle’s inconsistent
null-safety by replacing the non-null assertion on the track drawable with a
safe call and conditional handling (mirror the thumb drawable’s ?.let pattern)
to avoid potential crashes when drawables are missing.

---

Nitpick comments:
In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt`:
- Line 701: Remove the unused top-level variable `counter` declared in
UiExtensions.kt (the `var counter = 0` line); search for any references to
`counter` to confirm it's unused and then delete the declaration (or replace
with the intended implementation if it was meant to be used), ensuring no
remaining dead code or unused imports remain in the file.
- Around line 1001-1015: The useColoredStyle extension inconsistently
force-unwraps the track drawable with ContextCompat.getDrawable(... )!!; change
it to handle null defensively like the thumb drawable: retrieve the track with
ContextCompat.getDrawable(context, R.drawable.scroll_track) and only call
setTrackDrawable(...) when the result is non-null (e.g., using ?.let) or provide
a clear fallback drawable/resource before calling setTrackDrawable; update
FastScrollerBuilder.useColoredStyle to use that safe pattern.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 935915e2-a12f-406d-bb04-8c8e38cb9477

📥 Commits

Reviewing files that changed from the base of the PR and between 19c66c1 and e2db8f9.

📒 Files selected for processing (4)
  • app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
  • app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditActivity.kt
  • app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditNoteActivity.kt
  • app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditTextPlainActivity.kt

@Crustack Crustack changed the title Correctly update action and scrollbar colors Correctly update action and scrollbar and reminders colors Mar 8, 2026
Copy link
Contributor

@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.

♻️ Duplicate comments (1)
app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt (1)

1011-1013: ⚠️ Potential issue | 🟠 Major

Make fast-scroll installation idempotent.

setControlsColorForAllViews() can hit this helper multiple times for the same FastScrollNestedScrollView, and this implementation always creates a new FastScrollerBuilder(...).build(). That can stack multiple fast scrollers/listeners when note colors are reapplied.

Run this to confirm the recursive recolor path reaches an unguarded build() call:

#!/bin/bash
sed -n '704,729p' app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
printf '\n---\n'
sed -n '1011,1029p' app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt` around
lines 1011 - 1013, The addFastScroll helper creates a new FastScroller every
time and can be invoked repeatedly by setControlsColorForAllViews, stacking
listeners; modify addFastScroll(ViewGroup.addFastScroll) to be idempotent by
checking for and returning early if a marker is present (e.g.,
view.getTag(KEY_FAST_SCROLL_INSTALLED) or a boolean property on the
FastScrollNestedScrollView child) before calling
FastScrollerBuilder(...).useColoredStyle(...).build(), and after a successful
build set that same marker on the ViewGroup (or on the
FastScrollNestedScrollView child) so subsequent calls skip building again.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt`:
- Around line 1011-1013: The addFastScroll helper creates a new FastScroller
every time and can be invoked repeatedly by setControlsColorForAllViews,
stacking listeners; modify addFastScroll(ViewGroup.addFastScroll) to be
idempotent by checking for and returning early if a marker is present (e.g.,
view.getTag(KEY_FAST_SCROLL_INSTALLED) or a boolean property on the
FastScrollNestedScrollView child) before calling
FastScrollerBuilder(...).useColoredStyle(...).build(), and after a successful
build set that same marker on the ViewGroup (or on the
FastScrollNestedScrollView child) so subsequent calls skip building again.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b378ffb6-69d9-4ce8-b86f-85ae0a6af725

📥 Commits

Reviewing files that changed from the base of the PR and between e2db8f9 and 0fc4be5.

📒 Files selected for processing (3)
  • app/src/main/java/com/philkes/notallyx/presentation/UiExtensions.kt
  • app/src/main/java/com/philkes/notallyx/presentation/activity/note/EditActivity.kt
  • app/src/main/java/com/philkes/notallyx/presentation/view/main/BaseNoteVH.kt

@Crustack Crustack merged commit dde6d3d into main Mar 8, 2026
1 check passed
@Crustack Crustack deleted the fix/901 branch March 8, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some icons are barely visible in dark mode

1 participant