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

Commit b3c6ece7 authored by Jan Althaus's avatar Jan Althaus
Browse files

Widget types for unselectable and custom views

Added new constants to be used by custom text view implementions, as well
as a special case for non-selectable text that will only become meaningful
once we start logging linkified text.

Bug: 67674199
Test: Tested that there are no regressions in the existing behaviour.
Change-Id: I0167c39bdbde2783f13a8776d6e280aadf55476b
parent a9a65af6
Loading
Loading
Loading
Loading
+21 −5
Original line number Original line Diff line number Diff line
@@ -60,8 +60,12 @@ public final class SmartSelectionEventTracker {
    private static final String ZERO = "0";
    private static final String ZERO = "0";
    private static final String TEXTVIEW = "textview";
    private static final String TEXTVIEW = "textview";
    private static final String EDITTEXT = "edittext";
    private static final String EDITTEXT = "edittext";
    private static final String UNSELECTABLE_TEXTVIEW = "nosel-textview";
    private static final String WEBVIEW = "webview";
    private static final String WEBVIEW = "webview";
    private static final String EDIT_WEBVIEW = "edit-webview";
    private static final String EDIT_WEBVIEW = "edit-webview";
    private static final String CUSTOM_TEXTVIEW = "customview";
    private static final String CUSTOM_EDITTEXT = "customedit";
    private static final String CUSTOM_UNSELECTABLE_TEXTVIEW = "nosel-customview";
    private static final String UNKNOWN = "unknown";
    private static final String UNKNOWN = "unknown";


    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
@@ -73,6 +77,10 @@ public final class SmartSelectionEventTracker {
        int WEBVIEW = 2;
        int WEBVIEW = 2;
        int EDITTEXT = 3;
        int EDITTEXT = 3;
        int EDIT_WEBVIEW = 4;
        int EDIT_WEBVIEW = 4;
        int UNSELECTABLE_TEXTVIEW = 5;
        int CUSTOM_TEXTVIEW = 6;
        int CUSTOM_EDITTEXT = 7;
        int CUSTOM_UNSELECTABLE_TEXTVIEW = 8;
    }
    }


    private final MetricsLogger mMetricsLogger = new MetricsLogger();
    private final MetricsLogger mMetricsLogger = new MetricsLogger();
@@ -277,6 +285,14 @@ public final class SmartSelectionEventTracker {
                return EDITTEXT;
                return EDITTEXT;
            case WidgetType.EDIT_WEBVIEW:
            case WidgetType.EDIT_WEBVIEW:
                return EDIT_WEBVIEW;
                return EDIT_WEBVIEW;
            case WidgetType.UNSELECTABLE_TEXTVIEW:
                return UNSELECTABLE_TEXTVIEW;
            case WidgetType.CUSTOM_TEXTVIEW:
                return CUSTOM_TEXTVIEW;
            case WidgetType.CUSTOM_EDITTEXT:
                return CUSTOM_EDITTEXT;
            case WidgetType.CUSTOM_UNSELECTABLE_TEXTVIEW:
                return CUSTOM_UNSELECTABLE_TEXTVIEW;
            default:
            default:
                return UNKNOWN;
                return UNKNOWN;
        }
        }
+3 −1
Original line number Original line Diff line number Diff line
@@ -591,7 +591,9 @@ public final class SelectionActionModeHelper {
            Preconditions.checkNotNull(textView);
            Preconditions.checkNotNull(textView);
            final @SmartSelectionEventTracker.WidgetType int widgetType = textView.isTextEditable()
            final @SmartSelectionEventTracker.WidgetType int widgetType = textView.isTextEditable()
                    ? SmartSelectionEventTracker.WidgetType.EDITTEXT
                    ? SmartSelectionEventTracker.WidgetType.EDITTEXT
                    : SmartSelectionEventTracker.WidgetType.TEXTVIEW;
                    : (textView.isTextSelectable()
                            ? SmartSelectionEventTracker.WidgetType.TEXTVIEW
                            : SmartSelectionEventTracker.WidgetType.UNSELECTABLE_TEXTVIEW);
            mDelegate = new SmartSelectionEventTracker(textView.getContext(), widgetType);
            mDelegate = new SmartSelectionEventTracker(textView.getContext(), widgetType);
            mEditTextLogger = textView.isTextEditable();
            mEditTextLogger = textView.isTextEditable();
            mWordIterator = BreakIterator.getWordInstance(textView.getTextLocale());
            mWordIterator = BreakIterator.getWordInstance(textView.getTextLocale());