Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.appmenu; | 5 package org.chromium.chrome.browser.appmenu; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | |
| 7 import android.view.MotionEvent; | 8 import android.view.MotionEvent; |
| 8 import android.view.View; | 9 import android.view.View; |
| 9 import android.view.View.OnTouchListener; | 10 import android.view.View.OnTouchListener; |
| 10 | 11 |
| 11 import org.chromium.chrome.browser.UmaBridge; | 12 import org.chromium.chrome.browser.UmaBridge; |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * A helper class for a menu button to decide when to show the app menu and forw ard touch | 15 * A helper class for a menu button to decide when to show the app menu and forw ard touch |
| 15 * events. | 16 * events. |
| 16 * | 17 * |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 } | 69 } |
| 69 | 70 |
| 70 /** | 71 /** |
| 71 * Handle the key press event on a menu button. | 72 * Handle the key press event on a menu button. |
| 72 * @return Whether the app menu was shown as a result of this action. | 73 * @return Whether the app menu was shown as a result of this action. |
| 73 */ | 74 */ |
| 74 public boolean onEnterKeyPress() { | 75 public boolean onEnterKeyPress() { |
| 75 return showAppMenu(false); | 76 return showAppMenu(false); |
| 76 } | 77 } |
| 77 | 78 |
| 79 @SuppressLint("ClickableViewAccessibility") | |
|
aurimas (slooooooooow)
2014/08/12 02:47:55
This actually does not fix the bug, just adds a su
| |
| 78 @Override | 80 @Override |
| 79 | |
| 80 public boolean onTouch(View view, MotionEvent event) { | 81 public boolean onTouch(View view, MotionEvent event) { |
| 81 boolean isTouchEventConsumed = false; | 82 boolean isTouchEventConsumed = false; |
| 82 | 83 |
| 83 switch (event.getActionMasked()) { | 84 switch (event.getActionMasked()) { |
| 84 case MotionEvent.ACTION_DOWN: | 85 case MotionEvent.ACTION_DOWN: |
| 85 isTouchEventConsumed |= true; | 86 isTouchEventConsumed |= true; |
| 86 mMenuButton.setPressed(true); | 87 mMenuButton.setPressed(true); |
| 87 showAppMenu(true); | 88 showAppMenu(true); |
| 88 break; | 89 break; |
| 89 case MotionEvent.ACTION_UP: | 90 case MotionEvent.ACTION_UP: |
| 90 case MotionEvent.ACTION_CANCEL: | 91 case MotionEvent.ACTION_CANCEL: |
| 91 isTouchEventConsumed |= true; | 92 isTouchEventConsumed |= true; |
| 92 mMenuButton.setPressed(false); | 93 mMenuButton.setPressed(false); |
| 93 break; | 94 break; |
| 94 default: | 95 default: |
| 95 } | 96 } |
| 96 | 97 |
| 97 // If user starts to drag on this menu button, ACTION_DOWN and all the s ubsequent touch | 98 // If user starts to drag on this menu button, ACTION_DOWN and all the s ubsequent touch |
| 98 // events are received here. We need to forward this event to the app me nu to handle | 99 // events are received here. We need to forward this event to the app me nu to handle |
| 99 // dragging correctly. | 100 // dragging correctly. |
| 100 AppMenuDragHelper dragHelper = mMenuHandler.getAppMenuDragHelper(); | 101 AppMenuDragHelper dragHelper = mMenuHandler.getAppMenuDragHelper(); |
| 101 if (dragHelper != null) { | 102 if (dragHelper != null) { |
| 102 isTouchEventConsumed |= dragHelper.handleDragging(event); | 103 isTouchEventConsumed |= dragHelper.handleDragging(event); |
| 103 } | 104 } |
| 104 return isTouchEventConsumed; | 105 return isTouchEventConsumed; |
| 105 } | 106 } |
| 106 } | 107 } |
| OLD | NEW |