-
Notifications
You must be signed in to change notification settings - Fork 58
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 #951 from wordpress-mobile/release/1.4.0
Release/1.4.0
- Loading branch information
Showing
17 changed files
with
296 additions
and
175 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule gutenberg
updated
12 files
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
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
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
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
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
71 changes: 71 additions & 0 deletions
71
...ztec/android/src/main/kotlin/org/wordpress/mobile/ReactNativeAztec/EnterPressedWatcher.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,71 @@ | ||
package org.wordpress.mobile.ReactNativeAztec | ||
|
||
import android.text.Editable | ||
import android.text.SpannableStringBuilder | ||
import android.text.Spanned | ||
import android.text.TextWatcher | ||
import org.wordpress.aztec.AztecText | ||
import org.wordpress.aztec.Constants | ||
import java.lang.ref.WeakReference | ||
|
||
// Class to be used as a span to temporarily denote that Enter was detected | ||
class EnterPressedUnderway | ||
|
||
interface EnterDeleter { | ||
fun shouldDeleteEnter(): Boolean | ||
} | ||
|
||
class EnterPressedWatcher(aztecText: AztecText, var enterDeleter: EnterDeleter) : TextWatcher { | ||
|
||
private val aztecTextRef: WeakReference<AztecText?> = WeakReference(aztecText) | ||
private lateinit var textBefore : SpannableStringBuilder | ||
private var start: Int = -1 | ||
private var selStart: Int = 0 | ||
private var selEnd: Int = 0 | ||
var done = false | ||
|
||
override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) { | ||
val aztecText = aztecTextRef.get() | ||
if (aztecText?.getAztecKeyListener() != null && !aztecText.isTextChangedListenerDisabled()) { | ||
// we need to make a copy to preserve the contents as they were before the change | ||
textBefore = SpannableStringBuilder(text) | ||
this.start = start | ||
this.selStart = aztecText.selectionStart | ||
this.selEnd = aztecText.selectionEnd | ||
} | ||
} | ||
|
||
override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) { | ||
val aztecText = aztecTextRef.get() | ||
val aztecKeyListener = aztecText?.getAztecKeyListener() | ||
if (aztecText != null && !aztecText.isTextChangedListenerDisabled() && aztecKeyListener != null) { | ||
val newTextCopy = SpannableStringBuilder(text) | ||
// if new text length is longer than original text by 1 | ||
if (textBefore?.length == newTextCopy.length - 1) { | ||
// now check that the inserted character is actually a NEWLINE | ||
if (newTextCopy[this.start] == Constants.NEWLINE) { | ||
done = false | ||
aztecText.editableText.setSpan(EnterPressedUnderway(), 0, 0, Spanned.SPAN_USER) | ||
aztecKeyListener.onEnterKey(newTextCopy.replace(this.start, this.start+1, ""), true, selStart, selEnd) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun afterTextChanged(text: Editable) { | ||
aztecTextRef.get()?.editableText?.getSpans(0, 0, EnterPressedUnderway::class.java)?.forEach { | ||
if (!done) { | ||
done = true | ||
if (enterDeleter.shouldDeleteEnter()) | ||
text.replace(start, start + 1, "") | ||
} | ||
aztecTextRef.get()?.editableText?.removeSpan(it) | ||
} | ||
} | ||
|
||
companion object { | ||
fun isEnterPressedUnderway(spanned: Spanned?): Boolean { | ||
return spanned?.getSpans(0, 0, EnterPressedUnderway::class.java)?.isNotEmpty() ?: false | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
github "wordpress-mobile/AztecEditor-iOS" "1.6.0" | ||
github "wordpress-mobile/AztecEditor-iOS" "1.6.1" |
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 |
---|---|---|
@@ -1 +1 @@ | ||
github "wordpress-mobile/AztecEditor-iOS" "1.6.0" | ||
github "wordpress-mobile/AztecEditor-iOS" "1.6.1" |
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
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
Oops, something went wrong.