Skip to content

Conversation

@gladiuscode
Copy link
Owner

Goal

This PR fixes #58 that currently affect the library, specifically: when the user disables the auto rotation feature, the system prompts the user with an helpful icon that the user can tap to manually rotate the interface to the desired orientation, based on the last device orientation.
This means tho, that currently we don't intercept it and do not update the interface accordingly.

This PR implements a new Broadcast Receiver that intercepts the MainActivity.onConfigurationChanged call through a custom explicit intent.
It also means that the developer has to update its MainActivity with the following onConfigurationChanged override:

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)

    val orientationDirectorCustomAction =
      "${packageName}.${ConfigurationChangedBroadcastReceiver.CUSTOM_INTENT_ACTION}"

    val intent =
      Intent(orientationDirectorCustomAction).apply {
        putExtra("newConfig", newConfig)
        setPackage(packageName)
      }

    this.sendBroadcast(intent)
}

Note: on Expo, this android setup is handled by the plugin.

Useful Links

@gladiuscode gladiuscode linked an issue Mar 16, 2025 that may be closed by this pull request
@gladiuscode gladiuscode self-assigned this Mar 16, 2025
@gladiuscode gladiuscode added enhancement New feature or request Android Android only bug Something isn't working labels Mar 16, 2025
@gladiuscode gladiuscode marked this pull request as ready for review March 23, 2025 13:18
@gladiuscode gladiuscode merged commit 9c93d94 into main Mar 23, 2025
5 checks passed
@gladiuscode gladiuscode deleted the fix/interface-orientation-listener-not-working-with-manual-rotation branch April 7, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android Android only bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] listenForInterfaceOrientationChanges not firing

2 participants