Status Update
Comments
ag...@google.com <ag...@google.com> #2
ze...@google.com <ze...@google.com> #3
Same here. I need to do a custom action when pressing back when the modal is open. This is related to
ze...@google.com <ze...@google.com> #4
Branch: androidx-main
commit 90075b00a1b5e5ebd24fb8c03f8a3fc2a7c72e98
Author: Kevin Truong <kevinctruong@google.com>
Date: Wed Oct 04 16:06:44 2023
[BottomSheet] Adding ModalBottomSheetProperties class
Adding a ModalBottomSheetProperties that contains securePolicy, isFocuable, and shouldDismissOnBackPress. securePolicy is taken from the ModalBottomSheet API and placed into this class for neatness.
isFocusable and shouldDismissOnBackPress are parameters that can be used to determine if the modal bottom sheet should receive IME events, and shouldDismissOnBackPress determines if the modal bottom sheet should dismiss when back is pressed on the IME. These parameters are ported from PopupProperties and the implementation is very similar to their usage within Popup.
Bug: 278216859
Test: Updating modalBottomSheet_imePadding test to use the isFocusable parameter, so the text field within the modal bottom sheet can receive focus.
Relnote: adding ModalBottomSheetProperties. Moving securePolicy into ModalBottomSheetProperties. Adding isFocusable and shouldDismissOnBackPress to ModalBottomSheetProperties. These new booleans help determine how modal bottom sheet should handle IME events.
Change-Id: Iea56ff84fd2f8a70037607e8aef0ceaf7a47e3d0
M compose/material3/material3/api/current.txt
M compose/material3/material3/api/restricted_current.txt
M compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/ModalBottomSheetTest.kt
M compose/material3/material3/src/androidMain/kotlin/androidx/compose/material3/ModalBottomSheet.android.kt
ap...@google.com <ap...@google.com> #5
Any chance for a release including this fix soon?
da...@clevertap.com <da...@clevertap.com> #6
ag...@google.com <ag...@google.com> #7
There’s already a dedicated issue about the back not working when android:enableOnBackInvokedCallback=“true”
is set:
It seems like it’s blocked by a general lack of predictive back support in Compose, though:
ap...@google.com <ap...@google.com> #8
ap...@google.com <ap...@google.com> #9
I've tried androidx.compose.material3:material3:1.2.0-beta01
and I believe it's still not working. BackHandler {}
is not called inside ModalBottomSheet
, the sheet is closing instead.
ze...@google.com <ze...@google.com> #10
Any ideas on why this is marked as fixed?
da...@clevertap.com <da...@clevertap.com> #11
ze...@google.com <ze...@google.com>
ms...@gmail.com <ms...@gmail.com> #12
The fix wasn't to support BackHandler {}
. They just added a new properties
arg that you can set whether the sheet should be dismissed on back or not:
ModalBottomSheet(
...
properties = ModalBottomSheetDefaults.properties(shouldDismissOnBackPress = /* boolean goes here */),
...
)
Since the sheet is in a separate window, I'm afraid this might be the best they can do. That's pretty similar to the API of dialogs, which also have their own window:
Dialog(
...
properties = DialogProperties(dismissOnBackPress = /* boolean goes here */),
...
)
But of course the APIs aren't super consistent 😅
ch...@google.com <ch...@google.com> #13
ms...@gmail.com <ms...@gmail.com> #14
The bug as it's stated in the title and the snippet still exists despite the "fix": it remains impossible to use a BackHandler
inside a ModalBottomSheet.
Some thoughts after looking at the code: somehow the ModalBottomSheetWindow
needs to implement a OnBackPressedDispatcherOwner
and delegate to it when back is pressed (in dispatchKeyEvent
), instead of directly calling onDismissRequest like it does today (material3 version 1.2.0).
I note that the "ModalBottomSheetWindow" is actually a View
, not a Window
-- perhaps that's why this is not trivial to fix.
Knowing the code doesn't give me a good idea for a workaround though...
Description
01-15 16:28:34.556 28244 28244 E AndroidRuntime: FATAL EXCEPTION: main
01-15 16:28:34.556 28244 28244 E AndroidRuntime: Process: com.example.clevertapverifyerror, PID: 28244
01-15 16:28:34.556 28244 28244 E AndroidRuntime: java.lang.VerifyError: Verifier rejected class com.clevertap.android.sdk.InAppFCManager: int[] com.clevertap.android.sdk.InAppFCManager.getInAppCountsFromPersistentStore(java.lang.String) failed to verify: int[]
AppFCManager.getInAppCountsFromPersistentStore(java.lang.String): [0x3B] register v2 has type Conflict but expected Integer (declaration of 'com.clevertap.android.sdk.InAppFCManager' appears in /data/app/com.example.clevertapverifyerror-2/base.apk)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at com.clevertap.android.sdk.CleverTapAPI.<init>(CleverTapAPI.java:225)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at com.clevertap.android.sdk.CleverTapAPI.instanceWithConfig(CleverTapAPI.java:524)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at com.clevertap.android.sdk.CleverTapAPI.getDefaultInstance(CleverTapAPI.java:502)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at com.example.clevertapverifyerror.MainActivity.onCreate(MainActivity.java:16)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6915)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.ActivityThread.-wrap12(ActivityThread.java)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.os.Looper.loop(Looper.java:156)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6523)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
01-15 16:28:34.556 28244 28244 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
01-15 16:28:34.558 1291 3061 W ActivityManager: Force finishing activity com.example.clevertapverifyerror/.MainActivity
Downgrading to 3.2.1 fixes the issue.