-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #834 from wordpress-mobile/fix/ime-iob-fix
Fix/ime iob fix
- Loading branch information
Showing
3 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
aztec/src/main/kotlin/org/wordpress/aztec/ime/EditorInfoUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
return true | ||
} | ||
|
||
if (ed1.actionId == ed2.actionId | ||
&& (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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters