-
Notifications
You must be signed in to change notification settings - Fork 116
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/ime iob fix #834
Fix/ime iob fix #834
Changes from 2 commits
929eaf4
0ca13ce
d20fb85
2169aff
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.wordpress.aztec.ime | ||
|
||
import android.os.Build | ||
import android.view.inputmethod.EditorInfo | ||
import java.util.Arrays | ||
|
||
object EditorInfoUtils { | ||
@JvmStatic | ||
fun areEditorInfosTheSame(ed1: EditorInfo, ed2: EditorInfo): Boolean { | ||
if (ed1 == ed2) { | ||
mkevins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true | ||
} | ||
|
||
if (ed1.actionId == ed2.actionId | ||
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. np: Perhaps some comments here can be helpful to provide context on this comparison |
||
&& (ed1.actionLabel != null && ed1.actionLabel.equals(ed2.actionLabel) || ed1.actionLabel == null && ed2.actionLabel == null) | ||
&& ed1.inputType == ed2.inputType | ||
&& ed1.imeOptions == ed2.imeOptions | ||
&& (ed1.privateImeOptions != null && ed1.privateImeOptions.equals(ed2.privateImeOptions) || ed1.privateImeOptions == null && ed2.privateImeOptions == null) | ||
&& ed1.initialSelStart == ed2.initialSelStart | ||
&& ed1.initialSelEnd == ed2.initialSelEnd | ||
&& ed1.initialCapsMode == ed2.initialCapsMode | ||
&& ed1.fieldId == ed2.fieldId | ||
) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { | ||
// specific comparisons here | ||
if (ed1.contentMimeTypes != null && ed2.contentMimeTypes != null) { | ||
return Arrays.equals(ed1.contentMimeTypes, ed2.contentMimeTypes) | ||
} | ||
} | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
@JvmStatic | ||
fun copyEditorInfo(ed1: EditorInfo) : EditorInfo { | ||
val copy = EditorInfo() | ||
copy.actionId = ed1.actionId | ||
copy.actionLabel = ed1.actionLabel?.toString() | ||
copy.inputType = ed1.inputType | ||
copy.imeOptions = ed1.imeOptions | ||
copy.privateImeOptions = ed1.privateImeOptions?.toString() | ||
copy.initialSelStart = ed1.initialSelStart | ||
copy.initialSelEnd = ed1.initialSelEnd | ||
copy.initialCapsMode = ed1.initialCapsMode | ||
copy.fieldId = ed1.fieldId | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { | ||
// specific comparisons here | ||
if (ed1.contentMimeTypes != null) { | ||
copy.contentMimeTypes = Arrays.copyOf(ed1.contentMimeTypes, ed1.contentMimeTypes.size) | ||
} | ||
} | ||
return copy | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,9 @@ class CssUnderlinePlugin : ISpanPostprocessor, ISpanPreprocessor { | |
if (hiddenSpan.TAG == SPAN_TAG) { | ||
val parentStyle = hiddenSpan.attributes.getValue(CssStyleFormatter.STYLE_ATTRIBUTE) | ||
val childStyle = calypsoUnderlineSpan.attributes.getValue(CssStyleFormatter.STYLE_ATTRIBUTE) | ||
hiddenSpan.attributes.setValue(CssStyleFormatter.STYLE_ATTRIBUTE, CssStyleFormatter.mergeStyleAttributes(parentStyle, childStyle)) | ||
if (parentStyle != null && childStyle != null) { | ||
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. Is this part of the InputConnection issue, or solely part of #832 and just bundled with this PR? 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. 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. Ah, makes sense. 😄 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. Now that the PR has been reverted, the guard here also got reverted. So, #831 got opened again but I think it makes sense to re-address it on its own now. Can you wrangle that @mkevins ? 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. My understanding is that this particular commit was included in both #832, and #834, and was accidentally reverted in the revert of #834, so we need to revert the revert. Does that match your understanding @hypest ? I've created this branch here: https://github.com/wordpress-mobile/AztecEditor-Android/compare/issue/831-css-underline-illegal-state-revert-revert, but so far I've not been successful in reproducing the issue on develop using the monkeys ( 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.
Heh, I wouldn't just call it "revert the revert" anymore as it's not clear if it would bring back other things besides the guard but, judging from the branch you shared I'd say that yeah, re-instating the guard is the goal. 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.
From what I recall, there weren't steps to reliably reproduce the crash, not sure if @mzorz has a better recollection on this. 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. 👋 ok been looking into this, this is how it goes: the reverted code made this issue reappear #831, and #832 has the fix we need to re-apply so, basically adding that check back will prevent the crash from happening (that means it is my understanding @mkevins 's branch has the correct code to re-apply the condition check 👍 ). |
||
hiddenSpan.attributes.setValue(CssStyleFormatter.STYLE_ATTRIBUTE, CssStyleFormatter.mergeStyleAttributes(parentStyle, childStyle)) | ||
} | ||
|
||
// remove the extra child span | ||
spannable.removeSpan(calypsoUnderlineSpan) | ||
|
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 wonder if we should keep a
WeakReference
to those objects. These are objects used deeply withing the Android editing subsystem and I'm not sure if we'll introduce other bugs if we keep strong references to them. WDYT?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.
good call, updated the
inputConnection
to use aWeakReference
in d20fb85.The
var inputConnectionEditorInfo
is an actual new instance that copies the attributes values by value on this line so, left as it was 👍