Merge "[AD1] Add an option to read an arbitrary dictionary."
diff --git a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java
index 2fb7fe8..a2463c2 100644
--- a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java
+++ b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java
@@ -55,13 +55,20 @@
                 // A dead key.
                 return Event.createDeadEvent(
                         codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, null /* next */);
-            } else {
-                // A committable character. This should be committed right away, taking into
-                // account the current state.
-                return Event.createCommittableEvent(codePointAndFlags, null /* next */);
             }
-        } else {
-            return Event.createNotHandledEvent();
+            if (KeyEvent.KEYCODE_ENTER == keyCode) {
+                // The Enter key. If the Shift key is not being pressed, this should send a
+                // CODE_ACTION_ENTER to trigger the action if any, or a carriage return
+                // otherwise. If the Shift key is depressed, this should send a
+                // CODE_SHIFT_ENTER and let Latin IME decide what to do with it.
+                return Event.createCommittableEvent(keyEvent.isShiftPressed()
+                        ? Constants.CODE_SHIFT_ENTER : Constants.CODE_ACTION_ENTER,
+                        null /* next */);
+            }
+            // If not Enter, then we have a committable character. This should be committed
+            // right away, taking into account the current state.
+            return Event.createCommittableEvent(codePointAndFlags, null /* next */);
         }
+        return Event.createNotHandledEvent();
     }
 }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 829c5e5..d9e63da 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2429,6 +2429,7 @@
     // Hooks for hardware keyboard
     @Override
     public boolean onKeyDown(final int keyCode, final KeyEvent event) {
+        if (!ProductionFlag.IS_HARDWARE_KEYBOARD_SUPPORTED) return super.onKeyDown(keyCode, event);
         // onHardwareKeyEvent, like onKeyDown returns true if it handled the event, false if
         // it doesn't know what to do with it and leave it to the application. For example,
         // hardware key events for adjusting the screen's brightness are passed as is.
diff --git a/java/src/com/android/inputmethod/latin/define/ProductionFlag.java b/java/src/com/android/inputmethod/latin/define/ProductionFlag.java
index a14398f..f1e147f 100644
--- a/java/src/com/android/inputmethod/latin/define/ProductionFlag.java
+++ b/java/src/com/android/inputmethod/latin/define/ProductionFlag.java
@@ -28,4 +28,6 @@
     // be false, and any privacy controls should be enforced.  IS_EXPERIMENTAL_DEBUG should be false
     // for any released build.
     public static final boolean IS_EXPERIMENTAL_DEBUG = false;
+
+    public static final boolean IS_HARDWARE_KEYBOARD_SUPPORTED = true;
 }