aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java74
1 files changed, 49 insertions, 25 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index fdf58f6ef..733817edf 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -28,6 +28,7 @@ import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.media.AudioManager;
import android.net.ConnectivityManager;
+import android.os.Build;
import android.os.Debug;
import android.os.Message;
import android.os.SystemClock;
@@ -56,6 +57,7 @@ import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.compat.SuggestionSpanUtils;
+import com.android.inputmethod.compat.VibratorCompatWrapper;
import com.android.inputmethod.deprecated.LanguageSwitcherProxy;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.deprecated.recorrection.Recorrection;
@@ -158,7 +160,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private View mKeyPreviewBackingView;
private View mSuggestionsContainer;
- private int mSuggestionsStripHeight;
private SuggestionsView mSuggestionsView;
private Suggest mSuggest;
private CompletionInfo[] mApplicationSpecifiedCompletions;
@@ -211,6 +212,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private static float mFxVolume = -1.0f; // just a default value to be updated runtime
private boolean mSilentModeOn; // System-wide current configuration
+ private VibratorCompatWrapper mVibrator;
+ private long mKeypressVibrationDuration = -1;
+
// TODO: Move this flag to VoiceProxy
private boolean mConfigurationChanging;
@@ -434,13 +438,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mRecorrection = Recorrection.getInstance();
+ mVibrator = VibratorCompatWrapper.getInstance(this);
DEBUG = LatinImeLogger.sDBG;
- loadSettings();
-
final Resources res = getResources();
mResources = res;
+ loadSettings();
+
Utils.GCUtils.getInstance().reset();
boolean tryGC = true;
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
@@ -481,6 +486,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSettingsValues = new Settings.Values(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
updateSoundEffectVolume();
+ updateKeypressVibrationDuration();
}
private void initSuggest() {
@@ -612,7 +618,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view);
if (mSuggestionsView != null)
mSuggestionsView.setListener(this, view);
- mSuggestionsStripHeight = (int)mResources.getDimension(R.dimen.suggestions_strip_height);
}
@Override
@@ -681,6 +686,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (mSuggestionsView != null)
mSuggestionsView.clear();
+ // The EditorInfo might have a flag that affects fullscreen mode.
+ updateFullscreenMode();
setSuggestionStripShownInternal(
isSuggestionsStripVisible(), /* needsInputViewShown */ false);
// Delay updating suggestions because keyboard input view may not be shown at this point.
@@ -945,14 +952,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final boolean shouldShowSuggestions = shown
&& (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
if (isFullscreenMode()) {
- // No need to have extra space to show the key preview.
- mKeyPreviewBackingView.setVisibility(View.GONE);
mSuggestionsContainer.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.GONE);
} else {
- // We must control the visibility of the suggestion strip in order to avoid clipped
- // key previews, even when we don't show the suggestion strip.
- mKeyPreviewBackingView.setVisibility(View.VISIBLE);
mSuggestionsContainer.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE);
}
@@ -971,12 +973,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return;
final int backingHeight = (mKeyPreviewBackingView.getVisibility() == View.GONE) ? 0
: mKeyPreviewBackingView.getHeight();
- final int extraHeight = mSuggestionsContainer.getHeight() + backingHeight;
+ final int suggestionsHeight = (mSuggestionsContainer.getVisibility() == View.GONE) ? 0
+ : mSuggestionsContainer.getHeight();
+ final int extraHeight = backingHeight + suggestionsHeight;
int touchY = extraHeight;
// Need to set touchable region only if input view is being shown
if (mKeyboardSwitcher.isInputViewShown()) {
if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
- touchY -= mSuggestionsStripHeight;
+ touchY -= suggestionsHeight;
}
final int touchWidth = inputView.getWidth();
final int touchHeight = inputView.getHeight() + extraHeight
@@ -994,16 +998,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override
public boolean onEvaluateFullscreenMode() {
- final EditorInfo ei = getCurrentInputEditorInfo();
- if (ei != null) {
- final int imeOptions = ei.imeOptions;
- if (EditorInfoCompatUtils.hasFlagNoFullscreen(imeOptions))
- return false;
- if ((imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0)
- return false;
- }
+ return super.onEvaluateFullscreenMode()
+ && mResources.getBoolean(R.bool.config_use_fullscreen_mode);
+ }
+
+ @Override
+ public void updateFullscreenMode() {
+ super.updateFullscreenMode();
- return mResources.getBoolean(R.bool.config_use_fullscreen_mode);
+ if (mKeyPreviewBackingView == null) return;
+ // In fullscreen mode, no need to have extra space to show the key preview.
+ // If not, we should have extra space above the keyboard to show the key preview.
+ mKeyPreviewBackingView.setVisibility(isFullscreenMode() ? View.GONE : View.VISIBLE);
}
@Override
@@ -2062,6 +2068,19 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSilentModeOn = (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL);
}
+ private void updateKeypressVibrationDuration() {
+ final String[] durationPerHardwareList = mResources.getStringArray(
+ R.array.keypress_vibration_durations);
+ final String hardwarePrefix = Build.HARDWARE + ",";
+ for (final String element : durationPerHardwareList) {
+ if (element.startsWith(hardwarePrefix)) {
+ mKeypressVibrationDuration =
+ Long.parseLong(element.substring(element.lastIndexOf(',') + 1));
+ break;
+ }
+ }
+ }
+
private void playKeyClick(int primaryCode) {
// if mAudioManager is null, we don't have the ringer state yet
// mAudioManager will be set by updateRingerMode
@@ -2091,11 +2110,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (!mSettingsValues.mVibrateOn) {
return;
}
- LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
- if (inputView != null) {
- inputView.performHapticFeedback(
- HapticFeedbackConstants.KEYBOARD_TAP,
- HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ if (mKeypressVibrationDuration < 0) {
+ // Go ahead with the system default
+ LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
+ if (inputView != null) {
+ inputView.performHapticFeedback(
+ HapticFeedbackConstants.KEYBOARD_TAP,
+ HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ }
+ } else if (mVibrator != null) {
+ mVibrator.vibrate(mKeypressVibrationDuration);
}
}