Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/coordinator/CoordinatorLayoutForPointer.java

Issue 2878403002: Support setting mouse cursor icon in Android N. (Closed)
Patch Set: Override onResolvePointerIcon Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.coordinator;
6
7 import android.content.Context;
8 import android.os.Build;
9 import android.support.design.widget.CoordinatorLayout;
10 import android.util.AttributeSet;
11 import android.view.MotionEvent;
12 import android.view.PointerIcon;
13
14 /**
15 * This class extends a {@link CoordinatorLayout} which is the parent of
Ted C 2017/07/21 00:15:25 wrap comments at 100 chars in java land
jaebaek 2017/07/21 10:03:04 Done.
16 * {@link CompositorViewHolder} in Android view hierarchy. The main
17 * purpose of this class is to correctly determine the pointer icon that
18 * must be applied according to a mouse motion event.
mdjones 2017/07/20 21:49:06 nit: Mention this is needed because the default an
jaebaek 2017/07/21 10:03:04 Done.
19 */
20 public class CoordinatorLayoutForPointer extends CoordinatorLayout {
21 public CoordinatorLayoutForPointer(Context context) {
Ted C 2017/07/21 00:15:25 we should only need the second constructor for inf
jaebaek 2017/07/21 10:03:04 Done.
22 super(context);
23 }
24
25 public CoordinatorLayoutForPointer(Context context, AttributeSet attrs) {
26 super(context, attrs);
27 }
28
29 @Override
30 public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
Ted C 2017/07/21 00:15:25 I believe this got fixed in N-MR1 (b/34114031). S
jaebaek 2017/07/21 10:03:04 I want to check the updated code, but I cannot acc
31 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return null;
32
33 final int childrenCount = getChildCount();
34 for (int i = childrenCount - 1; i >= 0; --i) {
35 if (getChildAt(i).getVisibility() != VISIBLE) continue;
36 PointerIcon icon = getChildAt(i).onResolvePointerIcon(event, pointer Index);
Ted C 2017/07/21 18:45:31 this doesn't actually check that the mouse cursor
mdjones 2017/07/21 20:42:28 With the assumption that this layout is always mat
jaebaek 2017/07/24 07:34:11 Ah .. it's my mistake. I added bound check here. I
37 if (icon != null) return icon;
38 }
39 return null;
40 }
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698