-
-
Notifications
You must be signed in to change notification settings - Fork 25
ADFA-4051: Invisible symbol input view #1358
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
base: stage
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -354,7 +354,7 @@ constructor( | |||||
| } | ||||||
|
|
||||||
| private fun applyPeekHeight() { | ||||||
| behavior.peekHeight = if (isImeVisible || isSearchModeActive) 0 else collapsedHeight.toInt() | ||||||
| behavior.peekHeight = if (isSearchModeActive) 0 else collapsedHeight.toInt() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use The code uses 🔧 Proposed fix- behavior.peekHeight = if (isSearchModeActive) 0 else collapsedHeight.toInt()
+ behavior.peekHeight = if (isSearchModeActive) 0 else collapsedHeight.roundToInt()📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } | ||||||
|
|
||||||
| fun setOffsetAnchor(view: View) { | ||||||
|
|
||||||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 9661
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 111
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 10983
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 5010
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 690
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 1787
🌐 Web query:
com.blankj.utilcode.util.KeyboardUtils.isSoftInputVisible Activity signature ContextThemeWrapper ClassCastException💡 Result:
There is no evidence (in the sources I found) that Blankj utilcode’s KeyboardUtils.isSoftInputVisible(Activity) has an “Activity signature ContextThemeWrapper ClassCastException”. Instead, the isSoftInputVisible implementation is type-safe in that it only accepts an Activity parameter and uses activity.getWindow/getDecorView—it does not cast a Context to Activity inside the method. 1) What Blankj’s code actually does - KeyboardUtils.isSoftInputVisible(
@NonNullActivity activity) returns getDecorViewInvisibleHeight(activity.getWindow) > 0. [1] - getDecorViewInvisibleHeight(Window window) uses window.getDecorView, then decorView.getWindowVisibleDisplayFrame(outRect) and computes a delta from the decor view vs the visible frame. [1] So, within this implementation, there is no cast from ContextThemeWrapper (or any Context wrapper) to Activity. [1] 2) Why you might see ClassCastException involving ContextThemeWrapper + keyboard code - A ClassCastException like “android.view.ContextThemeWrapper cannot be cast to android.app.Activity” is a known pattern when code mistakenly does (Activity) getContext, but getContext is actually a ContextThemeWrapper rather than an Activity. - In React Native, keyboard visibility detection code in ReactRootView previously cast getContext directly to Activity, and the fix unwrapped the context using ContextWrapper.getBaseContext before casting. [2][3] This shows the general cause of the “ContextThemeWrapper -> Activity cast” failure is incorrect casting of an arbitrary Context; it is not an intrinsic issue with Blankj’s isSoftInputVisible(Activity) implementation. [2][3] 3) Android-soft-keyboard visibility detection guidance - Android’s official docs for keyboard/input-method visibility note that keyboard visibility behavior depends on window/view focus and windowSoftInputMode / flags, and recommends using InputMethodManager when you need to show it reliably. [4] This is consistent with the fact that any keyboard-visibility helper may produce incorrect results if it’s invoked with the wrong window/view state. [4] What to do if you are crashing - If you call KeyboardUtils.isSoftInputVisible(...) with something that is not actually an Activity (for example, passing view.getContext instead of the Activity), you can get crashes elsewhere in your stack. Ensure you pass a real Activity instance. - If you are using a framework view (e.g., React Native) that contains its own keyboard detection, check for code that casts getContext to Activity; apply the same pattern used in React Native’s fix: unwrap via ContextWrapper.getBaseContext (or use a safer way to obtain the owning Activity) before casting. [2][3] Top relevant sources: [1] https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/src/main/java/com/blankj/utilcode/util/KeyboardUtils.java [2] facebook/react-native@f7e35d4 [3] facebook/react-native#36121 [4] https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibilityCitations:
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 195
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 290
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 928
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 50
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 249
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 1920
🏁 Script executed:
Repository: appdevforall/CodeOnTheGo
Length of output: 3134
Avoid the unsafe
contentBinding.root.context as Activitycast inFullscreenManager.applyFullscreen.FullscreenManager.applyFullscreencasts the view context (contentBinding.root.context) toActivityto callKeyboardUtils.isSoftInputVisible(...). Since the view is inflated viaBaseIDEActivity(anAppCompatActivity) andActivityEditorBinding.inflate(layoutInflater),root.contextcan be aContextThemeWrapper, making this cast a potentialClassCastException. Unwrap the context chain (or pass the owning activity) before callingKeyboardUtils.🛡️ Proposed fix to safely resolve the Activity
Add
import android.content.ContextWrapperif you adopt this.📝 Committable suggestion
🤖 Prompt for AI Agents