add new preference for popup preview
this option is disabled as the default at x-large

Bug:2909517

Change-Id: Ifda1b7ff89bc4beeee02ba0f3e01d441a9435b37
diff --git a/java/res/values-xlarge/bools.xml b/java/res/values-xlarge/bools.xml
new file mode 100644
index 0000000..fe8fc58
--- /dev/null
+++ b/java/res/values-xlarge/bools.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources>
+    <!-- Whether or not Popup on key press is enabled by default -->
+    <bool name="default_popup_preview">false</bool>
+</resources>
diff --git a/java/res/values/bools.xml b/java/res/values/bools.xml
index a0cebbb..f5f2c3d 100644
--- a/java/res/values/bools.xml
+++ b/java/res/values/bools.xml
@@ -26,4 +26,6 @@
     <!-- Whether or not voice input is enabled by default. -->
     <bool name="voice_input_default">true</bool>
     <bool name="config_swipeDisambiguation">true</bool>
+    <!-- Whether or not Popup on key press is enabled by default -->
+    <bool name="default_popup_preview">true</bool>
 </resources>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index e77155d..d2166f7 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -29,6 +29,9 @@
     <!-- Option to play back sound on keypress in soft keyboard -->
     <string name="sound_on_keypress">Sound on keypress</string>
 
+    <!-- Option to pop up the character with a larger font above soft keyboard -->
+    <string name="popup_on_keypress">Popup on keypress</string>
+
     <!-- Option to enable using nearby keys when correcting/predicting -->
     <string name="hit_correction">Correct typing errors</string>
     
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index e4c689a..11cc3ac 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -31,6 +31,13 @@
             />
 
     <CheckBoxPreference
+            android:key="popup_on"
+            android:title="@string/popup_on_keypress"
+            android:persistent="true"
+            android:defaultValue="@bool/default_popup_preview"
+            />
+
+    <CheckBoxPreference
             android:key="auto_cap"
             android:title="@string/auto_cap"
             android:persistent="true"
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3ee9fe8..ace0b08 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -89,6 +89,7 @@
 
     private static final String PREF_VIBRATE_ON = "vibrate_on";
     private static final String PREF_SOUND_ON = "sound_on";
+    private static final String PREF_POPUP_ON = "popup_on";
     private static final String PREF_AUTO_CAP = "auto_cap";
     private static final String PREF_QUICK_FIXES = "quick_fixes";
     private static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
@@ -198,6 +199,7 @@
     private boolean mPasswordText;
     private boolean mVibrateOn;
     private boolean mSoundOn;
+    private boolean mPopupOn;
     private boolean mAutoCap;
     private boolean mQuickFixes;
     private boolean mHasUsedVoiceInput;
@@ -670,6 +672,7 @@
 
         updateCorrectionMode();
 
+        inputView.setPreviewEnabled(mPopupOn);
         inputView.setProximityCorrectionEnabled(true);
         mPredictionOn = mPredictionOn && (mCorrectionMode > 0 || mShowSuggestions);
         checkTutorial(attribute.privateImeOptions);
@@ -2295,6 +2298,7 @@
         SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
         mVibrateOn = sp.getBoolean(PREF_VIBRATE_ON, false);
         mSoundOn = sp.getBoolean(PREF_SOUND_ON, false);
+        mPopupOn = sp.getBoolean(PREF_POPUP_ON, true);
         mAutoCap = sp.getBoolean(PREF_AUTO_CAP, true);
         mQuickFixes = sp.getBoolean(PREF_QUICK_FIXES, true);
         mHasUsedVoiceInput = sp.getBoolean(PREF_HAS_USED_VOICE_INPUT, false);
@@ -2421,6 +2425,7 @@
         p.println("  TextEntryState.state=" + TextEntryState.getState());
         p.println("  mSoundOn=" + mSoundOn);
         p.println("  mVibrateOn=" + mVibrateOn);
+        p.println("  mPopupOn=" + mPopupOn);
     }
 
     // Characters per second measurement