-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix a crash which happens when user shakes the phone #ANDROID-15102 #43
Conversation
@@ -94,14 +96,18 @@ open class Tweaks : TweaksContract { | |||
@Composable | |||
fun NavController.navigateToTweaksOnShake() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature depends on a NavController, although in some cases we might not have a NavController.
In B2P we have this launched effect that does not depend on it, and also allows a custom action to launch the tweaks:
I think this approach would be very helpful to open tweaks from the command line into a different activity (same as SmartWifi does)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created another function which does not depends on navcontroller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Thanks!
@Composable | ||
fun NavController.navigateToTweaksOnShake() { | ||
DetectShakeAndNavigate { | ||
navigate(TWEAKS_NAVIGATION_ENTRYPOINT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can set this as default value for onOpenTweaks
and leave only one method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I can, because navigate is callable only within the NavController scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see, one method depends on the NavController and the other one doesn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
🥅 What's the goal?
Fix a crash which happens when user shakes the phone, tweaks activity is shown, goes back and then shakes again.
🚧 How do we do it?
📘 Documentation changes?
🧪 How can I test this?
4_5985619573649446339.mp4
4_5985619573649446337.mp4