File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed
auth/src/main/java/com/firebase/ui/auth/ui/phone Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -65,22 +65,31 @@ public void setText(CharSequence text, BufferType type) {
65
65
*/
66
66
@ Override
67
67
public void setSelection (int index ) {
68
- // If the index is the leading edge, there are no spaces before it.
69
- // For all other cases, the index is preceded by index - 1 spaces.
70
- int spacesUpToIndex ;
71
- if (index == 0 ) {
72
- spacesUpToIndex = 0 ;
73
- } else {
74
- spacesUpToIndex = index - 1 ;
75
- }
68
+ // Desired mapping:
69
+ // 0 --> 0
70
+ // 1 --> 1
71
+ // 2 --> 3
72
+ // 3 --> 5
73
+ // 4 --> 7
74
+ // 5 --> 9
75
+ // 6 --> 11
76
+
77
+ // Naive transformation
78
+ int newIndex = (index * 2 ) - 1 ;
79
+
80
+ // Lower bound is 0
81
+ newIndex = Math .max (newIndex , 0 );
82
+
83
+ // Upper bound is original length * 2 - 1
84
+ newIndex = Math .min (newIndex , (mOriginalText .length () * 2 ) - 1 );
76
85
77
86
try {
78
- super .setSelection (index + spacesUpToIndex );
87
+ super .setSelection (newIndex );
79
88
} catch (IndexOutOfBoundsException e ) {
80
- // TODO remove once we figure out the bug.
89
+ // For debug purposes only
81
90
throw new IndexOutOfBoundsException (e .getMessage () +
82
91
", requestedIndex=" + index +
83
- ", spacesUpToIndex= " + spacesUpToIndex +
92
+ ", newIndex= " + newIndex +
84
93
", originalText=" + mOriginalText );
85
94
}
86
95
}
You can’t perform that action at this time.
0 commit comments