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

Commit fb3d63ee authored by Abodunrinwa Toki's avatar Abodunrinwa Toki Committed by Android (Google) Code Review
Browse files

Merge "TRON logging for TextView gesture - Long press."

parents 554140fc 1b304e40
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ import android.widget.TextView.Drawables;
import android.widget.TextView.OnEditorActionListener;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.GrowingArrayUtils;
import com.android.internal.util.Preconditions;
@@ -1119,14 +1121,26 @@ public class Editor {
            getInsertionController().show();
            mIsInsertionActionModeStartPending = true;
            handled = true;
            MetricsLogger.action(
                    mTextView.getContext(),
                    MetricsEvent.TEXT_LONGPRESS,
                    TextViewMetrics.SUBTYPE_LONG_PRESS_OTHER);
        }

        if (!handled && mTextActionMode != null) {
            if (touchPositionIsInSelection()) {
                startDragAndDrop();
                MetricsLogger.action(
                        mTextView.getContext(),
                        MetricsEvent.TEXT_LONGPRESS,
                        TextViewMetrics.SUBTYPE_LONG_PRESS_DRAG_AND_DROP);
            } else {
                stopTextActionMode();
                selectCurrentWordAndStartDrag();
                MetricsLogger.action(
                        mTextView.getContext(),
                        MetricsEvent.TEXT_LONGPRESS,
                        TextViewMetrics.SUBTYPE_LONG_PRESS_SELECTION);
            }
            handled = true;
        }
@@ -1134,6 +1148,12 @@ public class Editor {
        // Start a new selection
        if (!handled) {
            handled = selectCurrentWordAndStartDrag();
            if (handled) {
                MetricsLogger.action(
                        mTextView.getContext(),
                        MetricsEvent.TEXT_LONGPRESS,
                        TextViewMetrics.SUBTYPE_LONG_PRESS_SELECTION);
            }
        }

        return handled;
+7 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ import android.view.textservice.TextServicesManager;
import android.widget.RemoteViews.RemoteView;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.FastMath;
import com.android.internal.widget.EditableInputConnection;

@@ -9685,6 +9687,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        if (handled) {
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            if (mEditor != null) mEditor.mDiscardNextActionUp = true;
        } else {
            MetricsLogger.action(
                    mContext,
                    MetricsEvent.TEXT_LONGPRESS,
                    TextViewMetrics.SUBTYPE_LONG_PRESS_OTHER);
        }

        return handled;
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.widget;

/**
 * {@link com.android.internal.logging.MetricsLogger} values for TextView.
 *
 * @hide
 */
final class TextViewMetrics {

    private TextViewMetrics() {}

    /**
     * Long press on TextView - no special classification.
     */
    static final int SUBTYPE_LONG_PRESS_OTHER = 0;
    /**
     * Long press on TextView - selection started.
     */
    static final int SUBTYPE_LONG_PRESS_SELECTION = 1;
    /**
     * Long press on TextView - drag and drop started.
     */
    static final int SUBTYPE_LONG_PRESS_DRAG_AND_DROP = 2;
}
+6 −0
Original line number Diff line number Diff line
@@ -2653,6 +2653,12 @@ message MetricsEvent {
    // OS: O
    ENTERPRISE_PRIVACY_SETTINGS = 628;

    // ACTION: Longpress on a TextView.
    //  SUBTYPE: 1 is for START_SELECTION, 2 is for START_DRAG_AND_DROP, 0 is for OTHER.
    // CATEGORY: TEXT_CONTROLS
    // OS: O
    TEXT_LONGPRESS = 629;

    // ---- End O Constants, all O constants go above this line ----

    // Add new aosp constants above this line.