Bug 1307779 - Only start long-press timer for back button r=sebastian a=ritu
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 05 Oct 2016 18:14:12 +0200
changeset 428777 c8c31aad61a18cbb9cdb589ef5118da8bab0e3af
parent 428776 9c7f589a8f74bc57fe02a85abb4bd5aa352af129
child 428778 23487c75faf7d5fc53202c2cd1628c7134489587
push id33416
push userpaul@paul.cx
push dateMon, 24 Oct 2016 16:26:20 +0000
reviewerssebastian, ritu
bugs1307779
milestone50.0
Bug 1307779 - Only start long-press timer for back button r=sebastian a=ritu Huge oversight in my original patch. Pressing any hardware button will result in the history list being shown after the long-press delay (regardless of long-pressing). MozReview-Commit-ID: KO8u0NzTxaO
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -561,17 +561,18 @@ public class BrowserApp extends GeckoApp
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         // Bug 1304688: Android N has broken passing onKeyLongPress events for the back button, so we
         // instead copy the long-press-handler technique from Android's KeyButtonView.
         // - For short presses, we cancel the callback in onKeyUp
         // - For long presses, the normal keypress is marked as cancelled, hence won't be handled elsewhere
         //   (but Android still provides the haptic feedback), and the runnable is run.
-        if (!Versions.preN) {
+        if (!Versions.preN &&
+                keyCode == KeyEvent.KEYCODE_BACK) {
             ThreadUtils.getUiHandler().removeCallbacks(mCheckLongPress);
             ThreadUtils.getUiHandler().postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
         }
 
         if (!mBrowserToolbar.isEditing() && onKey(null, keyCode, event)) {
             return true;
         }
         return super.onKeyDown(keyCode, event);