@@ -88,7 +88,8 @@ import org.wordpress.aztec.util.AztecLog
8888import org.wordpress.aztec.util.SpanWrapper
8989import org.wordpress.aztec.util.coerceToHtmlText
9090import org.wordpress.aztec.watchers.BlockElementWatcher
91- import org.wordpress.aztec.watchers.DeleteMediaElementWatcher
91+ import org.wordpress.aztec.watchers.DeleteMediaElementWatcherAPI25AndHigher
92+ import org.wordpress.aztec.watchers.DeleteMediaElementWatcherPreAPI25
9293import org.wordpress.aztec.watchers.EndOfBufferMarkerAdder
9394import org.wordpress.aztec.watchers.EndOfParagraphMarkerAdder
9495import org.wordpress.aztec.watchers.FullWidthImageElementWatcher
@@ -445,7 +446,11 @@ class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknownHtmlT
445446 EndOfBufferMarkerAdder .install(this )
446447 ZeroIndexContentWatcher .install(this )
447448
448- DeleteMediaElementWatcher .install(this )
449+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N_MR1 ) {
450+ DeleteMediaElementWatcherAPI25AndHigher .install(this )
451+ } else {
452+ DeleteMediaElementWatcherPreAPI25 .install(this )
453+ }
449454
450455 // History related logging has to happen before the changes in [ParagraphCollapseRemover]
451456 addHistoryLoggingWatcher()
@@ -852,6 +857,13 @@ class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknownHtmlT
852857 return (observationQueue.hasActiveBuckets() && ! bypassObservationQueue && (watchersNestingLevel == 1 ))
853858 }
854859
860+ fun isObservationQueueBeingPopulated () : Boolean {
861+ // TODO: use the value that is going to be published from ObservationQueue.MAXIMUM_TIME_BETWEEN_EVENTS_IN_PATTERN_MS
862+ val MAXIMUM_TIME_BETWEEN_EVENTS_IN_PATTERN_MS = 100
863+ return ! observationQueue.isEmpty() &&
864+ ((System .currentTimeMillis() - observationQueue.last().timestamp) < MAXIMUM_TIME_BETWEEN_EVENTS_IN_PATTERN_MS )
865+ }
866+
855867 override fun beforeTextChanged (text : CharSequence , start : Int , count : Int , after : Int ) {
856868 addWatcherNestingLevel()
857869 if (! isViewInitialized) return
0 commit comments