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 340508 637b73dad0ae2f0232deaf39ff674d6174dc506c
parent 340507 7d32fc01323516a87123b7d71afe07bae469968d
child 340509 be8c65a61bf7ad1d7335789cdadfc6bb3687d400
push id10124
push userkwierso@gmail.com
push dateMon, 10 Oct 2016 21:14:21 +0000
treeherdermozilla-aurora@6031d730c46a [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
@@ -563,17 +563,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);