Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5257525 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Fixing getOffsetBefore and getOffsetAfter to working properly on...

Merge "Fixing getOffsetBefore and getOffsetAfter to working properly on non-spacing mark character. This will make moving cursor to the left and right to work properly on non-spacing mark character." into gingerbread
parents c430373c e9c5e074
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.util.Printer;

import com.android.internal.util.ArrayUtils;

import java.text.Normalizer;
import java.util.regex.Pattern;
import java.util.Iterator;

@@ -861,7 +862,21 @@ public class TextUtils {
            else
                offset -= 1;
        } else {
            String decomposed = Normalizer.normalize(Character.toString(c), Normalizer.Form.NFKD);

            offset -= 1;
            c = decomposed.charAt(0);

            while (Character.getDirectionality(c) == Character.DIRECTIONALITY_NONSPACING_MARK) {
                offset -= 1;

                if (offset == 0)
                    break;

                decomposed = Normalizer.normalize(text.subSequence(offset, offset + 1),
                                                    Normalizer.Form.NFKD);
                c = decomposed.charAt(0);
            }
        }

        if (text instanceof Spanned) {
@@ -899,6 +914,18 @@ public class TextUtils {
                offset += 1;
        } else {
            offset += 1;

            do {
                String decomposed = Normalizer.normalize(text.subSequence(offset, offset + 1),
                                                        Normalizer.Form.NFKD);

                c = decomposed.charAt(0);

                if (Character.getDirectionality(c) != Character.DIRECTIONALITY_NONSPACING_MARK)
                    break;

                offset += 1;
            } while (offset < len);
        }

        if (text instanceof Spanned) {
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.text.*;
import android.text.method.TextKeyListener.Capitalize;
import android.text.style.ReplacementSpan;
import android.widget.TextView;

public abstract class BaseKeyListener
@@ -54,7 +55,7 @@ implements KeyListener {
        } else if (altBackspace(view, content, keyCode, event)) {
            result = true;
        } else {
            int to = TextUtils.getOffsetBefore(content, selEnd);
            int to = (selEnd < 2) ? 0 : selEnd - 1;

            if (to != selEnd) {
                content.delete(Math.min(to, selEnd), Math.max(to, selEnd));