Skip to content

feat: Add QAM display brightness control#1525

Open
xXJSONDeruloXx wants to merge 3 commits into
utkarshdalal:masterfrom
xXJSONDeruloXx:feat/qam-device-sliders
Open

feat: Add QAM display brightness control#1525
xXJSONDeruloXx wants to merge 3 commits into
utkarshdalal:masterfrom
xXJSONDeruloXx:feat/qam-device-sliders

Conversation

@xXJSONDeruloXx

@xXJSONDeruloXx xXJSONDeruloXx commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a transient Display brightness slider to QAM screen effects for adjusting the current app window brightness.

prevents the annoying android paradigm of swiping multiple times to show status bar then pull notification shade then expand shade then finally move brightness slider, this way it can be controller driven and done in very few presses.

Recording

gamenative-qam-brightness

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Add a display brightness slider to the QAM Screen Effects panel to adjust the current app window’s brightness in real time. Values snap to 5% steps (5%–100%) and only affect the active window, not system brightness.

  • New Features
    • New “Display brightness” row at the top of Screen Effects in both tab variants; first focusable item for quick access.
    • Reads the initial value from the window; falls back to the system setting if needed.
    • Applies per-window changes via BrightnessManager with 5% snapping, safe Activity detection, and clamping.
    • Adds the display_brightness string with translations across supported locales.

Written for commit 0b7c54e. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Display brightness control added to the Screen Effects settings panel for direct in-app adjustment.
    • Brightness slider positioned at the top of the effects menu for faster access and initial focus.
    • Localized UI text for the brightness control added across 16+ languages for broader language support.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff44da89-25f8-4944-9296-84190ba8bd14

📥 Commits

Reviewing files that changed from the base of the PR and between f9faf24 and 0b7c54e.

📒 Files selected for processing (2)
  • app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt
  • app/src/main/java/app/gamenative/utils/BrightnessManager.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/app/gamenative/utils/BrightnessManager.kt

📝 Walkthrough

Walkthrough

Adds a display brightness adjustment control to the screen effects panel, extends BrightnessManager with activity lookup/read/snap/apply helpers, places a new DisplayBrightnessRow composable at the top of GL and Vulkan tabs, and adds localized display_brightness string resources.

Changes

Display Brightness Control

Layer / File(s) Summary
BrightnessManager utilities and constants
app/src/main/java/app/gamenative/utils/BrightnessManager.kt
BrightnessManager companion object extended with imports, public brightness constants and utility functions: findActivity() for Activity lookup, snapDisplayBrightness() for step snapping and clamping, readDisplayBrightness() reading from window attributes with system-settings fallback, and applyDisplayBrightness() applying clamped brightness to Activity windows.
DisplayBrightnessRow composable
app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt
New private DisplayBrightnessRow composable added; uses LocalContext and BrightnessManager to read/apply display brightness, applies snapping on changes, and renders percent label plus normalized progress. Imports updated (LocalContext, BrightnessManager, roundToInt).
Integration into GL and Vulkan tabs
app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt
DisplayBrightnessRow inserted as the first item in GLScreenEffectsTabContent and the Vulkan variant; initial focus requester moved from the "scaling mode none" radio row onto the brightness row.
Localized string resources
app/src/main/res/values/strings.xml, app/src/main/res/values-*/strings.xml
Added display_brightness string resource to default and multiple locale-specific values-*.xml files to provide UI label translations for the new brightness control.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • utkarshdalal
  • phobos665

Poem

🐇 I nudged a slider, small and bright,
Steps that snap and keep things right,
GL and Vulkan now both glow,
Percent ticks steady, soft and slow,
A rabbit cheers — adjust the light!

🚥 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
Title check ✅ Passed The title accurately describes the main change: adding a display brightness control feature to the QAM (Quick Access Menu) screen effects panel.
Description check ✅ Passed The description covers all required template sections: clear explanation of the change, attached recording/screenshot, identified change type (Other), and completed checklist items confirming discussion approval and project alignment.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@xXJSONDeruloXx xXJSONDeruloXx changed the title Add QAM display brightness control feat: Add QAM display brightness control Jun 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt (1)

