Bug 1307779 - Only start long-press timer for back button r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 05 Oct 2016 18:14:12 +0200
changeset 421271 91864ad22b216e40710144ce911e483ad3804b88
parent 421270 4f41a594f88d17e25bbfd362f2e45e6dc891bfc6
child 533010 33d6c61042348dcda1ee75ae8e2b613daea4ed74
push id31427
push userahunt@mozilla.com
push dateWed, 05 Oct 2016 16:24:51 +0000
reviewerssebastian
bugs1307779
milestone52.0a1
Bug 1307779 - Only start long-press timer for back button r?sebastian 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
@@ -565,17 +565,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);