Merge "TRON logging for TextView gesture - Long press."
This commit is contained in:
committed by
Android (Google) Code Review
commit
fb3d63ee69
@@ -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;
|
||||
|
||||
@@ -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
core/java/android/widget/TextViewMetrics.java
Normal file
40
core/java/android/widget/TextViewMetrics.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user