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

Commit bda6275c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "No smart text assist for unprovisioned device." into oc-dr1-dev

parents 857b0ff5 9796a1bd
Loading
Loading
Loading
Loading
+21 −16
Original line number Diff line number Diff line
@@ -3909,16 +3909,10 @@ public class Editor {
            menu.removeItem(TextView.ID_ASSIST);
            final TextClassification textClassification =
                    getSelectionActionModeHelper().getTextClassification();
            if (textClassification != null) {
                final Drawable icon = textClassification.getIcon();
                final CharSequence label = textClassification.getLabel();
                final OnClickListener onClickListener =
                        textClassification.getOnClickListener();
                final Intent intent = textClassification.getIntent();
                if ((icon != null || !TextUtils.isEmpty(label))
                        && (onClickListener != null || intent != null)) {
                    menu.add(TextView.ID_ASSIST, TextView.ID_ASSIST, MENU_ITEM_ORDER_ASSIST, label)
                            .setIcon(icon)
            if (canAssist()) {
                menu.add(TextView.ID_ASSIST, TextView.ID_ASSIST, MENU_ITEM_ORDER_ASSIST,
                        textClassification.getLabel())
                        .setIcon(textClassification.getIcon())
                        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
                mMetricsLogger.write(
                        new LogMaker(MetricsEvent.TEXT_SELECTION_MENU_ITEM_ASSIST)
@@ -3926,6 +3920,17 @@ public class Editor {
                                .setSubtype(textClassification.getLogType()));
            }
        }

        private boolean canAssist() {
            final TextClassification textClassification =
                    getSelectionActionModeHelper().getTextClassification();
            return mTextView.isDeviceProvisioned()
                    && textClassification != null
                    && (textClassification.getIcon() != null
                            || !TextUtils.isEmpty(textClassification.getLabel()))
                    && (textClassification.getOnClickListener() != null
                            || (textClassification.getIntent() != null
                                    && mTextView.getContext().canStartActivityForResult()));
        }

        @Override