Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
santalu committed Jul 22, 2020
1 parent 3770da2 commit e46208c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />
android:textAppearance="?attr/textAppearanceBody1" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/unMasked"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />
android:textAppearance="?attr/textAppearanceBody1" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />
android:textAppearance="?attr/textAppearanceBody1" />

<com.santalu.maskara.widget.MaskEditText
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:textAppearance="?attr/textAppearanceHeadline6"
app:mask="+90 (___) ___ __ __" />

</LinearLayout>
4 changes: 3 additions & 1 deletion library/src/main/java/com/santalu/maskara/Maskara.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ internal fun Mask.nextSelection(before: CharSequence, after: CharSequence, actio
val end = after.length
var nextMaskIndex = value.indexOf(character, start)
// Make sure the cursor is located to the end of the selection
if (before.getOrNull(start) != after.getOrNull(nextMaskIndex)) {
val previousChar = before.getOrNull(start)
val nextChar = after.getOrNull(nextMaskIndex)
if (previousChar != nextChar && nextChar != character) {
++nextMaskIndex
}

Expand Down

0 comments on commit e46208c

Please sign in to comment.