Loading core/api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -52358,6 +52358,7 @@ package android.view { public static interface View.OnLongClickListener { public static interface View.OnLongClickListener { method public boolean onLongClick(android.view.View); method public boolean onLongClick(android.view.View); method public default boolean onLongClickUseDefaultHapticFeedback(@NonNull android.view.View); } } public static interface View.OnScrollChangeListener { public static interface View.OnScrollChangeListener { core/java/android/view/View.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -7698,8 +7698,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, boolean handled = false; boolean handled = false; final ListenerInfo li = mListenerInfo; final ListenerInfo li = mListenerInfo; boolean shouldPerformHapticFeedback = true; if (li != null && li.mOnLongClickListener != null) { if (li != null && li.mOnLongClickListener != null) { handled = li.mOnLongClickListener.onLongClick(View.this); handled = li.mOnLongClickListener.onLongClick(View.this); if (handled) { shouldPerformHapticFeedback = li.mOnLongClickListener.onLongClickUseDefaultHapticFeedback(View.this); } } } if (!handled) { if (!handled) { final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y); final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y); Loading @@ -7710,7 +7715,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, handled = showLongClickTooltip((int) x, (int) y); handled = showLongClickTooltip((int) x, (int) y); } } } } if (handled) { if (handled && shouldPerformHapticFeedback) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } } return handled; return handled; Loading Loading @@ -29922,6 +29927,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @return true if the callback consumed the long click, false otherwise. * @return true if the callback consumed the long click, false otherwise. */ */ boolean onLongClick(View v); boolean onLongClick(View v); /** * Returns whether the default {@link HapticFeedbackConstants#LONG_PRESS} haptic feedback * is performed when this listener has consumed the long click. This method is called * immediately after {@link #onLongClick} has returned true. * * @param v The view that was clicked and held. * @return true to perform the default {@link HapticFeedbackConstants#LONG_PRESS} haptic * feedback, or false if the handler manages all haptics itself. */ default boolean onLongClickUseDefaultHapticFeedback(@NonNull View v) { return true; } } } /** /** Loading
core/api/current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -52358,6 +52358,7 @@ package android.view { public static interface View.OnLongClickListener { public static interface View.OnLongClickListener { method public boolean onLongClick(android.view.View); method public boolean onLongClick(android.view.View); method public default boolean onLongClickUseDefaultHapticFeedback(@NonNull android.view.View); } } public static interface View.OnScrollChangeListener { public static interface View.OnScrollChangeListener {
core/java/android/view/View.java +19 −1 Original line number Original line Diff line number Diff line Loading @@ -7698,8 +7698,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, boolean handled = false; boolean handled = false; final ListenerInfo li = mListenerInfo; final ListenerInfo li = mListenerInfo; boolean shouldPerformHapticFeedback = true; if (li != null && li.mOnLongClickListener != null) { if (li != null && li.mOnLongClickListener != null) { handled = li.mOnLongClickListener.onLongClick(View.this); handled = li.mOnLongClickListener.onLongClick(View.this); if (handled) { shouldPerformHapticFeedback = li.mOnLongClickListener.onLongClickUseDefaultHapticFeedback(View.this); } } } if (!handled) { if (!handled) { final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y); final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y); Loading @@ -7710,7 +7715,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, handled = showLongClickTooltip((int) x, (int) y); handled = showLongClickTooltip((int) x, (int) y); } } } } if (handled) { if (handled && shouldPerformHapticFeedback) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } } return handled; return handled; Loading Loading @@ -29922,6 +29927,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @return true if the callback consumed the long click, false otherwise. * @return true if the callback consumed the long click, false otherwise. */ */ boolean onLongClick(View v); boolean onLongClick(View v); /** * Returns whether the default {@link HapticFeedbackConstants#LONG_PRESS} haptic feedback * is performed when this listener has consumed the long click. This method is called * immediately after {@link #onLongClick} has returned true. * * @param v The view that was clicked and held. * @return true to perform the default {@link HapticFeedbackConstants#LONG_PRESS} haptic * feedback, or false if the handler manages all haptics itself. */ default boolean onLongClickUseDefaultHapticFeedback(@NonNull View v) { return true; } } } /** /**