157-159: ⚡ Quick win

Consider guarding against null activity for better UX.

When findActivity returns null (line 157), the brightness controls still render but have no effect: setDisplayBrightness updates local state (line 164) but the activity?.let at line 165 prevents any actual brightness change. This creates a confusing UX where the slider appears interactive but does nothing.

While activity should rarely be null in normal Compose UI contexts, consider either:

  • Not rendering the row when activity is null
  • Showing a disabled/grayed-out state
  • Adding a brief log or comment explaining the fallback behavior
Example: skip rendering when activity is null
 `@Composable`
 private fun DisplayBrightnessRow(
     focusRequester: FocusRequester? = null,
 ) {
     val context = LocalContext.current
     val activity = remember(context) { BrightnessManager.findActivity(context) }
+    
+    // Don't render brightness controls if we can't find an Activity to control
+    if (activity == null) return
+    
     var displayBrightness by remember(activity) {
-        mutableFloatStateOf(activity?.let(BrightnessManager::readDisplayBrightness) ?: 0.5f)
+        mutableFloatStateOf(BrightnessManager.readDisplayBrightness(activity))
     }

     fun setDisplayBrightness(value: Float) {
         val next = BrightnessManager.snapDisplayBrightness(value)
         displayBrightness = next
-        activity?.let { BrightnessManager.applyDisplayBrightness(it, next) }
+        BrightnessManager.applyDisplayBrightness(activity, next)
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt` around
lines 157 - 159, The brightness slider currently renders even when
BrightnessManager.findActivity(context) returns null, so setDisplayBrightness
updates local displayBrightness but
activity?.let(BrightnessManager::setDisplayBrightness) is skipped; update
ScreenEffectsPanel to guard on the activity from remember(context) {
BrightnessManager.findActivity(context) }—either skip rendering the brightness
Row entirely when activity is null, or render it in a disabled/greyed-out state
(disable the Slider and related controls) and reflect that in displayBrightness
state; also add a brief log or comment near BrightnessManager.findActivity and
where setDisplayBrightness is called to document the fallback behavior so UX is
not misleading.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/main/java/app/gamenative/utils/BrightnessManager.kt`:
- Around line 57-71: The readDisplayBrightness(Activity) function reads UI state
via activity.window.attributes and must be executed on Android's main thread;
add the `@MainThread` annotation to the readDisplayBrightness method (the same
annotation already used on applyDisplayBrightness) so the compiler/lint enforce
main-thread usage and keep consistency in BrightnessManager; ensure you import
androidx.annotation.MainThread if not already imported.

---

Nitpick comments:
In `@app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt`:
- Around line 157-159: The brightness slider currently renders even when
BrightnessManager.findActivity(context) returns null, so setDisplayBrightness
updates local displayBrightness but
activity?.let(BrightnessManager::setDisplayBrightness) is skipped; update
ScreenEffectsPanel to guard on the activity from remember(context) {
BrightnessManager.findActivity(context) }—either skip rendering the brightness
Row entirely when activity is null, or render it in a disabled/greyed-out state
(disable the Slider and related controls) and reflect that in displayBrightness
state; also add a brief log or comment near BrightnessManager.findActivity and
where setDisplayBrightness is called to document the fallback behavior so UX is
not misleading.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: eb37c767-a8af-4047-a65c-44933e91dff5

📥 Commits

Reviewing files that changed from the base of the PR and between 7b02172 and ad0be3a.

📒 Files selected for processing (3)
  • app/src/main/java/app/gamenative/ui/component/ScreenEffectsPanel.kt
  • app/src/main/java/app/gamenative/utils/BrightnessManager.kt
  • app/src/main/res/values/strings.xml

Comment thread app/src/main/java/app/gamenative/utils/BrightnessManager.kt

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 17 files

Re-trigger cubic

@phobos665 phobos665 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

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.

2 participants