Skip to content

Fix Deprecation Warnings Without Suppression - #186

Closed
mmdparsa-dev wants to merge 3 commits into
MrDemonc:mainfrom
mmdparsa-dev:main
Closed

mmdparsa-dev wants to merge 3 commits into
MrDemonc:mainfrom
mmdparsa-dev:main

Conversation

@mmdparsa-dev

Copy link
Copy Markdown
Contributor

Hi, I made some changes

  • I replaced deprecated apis with new methods
  • Improving Compatibility with different Androids
  • Management of background services, audio focus, external storage, vibration and interaction with windows and system bars
  • Remove duplicate code and outdated unnecessary implementations
  • Removing redundant @Suppress("DEPRECATION") annotations and reducing compiler warnings

MrDemonc added a commit that referenced this pull request Nov 5, 2026
@MrDemonc

MrDemonc commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hi @mmdparsa-dev,

Thank you very much for taking the time to contribute to Lune and for your efforts to clean up deprecation warnings!       

After reviewing the changes, we cannot merge this pull request as is. Replacing direct legacy API calls with Java          
Reflection (`getMethod().invoke()`) or using magic numbers (such as `0x10`) to bypass compiler deprecation warnings is an  
anti-pattern:
- It introduces runtime reflection overhead and removes compile-time type safety.
- It can cause unexpected issues or crashes with R8 / code shrinking.
- Under Android & Kotlin best practices, using `@Suppress("DEPRECATION")` inside version-gated branches (`if
(Build.VERSION.SDK_INT < ...)`) is the intended and documented way to maintain backward compatibility for older API levels.

However, several of your suggestions were very valuable, so we have manually adopted them into `main`:
1. Using AndroidX's `IntentCompat.getParcelableExtra` for media key events in `MusicService`.
2. Simplifying `stopForeground` calls to `stopForeground(STOP_FOREGROUND_REMOVE)` since our `minSdk` is 24 (Android N).    
3. Removing redundant `Build.VERSION_CODES.N` checks in `FolderBrowserActivity`.
4. Consolidating vibration handling with `triggerLightVibration()`, including the `Oreo` (API 26+)
`VibrationEffect.createOneShot` branch.

We really appreciate your initiative and help in improving the codebase! Closing this PR as the valid improvements have now
been incorporated directly.

@MrDemonc MrDemonc closed this Nov 5, 2026
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