Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expands documentation for AmbientAware, adds support for AmbientDetails #1674

Merged
merged 6 commits into from
Sep 13, 2023

Conversation

garanj
Copy link
Collaborator

@garanj garanj commented Sep 13, 2023

WHAT

Provides further guidance on using AmbientAware and adds support for AmbientDetails

WHY

Using the AmbientAware composable changes the behavior of the Activity, so should ideally be used high up in the composable tree. This needs clarifying in the documentation.

AmbientDetails are provided by the system when entering ambient mode, and can be used by the app to make decisions about how to render the UI.

HOW

Updates kdoc and adds AmbientDetails as a property of the Ambient state.

Checklist 📋

  • [ x] Add explicit visibility modifier and explicit return types for public declarations
  • [ x] Run spotless check
  • [ x] Run tests
  • [ x] Update metalava's signature text files

@garanj garanj requested a review from yschimke September 13, 2023 11:17
}

override fun onUpdateAmbient() {
ambientUpdate = AmbientStateUpdate(AmbientState.AMBIENT)
ambientUpdate = AmbientStateUpdate(AmbientState.Ambient())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we retain the previous value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I wondered about that, do these things change? I will add it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's about them changing, I think more about having immediate access to it via this type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added. Unfortunately, there still remains the chance of it being null, if the device is already in ambient, so onEnterAmbient has not been called. I don't think this seems very likely in practice?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure, we should test. If it's the case we should push it up to the Activity, out of the composition?

Or accept it can be null?

@garanj
Copy link
Collaborator Author

garanj commented Sep 13, 2023

@yschimke - modified to remove the need for the extra field for the last ambient details.

garanj and others added 2 commits September 13, 2023 13:32
…pose/ambient/AmbientAware.kt

Co-authored-by: Yuri Schimke <yuri@schimke.ee>
@garanj garanj merged commit 4f1a5b3 into main Sep 13, 2023
@garanj garanj deleted the ambient-2 branch September 13, 2023 13:08
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