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 348564 c8c31aad61a18cbb9cdb589ef5118da8bab0e3af
parent 348563 9c7f589a8f74bc57fe02a85abb4bd5aa352af129
child 348565 23487c75faf7d5fc53202c2cd1628c7134489587
push id6475
push userkwierso@gmail.com
push dateMon, 10 Oct 2016 21:14:32 +0000
treeherdermozilla-beta@0c41036b9e63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, ritu
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
--- 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
     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().postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
         if (!mBrowserToolbar.isEditing() && onKey(null, keyCode, event)) {
             return true;
         return super.onKeyDown(keyCode, event);