Skip to content

Commit e6fc800

Browse files
authored
Merge pull request #621 from wordpress-mobile/issue/530-API25-intra-word-space-formatting-disappears
Fix formatting disappears on API25 when inserting space before formatted text
2 parents 5e78cf1 + 992a819 commit e6fc800

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.wordpress.aztec.watchers.event.buckets
2+
3+
import org.wordpress.aztec.watchers.event.sequence.known.space.API25InWordSpaceInsertionEvent
4+
5+
class API25Bucket : Bucket() {
6+
init {
7+
// constructor - here add all identified sequences for this bucket
8+
userOperations.add(API25InWordSpaceInsertionEvent())
9+
//mUserOperations.add(new ...);
10+
//mUserOperations.add(new ...);
11+
//mUserOperations.add(new ...);
12+
}
13+
}

aztec/src/main/kotlin/org/wordpress/aztec/watchers/event/buckets/API26Bucket.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.wordpress.aztec.watchers.event.buckets
22

3-
import org.wordpress.aztec.watchers.event.sequence.known.space.API26InWordSpaceInsertionEvent
3+
import org.wordpress.aztec.watchers.event.sequence.known.space.API25InWordSpaceInsertionEvent
44

55
class API26Bucket : Bucket() {
66
init {
77
// constructor - here add all identified sequences for this bucket
8-
userOperations.add(API26InWordSpaceInsertionEvent())
8+
userOperations.add(API25InWordSpaceInsertionEvent())
99
//mUserOperations.add(new ...);
1010
//mUserOperations.add(new ...);
1111
//mUserOperations.add(new ...);

aztec/src/main/kotlin/org/wordpress/aztec/watchers/event/sequence/ObservationQueue.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.wordpress.aztec.watchers.event.sequence
22

33
import android.os.Build
44
import org.wordpress.aztec.watchers.event.IEventInjector
5+
import org.wordpress.aztec.watchers.event.buckets.API25Bucket
56
import org.wordpress.aztec.watchers.event.buckets.API26Bucket
67
import org.wordpress.aztec.watchers.event.buckets.Bucket
78
import org.wordpress.aztec.watchers.event.text.TextWatcherEvent
@@ -12,6 +13,8 @@ class ObservationQueue(val injector: IEventInjector) : EventSequence<TextWatcher
1213
init {
1314
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
1415
buckets.add(API26Bucket())
16+
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
17+
buckets.add(API25Bucket())
1518
}
1619
/*
1720
remember to add here any other buckets and init logic as suitable, depending on the context

aztec/src/main/kotlin/org/wordpress/aztec/watchers/event/sequence/known/space/API26InWordSpaceInsertionEvent.kt renamed to aztec/src/main/kotlin/org/wordpress/aztec/watchers/event/sequence/known/space/API25InWordSpaceInsertionEvent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import org.wordpress.aztec.watchers.event.text.TextWatcherEvent
1111
/*
1212
This case implements the behavior observed in https://github.com/wordpress-mobile/AztecEditor-Android/issues/555
1313
*/
14-
class API26InWordSpaceInsertionEvent : UserOperationEvent() {
14+
class API25InWordSpaceInsertionEvent : UserOperationEvent() {
1515
private val SPACE = ' '
1616
private val SPACE_STRING = "" + SPACE
1717
private val MAXIMUM_TIME_BETWEEN_EVENTS_IN_PATTERN_MS = 50
@@ -35,7 +35,7 @@ class API26InWordSpaceInsertionEvent : UserOperationEvent() {
3535
val builderStep4 = TextWatcherEventInsertText.Builder()
3636
val step4 = builderStep4.build()
3737

38-
// add each of the steps that make up for the identified API26InWordSpaceInsertionEvent here
38+
// add each of the steps that make up for the identified API25InWordSpaceInsertionEvent here
3939
clear()
4040
addSequenceStep(step1)
4141
addSequenceStep(step2)

0 commit comments

Comments
 (0)