2009-03-13 22:11:42 +00:00
|
|
|
/*
|
2010-03-26 22:07:10 +00:00
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
2010-09-15 04:03:34 +00:00
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* 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
|
2010-01-28 18:09:44 +00:00
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2010-01-28 18:09:44 +00:00
|
|
|
*
|
2009-03-13 22:11:42 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
2013-01-21 12:52:57 +00:00
|
|
|
* 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.
|
2009-03-13 22:11:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.inputmethod.latin;
|
|
|
|
|
2012-04-19 03:42:13 +00:00
|
|
|
import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII;
|
|
|
|
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
|
|
|
|
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
2014-02-19 04:17:36 +00:00
|
|
|
import android.content.DialogInterface.OnClickListener;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.content.res.Configuration;
|
2009-10-12 20:48:35 +00:00
|
|
|
import android.content.res.Resources;
|
2013-08-30 07:50:37 +00:00
|
|
|
import android.graphics.Rect;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.inputmethodservice.InputMethodService;
|
|
|
|
import android.media.AudioManager;
|
2011-01-26 14:13:18 +00:00
|
|
|
import android.net.ConnectivityManager;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.os.Debug;
|
2012-02-18 01:46:01 +00:00
|
|
|
import android.os.IBinder;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.os.Message;
|
2014-07-17 01:41:46 +00:00
|
|
|
import android.preference.PreferenceManager;
|
2010-12-10 06:24:28 +00:00
|
|
|
import android.text.InputType;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.PrintWriterPrinter;
|
|
|
|
import android.util.Printer;
|
2014-03-14 11:11:01 +00:00
|
|
|
import android.util.SparseArray;
|
2012-05-25 10:56:45 +00:00
|
|
|
import android.view.KeyEvent;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.view.View;
|
2013-08-30 07:50:37 +00:00
|
|
|
import android.view.ViewGroup.LayoutParams;
|
2012-04-02 13:25:08 +00:00
|
|
|
import android.view.Window;
|
|
|
|
import android.view.WindowManager;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.view.inputmethod.CompletionInfo;
|
|
|
|
import android.view.inputmethod.EditorInfo;
|
2012-04-02 12:31:52 +00:00
|
|
|
import android.view.inputmethod.InputMethodSubtype;
|
2011-05-23 09:30:21 +00:00
|
|
|
|
2011-05-18 00:03:25 +00:00
|
|
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
2012-10-03 08:36:45 +00:00
|
|
|
import com.android.inputmethod.annotations.UsedForTesting;
|
2014-07-19 04:33:42 +00:00
|
|
|
import com.android.inputmethod.compat.InputConnectionCompatUtils;
|
2012-08-02 04:25:17 +00:00
|
|
|
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
2013-03-19 07:45:25 +00:00
|
|
|
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
2014-03-12 07:41:45 +00:00
|
|
|
import com.android.inputmethod.event.Event;
|
2014-03-14 11:11:01 +00:00
|
|
|
import com.android.inputmethod.event.HardwareEventDecoder;
|
|
|
|
import com.android.inputmethod.event.HardwareKeyboardEventDecoder;
|
2014-03-04 08:28:20 +00:00
|
|
|
import com.android.inputmethod.event.InputTransaction;
|
2011-05-23 09:30:21 +00:00
|
|
|
import com.android.inputmethod.keyboard.Keyboard;
|
|
|
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
2011-12-07 12:27:59 +00:00
|
|
|
import com.android.inputmethod.keyboard.KeyboardId;
|
2011-05-23 09:30:21 +00:00
|
|
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
2012-07-23 01:27:14 +00:00
|
|
|
import com.android.inputmethod.keyboard.MainKeyboardView;
|
2013-08-29 06:15:49 +00:00
|
|
|
import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
|
2013-04-04 08:45:21 +00:00
|
|
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
2014-07-17 01:41:46 +00:00
|
|
|
import com.android.inputmethod.latin.define.DebugFlags;
|
2014-07-17 02:22:35 +00:00
|
|
|
import com.android.inputmethod.latin.define.ProductionFlags;
|
2013-12-18 09:08:35 +00:00
|
|
|
import com.android.inputmethod.latin.inputlogic.InputLogic;
|
2014-06-13 09:39:29 +00:00
|
|
|
import com.android.inputmethod.latin.personalization.ContextualDictionaryUpdater;
|
2013-10-02 09:06:08 +00:00
|
|
|
import com.android.inputmethod.latin.personalization.DictionaryDecayBroadcastReciever;
|
2014-06-13 07:31:12 +00:00
|
|
|
import com.android.inputmethod.latin.personalization.PersonalizationDictionaryUpdater;
|
2013-12-25 02:44:16 +00:00
|
|
|
import com.android.inputmethod.latin.personalization.PersonalizationHelper;
|
2013-07-22 03:43:37 +00:00
|
|
|
import com.android.inputmethod.latin.settings.Settings;
|
|
|
|
import com.android.inputmethod.latin.settings.SettingsActivity;
|
|
|
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
2012-07-23 06:28:28 +00:00
|
|
|
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
|
2014-01-24 14:11:48 +00:00
|
|
|
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
|
2013-07-05 09:23:22 +00:00
|
|
|
import com.android.inputmethod.latin.utils.ApplicationUtils;
|
2013-06-23 16:11:32 +00:00
|
|
|
import com.android.inputmethod.latin.utils.CapsModeUtils;
|
2013-12-27 11:58:32 +00:00
|
|
|
import com.android.inputmethod.latin.utils.CoordinateUtils;
|
2014-04-04 05:14:47 +00:00
|
|
|
import com.android.inputmethod.latin.utils.DialogUtils;
|
2014-08-08 03:31:02 +00:00
|
|
|
import com.android.inputmethod.latin.utils.DistracterFilterCheckingExactMatchesAndSuggestions;
|
2014-02-03 05:03:58 +00:00
|
|
|
import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
|
2013-06-23 16:11:32 +00:00
|
|
|
import com.android.inputmethod.latin.utils.IntentUtils;
|
2013-06-24 06:26:29 +00:00
|
|
|
import com.android.inputmethod.latin.utils.JniUtils;
|
2013-12-13 08:09:16 +00:00
|
|
|
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
2014-04-08 09:33:41 +00:00
|
|
|
import com.android.inputmethod.latin.utils.StatsUtils;
|
2014-01-27 10:04:40 +00:00
|
|
|
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
2009-03-13 22:11:42 +00:00
|
|
|
|
2010-01-16 20:21:23 +00:00
|
|
|
import java.io.FileDescriptor;
|
|
|
|
import java.io.PrintWriter;
|
2012-03-13 09:21:35 +00:00
|
|
|
import java.util.ArrayList;
|
2014-05-23 07:10:36 +00:00
|
|
|
import java.util.List;
|
2010-01-16 20:21:23 +00:00
|
|
|
import java.util.Locale;
|
2014-01-08 09:59:43 +00:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2010-01-16 20:21:23 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
/**
|
|
|
|
* Input method implementation for Qwerty'ish keyboard.
|
|
|
|
*/
|
2013-05-15 03:12:58 +00:00
|
|
|
public class LatinIME extends InputMethodService implements KeyboardActionListener,
|
2014-01-24 14:11:48 +00:00
|
|
|
SuggestionStripView.Listener, SuggestionStripViewAccessor,
|
2014-05-23 00:30:55 +00:00
|
|
|
DictionaryFacilitator.DictionaryInitializationListener,
|
2014-02-20 15:54:02 +00:00
|
|
|
ImportantNoticeDialog.ImportantNoticeDialogListener {
|
2011-02-23 08:23:29 +00:00
|
|
|
private static final String TAG = LatinIME.class.getSimpleName();
|
2010-11-21 01:36:37 +00:00
|
|
|
private static final boolean TRACE = false;
|
2013-12-19 13:18:46 +00:00
|
|
|
private static boolean DEBUG = false;
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2011-01-21 10:04:00 +00:00
|
|
|
private static final int EXTENDED_TOUCHABLE_REGION_HEIGHT = 100;
|
2010-10-27 09:05:27 +00:00
|
|
|
|
2011-09-29 08:27:48 +00:00
|
|
|
private static final int PENDING_IMS_CALLBACK_DURATION = 800;
|
2011-07-29 17:45:37 +00:00
|
|
|
|
2014-07-01 09:07:42 +00:00
|
|
|
private static final int DELAY_WAIT_FOR_DICTIONARY_LOAD = 2000; // 2s
|
|
|
|
|
2013-08-13 03:10:26 +00:00
|
|
|
private static final int PERIOD_FOR_AUDIO_AND_HAPTIC_FEEDBACK_IN_KEY_REPEAT = 2;
|
|
|
|
|
2011-03-14 18:46:15 +00:00
|
|
|
/**
|
|
|
|
* The name of the scheme used by the Package Manager to warn of a new package installation,
|
|
|
|
* replacement or removal.
|
|
|
|
*/
|
|
|
|
private static final String SCHEME_PACKAGE = "package";
|
|
|
|
|
2013-01-08 07:35:21 +00:00
|
|
|
private final Settings mSettings;
|
2014-05-23 07:10:36 +00:00
|
|
|
private final DictionaryFacilitator mDictionaryFacilitator =
|
2014-08-08 03:31:02 +00:00
|
|
|
new DictionaryFacilitator(
|
|
|
|
new DistracterFilterCheckingExactMatchesAndSuggestions(this /* context */));
|
2014-06-13 07:31:12 +00:00
|
|
|
// TODO: Move from LatinIME.
|
|
|
|
private final PersonalizationDictionaryUpdater mPersonalizationDictionaryUpdater =
|
|
|
|
new PersonalizationDictionaryUpdater(this /* context */, mDictionaryFacilitator);
|
2014-06-13 09:39:29 +00:00
|
|
|
private final ContextualDictionaryUpdater mContextualDictionaryUpdater =
|
2014-06-16 09:30:59 +00:00
|
|
|
new ContextualDictionaryUpdater(this /* context */, mDictionaryFacilitator,
|
|
|
|
new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
mHandler.postUpdateSuggestionStrip();
|
|
|
|
}
|
|
|
|
});
|
2014-01-24 14:17:40 +00:00
|
|
|
private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */,
|
2014-05-23 00:30:55 +00:00
|
|
|
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
|
2014-03-14 11:11:01 +00:00
|
|
|
// We expect to have only one decoder in almost all cases, hence the default capacity of 1.
|
|
|
|
// If it turns out we need several, it will get grown seamlessly.
|
2014-05-23 11:18:17 +00:00
|
|
|
final SparseArray<HardwareEventDecoder> mHardwareEventDecoders = new SparseArray<>(1);
|
2011-05-10 06:51:43 +00:00
|
|
|
|
2014-08-08 07:26:25 +00:00
|
|
|
// TODO: Move these {@link View}s to {@link KeyboardSwitcher}.
|
|
|
|
private View mInputView;
|
2013-08-30 07:50:37 +00:00
|
|
|
private View mExtractArea;
|
|
|
|
private View mKeyPreviewBackingView;
|
2012-07-23 06:28:28 +00:00
|
|
|
private SuggestionStripView mSuggestionStripView;
|
2013-12-18 09:08:35 +00:00
|
|
|
|
2012-11-09 09:21:41 +00:00
|
|
|
private RichInputMethodManager mRichImm;
|
2012-10-03 08:36:45 +00:00
|
|
|
@UsedForTesting final KeyboardSwitcher mKeyboardSwitcher;
|
2012-03-06 10:06:58 +00:00
|
|
|
private final SubtypeSwitcher mSubtypeSwitcher;
|
2012-10-02 09:40:06 +00:00
|
|
|
private final SubtypeState mSubtypeState = new SubtypeState();
|
2014-08-12 13:28:53 +00:00
|
|
|
private final SpecialKeyDetector mSpecialKeyDetector;
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2011-03-14 18:46:15 +00:00
|
|
|
// Object for reacting to adding/removing a dictionary pack.
|
2014-05-16 13:19:41 +00:00
|
|
|
private final BroadcastReceiver mDictionaryPackInstallReceiver =
|
2013-06-06 05:11:20 +00:00
|
|
|
new DictionaryPackInstallBroadcastReceiver(this);
|
2011-03-14 18:46:15 +00:00
|
|
|
|
2014-05-16 13:19:41 +00:00
|
|
|
private final BroadcastReceiver mDictionaryDumpBroadcastReceiver =
|
2014-02-04 12:29:09 +00:00
|
|
|
new DictionaryDumpBroadcastReceiver(this);
|
|
|
|
|
2012-04-02 13:25:08 +00:00
|
|
|
private AlertDialog mOptionsDialog;
|
|
|
|
|
2012-08-02 04:25:17 +00:00
|
|
|
private final boolean mIsHardwareAcceleratedDrawingEnabled;
|
|
|
|
|
2011-06-24 18:54:11 +00:00
|
|
|
public final UIHandler mHandler = new UIHandler(this);
|
2010-11-16 09:07:06 +00:00
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public static final class UIHandler extends LeakGuardHandlerWrapper<LatinIME> {
|
2012-08-07 02:48:10 +00:00
|
|
|
private static final int MSG_UPDATE_SHIFT_STATE = 0;
|
|
|
|
private static final int MSG_PENDING_IMS_CALLBACK = 1;
|
|
|
|
private static final int MSG_UPDATE_SUGGESTION_STRIP = 2;
|
2012-09-12 04:03:44 +00:00
|
|
|
private static final int MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP = 3;
|
2013-04-10 07:38:37 +00:00
|
|
|
private static final int MSG_RESUME_SUGGESTIONS = 4;
|
2013-06-13 06:26:47 +00:00
|
|
|
private static final int MSG_REOPEN_DICTIONARIES = 5;
|
2014-03-06 07:10:15 +00:00
|
|
|
private static final int MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED = 6;
|
2013-09-20 09:01:32 +00:00
|
|
|
private static final int MSG_RESET_CACHES = 7;
|
2014-07-01 09:07:42 +00:00
|
|
|
private static final int MSG_WAIT_FOR_DICTIONARY_LOAD = 8;
|
2013-12-13 08:09:16 +00:00
|
|
|
// Update this when adding new messages
|
2014-07-01 09:07:42 +00:00
|
|
|
private static final int MSG_LAST = MSG_WAIT_FOR_DICTIONARY_LOAD;
|
2012-09-12 04:03:44 +00:00
|
|
|
|
2013-09-02 07:49:32 +00:00
|
|
|
private static final int ARG1_NOT_GESTURE_INPUT = 0;
|
2012-09-12 04:03:44 +00:00
|
|
|
private static final int ARG1_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT = 1;
|
2013-09-02 07:49:32 +00:00
|
|
|
private static final int ARG1_SHOW_GESTURE_FLOATING_PREVIEW_TEXT = 2;
|
2014-01-24 13:42:40 +00:00
|
|
|
private static final int ARG2_UNUSED = 0;
|
2014-06-06 04:12:11 +00:00
|
|
|
private static final int ARG1_FALSE = 0;
|
|
|
|
private static final int ARG1_TRUE = 1;
|
2012-03-13 03:44:03 +00:00
|
|
|
|
2011-11-18 05:45:49 +00:00
|
|
|
private int mDelayUpdateSuggestions;
|
|
|
|
private int mDelayUpdateShiftState;
|
2011-07-21 06:57:00 +00:00
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
public UIHandler(final LatinIME ownerInstance) {
|
|
|
|
super(ownerInstance);
|
2011-11-18 05:45:49 +00:00
|
|
|
}
|
2011-11-16 23:58:42 +00:00
|
|
|
|
2011-11-18 05:45:49 +00:00
|
|
|
public void onCreate() {
|
2014-02-28 07:13:51 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
|
|
|
if (latinIme == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final Resources res = latinIme.getResources();
|
2014-02-18 05:48:41 +00:00
|
|
|
mDelayUpdateSuggestions = res.getInteger(R.integer.config_delay_update_suggestions);
|
|
|
|
mDelayUpdateShiftState = res.getInteger(R.integer.config_delay_update_shift_state);
|
2011-06-24 18:54:11 +00:00
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void handleMessage(final Message msg) {
|
2013-12-13 08:09:16 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
2014-02-28 07:13:51 +00:00
|
|
|
if (latinIme == null) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-24 18:54:11 +00:00
|
|
|
final KeyboardSwitcher switcher = latinIme.mKeyboardSwitcher;
|
2009-03-13 22:11:42 +00:00
|
|
|
switch (msg.what) {
|
2012-07-06 03:15:45 +00:00
|
|
|
case MSG_UPDATE_SUGGESTION_STRIP:
|
2014-03-03 05:19:52 +00:00
|
|
|
cancelUpdateSuggestionStrip();
|
2013-12-19 13:08:31 +00:00
|
|
|
latinIme.mInputLogic.performUpdateSuggestionStripSync(
|
2014-03-03 05:19:52 +00:00
|
|
|
latinIme.mSettings.getCurrent());
|
2010-11-16 09:07:06 +00:00
|
|
|
break;
|
|
|
|
case MSG_UPDATE_SHIFT_STATE:
|
2014-03-27 09:37:16 +00:00
|
|
|
switcher.requestUpdatingShiftState(latinIme.getCurrentAutoCapsState(),
|
|
|
|
latinIme.getCurrentRecapitalizeState());
|
2010-11-16 09:07:06 +00:00
|
|
|
break;
|
2012-09-12 04:03:44 +00:00
|
|
|
case MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP:
|
2013-09-02 07:49:32 +00:00
|
|
|
if (msg.arg1 == ARG1_NOT_GESTURE_INPUT) {
|
2014-01-24 13:42:40 +00:00
|
|
|
final SuggestedWords suggestedWords = (SuggestedWords) msg.obj;
|
2014-01-24 13:45:20 +00:00
|
|
|
latinIme.showSuggestionStrip(suggestedWords);
|
2013-09-02 07:49:32 +00:00
|
|
|
} else {
|
|
|
|
latinIme.showGesturePreviewAndSuggestionStrip((SuggestedWords) msg.obj,
|
|
|
|
msg.arg1 == ARG1_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT);
|
|
|
|
}
|
2012-09-12 04:03:44 +00:00
|
|
|
break;
|
2013-04-10 07:38:37 +00:00
|
|
|
case MSG_RESUME_SUGGESTIONS:
|
2013-12-20 09:05:35 +00:00
|
|
|
latinIme.mInputLogic.restartSuggestionsOnWordTouchedByCursor(
|
2014-01-10 11:18:24 +00:00
|
|
|
latinIme.mSettings.getCurrent(),
|
2014-06-26 09:43:14 +00:00
|
|
|
msg.arg1 == ARG1_TRUE /* shouldIncludeResumedWordInSuggestions */,
|
|
|
|
latinIme.mKeyboardSwitcher.getCurrentKeyboardScriptId());
|
2013-04-10 07:38:37 +00:00
|
|
|
break;
|
2013-06-13 06:26:47 +00:00
|
|
|
case MSG_REOPEN_DICTIONARIES:
|
2014-06-27 12:38:57 +00:00
|
|
|
// We need to re-evaluate the currently composing word in case the script has
|
|
|
|
// changed.
|
2014-07-01 09:07:42 +00:00
|
|
|
postWaitForDictionaryLoad();
|
2014-07-28 10:33:49 +00:00
|
|
|
latinIme.resetSuggest();
|
2013-06-13 06:26:47 +00:00
|
|
|
break;
|
2014-03-06 07:10:15 +00:00
|
|
|
case MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED:
|
|
|
|
latinIme.mInputLogic.onUpdateTailBatchInputCompleted(
|
|
|
|
latinIme.mSettings.getCurrent(),
|
2013-12-25 11:08:52 +00:00
|
|
|
(SuggestedWords) msg.obj, latinIme.mKeyboardSwitcher);
|
2013-09-02 07:49:32 +00:00
|
|
|
break;
|
2013-09-20 09:01:32 +00:00
|
|
|
case MSG_RESET_CACHES:
|
2013-12-27 08:04:12 +00:00
|
|
|
final SettingsValues settingsValues = latinIme.mSettings.getCurrent();
|
2014-08-04 13:07:15 +00:00
|
|
|
if (latinIme.mInputLogic.retryResetCachesAndReturnSuccess(
|
2013-12-20 11:07:16 +00:00
|
|
|
msg.arg1 == 1 /* tryResumeSuggestions */,
|
2013-12-27 08:04:12 +00:00
|
|
|
msg.arg2 /* remainingTries */, this /* handler */)) {
|
|
|
|
// If we were able to reset the caches, then we can reload the keyboard.
|
|
|
|
// Otherwise, we'll do it when we can.
|
|
|
|
latinIme.mKeyboardSwitcher.loadKeyboard(latinIme.getCurrentInputEditorInfo(),
|
2014-04-14 08:04:50 +00:00
|
|
|
settingsValues, latinIme.getCurrentAutoCapsState(),
|
2014-04-17 06:44:55 +00:00
|
|
|
latinIme.getCurrentRecapitalizeState());
|
2013-12-27 08:04:12 +00:00
|
|
|
}
|
2013-09-20 09:01:32 +00:00
|
|
|
break;
|
2014-07-01 09:07:42 +00:00
|
|
|
case MSG_WAIT_FOR_DICTIONARY_LOAD:
|
|
|
|
Log.i(TAG, "Timeout waiting for dictionary load");
|
|
|
|
break;
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-16 09:07:06 +00:00
|
|
|
|
2012-07-06 02:33:16 +00:00
|
|
|
public void postUpdateSuggestionStrip() {
|
2012-07-06 03:15:45 +00:00
|
|
|
sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTION_STRIP), mDelayUpdateSuggestions);
|
2010-11-16 09:07:06 +00:00
|
|
|
}
|
|
|
|
|
2013-06-13 06:26:47 +00:00
|
|
|
public void postReopenDictionaries() {
|
|
|
|
sendMessage(obtainMessage(MSG_REOPEN_DICTIONARIES));
|
|
|
|
}
|
|
|
|
|
2014-07-01 09:07:42 +00:00
|
|
|
public void postResumeSuggestions(final boolean shouldIncludeResumedWordInSuggestions,
|
|
|
|
final boolean shouldDelay) {
|
2014-02-28 07:13:51 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
|
|
|
if (latinIme == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-05-23 17:28:00 +00:00
|
|
|
if (!latinIme.mSettings.getCurrent()
|
2014-07-22 17:18:38 +00:00
|
|
|
.isSuggestionsEnabledPerUserSettings()) {
|
2013-12-25 12:48:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-08 09:44:50 +00:00
|
|
|
removeMessages(MSG_RESUME_SUGGESTIONS);
|
2014-07-01 09:07:42 +00:00
|
|
|
if (shouldDelay) {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_RESUME_SUGGESTIONS,
|
|
|
|
shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
|
|
|
|
0 /* ignored */),
|
|
|
|
mDelayUpdateSuggestions);
|
|
|
|
} else {
|
|
|
|
sendMessage(obtainMessage(MSG_RESUME_SUGGESTIONS,
|
|
|
|
shouldIncludeResumedWordInSuggestions ? ARG1_TRUE : ARG1_FALSE,
|
|
|
|
0 /* ignored */));
|
|
|
|
}
|
2013-04-10 07:38:37 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 09:34:26 +00:00
|
|
|
public void postResetCaches(final boolean tryResumeSuggestions, final int remainingTries) {
|
2013-09-20 09:01:32 +00:00
|
|
|
removeMessages(MSG_RESET_CACHES);
|
|
|
|
sendMessage(obtainMessage(MSG_RESET_CACHES, tryResumeSuggestions ? 1 : 0,
|
|
|
|
remainingTries, null));
|
|
|
|
}
|
|
|
|
|
2014-07-01 09:07:42 +00:00
|
|
|
public void postWaitForDictionaryLoad() {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_WAIT_FOR_DICTIONARY_LOAD),
|
|
|
|
DELAY_WAIT_FOR_DICTIONARY_LOAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void cancelWaitForDictionaryLoad() {
|
|
|
|
removeMessages(MSG_WAIT_FOR_DICTIONARY_LOAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasPendingWaitForDictionaryLoad() {
|
|
|
|
return hasMessages(MSG_WAIT_FOR_DICTIONARY_LOAD);
|
|
|
|
}
|
|
|
|
|
2012-07-05 02:34:48 +00:00
|
|
|
public void cancelUpdateSuggestionStrip() {
|
2012-07-06 03:15:45 +00:00
|
|
|
removeMessages(MSG_UPDATE_SUGGESTION_STRIP);
|
2010-11-16 09:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasPendingUpdateSuggestions() {
|
2012-07-06 03:15:45 +00:00
|
|
|
return hasMessages(MSG_UPDATE_SUGGESTION_STRIP);
|
2010-11-16 09:07:06 +00:00
|
|
|
}
|
|
|
|
|
2013-06-13 06:26:47 +00:00
|
|
|
public boolean hasPendingReopenDictionaries() {
|
|
|
|
return hasMessages(MSG_REOPEN_DICTIONARIES);
|
|
|
|
}
|
|
|
|
|
2012-02-16 19:45:35 +00:00
|
|
|
public void postUpdateShiftState() {
|
2010-11-16 09:07:06 +00:00
|
|
|
removeMessages(MSG_UPDATE_SHIFT_STATE);
|
2011-11-16 23:58:42 +00:00
|
|
|
sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE), mDelayUpdateShiftState);
|
2010-11-16 09:07:06 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 08:09:16 +00:00
|
|
|
@UsedForTesting
|
|
|
|
public void removeAllMessages() {
|
|
|
|
for (int i = 0; i <= MSG_LAST; ++i) {
|
|
|
|
removeMessages(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
public void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
|
|
|
|
final boolean dismissGestureFloatingPreviewText) {
|
|
|
|
removeMessages(MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP);
|
|
|
|
final int arg1 = dismissGestureFloatingPreviewText
|
2013-09-02 07:49:32 +00:00
|
|
|
? ARG1_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT
|
|
|
|
: ARG1_SHOW_GESTURE_FLOATING_PREVIEW_TEXT;
|
2013-09-19 11:31:15 +00:00
|
|
|
obtainMessage(MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP, arg1,
|
2014-01-24 13:42:40 +00:00
|
|
|
ARG2_UNUSED, suggestedWords).sendToTarget();
|
2012-09-12 04:03:44 +00:00
|
|
|
}
|
|
|
|
|
2013-09-02 07:49:32 +00:00
|
|
|
public void showSuggestionStrip(final SuggestedWords suggestedWords) {
|
|
|
|
removeMessages(MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP);
|
|
|
|
obtainMessage(MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP,
|
2014-01-24 13:42:40 +00:00
|
|
|
ARG1_NOT_GESTURE_INPUT, ARG2_UNUSED, suggestedWords).sendToTarget();
|
2013-09-02 07:49:32 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 07:10:15 +00:00
|
|
|
public void showTailBatchInputResult(final SuggestedWords suggestedWords) {
|
|
|
|
obtainMessage(MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED, suggestedWords).sendToTarget();
|
2013-09-02 07:49:32 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 08:27:48 +00:00
|
|
|
// Working variables for the following methods.
|
|
|
|
private boolean mIsOrientationChanging;
|
2012-01-24 02:58:07 +00:00
|
|
|
private boolean mPendingSuccessiveImsCallback;
|
2011-09-29 08:27:48 +00:00
|
|
|
private boolean mHasPendingStartInput;
|
|
|
|
private boolean mHasPendingFinishInputView;
|
|
|
|
private boolean mHasPendingFinishInput;
|
2011-11-21 22:58:32 +00:00
|
|
|
private EditorInfo mAppliedEditorInfo;
|
2011-09-29 08:27:48 +00:00
|
|
|
|
|
|
|
public void startOrientationChanging() {
|
2011-10-27 08:03:03 +00:00
|
|
|
removeMessages(MSG_PENDING_IMS_CALLBACK);
|
|
|
|
resetPendingImsCallback();
|
2011-09-29 08:27:48 +00:00
|
|
|
mIsOrientationChanging = true;
|
2013-12-13 08:09:16 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
2014-02-28 07:13:51 +00:00
|
|
|
if (latinIme == null) {
|
|
|
|
return;
|
|
|
|
}
|
2011-11-29 05:12:49 +00:00
|
|
|
if (latinIme.isInputViewShown()) {
|
|
|
|
latinIme.mKeyboardSwitcher.saveKeyboardState();
|
|
|
|
}
|
2011-09-29 08:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void resetPendingImsCallback() {
|
|
|
|
mHasPendingFinishInputView = false;
|
|
|
|
mHasPendingFinishInput = false;
|
|
|
|
mHasPendingStartInput = false;
|
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
private void executePendingImsCallback(final LatinIME latinIme, final EditorInfo editorInfo,
|
2011-09-29 08:27:48 +00:00
|
|
|
boolean restarting) {
|
2014-02-18 05:48:41 +00:00
|
|
|
if (mHasPendingFinishInputView) {
|
2011-09-29 08:27:48 +00:00
|
|
|
latinIme.onFinishInputViewInternal(mHasPendingFinishInput);
|
2014-02-18 05:48:41 +00:00
|
|
|
}
|
|
|
|
if (mHasPendingFinishInput) {
|
2011-09-29 08:27:48 +00:00
|
|
|
latinIme.onFinishInputInternal();
|
2014-02-18 05:48:41 +00:00
|
|
|
}
|
|
|
|
if (mHasPendingStartInput) {
|
2011-11-21 22:58:32 +00:00
|
|
|
latinIme.onStartInputInternal(editorInfo, restarting);
|
2014-02-18 05:48:41 +00:00
|
|
|
}
|
2011-09-29 08:27:48 +00:00
|
|
|
resetPendingImsCallback();
|
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onStartInput(final EditorInfo editorInfo, final boolean restarting) {
|
2011-09-29 08:27:48 +00:00
|
|
|
if (hasMessages(MSG_PENDING_IMS_CALLBACK)) {
|
|
|
|
// Typically this is the second onStartInput after orientation changed.
|
|
|
|
mHasPendingStartInput = true;
|
|
|
|
} else {
|
|
|
|
if (mIsOrientationChanging && restarting) {
|
|
|
|
// This is the first onStartInput after orientation changed.
|
|
|
|
mIsOrientationChanging = false;
|
2012-01-24 02:58:07 +00:00
|
|
|
mPendingSuccessiveImsCallback = true;
|
2011-09-29 08:27:48 +00:00
|
|
|
}
|
2013-12-13 08:09:16 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
2014-02-28 07:13:51 +00:00
|
|
|
if (latinIme != null) {
|
|
|
|
executePendingImsCallback(latinIme, editorInfo, restarting);
|
|
|
|
latinIme.onStartInputInternal(editorInfo, restarting);
|
2014-07-19 04:33:42 +00:00
|
|
|
if (ProductionFlags.ENABLE_CURSOR_RECT_CALLBACK) {
|
|
|
|
InputConnectionCompatUtils.requestCursorRect(
|
|
|
|
latinIme.getCurrentInputConnection(), true /* enableMonitor */);
|
|
|
|
}
|
|
|
|
if (ProductionFlags.ENABLE_CURSOR_ANCHOR_INFO_CALLBACK) {
|
|
|
|
InputConnectionCompatUtils.requestCursorAnchorInfo(
|
|
|
|
latinIme.getCurrentInputConnection(), true /* enableMonitor */,
|
|
|
|
true /* requestImmediateCallback */);
|
2014-04-11 01:41:12 +00:00
|
|
|
}
|
2014-02-28 07:13:51 +00:00
|
|
|
}
|
2011-07-29 17:45:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onStartInputView(final EditorInfo editorInfo, final boolean restarting) {
|
2011-12-07 12:27:59 +00:00
|
|
|
if (hasMessages(MSG_PENDING_IMS_CALLBACK)
|
|
|
|
&& KeyboardId.equivalentEditorInfoForKeyboard(editorInfo, mAppliedEditorInfo)) {
|
2011-11-21 22:58:32 +00:00
|
|
|
// Typically this is the second onStartInputView after orientation changed.
|
|
|
|
resetPendingImsCallback();
|
|
|
|
} else {
|
2012-01-24 02:58:07 +00:00
|
|
|
if (mPendingSuccessiveImsCallback) {
|
2011-11-21 22:58:32 +00:00
|
|
|
// This is the first onStartInputView after orientation changed.
|
2012-01-24 02:58:07 +00:00
|
|
|
mPendingSuccessiveImsCallback = false;
|
2011-11-21 22:58:32 +00:00
|
|
|
resetPendingImsCallback();
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_PENDING_IMS_CALLBACK),
|
|
|
|
PENDING_IMS_CALLBACK_DURATION);
|
|
|
|
}
|
2013-12-13 08:09:16 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
2014-02-28 07:13:51 +00:00
|
|
|
if (latinIme != null) {
|
|
|
|
executePendingImsCallback(latinIme, editorInfo, restarting);
|
|
|
|
latinIme.onStartInputViewInternal(editorInfo, restarting);
|
|
|
|
mAppliedEditorInfo = editorInfo;
|
|
|
|
}
|
2011-11-21 22:58:32 +00:00
|
|
|
}
|
2011-09-29 08:27:48 +00:00
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onFinishInputView(final boolean finishingInput) {
|
2011-09-29 08:27:48 +00:00
|
|
|
if (hasMessages(MSG_PENDING_IMS_CALLBACK)) {
|
|
|
|
// Typically this is the first onFinishInputView after orientation changed.
|
|
|
|
mHasPendingFinishInputView = true;
|
|
|
|
} else {
|
2013-12-13 08:09:16 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
2014-02-28 07:13:51 +00:00
|
|
|
if (latinIme != null) {
|
|
|
|
latinIme.onFinishInputViewInternal(finishingInput);
|
|
|
|
mAppliedEditorInfo = null;
|
|
|
|
}
|
2011-07-21 06:57:00 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-27 09:47:54 +00:00
|
|
|
|
2011-09-29 08:27:48 +00:00
|
|
|
public void onFinishInput() {
|
|
|
|
if (hasMessages(MSG_PENDING_IMS_CALLBACK)) {
|
|
|
|
// Typically this is the first onFinishInput after orientation changed.
|
|
|
|
mHasPendingFinishInput = true;
|
|
|
|
} else {
|
2013-12-13 08:09:16 +00:00
|
|
|
final LatinIME latinIme = getOwnerInstance();
|
2014-02-28 07:13:51 +00:00
|
|
|
if (latinIme != null) {
|
|
|
|
executePendingImsCallback(latinIme, null, false);
|
|
|
|
latinIme.onFinishInputInternal();
|
|
|
|
}
|
2011-09-27 09:47:54 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-21 06:57:00 +00:00
|
|
|
}
|
|
|
|
|
2012-10-02 09:40:06 +00:00
|
|
|
static final class SubtypeState {
|
|
|
|
private InputMethodSubtype mLastActiveSubtype;
|
2014-06-27 12:38:57 +00:00
|
|
|
private boolean mCurrentSubtypeHasBeenUsed;
|
2012-10-02 09:40:06 +00:00
|
|
|
|
2014-06-27 12:38:57 +00:00
|
|
|
public void setCurrentSubtypeHasBeenUsed() {
|
|
|
|
mCurrentSubtypeHasBeenUsed = true;
|
2012-10-02 09:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void switchSubtype(final IBinder token, final RichInputMethodManager richImm) {
|
|
|
|
final InputMethodSubtype currentSubtype = richImm.getInputMethodManager()
|
|
|
|
.getCurrentInputMethodSubtype();
|
|
|
|
final InputMethodSubtype lastActiveSubtype = mLastActiveSubtype;
|
2014-06-27 12:38:57 +00:00
|
|
|
final boolean currentSubtypeHasBeenUsed = mCurrentSubtypeHasBeenUsed;
|
|
|
|
if (currentSubtypeHasBeenUsed) {
|
2012-10-02 09:40:06 +00:00
|
|
|
mLastActiveSubtype = currentSubtype;
|
2014-06-27 12:38:57 +00:00
|
|
|
mCurrentSubtypeHasBeenUsed = false;
|
2012-10-02 09:40:06 +00:00
|
|
|
}
|
2014-06-27 12:38:57 +00:00
|
|
|
if (currentSubtypeHasBeenUsed
|
2012-10-02 09:40:06 +00:00
|
|
|
&& richImm.checkIfSubtypeBelongsToThisImeAndEnabled(lastActiveSubtype)
|
|
|
|
&& !currentSubtype.equals(lastActiveSubtype)) {
|
|
|
|
richImm.setInputMethodAndSubtype(token, lastActiveSubtype);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
richImm.switchToNextInputMethod(token, true /* onlyCurrentIme */);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-24 06:26:29 +00:00
|
|
|
// Loading the native library eagerly to avoid unexpected UnsatisfiedLinkError at the initial
|
|
|
|
// JNI call as much as possible.
|
|
|
|
static {
|
|
|
|
JniUtils.loadNativeLibrary();
|
|
|
|
}
|
|
|
|
|
2012-03-06 10:06:58 +00:00
|
|
|
public LatinIME() {
|
|
|
|
super();
|
2013-01-08 07:35:21 +00:00
|
|
|
mSettings = Settings.getInstance();
|
2012-03-06 10:06:58 +00:00
|
|
|
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
|
|
|
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
2014-08-12 13:28:53 +00:00
|
|
|
mSpecialKeyDetector = new SpecialKeyDetector(this);
|
2012-08-02 04:25:17 +00:00
|
|
|
mIsHardwareAcceleratedDrawingEnabled =
|
|
|
|
InputMethodServiceCompatUtils.enableHardwareAcceleration(this);
|
|
|
|
Log.i(TAG, "Hardware accelerated drawing: " + mIsHardwareAcceleratedDrawingEnabled);
|
2012-03-06 10:06:58 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 13:17:16 +00:00
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
2013-01-08 07:35:21 +00:00
|
|
|
Settings.init(this);
|
2014-07-17 01:41:46 +00:00
|
|
|
DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this));
|
2013-01-07 09:40:59 +00:00
|
|
|
RichInputMethodManager.init(this);
|
2012-11-28 04:28:18 +00:00
|
|
|
mRichImm = RichInputMethodManager.getInstance();
|
2011-07-17 22:23:52 +00:00
|
|
|
SubtypeSwitcher.init(this);
|
2013-01-07 09:40:59 +00:00
|
|
|
KeyboardSwitcher.init(this);
|
2013-01-08 05:58:08 +00:00
|
|
|
AudioAndHapticFeedbackManager.init(this);
|
2011-12-15 10:32:11 +00:00
|
|
|
AccessibilityUtils.init(this);
|
2014-05-14 05:26:29 +00:00
|
|
|
StatsUtils.init(this);
|
2010-12-23 03:24:27 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onCreate();
|
2010-12-23 03:24:27 +00:00
|
|
|
|
2011-11-18 05:45:49 +00:00
|
|
|
mHandler.onCreate();
|
2014-07-17 01:41:46 +00:00
|
|
|
DEBUG = DebugFlags.DEBUG_ENABLED;
|
2010-12-23 03:24:27 +00:00
|
|
|
|
2013-04-18 03:34:45 +00:00
|
|
|
// TODO: Resolve mutual dependencies of {@link #loadSettings()} and {@link #initSuggest()}.
|
2011-09-19 05:51:31 +00:00
|
|
|
loadSettings();
|
2014-03-25 06:35:20 +00:00
|
|
|
resetSuggest();
|
2010-08-20 05:35:02 +00:00
|
|
|
|
2011-03-14 18:46:15 +00:00
|
|
|
// Register to receive ringer mode change and network state change.
|
|
|
|
// Also receive installation and removal of a dictionary pack.
|
2011-01-26 14:13:18 +00:00
|
|
|
final IntentFilter filter = new IntentFilter();
|
|
|
|
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
2012-03-09 02:00:23 +00:00
|
|
|
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
2014-04-15 10:23:01 +00:00
|
|
|
registerReceiver(mConnectivityAndRingerModeChangeReceiver, filter);
|
2011-03-14 18:46:15 +00:00
|
|
|
|
2013-06-06 05:11:20 +00:00
|
|
|
final IntentFilter packageFilter = new IntentFilter();
|
|
|
|
packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
|
|
|
packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
|
|
|
packageFilter.addDataScheme(SCHEME_PACKAGE);
|
|
|
|
registerReceiver(mDictionaryPackInstallReceiver, packageFilter);
|
|
|
|
|
|
|
|
final IntentFilter newDictFilter = new IntentFilter();
|
|
|
|
newDictFilter.addAction(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
|
|
|
|
registerReceiver(mDictionaryPackInstallReceiver, newDictFilter);
|
2013-09-02 07:49:32 +00:00
|
|
|
|
2014-02-04 12:29:09 +00:00
|
|
|
final IntentFilter dictDumpFilter = new IntentFilter();
|
|
|
|
dictDumpFilter.addAction(DictionaryDumpBroadcastReceiver.DICTIONARY_DUMP_INTENT_ACTION);
|
|
|
|
registerReceiver(mDictionaryDumpBroadcastReceiver, dictDumpFilter);
|
|
|
|
|
2013-10-02 09:06:08 +00:00
|
|
|
DictionaryDecayBroadcastReciever.setUpIntervalAlarmForDictionaryDecaying(this);
|
2014-04-08 09:33:41 +00:00
|
|
|
|
2014-05-14 05:26:29 +00:00
|
|
|
StatsUtils.onCreate(mSettings.getCurrent());
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2009-10-12 20:48:35 +00:00
|
|
|
|
2011-05-10 06:51:43 +00:00
|
|
|
// Has to be package-visible for unit tests
|
2012-10-03 08:36:45 +00:00
|
|
|
@UsedForTesting
|
2012-08-22 01:19:56 +00:00
|
|
|
void loadSettings() {
|
2013-01-08 07:35:21 +00:00
|
|
|
final Locale locale = mSubtypeSwitcher.getCurrentSubtypeLocale();
|
2013-12-20 06:00:44 +00:00
|
|
|
final EditorInfo editorInfo = getCurrentInputEditorInfo();
|
2014-06-05 16:41:42 +00:00
|
|
|
final InputAttributes inputAttributes = new InputAttributes(
|
|
|
|
editorInfo, isFullscreenMode(), getPackageName());
|
2013-12-20 06:00:44 +00:00
|
|
|
mSettings.loadSettings(this, locale, inputAttributes);
|
2013-12-25 02:44:16 +00:00
|
|
|
final SettingsValues currentSettingsValues = mSettings.getCurrent();
|
2014-02-27 13:31:57 +00:00
|
|
|
AudioAndHapticFeedbackManager.getInstance().onSettingsChanged(currentSettingsValues);
|
|
|
|
// This method is called on startup and language switch, before the new layout has
|
|
|
|
// been displayed. Opening dictionaries never affects responsivity as dictionaries are
|
|
|
|
// asynchronously loaded.
|
2014-03-25 06:35:20 +00:00
|
|
|
if (!mHandler.hasPendingReopenDictionaries()) {
|
|
|
|
resetSuggestForLocale(locale);
|
2013-12-25 02:44:16 +00:00
|
|
|
}
|
2014-05-23 07:10:36 +00:00
|
|
|
mDictionaryFacilitator.updateEnabledSubtypes(mRichImm.getMyEnabledInputMethodSubtypeList(
|
|
|
|
true /* allowsImplicitlySelectedSubtypes */));
|
2014-06-13 07:31:12 +00:00
|
|
|
refreshPersonalizationDictionarySession(currentSettingsValues);
|
2014-05-14 05:26:29 +00:00
|
|
|
StatsUtils.onLoadSettings(currentSettingsValues);
|
2014-01-08 09:59:43 +00:00
|
|
|
}
|
|
|
|
|
2014-06-13 07:31:12 +00:00
|
|
|
private void refreshPersonalizationDictionarySession(
|
|
|
|
final SettingsValues currentSettingsValues) {
|
|
|
|
mPersonalizationDictionaryUpdater.onLoadSettings(
|
|
|
|
currentSettingsValues.mUsePersonalizedDicts,
|
|
|
|
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes());
|
2014-06-13 09:39:29 +00:00
|
|
|
mContextualDictionaryUpdater.onLoadSettings(currentSettingsValues.mUsePersonalizedDicts);
|
2014-02-19 12:00:27 +00:00
|
|
|
final boolean shouldKeepUserHistoryDictionaries;
|
2014-06-13 09:39:29 +00:00
|
|
|
if (currentSettingsValues.mUsePersonalizedDicts) {
|
2014-02-19 12:00:27 +00:00
|
|
|
shouldKeepUserHistoryDictionaries = true;
|
2013-12-25 02:44:16 +00:00
|
|
|
} else {
|
2014-02-19 12:00:27 +00:00
|
|
|
shouldKeepUserHistoryDictionaries = false;
|
|
|
|
}
|
|
|
|
if (!shouldKeepUserHistoryDictionaries) {
|
|
|
|
// Remove user history dictionaries.
|
|
|
|
PersonalizationHelper.removeAllUserHistoryDictionaries(this);
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.clearUserHistoryDictionary();
|
2014-02-19 12:00:27 +00:00
|
|
|
}
|
2011-05-10 06:51:43 +00:00
|
|
|
}
|
|
|
|
|
2012-08-08 02:41:58 +00:00
|
|
|
// Note that this method is called from a non-UI thread.
|
2012-07-24 06:56:25 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onUpdateMainDictionaryAvailability(final boolean isMainDictionaryAvailable) {
|
2012-08-08 02:41:58 +00:00
|
|
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
|
|
|
if (mainKeyboardView != null) {
|
|
|
|
mainKeyboardView.setMainDictionaryAvailability(isMainDictionaryAvailable);
|
|
|
|
}
|
2014-07-01 09:07:42 +00:00
|
|
|
if (mHandler.hasPendingWaitForDictionaryLoad()) {
|
|
|
|
mHandler.cancelWaitForDictionaryLoad();
|
|
|
|
mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
|
|
|
|
false /* shouldDelay */);
|
|
|
|
}
|
2012-07-24 06:56:25 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:35:20 +00:00
|
|
|
private void resetSuggest() {
|
2013-10-04 11:24:41 +00:00
|
|
|
final Locale switcherSubtypeLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
|
|
|
|
final String switcherLocaleStr = switcherSubtypeLocale.toString();
|
|
|
|
final Locale subtypeLocale;
|
|
|
|
if (TextUtils.isEmpty(switcherLocaleStr)) {
|
|
|
|
// This happens in very rare corner cases - for example, immediately after a switch
|
|
|
|
// to LatinIME has been requested, about a frame later another switch happens. In this
|
|
|
|
// case, we are about to go down but we still don't know it, however the system tells
|
|
|
|
// us there is no current subtype so the locale is the empty string. Take the best
|
|
|
|
// possible guess instead -- it's bound to have no consequences, and we have no way
|
|
|
|
// of knowing anyway.
|
|
|
|
Log.e(TAG, "System is reporting no current subtype.");
|
|
|
|
subtypeLocale = getResources().getConfiguration().locale;
|
|
|
|
} else {
|
|
|
|
subtypeLocale = switcherSubtypeLocale;
|
|
|
|
}
|
2014-03-25 06:35:20 +00:00
|
|
|
resetSuggestForLocale(subtypeLocale);
|
2014-01-08 09:59:43 +00:00
|
|
|
}
|
2009-10-12 20:48:35 +00:00
|
|
|
|
2014-03-25 06:35:20 +00:00
|
|
|
/**
|
|
|
|
* Reset suggest by loading dictionaries for the locale and the current settings values.
|
|
|
|
*
|
|
|
|
* @param locale the locale
|
|
|
|
*/
|
|
|
|
private void resetSuggestForLocale(final Locale locale) {
|
|
|
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.resetDictionaries(this /* context */, locale,
|
2014-03-25 06:35:20 +00:00
|
|
|
settingsValues.mUseContactsDict, settingsValues.mUsePersonalizedDicts,
|
|
|
|
false /* forceReloadMainDictionary */, this);
|
2014-07-22 17:18:38 +00:00
|
|
|
if (settingsValues.mAutoCorrectionEnabledPerUserSettings) {
|
2014-03-25 06:35:20 +00:00
|
|
|
mInputLogic.mSuggest.setAutoCorrectionThreshold(
|
|
|
|
settingsValues.mAutoCorrectionThreshold);
|
2012-04-11 05:58:02 +00:00
|
|
|
}
|
2014-01-08 09:59:43 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:35:20 +00:00
|
|
|
/**
|
|
|
|
* Reset suggest by loading the main dictionary of the current locale.
|
|
|
|
*/
|
2014-01-08 09:59:43 +00:00
|
|
|
/* package private */ void resetSuggestMainDict() {
|
2014-03-25 06:35:20 +00:00
|
|
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.resetDictionaries(this /* context */,
|
|
|
|
mDictionaryFacilitator.getLocale(), settingsValues.mUseContactsDict,
|
2014-03-25 06:35:20 +00:00
|
|
|
settingsValues.mUsePersonalizedDicts, true /* forceReloadMainDictionary */, this);
|
2011-03-14 18:46:15 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 20:21:23 +00:00
|
|
|
@Override
|
|
|
|
public void onDestroy() {
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.closeDictionaries();
|
2014-06-13 07:31:12 +00:00
|
|
|
mPersonalizationDictionaryUpdater.onDestroy();
|
2014-06-13 09:39:29 +00:00
|
|
|
mContextualDictionaryUpdater.onDestroy();
|
2013-01-08 07:35:21 +00:00
|
|
|
mSettings.onDestroy();
|
2014-04-15 10:23:01 +00:00
|
|
|
unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
|
2013-06-06 05:11:20 +00:00
|
|
|
unregisterReceiver(mDictionaryPackInstallReceiver);
|
2014-02-06 06:37:41 +00:00
|
|
|
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
|
2014-04-08 09:33:41 +00:00
|
|
|
StatsUtils.onDestroy();
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
|
2014-04-07 13:32:06 +00:00
|
|
|
@UsedForTesting
|
|
|
|
public void recycle() {
|
2014-04-15 10:23:01 +00:00
|
|
|
unregisterReceiver(mDictionaryPackInstallReceiver);
|
|
|
|
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
|
|
|
|
unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
|
2014-04-07 13:32:06 +00:00
|
|
|
mInputLogic.recycle();
|
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onConfigurationChanged(final Configuration conf) {
|
2013-12-20 07:34:38 +00:00
|
|
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
|
|
|
if (settingsValues.mDisplayOrientation != conf.orientation) {
|
2011-08-23 05:58:45 +00:00
|
|
|
mHandler.startOrientationChanging();
|
2014-06-30 13:15:36 +00:00
|
|
|
mInputLogic.onOrientationChange(mSettings.getCurrent());
|
2009-07-21 22:47:11 +00:00
|
|
|
}
|
2014-06-13 07:31:12 +00:00
|
|
|
// TODO: Remove this test.
|
|
|
|
if (!conf.locale.equals(mPersonalizationDictionaryUpdater.getLocale())) {
|
|
|
|
refreshPersonalizationDictionarySession(settingsValues);
|
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onConfigurationChanged(conf);
|
|
|
|
}
|
2009-07-21 22:47:11 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
|
|
|
public View onCreateInputView() {
|
2012-08-02 07:39:27 +00:00
|
|
|
return mKeyboardSwitcher.onCreateInputView(mIsHardwareAcceleratedDrawingEnabled);
|
2011-05-25 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-08-30 07:50:37 +00:00
|
|
|
public void setInputView(final View view) {
|
|
|
|
super.setInputView(view);
|
2014-08-08 07:26:25 +00:00
|
|
|
mInputView = view;
|
2013-08-30 07:50:37 +00:00
|
|
|
mExtractArea = getWindow().getWindow().getDecorView()
|
|
|
|
.findViewById(android.R.id.extractArea);
|
|
|
|
mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing);
|
|
|
|
mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view);
|
2014-02-18 05:48:41 +00:00
|
|
|
if (hasSuggestionStripView()) {
|
2013-08-30 07:50:37 +00:00
|
|
|
mSuggestionStripView.setListener(this, view);
|
2013-12-13 08:09:16 +00:00
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void setCandidatesView(final View view) {
|
2011-05-23 09:30:21 +00:00
|
|
|
// To ensure that CandidatesView will never be set.
|
|
|
|
return;
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 08:27:48 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onStartInput(final EditorInfo editorInfo, final boolean restarting) {
|
2011-11-21 22:58:32 +00:00
|
|
|
mHandler.onStartInput(editorInfo, restarting);
|
2011-09-29 08:27:48 +00:00
|
|
|
}
|
|
|
|
|
2010-01-28 18:09:44 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onStartInputView(final EditorInfo editorInfo, final boolean restarting) {
|
2011-11-21 22:58:32 +00:00
|
|
|
mHandler.onStartInputView(editorInfo, restarting);
|
2011-09-29 08:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onFinishInputView(final boolean finishingInput) {
|
2011-09-29 08:27:48 +00:00
|
|
|
mHandler.onFinishInputView(finishingInput);
|
|
|
|
}
|
2011-07-21 06:57:00 +00:00
|
|
|
|
2011-09-29 08:27:48 +00:00
|
|
|
@Override
|
|
|
|
public void onFinishInput() {
|
|
|
|
mHandler.onFinishInput();
|
|
|
|
}
|
|
|
|
|
2012-04-02 12:31:52 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) {
|
2012-06-01 02:22:39 +00:00
|
|
|
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
|
|
|
|
// is not guaranteed. It may even be called at the same time on a different thread.
|
2012-12-26 05:31:13 +00:00
|
|
|
mSubtypeSwitcher.onSubtypeChanged(subtype);
|
2014-05-08 05:53:56 +00:00
|
|
|
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype));
|
2012-08-22 01:19:56 +00:00
|
|
|
loadKeyboard();
|
2012-04-02 12:31:52 +00:00
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
private void onStartInputInternal(final EditorInfo editorInfo, final boolean restarting) {
|
2011-11-21 22:58:32 +00:00
|
|
|
super.onStartInput(editorInfo, restarting);
|
2011-09-29 08:27:48 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 03:42:13 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2012-09-12 04:03:44 +00:00
|
|
|
private void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restarting) {
|
2011-11-21 22:58:32 +00:00
|
|
|
super.onStartInputView(editorInfo, restarting);
|
2014-08-06 09:34:26 +00:00
|
|
|
mRichImm.clearSubtypeCaches();
|
2010-11-12 23:49:56 +00:00
|
|
|
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
2013-11-11 11:39:03 +00:00
|
|
|
switcher.updateKeyboardTheme();
|
2012-08-07 02:48:10 +00:00
|
|
|
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
|
2014-08-06 09:34:59 +00:00
|
|
|
// If we are starting input in a different text field from before, we'll have to reload
|
|
|
|
// settings, so currentSettingsValues can't be final.
|
|
|
|
SettingsValues currentSettingsValues = mSettings.getCurrent();
|
2010-11-21 03:43:10 +00:00
|
|
|
|
2012-03-06 05:56:46 +00:00
|
|
|
if (editorInfo == null) {
|
|
|
|
Log.e(TAG, "Null EditorInfo in onStartInputView()");
|
2014-07-17 01:41:46 +00:00
|
|
|
if (DebugFlags.DEBUG_ENABLED) {
|
2012-03-06 05:56:46 +00:00
|
|
|
throw new NullPointerException("Null EditorInfo in onStartInputView()");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2011-04-20 02:50:05 +00:00
|
|
|
if (DEBUG) {
|
2012-03-06 05:56:46 +00:00
|
|
|
Log.d(TAG, "onStartInputView: editorInfo:"
|
|
|
|
+ String.format("inputType=0x%08x imeOptions=0x%08x",
|
|
|
|
editorInfo.inputType, editorInfo.imeOptions));
|
2012-05-11 07:52:22 +00:00
|
|
|
Log.d(TAG, "All caps = "
|
|
|
|
+ ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0)
|
|
|
|
+ ", sentence caps = "
|
|
|
|
+ ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0)
|
|
|
|
+ ", word caps = "
|
|
|
|
+ ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) != 0));
|
2011-01-22 20:46:30 +00:00
|
|
|
}
|
2014-02-20 06:35:01 +00:00
|
|
|
Log.i(TAG, "Starting input. Cursor position = "
|
|
|
|
+ editorInfo.initialSelStart + "," + editorInfo.initialSelEnd);
|
2014-06-05 09:09:24 +00:00
|
|
|
// TODO: Consolidate these checks with {@link InputAttributes}.
|
2012-04-19 03:42:13 +00:00
|
|
|
if (InputAttributes.inPrivateImeOptions(null, NO_MICROPHONE_COMPAT, editorInfo)) {
|
2014-02-18 05:48:41 +00:00
|
|
|
Log.w(TAG, "Deprecated private IME option specified: " + editorInfo.privateImeOptions);
|
2012-04-19 03:42:13 +00:00
|
|
|
Log.w(TAG, "Use " + getPackageName() + "." + NO_MICROPHONE + " instead");
|
2012-01-25 11:54:00 +00:00
|
|
|
}
|
2012-04-19 03:42:13 +00:00
|
|
|
if (InputAttributes.inPrivateImeOptions(getPackageName(), FORCE_ASCII, editorInfo)) {
|
2014-02-18 05:48:41 +00:00
|
|
|
Log.w(TAG, "Deprecated private IME option specified: " + editorInfo.privateImeOptions);
|
2012-01-25 11:54:00 +00:00
|
|
|
Log.w(TAG, "Use EditorInfo.IME_FLAG_FORCE_ASCII flag instead");
|
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
// In landscape mode, this method gets called without the input view being created.
|
2012-08-07 02:48:10 +00:00
|
|
|
if (mainKeyboardView == null) {
|
2009-03-13 22:11:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-05 23:59:31 +00:00
|
|
|
// Forward this event to the accessibility utilities, if enabled.
|
|
|
|
final AccessibilityUtils accessUtils = AccessibilityUtils.getInstance();
|
|
|
|
if (accessUtils.isTouchExplorationEnabled()) {
|
2012-08-14 22:34:29 +00:00
|
|
|
accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting);
|
2011-10-05 23:59:31 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 09:34:59 +00:00
|
|
|
final boolean inputTypeChanged = !currentSettingsValues.isSameInputType(editorInfo);
|
2012-08-15 08:57:38 +00:00
|
|
|
final boolean isDifferentTextField = !restarting || inputTypeChanged;
|
|
|
|
if (isDifferentTextField) {
|
2012-12-26 05:31:13 +00:00
|
|
|
mSubtypeSwitcher.updateParametersOnStartInputView();
|
2012-07-25 10:31:19 +00:00
|
|
|
}
|
2010-11-18 00:55:23 +00:00
|
|
|
|
2011-10-24 06:26:53 +00:00
|
|
|
// The EditorInfo might have a flag that affects fullscreen mode.
|
|
|
|
// Note: This call should be done by InputMethodService?
|
|
|
|
updateFullscreenMode();
|
2011-01-18 06:28:21 +00:00
|
|
|
|
2014-08-06 09:34:26 +00:00
|
|
|
// The app calling setText() has the effect of clearing the composing
|
|
|
|
// span, so we should reset our state unconditionally, even if restarting is true.
|
|
|
|
// We also tell the input logic about the combining rules for the current subtype, so
|
|
|
|
// it can adjust its combiners if needed.
|
|
|
|
mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype());
|
|
|
|
|
|
|
|
// Note: the following does a round-trip IPC on the main thread: be careful
|
|
|
|
final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
|
|
|
|
final Suggest suggest = mInputLogic.mSuggest;
|
|
|
|
if (null != currentLocale && !currentLocale.equals(suggest.getLocale())) {
|
|
|
|
// TODO: Do this automatically.
|
|
|
|
resetSuggest();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO[IL]: Can the following be moved to InputLogic#startInput?
|
|
|
|
final boolean canReachInputConnection;
|
|
|
|
if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess(
|
|
|
|
editorInfo.initialSelStart, editorInfo.initialSelEnd,
|
|
|
|
false /* shouldFinishComposition */)) {
|
|
|
|
// Sometimes, while rotating, for some reason the framework tells the app we are not
|
|
|
|
// connected to it and that means we can't refresh the cache. In this case, schedule a
|
|
|
|
// refresh later.
|
|
|
|
// We try resetting the caches up to 5 times before giving up.
|
|
|
|
mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
|
|
|
|
// mLastSelection{Start,End} are reset later in this method, don't need to do it here
|
|
|
|
canReachInputConnection = false;
|
|
|
|
} else {
|
|
|
|
// When rotating, initialSelStart and initialSelEnd sometimes are lying. Make a best
|
|
|
|
// effort to work around this bug.
|
|
|
|
mInputLogic.mConnection.tryFixLyingCursorPosition();
|
|
|
|
mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
|
|
|
|
true /* shouldDelay */);
|
|
|
|
canReachInputConnection = true;
|
|
|
|
}
|
|
|
|
|
2014-08-06 09:34:59 +00:00
|
|
|
if (isDifferentTextField ||
|
|
|
|
!currentSettingsValues.hasSameOrientation(getResources().getConfiguration())) {
|
2014-08-06 09:34:26 +00:00
|
|
|
loadSettings();
|
|
|
|
}
|
2012-08-15 08:57:38 +00:00
|
|
|
if (isDifferentTextField) {
|
2012-08-07 02:48:10 +00:00
|
|
|
mainKeyboardView.closing();
|
2014-08-06 09:34:59 +00:00
|
|
|
currentSettingsValues = mSettings.getCurrent();
|
2013-07-30 03:57:35 +00:00
|
|
|
|
2014-08-06 09:34:26 +00:00
|
|
|
if (currentSettingsValues.mAutoCorrectionEnabledPerUserSettings) {
|
|
|
|
suggest.setAutoCorrectionThreshold(
|
|
|
|
currentSettingsValues.mAutoCorrectionThreshold);
|
|
|
|
}
|
|
|
|
|
2014-04-14 08:04:50 +00:00
|
|
|
switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2014-08-06 09:34:26 +00:00
|
|
|
if (!canReachInputConnection) {
|
2013-10-08 07:33:27 +00:00
|
|
|
// If we can't reach the input connection, we will call loadKeyboard again later,
|
|
|
|
// so we need to save its state now. The call will be done in #retryResetCaches.
|
|
|
|
switcher.saveKeyboardState();
|
2013-10-07 12:43:05 +00:00
|
|
|
}
|
2012-11-06 07:45:44 +00:00
|
|
|
} else if (restarting) {
|
|
|
|
// TODO: Come up with a more comprehensive way to reset the keyboard layout when
|
|
|
|
// a keyboard layout set doesn't get reloaded in this method.
|
2014-04-14 08:04:50 +00:00
|
|
|
switcher.resetKeyboardStateToAlphabet(getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2012-11-14 08:37:55 +00:00
|
|
|
// In apps like Talk, we come here when the text is sent and the field gets emptied and
|
|
|
|
// we need to re-evaluate the shift state, but not the whole layout which would be
|
|
|
|
// disruptive.
|
|
|
|
// Space state must be updated before calling updateShiftState
|
2014-03-27 09:37:16 +00:00
|
|
|
switcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2012-07-25 10:31:19 +00:00
|
|
|
}
|
2014-02-17 16:10:17 +00:00
|
|
|
// This will set the punctuation suggestions if next word suggestion is off;
|
|
|
|
// otherwise it will clear the suggestion strip.
|
2014-02-26 06:26:41 +00:00
|
|
|
setNeutralSuggestionStrip();
|
2012-07-05 06:26:43 +00:00
|
|
|
|
|
|
|
mHandler.cancelUpdateSuggestionStrip();
|
2011-01-18 06:28:21 +00:00
|
|
|
|
2014-03-25 06:35:20 +00:00
|
|
|
mainKeyboardView.setMainDictionaryAvailability(
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.hasInitializedMainDictionary());
|
2013-07-29 09:53:23 +00:00
|
|
|
mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn,
|
|
|
|
currentSettingsValues.mKeyPreviewPopupDismissDelay);
|
2013-01-24 07:08:33 +00:00
|
|
|
mainKeyboardView.setSlidingKeyInputPreviewEnabled(
|
2013-07-29 09:53:23 +00:00
|
|
|
currentSettingsValues.mSlidingKeyInputPreviewEnabled);
|
2013-01-08 07:35:21 +00:00
|
|
|
mainKeyboardView.setGestureHandlingEnabledByUser(
|
2013-08-09 12:07:40 +00:00
|
|
|
currentSettingsValues.mGestureInputEnabled,
|
|
|
|
currentSettingsValues.mGestureTrailEnabled,
|
2013-07-29 09:53:23 +00:00
|
|
|
currentSettingsValues.mGestureFloatingPreviewTextEnabled);
|
2011-01-18 06:28:21 +00:00
|
|
|
|
2014-06-13 09:39:29 +00:00
|
|
|
// Contextual dictionary should be updated for the current application.
|
|
|
|
mContextualDictionaryUpdater.onStartInputView(editorInfo.packageName);
|
2011-01-18 06:28:21 +00:00
|
|
|
if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
|
|
|
|
}
|
|
|
|
|
2011-05-17 10:02:32 +00:00
|
|
|
@Override
|
|
|
|
public void onWindowHidden() {
|
|
|
|
super.onWindowHidden();
|
2012-09-12 04:03:44 +00:00
|
|
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
2012-08-07 02:48:10 +00:00
|
|
|
if (mainKeyboardView != null) {
|
|
|
|
mainKeyboardView.closing();
|
|
|
|
}
|
2011-05-17 10:02:32 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 08:27:48 +00:00
|
|
|
private void onFinishInputInternal() {
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onFinishInput();
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
2012-08-07 02:48:10 +00:00
|
|
|
if (mainKeyboardView != null) {
|
|
|
|
mainKeyboardView.closing();
|
|
|
|
}
|
2010-01-16 20:21:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-12 04:03:44 +00:00
|
|
|
private void onFinishInputViewInternal(final boolean finishingInput) {
|
2010-10-06 09:39:47 +00:00
|
|
|
super.onFinishInputView(finishingInput);
|
2013-10-08 11:11:35 +00:00
|
|
|
mKeyboardSwitcher.deallocateMemory();
|
2010-11-16 09:07:06 +00:00
|
|
|
// Remove pending messages related to update suggestions
|
2012-07-05 02:34:48 +00:00
|
|
|
mHandler.cancelUpdateSuggestionStrip();
|
2013-06-11 08:33:58 +00:00
|
|
|
// Should do the following in onFinishInputInternal but until JB MR2 it's not called :(
|
2013-12-25 12:03:24 +00:00
|
|
|
mInputLogic.finishInput();
|
2010-10-06 09:39:47 +00:00
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onUpdateSelection(final int oldSelStart, final int oldSelEnd,
|
|
|
|
final int newSelStart, final int newSelEnd,
|
|
|
|
final int composingSpanStart, final int composingSpanEnd) {
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd,
|
2012-02-20 01:26:41 +00:00
|
|
|
composingSpanStart, composingSpanEnd);
|
2010-01-16 20:21:23 +00:00
|
|
|
if (DEBUG) {
|
2014-02-18 05:48:41 +00:00
|
|
|
Log.i(TAG, "onUpdateSelection: oss=" + oldSelStart + ", ose=" + oldSelEnd
|
|
|
|
+ ", nss=" + newSelStart + ", nse=" + newSelEnd
|
|
|
|
+ ", cs=" + composingSpanStart + ", ce=" + composingSpanEnd);
|
2010-01-16 20:21:23 +00:00
|
|
|
}
|
|
|
|
|
2014-01-24 05:03:08 +00:00
|
|
|
// If the keyboard is not visible, we don't need to do all the housekeeping work, as it
|
|
|
|
// will be reset when the keyboard shows up anyway.
|
|
|
|
// TODO: revisit this when LatinIME supports hardware keyboards.
|
|
|
|
// NOTE: the test harness subclasses LatinIME and overrides isInputViewShown().
|
|
|
|
// TODO: find a better way to simulate actual execution.
|
|
|
|
if (isInputViewShown() &&
|
2014-03-03 05:19:52 +00:00
|
|
|
mInputLogic.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd)) {
|
2014-03-27 09:37:16 +00:00
|
|
|
mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2011-06-08 07:47:19 +00:00
|
|
|
}
|
2011-05-06 09:27:24 +00:00
|
|
|
}
|
|
|
|
|
2014-04-11 01:41:12 +00:00
|
|
|
@Override
|
2014-06-27 12:38:57 +00:00
|
|
|
public void onUpdateCursor(final Rect rect) {
|
2014-04-11 01:41:12 +00:00
|
|
|
if (DEBUG) {
|
|
|
|
Log.i(TAG, "onUpdateCursor:" + rect.toShortString());
|
|
|
|
}
|
|
|
|
super.onUpdateCursor(rect);
|
|
|
|
}
|
|
|
|
|
2010-09-15 04:03:34 +00:00
|
|
|
/**
|
|
|
|
* This is called when the user has clicked on the extracted text view,
|
|
|
|
* when running in fullscreen mode. The default implementation hides
|
2011-09-01 05:54:28 +00:00
|
|
|
* the suggestions view when this happens, but only if the extracted text
|
2010-09-15 04:03:34 +00:00
|
|
|
* editor has a vertical scroll bar because its text doesn't fit.
|
|
|
|
* Here we override the behavior due to the possibility that a re-correction could
|
2011-09-01 05:54:28 +00:00
|
|
|
* cause the suggestions strip to disappear and re-appear.
|
2010-09-15 04:03:34 +00:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onExtractedTextClicked() {
|
2014-07-22 17:18:38 +00:00
|
|
|
if (mSettings.getCurrent().needsToLookupSuggestions()) {
|
2013-12-20 07:34:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-09-15 04:03:34 +00:00
|
|
|
|
|
|
|
super.onExtractedTextClicked();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called when the user has performed a cursor movement in the
|
|
|
|
* extracted text view, when it is running in fullscreen mode. The default
|
2011-09-01 05:54:28 +00:00
|
|
|
* implementation hides the suggestions view when a vertical movement
|
2010-09-15 04:03:34 +00:00
|
|
|
* happens, but only if the extracted text editor has a vertical scroll bar
|
|
|
|
* because its text doesn't fit.
|
|
|
|
* Here we override the behavior due to the possibility that a re-correction could
|
2011-09-01 05:54:28 +00:00
|
|
|
* cause the suggestions strip to disappear and re-appear.
|
2010-09-15 04:03:34 +00:00
|
|
|
*/
|
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onExtractedCursorMovement(final int dx, final int dy) {
|
2014-07-22 17:18:38 +00:00
|
|
|
if (mSettings.getCurrent().needsToLookupSuggestions()) {
|
2013-12-20 07:34:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-09-15 04:03:34 +00:00
|
|
|
|
|
|
|
super.onExtractedCursorMovement(dx, dy);
|
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
|
|
|
public void hideWindow() {
|
2011-07-27 22:32:25 +00:00
|
|
|
mKeyboardSwitcher.onHideWindow();
|
2010-08-20 05:35:02 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
if (TRACE) Debug.stopMethodTracing();
|
2014-04-14 02:31:44 +00:00
|
|
|
if (isShowingOptionDialog()) {
|
2009-03-26 00:39:38 +00:00
|
|
|
mOptionsDialog.dismiss();
|
|
|
|
mOptionsDialog = null;
|
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
super.hideWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions) {
|
2010-08-20 05:35:02 +00:00
|
|
|
if (DEBUG) {
|
2011-01-10 02:59:46 +00:00
|
|
|
Log.i(TAG, "Received completions:");
|
2011-03-04 07:56:10 +00:00
|
|
|
if (applicationSpecifiedCompletions != null) {
|
|
|
|
for (int i = 0; i < applicationSpecifiedCompletions.length; i++) {
|
|
|
|
Log.i(TAG, " #" + i + ": " + applicationSpecifiedCompletions[i]);
|
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-18 02:48:00 +00:00
|
|
|
if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-27 07:55:03 +00:00
|
|
|
// If we have an update request in flight, we need to cancel it so it does not override
|
|
|
|
// these completions.
|
|
|
|
mHandler.cancelUpdateSuggestionStrip();
|
2012-06-12 00:35:51 +00:00
|
|
|
if (applicationSpecifiedCompletions == null) {
|
2014-01-24 09:39:05 +00:00
|
|
|
setNeutralSuggestionStrip();
|
2012-06-12 00:35:51 +00:00
|
|
|
return;
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2012-06-12 00:35:51 +00:00
|
|
|
|
|
|
|
final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
|
|
|
|
SuggestedWords.getFromApplicationSpecifiedCompletions(
|
|
|
|
applicationSpecifiedCompletions);
|
2014-02-18 02:48:00 +00:00
|
|
|
final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords,
|
|
|
|
null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */,
|
|
|
|
false /* isObsoleteSuggestions */, false /* isPrediction */);
|
|
|
|
// When in fullscreen mode, show completions generated by the application forcibly
|
2014-06-05 02:25:56 +00:00
|
|
|
setSuggestedWords(suggestedWords);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 07:50:37 +00:00
|
|
|
private int getAdjustedBackingViewHeight() {
|
|
|
|
final int currentHeight = mKeyPreviewBackingView.getHeight();
|
|
|
|
if (currentHeight > 0) {
|
|
|
|
return currentHeight;
|
|
|
|
}
|
|
|
|
|
2013-08-29 11:43:03 +00:00
|
|
|
final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
|
|
|
|
if (visibleKeyboardView == null) {
|
2013-08-30 07:50:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2013-08-29 11:43:03 +00:00
|
|
|
// TODO: !!!!!!!!!!!!!!!!!!!! Handle different backing view heights between the main !!!
|
|
|
|
// keyboard and the emoji keyboard. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
final int keyboardHeight = visibleKeyboardView.getHeight();
|
2013-08-30 07:50:37 +00:00
|
|
|
final int suggestionsHeight = mSuggestionStripView.getHeight();
|
|
|
|
final int displayHeight = getResources().getDisplayMetrics().heightPixels;
|
|
|
|
final Rect rect = new Rect();
|
|
|
|
mKeyPreviewBackingView.getWindowVisibleDisplayFrame(rect);
|
|
|
|
final int notificationBarHeight = rect.top;
|
|
|
|
final int remainingHeight = displayHeight - notificationBarHeight - suggestionsHeight
|
|
|
|
- keyboardHeight;
|
|
|
|
|
|
|
|
final LayoutParams params = mKeyPreviewBackingView.getLayoutParams();
|
|
|
|
params.height = mSuggestionStripView.setMoreSuggestionsHeight(remainingHeight);
|
|
|
|
mKeyPreviewBackingView.setLayoutParams(params);
|
|
|
|
return params.height;
|
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onComputeInsets(final InputMethodService.Insets outInsets) {
|
2009-03-13 22:11:42 +00:00
|
|
|
super.onComputeInsets(outInsets);
|
2013-08-29 11:43:03 +00:00
|
|
|
final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
|
2014-02-18 05:48:41 +00:00
|
|
|
if (visibleKeyboardView == null || !hasSuggestionStripView()) {
|
2011-04-21 05:51:53 +00:00
|
|
|
return;
|
2012-08-07 02:48:10 +00:00
|
|
|
}
|
2014-08-08 07:26:25 +00:00
|
|
|
final boolean hasHardwareKeyboard = mKeyboardSwitcher.hasHardwareKeyboard();
|
|
|
|
if (hasHardwareKeyboard && visibleKeyboardView.getVisibility() == View.GONE) {
|
|
|
|
// If there is a hardware keyboard and a visible software keyboard view has been hidden,
|
|
|
|
// no visual element will be shown on the screen.
|
|
|
|
outInsets.touchableInsets = mInputView.getHeight();
|
|
|
|
outInsets.visibleTopInsets = mInputView.getHeight();
|
|
|
|
return;
|
|
|
|
}
|
2013-08-30 07:50:37 +00:00
|
|
|
final int adjustedBackingHeight = getAdjustedBackingViewHeight();
|
|
|
|
final boolean backingGone = (mKeyPreviewBackingView.getVisibility() == View.GONE);
|
|
|
|
final int backingHeight = backingGone ? 0 : adjustedBackingHeight;
|
|
|
|
// In fullscreen mode, the height of the extract area managed by InputMethodService should
|
|
|
|
// be considered.
|
|
|
|
// See {@link android.inputmethodservice.InputMethodService#onComputeInsets}.
|
|
|
|
final int extractHeight = isFullscreenMode() ? mExtractArea.getHeight() : 0;
|
|
|
|
final int suggestionsHeight = (mSuggestionStripView.getVisibility() == View.GONE) ? 0
|
|
|
|
: mSuggestionStripView.getHeight();
|
|
|
|
final int extraHeight = extractHeight + backingHeight + suggestionsHeight;
|
|
|
|
int visibleTopY = extraHeight;
|
2011-01-21 10:04:00 +00:00
|
|
|
// Need to set touchable region only if input view is being shown
|
2013-08-29 11:43:03 +00:00
|
|
|
if (visibleKeyboardView.isShown()) {
|
2013-09-05 03:19:43 +00:00
|
|
|
// Note that the height of Emoji layout is the same as the height of the main keyboard
|
|
|
|
// and the suggestion strip
|
2013-10-11 10:15:16 +00:00
|
|
|
if (mKeyboardSwitcher.isShowingEmojiPalettes()
|
2013-09-05 03:19:43 +00:00
|
|
|
|| mSuggestionStripView.getVisibility() == View.VISIBLE) {
|
2013-08-30 07:50:37 +00:00
|
|
|
visibleTopY -= suggestionsHeight;
|
|
|
|
}
|
2013-08-29 11:43:03 +00:00
|
|
|
final int touchY = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
|
|
|
|
final int touchWidth = visibleKeyboardView.getWidth();
|
|
|
|
final int touchHeight = visibleKeyboardView.getHeight() + extraHeight
|
2011-04-13 05:12:24 +00:00
|
|
|
// Extend touchable region below the keyboard.
|
|
|
|
+ EXTENDED_TOUCHABLE_REGION_HEIGHT;
|
2012-04-02 13:25:08 +00:00
|
|
|
outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
|
2013-08-30 07:50:37 +00:00
|
|
|
outInsets.touchableRegion.set(0, touchY, touchWidth, touchHeight);
|
2011-01-21 10:04:00 +00:00
|
|
|
}
|
2013-08-30 07:50:37 +00:00
|
|
|
outInsets.contentTopInsets = visibleTopY;
|
|
|
|
outInsets.visibleTopInsets = visibleTopY;
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2014-08-08 07:26:25 +00:00
|
|
|
@Override
|
|
|
|
public boolean onEvaluateInputViewShown() {
|
|
|
|
// Always show {@link InputView}.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-20 05:35:02 +00:00
|
|
|
@Override
|
|
|
|
public boolean onEvaluateFullscreenMode() {
|
2014-08-08 07:26:25 +00:00
|
|
|
if (mKeyboardSwitcher.hasHardwareKeyboard()) {
|
|
|
|
// If there is a hardware keyboard, disable full screen mode.
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-24 12:55:09 +00:00
|
|
|
// Reread resource value here, because this method is called by the framework as needed.
|
2013-12-13 08:09:16 +00:00
|
|
|
final boolean isFullscreenModeAllowed = Settings.readUseFullscreenMode(getResources());
|
2012-10-25 05:48:12 +00:00
|
|
|
if (super.onEvaluateFullscreenMode() && isFullscreenModeAllowed) {
|
|
|
|
// TODO: Remove this hack. Actually we should not really assume NO_EXTRACT_UI
|
|
|
|
// implies NO_FULLSCREEN. However, the framework mistakenly does. i.e. NO_EXTRACT_UI
|
|
|
|
// without NO_FULLSCREEN doesn't work as expected. Because of this we need this
|
|
|
|
// hack for now. Let's get rid of this once the framework gets fixed.
|
|
|
|
final EditorInfo ei = getCurrentInputEditorInfo();
|
|
|
|
return !(ei != null && ((ei.imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0));
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-20 05:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateFullscreenMode() {
|
|
|
|
super.updateFullscreenMode();
|
2013-08-30 07:50:37 +00:00
|
|
|
|
|
|
|
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);
|
2010-08-20 05:35:02 +00:00
|
|
|
}
|
|
|
|
|
2014-04-14 08:04:50 +00:00
|
|
|
private int getCurrentAutoCapsState() {
|
2014-01-24 05:00:26 +00:00
|
|
|
return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent());
|
2010-01-24 15:34:07 +00:00
|
|
|
}
|
|
|
|
|
2014-04-14 08:04:50 +00:00
|
|
|
private int getCurrentRecapitalizeState() {
|
2013-12-19 11:36:32 +00:00
|
|
|
return mInputLogic.getCurrentRecapitalizeState();
|
2013-04-15 13:00:29 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 10:05:33 +00:00
|
|
|
public Locale getCurrentSubtypeLocale() {
|
|
|
|
return mSubtypeSwitcher.getCurrentSubtypeLocale();
|
|
|
|
}
|
|
|
|
|
2013-12-27 11:58:32 +00:00
|
|
|
/**
|
|
|
|
* @param codePoints code points to get coordinates for.
|
|
|
|
* @return x,y coordinates for this keyboard, as a flattened array.
|
|
|
|
*/
|
|
|
|
public int[] getCoordinatesForCurrentKeyboard(final int[] codePoints) {
|
2014-01-23 07:10:26 +00:00
|
|
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
|
|
|
if (null == keyboard) {
|
|
|
|
return CoordinateUtils.newCoordinateArray(codePoints.length,
|
|
|
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
|
|
|
} else {
|
|
|
|
return keyboard.getCoordinates(codePoints);
|
2013-12-27 11:58:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-23 06:28:28 +00:00
|
|
|
// Callback for the {@link SuggestionStripView}, to call when the "add to dictionary" hint is
|
|
|
|
// pressed.
|
2011-06-09 05:22:37 +00:00
|
|
|
@Override
|
2012-12-13 12:59:13 +00:00
|
|
|
public void addWordToUserDictionary(final String word) {
|
|
|
|
if (TextUtils.isEmpty(word)) {
|
|
|
|
// Probably never supposed to happen, but just in case.
|
|
|
|
return;
|
|
|
|
}
|
2013-01-16 13:07:43 +00:00
|
|
|
final String wordToEdit;
|
2013-12-18 09:08:35 +00:00
|
|
|
if (CapsModeUtils.isAutoCapsMode(mInputLogic.mLastComposedWord.mCapitalizedMode)) {
|
2013-12-20 10:05:33 +00:00
|
|
|
wordToEdit = word.toLowerCase(getCurrentSubtypeLocale());
|
2013-01-16 13:07:43 +00:00
|
|
|
} else {
|
|
|
|
wordToEdit = word;
|
|
|
|
}
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.addWordToUserDictionary(this /* context */, wordToEdit);
|
2012-12-13 12:59:13 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 07:19:29 +00:00
|
|
|
// Callback for the {@link SuggestionStripView}, to call when the important notice strip is
|
|
|
|
// pressed.
|
|
|
|
@Override
|
|
|
|
public void showImportantNoticeContents() {
|
2014-02-20 15:54:02 +00:00
|
|
|
showOptionDialog(new ImportantNoticeDialog(this /* context */, this /* listener */));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implement {@link ImportantNoticeDialog.ImportantNoticeDialogListener}
|
|
|
|
@Override
|
|
|
|
public void onClickSettingsOfImportantNoticeDialog(final int nextVersion) {
|
|
|
|
launchSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implement {@link ImportantNoticeDialog.ImportantNoticeDialogListener}
|
|
|
|
@Override
|
2014-04-14 02:31:44 +00:00
|
|
|
public void onUserAcknowledgmentOfImportantNoticeDialog(final int nextVersion) {
|
2014-02-20 15:54:02 +00:00
|
|
|
setNeutralSuggestionStrip();
|
2014-02-19 04:17:36 +00:00
|
|
|
}
|
|
|
|
|
2013-12-19 11:56:37 +00:00
|
|
|
public void displaySettingsDialog() {
|
2014-02-18 05:48:41 +00:00
|
|
|
if (isShowingOptionDialog()) {
|
|
|
|
return;
|
|
|
|
}
|
2012-03-30 07:08:11 +00:00
|
|
|
showSubtypeSelectorAndSettings();
|
2010-09-02 19:25:31 +00:00
|
|
|
}
|
|
|
|
|
2011-08-06 01:45:19 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public boolean onCustomRequest(final int requestCode) {
|
2011-08-06 01:45:19 +00:00
|
|
|
if (isShowingOptionDialog()) return false;
|
|
|
|
switch (requestCode) {
|
2013-07-02 09:07:35 +00:00
|
|
|
case Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER:
|
2012-11-09 09:21:41 +00:00
|
|
|
if (mRichImm.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) {
|
|
|
|
mRichImm.getInputMethodManager().showInputMethodPicker();
|
2011-08-06 01:45:19 +00:00
|
|
|
return true;
|
2010-09-02 19:25:31 +00:00
|
|
|
}
|
2011-08-06 01:45:19 +00:00
|
|
|
return false;
|
2010-09-02 19:25:31 +00:00
|
|
|
}
|
2011-08-06 01:45:19 +00:00
|
|
|
return false;
|
2010-09-02 19:25:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isShowingOptionDialog() {
|
|
|
|
return mOptionsDialog != null && mOptionsDialog.isShowing();
|
|
|
|
}
|
|
|
|
|
2012-10-02 08:09:56 +00:00
|
|
|
// TODO: Revise the language switch key behavior to make it much smarter and more reasonable.
|
2013-12-19 11:36:32 +00:00
|
|
|
public void switchToNextSubtype() {
|
2012-02-18 01:46:01 +00:00
|
|
|
final IBinder token = getWindow().getWindow().getAttributes().token;
|
2014-04-27 22:39:00 +00:00
|
|
|
if (shouldSwitchToOtherInputMethods()) {
|
2012-11-09 09:21:41 +00:00
|
|
|
mRichImm.switchToNextInputMethod(token, false /* onlyCurrentIme */);
|
2012-10-02 08:09:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-10-02 09:40:06 +00:00
|
|
|
mSubtypeState.switchSubtype(token, mRichImm);
|
2012-02-18 01:46:01 +00:00
|
|
|
}
|
|
|
|
|
2010-12-30 08:19:55 +00:00
|
|
|
// Implementation of {@link KeyboardActionListener}.
|
2010-12-02 09:46:21 +00:00
|
|
|
@Override
|
2014-03-31 10:43:12 +00:00
|
|
|
public void onCodeInput(final int codePoint, final int x, final int y,
|
|
|
|
final boolean isKeyRepeat) {
|
2013-12-27 07:38:13 +00:00
|
|
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
|
|
|
// x and y include some padding, but everything down the line (especially native
|
|
|
|
// code) needs the coordinates in the keyboard frame.
|
|
|
|
// TODO: We should reconsider which coordinate system should be used to represent
|
|
|
|
// keyboard event. Also we should pull this up -- LatinIME has no business doing
|
|
|
|
// this transformation, it should be done already before calling onCodeInput.
|
2013-12-27 07:43:07 +00:00
|
|
|
final int keyX = mainKeyboardView.getKeyX(x);
|
|
|
|
final int keyY = mainKeyboardView.getKeyY(y);
|
2014-08-06 23:57:03 +00:00
|
|
|
final int codeToSend;
|
|
|
|
if (Constants.CODE_SHIFT == codePoint) {
|
|
|
|
// TODO: Instead of checking for alphabetic keyboard here, separate keycodes for
|
|
|
|
// alphabetic shift and shift while in symbol layout.
|
|
|
|
final Keyboard currentKeyboard = mKeyboardSwitcher.getKeyboard();
|
|
|
|
if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {
|
|
|
|
codeToSend = codePoint;
|
|
|
|
} else {
|
|
|
|
codeToSend = Constants.CODE_SYMBOL_SHIFT;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
codeToSend = codePoint;
|
|
|
|
}
|
|
|
|
if (Constants.CODE_SHORTCUT == codePoint) {
|
2014-01-15 02:27:27 +00:00
|
|
|
mSubtypeSwitcher.switchToShortcutIME(this);
|
2014-08-06 23:57:03 +00:00
|
|
|
// Still call the *#onCodeInput methods for readability.
|
2014-01-15 02:27:27 +00:00
|
|
|
}
|
2014-08-06 23:57:03 +00:00
|
|
|
final Event event = createSoftwareKeypressEvent(codeToSend, keyX, keyY, isKeyRepeat);
|
2014-03-04 08:28:20 +00:00
|
|
|
final InputTransaction completeInputTransaction =
|
2014-03-12 07:41:45 +00:00
|
|
|
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
2014-06-26 09:43:14 +00:00
|
|
|
mKeyboardSwitcher.getKeyboardShiftMode(),
|
|
|
|
mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler);
|
2014-03-05 07:37:44 +00:00
|
|
|
updateStateAfterInputTransaction(completeInputTransaction);
|
2014-08-06 23:57:03 +00:00
|
|
|
mKeyboardSwitcher.onCodeInput(codePoint, getCurrentAutoCapsState(),
|
2014-04-14 08:04:50 +00:00
|
|
|
getCurrentRecapitalizeState());
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2014-03-12 07:41:45 +00:00
|
|
|
// A helper method to split the code point and the key code. Ultimately, they should not be
|
|
|
|
// squashed into the same variable, and this method should be removed.
|
|
|
|
private static Event createSoftwareKeypressEvent(final int keyCodeOrCodePoint, final int keyX,
|
2014-03-31 10:43:12 +00:00
|
|
|
final int keyY, final boolean isKeyRepeat) {
|
2014-03-12 07:41:45 +00:00
|
|
|
final int keyCode;
|
|
|
|
final int codePoint;
|
|
|
|
if (keyCodeOrCodePoint <= 0) {
|
|
|
|
keyCode = keyCodeOrCodePoint;
|
|
|
|
codePoint = Event.NOT_A_CODE_POINT;
|
|
|
|
} else {
|
|
|
|
keyCode = Event.NOT_A_KEY_CODE;
|
|
|
|
codePoint = keyCodeOrCodePoint;
|
|
|
|
}
|
2014-03-31 10:43:12 +00:00
|
|
|
return Event.createSoftwareKeypressEvent(codePoint, keyCode, keyX, keyY, isKeyRepeat);
|
2014-03-12 07:41:45 +00:00
|
|
|
}
|
|
|
|
|
2013-09-10 07:16:25 +00:00
|
|
|
// Called from PointerTracker through the KeyboardActionListener interface
|
|
|
|
@Override
|
|
|
|
public void onTextInput(final String rawText) {
|
2014-03-19 06:59:49 +00:00
|
|
|
// TODO: have the keyboard pass the correct key code when we need it.
|
|
|
|
final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE);
|
2014-06-27 12:38:57 +00:00
|
|
|
final InputTransaction completeInputTransaction =
|
|
|
|
mInputLogic.onTextInput(mSettings.getCurrent(), event,
|
|
|
|
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
|
|
|
updateStateAfterInputTransaction(completeInputTransaction);
|
2014-04-14 08:04:50 +00:00
|
|
|
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2012-07-04 06:24:59 +00:00
|
|
|
@Override
|
|
|
|
public void onStartBatchInput() {
|
2014-02-27 13:30:46 +00:00
|
|
|
mInputLogic.onStartBatchInput(mSettings.getCurrent(), mKeyboardSwitcher, mHandler);
|
2013-12-20 11:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdateBatchInput(final InputPointers batchPointers) {
|
2013-12-25 12:04:27 +00:00
|
|
|
mInputLogic.onUpdateBatchInput(mSettings.getCurrent(), batchPointers, mKeyboardSwitcher);
|
2013-12-20 11:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEndBatchInput(final InputPointers batchPointers) {
|
2014-03-03 05:19:52 +00:00
|
|
|
mInputLogic.onEndBatchInput(batchPointers);
|
2013-12-20 11:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCancelBatchInput() {
|
2013-12-25 12:04:27 +00:00
|
|
|
mInputLogic.onCancelBatchInput(mHandler);
|
2012-09-12 04:03:44 +00:00
|
|
|
}
|
|
|
|
|
2013-12-24 09:07:20 +00:00
|
|
|
// This method must run on the UI Thread.
|
2012-09-12 04:03:44 +00:00
|
|
|
private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
|
|
|
|
final boolean dismissGestureFloatingPreviewText) {
|
2014-01-24 13:45:20 +00:00
|
|
|
showSuggestionStrip(suggestedWords);
|
2013-01-21 06:57:32 +00:00
|
|
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
2013-01-10 02:31:47 +00:00
|
|
|
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
|
2012-09-12 04:03:44 +00:00
|
|
|
if (dismissGestureFloatingPreviewText) {
|
|
|
|
mainKeyboardView.dismissGestureFloatingPreviewText();
|
|
|
|
}
|
2012-07-04 06:24:59 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 03:25:21 +00:00
|
|
|
// Called from PointerTracker through the KeyboardActionListener interface
|
|
|
|
@Override
|
|
|
|
public void onFinishSlidingInput() {
|
|
|
|
// User finished sliding input.
|
2014-04-14 08:04:50 +00:00
|
|
|
mKeyboardSwitcher.onFinishSlidingInput(getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2013-05-14 03:25:21 +00:00
|
|
|
}
|
|
|
|
|
2012-07-09 03:54:42 +00:00
|
|
|
// Called from PointerTracker through the KeyboardActionListener interface
|
2010-12-02 09:46:21 +00:00
|
|
|
@Override
|
2010-12-20 07:13:57 +00:00
|
|
|
public void onCancelInput() {
|
2010-09-07 06:37:59 +00:00
|
|
|
// User released a finger outside any key
|
2013-05-14 03:25:21 +00:00
|
|
|
// Nothing to do so far.
|
2010-09-07 06:37:59 +00:00
|
|
|
}
|
|
|
|
|
2014-01-24 14:11:48 +00:00
|
|
|
public boolean hasSuggestionStripView() {
|
|
|
|
return null != mSuggestionStripView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isShowingAddToDictionaryHint() {
|
|
|
|
return hasSuggestionStripView() && mSuggestionStripView.isShowingAddToDictionaryHint();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-19 08:57:10 +00:00
|
|
|
public void dismissAddToDictionaryHint() {
|
2014-02-18 05:48:41 +00:00
|
|
|
if (!hasSuggestionStripView()) {
|
|
|
|
return;
|
2013-12-19 08:57:10 +00:00
|
|
|
}
|
2014-02-18 05:48:41 +00:00
|
|
|
mSuggestionStripView.dismissAddToDictionaryHint();
|
2013-12-19 08:57:10 +00:00
|
|
|
}
|
|
|
|
|
2014-06-05 02:25:56 +00:00
|
|
|
private void setSuggestedWords(final SuggestedWords suggestedWords) {
|
2014-01-24 12:57:34 +00:00
|
|
|
mInputLogic.setSuggestedWords(suggestedWords);
|
2014-02-28 07:40:16 +00:00
|
|
|
// TODO: Modify this when we support suggestions with hard keyboard
|
2014-02-18 05:48:41 +00:00
|
|
|
if (!hasSuggestionStripView()) {
|
2014-02-17 16:10:17 +00:00
|
|
|
return;
|
2014-01-24 12:50:46 +00:00
|
|
|
}
|
2014-02-28 07:40:16 +00:00
|
|
|
if (!onEvaluateInputViewShown()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-05 09:09:24 +00:00
|
|
|
|
2014-06-05 02:25:56 +00:00
|
|
|
final SettingsValues currentSettingsValues = mSettings.getCurrent();
|
|
|
|
final boolean shouldShowImportantNotice =
|
|
|
|
ImportantNoticeUtils.shouldShowImportantNotice(this);
|
2014-06-11 01:33:31 +00:00
|
|
|
final boolean shouldShowSuggestionCandidates =
|
|
|
|
currentSettingsValues.mInputAttributes.mShouldShowSuggestions
|
2014-07-22 17:18:38 +00:00
|
|
|
&& currentSettingsValues.isSuggestionsEnabledPerUserSettings();
|
2014-06-05 02:25:56 +00:00
|
|
|
final boolean shouldShowSuggestionsStripUnlessPassword = shouldShowImportantNotice
|
|
|
|
|| currentSettingsValues.mShowsVoiceInputKey
|
2014-06-11 01:33:31 +00:00
|
|
|
|| shouldShowSuggestionCandidates
|
2014-06-05 02:25:56 +00:00
|
|
|
|| currentSettingsValues.isApplicationSpecifiedCompletionsOn();
|
|
|
|
final boolean shouldShowSuggestionsStrip = shouldShowSuggestionsStripUnlessPassword
|
|
|
|
&& !currentSettingsValues.mInputAttributes.mIsPasswordField;
|
|
|
|
mSuggestionStripView.updateVisibility(shouldShowSuggestionsStrip, isFullscreenMode());
|
|
|
|
if (!shouldShowSuggestionsStrip) {
|
2014-02-28 07:40:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-05 02:25:56 +00:00
|
|
|
final boolean isEmptyApplicationSpecifiedCompletions =
|
|
|
|
currentSettingsValues.isApplicationSpecifiedCompletionsOn()
|
|
|
|
&& suggestedWords.isEmpty();
|
|
|
|
final boolean noSuggestionsToShow = (SuggestedWords.EMPTY == suggestedWords)
|
2014-05-23 17:28:00 +00:00
|
|
|
|| suggestedWords.isPunctuationSuggestions()
|
2014-06-05 02:25:56 +00:00
|
|
|
|| isEmptyApplicationSpecifiedCompletions;
|
|
|
|
if (shouldShowImportantNotice && noSuggestionsToShow) {
|
2014-06-11 01:33:31 +00:00
|
|
|
if (mSuggestionStripView.maybeShowImportantNoticeTitle()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-02-17 16:10:17 +00:00
|
|
|
}
|
2014-06-05 02:25:56 +00:00
|
|
|
|
2014-07-22 17:18:38 +00:00
|
|
|
if (currentSettingsValues.isSuggestionsEnabledPerUserSettings()
|
2014-06-11 01:33:31 +00:00
|
|
|
// We should clear suggestions if there is no suggestion to show.
|
|
|
|
|| noSuggestionsToShow
|
|
|
|
|| currentSettingsValues.isApplicationSpecifiedCompletionsOn()) {
|
2014-02-17 16:10:17 +00:00
|
|
|
mSuggestionStripView.setSuggestions(suggestedWords,
|
|
|
|
SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
|
|
|
|
}
|
2010-01-16 20:21:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-25 12:04:27 +00:00
|
|
|
// TODO[IL]: Move this out of LatinIME.
|
|
|
|
public void getSuggestedWords(final int sessionId, final int sequenceNumber,
|
2013-08-29 06:15:49 +00:00
|
|
|
final OnGetSuggestedWordsCallback callback) {
|
2012-10-03 04:01:52 +00:00
|
|
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
2014-03-25 06:35:20 +00:00
|
|
|
if (keyboard == null) {
|
2013-08-29 06:15:49 +00:00
|
|
|
callback.onGetSuggestedWords(SuggestedWords.EMPTY);
|
|
|
|
return;
|
2012-10-03 04:01:52 +00:00
|
|
|
}
|
2014-06-13 07:50:05 +00:00
|
|
|
mInputLogic.getSuggestedWords(mSettings.getCurrent(), keyboard.getProximityInfo(),
|
|
|
|
mKeyboardSwitcher.getKeyboardShiftMode(), sessionId, sequenceNumber, callback);
|
2013-04-19 02:48:14 +00:00
|
|
|
}
|
|
|
|
|
2014-01-24 14:11:48 +00:00
|
|
|
@Override
|
2014-01-24 13:45:20 +00:00
|
|
|
public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords) {
|
2014-01-24 11:56:16 +00:00
|
|
|
final SuggestedWords suggestedWords =
|
|
|
|
sourceSuggestedWords.isEmpty() ? SuggestedWords.EMPTY : sourceSuggestedWords;
|
2014-02-03 06:03:41 +00:00
|
|
|
if (SuggestedWords.EMPTY == suggestedWords) {
|
|
|
|
setNeutralSuggestionStrip();
|
|
|
|
} else {
|
2014-06-05 02:25:56 +00:00
|
|
|
setSuggestedWords(suggestedWords);
|
2014-01-24 11:57:48 +00:00
|
|
|
}
|
|
|
|
// Cache the auto-correction in accessibility code so we can speak it if the user
|
|
|
|
// touches a key that will insert it.
|
2014-01-24 13:45:20 +00:00
|
|
|
AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords,
|
|
|
|
sourceSuggestedWords.mTypedWord);
|
2013-09-19 11:31:15 +00:00
|
|
|
}
|
|
|
|
|
2012-07-23 06:28:28 +00:00
|
|
|
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
|
|
|
|
// interface
|
2011-06-09 05:22:37 +00:00
|
|
|
@Override
|
2014-06-26 09:43:14 +00:00
|
|
|
public void pickSuggestionManually(final SuggestedWordInfo suggestionInfo) {
|
2014-03-04 09:06:50 +00:00
|
|
|
final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
|
2014-06-26 09:43:14 +00:00
|
|
|
mSettings.getCurrent(), suggestionInfo,
|
|
|
|
mKeyboardSwitcher.getKeyboardShiftMode(),
|
|
|
|
mKeyboardSwitcher.getCurrentKeyboardScriptId(),
|
|
|
|
mHandler);
|
2014-03-05 07:37:44 +00:00
|
|
|
updateStateAfterInputTransaction(completeInputTransaction);
|
2014-01-29 07:15:12 +00:00
|
|
|
}
|
2010-08-20 05:35:02 +00:00
|
|
|
|
2014-01-29 07:15:12 +00:00
|
|
|
@Override
|
|
|
|
public void showAddToDictionaryHint(final String word) {
|
2014-02-18 05:48:41 +00:00
|
|
|
if (!hasSuggestionStripView()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-29 07:15:12 +00:00
|
|
|
mSuggestionStripView.showAddToDictionaryHint(word);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2014-01-24 09:36:18 +00:00
|
|
|
// This will show either an empty suggestion strip (if prediction is enabled) or
|
|
|
|
// punctuation suggestions (if it's disabled).
|
2014-01-24 14:11:48 +00:00
|
|
|
@Override
|
2014-01-24 09:36:18 +00:00
|
|
|
public void setNeutralSuggestionStrip() {
|
2013-07-30 03:54:33 +00:00
|
|
|
final SettingsValues currentSettings = mSettings.getCurrent();
|
2014-02-17 16:10:17 +00:00
|
|
|
final SuggestedWords neutralSuggestions = currentSettings.mBigramPredictionEnabled
|
|
|
|
? SuggestedWords.EMPTY : currentSettings.mSpacingAndPunctuations.mSuggestPuncList;
|
2014-06-05 02:25:56 +00:00
|
|
|
setSuggestedWords(neutralSuggestions);
|
2010-02-03 23:35:49 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 01:19:56 +00:00
|
|
|
// TODO: Make this private
|
|
|
|
// Outside LatinIME, only used by the {@link InputTestsBase} test suite.
|
2012-10-03 08:36:45 +00:00
|
|
|
@UsedForTesting
|
2012-08-22 01:19:56 +00:00
|
|
|
void loadKeyboard() {
|
2013-06-13 06:26:47 +00:00
|
|
|
// Since we are switching languages, the most urgent thing is to let the keyboard graphics
|
|
|
|
// update. LoadKeyboard does that, but we need to wait for buffer flip for it to be on
|
|
|
|
// the screen. Anything we do right now will delay this, so wait until the next frame
|
|
|
|
// before we do the rest, like reopening dictionaries and updating suggestions. So we
|
|
|
|
// post a message.
|
|
|
|
mHandler.postReopenDictionaries();
|
2012-07-23 05:59:19 +00:00
|
|
|
loadSettings();
|
2012-08-07 02:48:10 +00:00
|
|
|
if (mKeyboardSwitcher.getMainKeyboardView() != null) {
|
2011-11-04 03:36:38 +00:00
|
|
|
// Reload keyboard because the current language has been changed.
|
2014-04-14 08:04:50 +00:00
|
|
|
mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mSettings.getCurrent(),
|
|
|
|
getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
2011-11-04 03:36:38 +00:00
|
|
|
}
|
2009-10-12 20:48:35 +00:00
|
|
|
}
|
|
|
|
|
2014-03-05 07:37:44 +00:00
|
|
|
/**
|
|
|
|
* After an input transaction has been executed, some state must be updated. This includes
|
|
|
|
* the shift state of the keyboard and suggestions. This method looks at the finished
|
|
|
|
* inputTransaction to find out what is necessary and updates the state accordingly.
|
|
|
|
* @param inputTransaction The transaction that has been executed.
|
|
|
|
*/
|
|
|
|
private void updateStateAfterInputTransaction(final InputTransaction inputTransaction) {
|
|
|
|
switch (inputTransaction.getRequiredShiftUpdate()) {
|
2014-03-04 09:06:50 +00:00
|
|
|
case InputTransaction.SHIFT_UPDATE_LATER:
|
|
|
|
mHandler.postUpdateShiftState();
|
|
|
|
break;
|
|
|
|
case InputTransaction.SHIFT_UPDATE_NOW:
|
2014-03-27 09:37:16 +00:00
|
|
|
mKeyboardSwitcher.requestUpdatingShiftState(getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2014-03-04 09:06:50 +00:00
|
|
|
break;
|
|
|
|
default: // SHIFT_NO_UPDATE
|
|
|
|
}
|
2014-03-05 07:37:44 +00:00
|
|
|
if (inputTransaction.requiresUpdateSuggestions()) {
|
|
|
|
mHandler.postUpdateSuggestionStrip();
|
|
|
|
}
|
2014-06-27 12:38:57 +00:00
|
|
|
if (inputTransaction.didAffectContents()) {
|
|
|
|
mSubtypeState.setCurrentSubtypeHasBeenUsed();
|
|
|
|
}
|
2014-03-04 09:06:50 +00:00
|
|
|
}
|
|
|
|
|
2013-08-13 03:10:26 +00:00
|
|
|
private void hapticAndAudioFeedback(final int code, final int repeatCount) {
|
2013-07-16 03:29:50 +00:00
|
|
|
final MainKeyboardView keyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
2013-12-13 08:09:16 +00:00
|
|
|
if (keyboardView != null && keyboardView.isInDraggingFinger()) {
|
|
|
|
// No need to feedback while finger is dragging.
|
2013-07-16 03:29:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-08-13 03:10:26 +00:00
|
|
|
if (repeatCount > 0) {
|
2013-12-18 09:08:35 +00:00
|
|
|
if (code == Constants.CODE_DELETE && !mInputLogic.mConnection.canDeleteCharacters()) {
|
2013-08-13 03:10:26 +00:00
|
|
|
// No need to feedback when repeat delete key will have no effect.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// TODO: Use event time that the last feedback has been generated instead of relying on
|
|
|
|
// a repeat count to thin out feedback.
|
|
|
|
if (repeatCount % PERIOD_FOR_AUDIO_AND_HAPTIC_FEEDBACK_IN_KEY_REPEAT == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final AudioAndHapticFeedbackManager feedbackManager =
|
|
|
|
AudioAndHapticFeedbackManager.getInstance();
|
|
|
|
if (repeatCount == 0) {
|
|
|
|
// TODO: Reconsider how to perform haptic feedback when repeating key.
|
|
|
|
feedbackManager.performHapticFeedback(keyboardView);
|
2013-07-16 03:29:50 +00:00
|
|
|
}
|
2013-08-13 03:10:26 +00:00
|
|
|
feedbackManager.performAudioFeedback(code);
|
2013-07-16 03:29:50 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 09:07:35 +00:00
|
|
|
// Callback of the {@link KeyboardActionListener}. This is called when a key is depressed;
|
|
|
|
// release matching call is {@link #onReleaseKey(int,boolean)} below.
|
2010-12-02 09:46:21 +00:00
|
|
|
@Override
|
2013-08-13 03:10:26 +00:00
|
|
|
public void onPressKey(final int primaryCode, final int repeatCount,
|
2013-07-16 03:29:50 +00:00
|
|
|
final boolean isSinglePointer) {
|
2014-04-14 08:04:50 +00:00
|
|
|
mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer, getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2013-08-13 03:10:26 +00:00
|
|
|
hapticAndAudioFeedback(primaryCode, repeatCount);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 09:07:35 +00:00
|
|
|
// Callback of the {@link KeyboardActionListener}. This is called when a key is released;
|
2013-08-13 03:10:26 +00:00
|
|
|
// press matching call is {@link #onPressKey(int,int,boolean)} above.
|
2010-12-02 09:46:21 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onReleaseKey(final int primaryCode, final boolean withSliding) {
|
2014-04-14 06:33:30 +00:00
|
|
|
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding, getCurrentAutoCapsState(),
|
|
|
|
getCurrentRecapitalizeState());
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2014-03-14 11:11:01 +00:00
|
|
|
private HardwareEventDecoder getHardwareKeyEventDecoder(final int deviceId) {
|
|
|
|
final HardwareEventDecoder decoder = mHardwareEventDecoders.get(deviceId);
|
|
|
|
if (null != decoder) return decoder;
|
|
|
|
// TODO: create the decoder according to the specification
|
|
|
|
final HardwareEventDecoder newDecoder = new HardwareKeyboardEventDecoder(deviceId);
|
|
|
|
mHardwareEventDecoders.put(deviceId, newDecoder);
|
|
|
|
return newDecoder;
|
|
|
|
}
|
|
|
|
|
2012-12-06 11:35:59 +00:00
|
|
|
// Hooks for hardware keyboard
|
|
|
|
@Override
|
2014-03-14 11:11:01 +00:00
|
|
|
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
|
2014-08-08 07:26:25 +00:00
|
|
|
mSpecialKeyDetector.onKeyDown(keyEvent);
|
2014-07-17 02:22:35 +00:00
|
|
|
if (!ProductionFlags.IS_HARDWARE_KEYBOARD_SUPPORTED) {
|
2014-03-14 11:11:01 +00:00
|
|
|
return super.onKeyDown(keyCode, keyEvent);
|
|
|
|
}
|
|
|
|
final Event event = getHardwareKeyEventDecoder(
|
|
|
|
keyEvent.getDeviceId()).decodeHardwareKey(keyEvent);
|
|
|
|
// If the event is not handled by LatinIME, we just pass it to the parent implementation.
|
|
|
|
// If it's handled, we return true because we did handle it.
|
|
|
|
if (event.isHandled()) {
|
|
|
|
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
|
2014-06-26 09:43:14 +00:00
|
|
|
mKeyboardSwitcher.getKeyboardShiftMode(),
|
|
|
|
// TODO: this is not necessarily correct for a hardware keyboard right now
|
|
|
|
mKeyboardSwitcher.getCurrentKeyboardScriptId(),
|
|
|
|
mHandler);
|
2013-01-17 10:27:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-03-14 11:11:01 +00:00
|
|
|
return super.onKeyDown(keyCode, keyEvent);
|
2012-12-06 11:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-08-08 07:26:25 +00:00
|
|
|
public boolean onKeyUp(final int keyCode, final KeyEvent keyEvent) {
|
|
|
|
mSpecialKeyDetector.onKeyUp(keyEvent);
|
|
|
|
if (!ProductionFlags.IS_HARDWARE_KEYBOARD_SUPPORTED) {
|
|
|
|
return super.onKeyUp(keyCode, keyEvent);
|
|
|
|
}
|
|
|
|
final long keyIdentifier = keyEvent.getDeviceId() << 32 + keyEvent.getKeyCode();
|
2013-12-18 09:08:35 +00:00
|
|
|
if (mInputLogic.mCurrentlyPressedHardwareKeys.remove(keyIdentifier)) {
|
2013-01-17 10:27:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-08-08 07:26:25 +00:00
|
|
|
return super.onKeyUp(keyCode, keyEvent);
|
2012-12-06 11:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// onKeyDown and onKeyUp are the main events we are interested in. There are two more events
|
|
|
|
// related to handling of hardware key events that we may want to implement in the future:
|
|
|
|
// boolean onKeyLongPress(final int keyCode, final KeyEvent event);
|
|
|
|
// boolean onKeyMultiple(final int keyCode, final int count, final KeyEvent event);
|
|
|
|
|
2011-01-26 14:13:18 +00:00
|
|
|
// receive ringer mode change and network state change.
|
2014-05-16 13:19:41 +00:00
|
|
|
private final BroadcastReceiver mConnectivityAndRingerModeChangeReceiver =
|
|
|
|
new BroadcastReceiver() {
|
2009-03-13 22:11:42 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
public void onReceive(final Context context, final Intent intent) {
|
2011-01-26 14:13:18 +00:00
|
|
|
final String action = intent.getAction();
|
2012-03-06 10:00:23 +00:00
|
|
|
if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
2011-01-26 14:13:18 +00:00
|
|
|
mSubtypeSwitcher.onNetworkStateChanged(intent);
|
2012-03-09 02:00:23 +00:00
|
|
|
} else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
|
2013-05-21 22:32:08 +00:00
|
|
|
AudioAndHapticFeedbackManager.getInstance().onRingerModeChanged();
|
2011-01-26 14:13:18 +00:00
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-13 10:53:44 +00:00
|
|
|
private void launchSettings() {
|
2013-12-20 07:35:35 +00:00
|
|
|
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
|
|
|
|
requestHideSelf(0);
|
|
|
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
|
|
|
if (mainKeyboardView != null) {
|
|
|
|
mainKeyboardView.closing();
|
|
|
|
}
|
2014-07-23 21:12:27 +00:00
|
|
|
final Intent intent = new Intent();
|
|
|
|
intent.setClass(LatinIME.this, SettingsActivity.class);
|
2013-01-23 05:35:39 +00:00
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
|
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
|
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
2014-07-23 21:12:27 +00:00
|
|
|
intent.putExtra(SettingsActivity.EXTRA_SHOW_HOME_AS_UP, false);
|
2009-03-13 22:11:42 +00:00
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2011-01-20 13:52:02 +00:00
|
|
|
private void showSubtypeSelectorAndSettings() {
|
2011-01-25 02:48:06 +00:00
|
|
|
final CharSequence title = getString(R.string.english_ime_input_options);
|
2014-07-23 21:12:27 +00:00
|
|
|
// TODO: Should use new string "Select active input modes".
|
|
|
|
final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
|
2011-01-25 02:48:06 +00:00
|
|
|
final CharSequence[] items = new CharSequence[] {
|
2014-07-23 21:12:27 +00:00
|
|
|
languageSelectionTitle,
|
|
|
|
getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
|
2011-01-25 02:48:06 +00:00
|
|
|
};
|
2014-02-19 04:17:36 +00:00
|
|
|
final OnClickListener listener = new OnClickListener() {
|
2011-01-20 13:52:02 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface di, int position) {
|
|
|
|
di.dismiss();
|
|
|
|
switch (position) {
|
2011-01-25 02:48:06 +00:00
|
|
|
case 0:
|
2013-02-04 23:59:59 +00:00
|
|
|
final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
|
2012-11-09 09:21:41 +00:00
|
|
|
mRichImm.getInputMethodIdOfThisIme(),
|
2011-12-12 10:55:42 +00:00
|
|
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
2013-12-13 08:09:16 +00:00
|
|
|
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
|
|
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
2014-07-23 21:12:27 +00:00
|
|
|
intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
|
2011-01-20 13:52:02 +00:00
|
|
|
startActivity(intent);
|
|
|
|
break;
|
2011-01-25 17:56:09 +00:00
|
|
|
case 1:
|
|
|
|
launchSettings();
|
|
|
|
break;
|
2011-01-20 13:52:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-25 02:48:06 +00:00
|
|
|
};
|
2014-04-04 05:14:47 +00:00
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(
|
|
|
|
DialogUtils.getPlatformDialogThemeContext(this));
|
|
|
|
builder.setItems(items, listener).setTitle(title);
|
2014-04-14 02:31:44 +00:00
|
|
|
final AlertDialog dialog = builder.create();
|
|
|
|
dialog.setCancelable(true /* cancelable */);
|
|
|
|
dialog.setCanceledOnTouchOutside(true /* cancelable */);
|
|
|
|
showOptionDialog(dialog);
|
2011-01-20 13:52:02 +00:00
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
|
2014-02-03 05:03:58 +00:00
|
|
|
// TODO: Move this method out of {@link LatinIME}.
|
2014-02-19 04:17:36 +00:00
|
|
|
private void showOptionDialog(final AlertDialog dialog) {
|
2012-08-07 02:48:10 +00:00
|
|
|
final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
|
|
|
|
if (windowToken == null) {
|
|
|
|
return;
|
|
|
|
}
|
2012-04-02 13:25:08 +00:00
|
|
|
|
|
|
|
final Window window = dialog.getWindow();
|
|
|
|
final WindowManager.LayoutParams lp = window.getAttributes();
|
|
|
|
lp.token = windowToken;
|
|
|
|
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
|
|
|
|
window.setAttributes(lp);
|
|
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
|
|
|
|
|
|
|
mOptionsDialog = dialog;
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
2013-02-26 07:25:30 +00:00
|
|
|
// TODO: can this be removed somehow without breaking the tests?
|
|
|
|
@UsedForTesting
|
2014-02-18 08:07:46 +00:00
|
|
|
/* package for test */ SuggestedWords getSuggestedWordsForTest() {
|
2013-12-18 07:53:54 +00:00
|
|
|
// You may not use this method for anything else than debug
|
2013-12-18 09:08:35 +00:00
|
|
|
return DEBUG ? mInputLogic.mSuggestedWords : null;
|
2013-02-26 07:25:30 +00:00
|
|
|
}
|
|
|
|
|
2013-07-29 08:47:13 +00:00
|
|
|
// DO NOT USE THIS for any other purpose than testing. This is information private to LatinIME.
|
|
|
|
@UsedForTesting
|
2014-02-20 13:20:43 +00:00
|
|
|
/* package for test */ void waitForLoadingDictionaries(final long timeout, final TimeUnit unit)
|
2014-01-08 09:59:43 +00:00
|
|
|
throws InterruptedException {
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.waitForLoadingDictionariesForTesting(timeout, unit);
|
2013-07-29 08:47:13 +00:00
|
|
|
}
|
|
|
|
|
2013-08-15 07:31:29 +00:00
|
|
|
// DO NOT USE THIS for any other purpose than testing. This can break the keyboard badly.
|
|
|
|
@UsedForTesting
|
2014-01-08 09:59:43 +00:00
|
|
|
/* package for test */ void replaceDictionariesForTest(final Locale locale) {
|
2014-03-25 06:35:20 +00:00
|
|
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.resetDictionaries(this, locale,
|
2014-03-25 06:35:20 +00:00
|
|
|
settingsValues.mUseContactsDict, settingsValues.mUsePersonalizedDicts,
|
|
|
|
false /* forceReloadMainDictionary */, this /* listener */);
|
2013-08-15 07:31:29 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:20:43 +00:00
|
|
|
// DO NOT USE THIS for any other purpose than testing.
|
|
|
|
@UsedForTesting
|
|
|
|
/* package for test */ void clearPersonalizedDictionariesForTest() {
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.clearUserHistoryDictionary();
|
|
|
|
mDictionaryFacilitator.clearPersonalizationDictionary();
|
2014-02-20 13:20:43 +00:00
|
|
|
}
|
|
|
|
|
2014-04-24 22:36:21 +00:00
|
|
|
@UsedForTesting
|
2014-05-23 07:10:36 +00:00
|
|
|
/* package for test */ List<InputMethodSubtype> getEnabledSubtypesForTest() {
|
|
|
|
return (mRichImm != null) ? mRichImm.getMyEnabledInputMethodSubtypeList(
|
|
|
|
true /* allowsImplicitlySelectedSubtypes */) : new ArrayList<InputMethodSubtype>();
|
2014-04-24 22:36:21 +00:00
|
|
|
}
|
|
|
|
|
2014-02-04 12:29:09 +00:00
|
|
|
public void dumpDictionaryForDebug(final String dictName) {
|
2014-05-23 00:30:55 +00:00
|
|
|
if (mDictionaryFacilitator.getLocale() == null) {
|
2014-03-25 06:35:20 +00:00
|
|
|
resetSuggest();
|
2014-02-04 12:29:09 +00:00
|
|
|
}
|
2014-05-23 00:30:55 +00:00
|
|
|
mDictionaryFacilitator.dumpDictionaryForDebug(dictName);
|
2014-02-04 12:29:09 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 10:27:45 +00:00
|
|
|
public void debugDumpStateAndCrashWithException(final String context) {
|
2013-12-20 06:00:44 +00:00
|
|
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
|
|
|
final StringBuilder s = new StringBuilder(settingsValues.toString());
|
|
|
|
s.append("\nAttributes : ").append(settingsValues.mInputAttributes)
|
2012-09-10 10:27:45 +00:00
|
|
|
.append("\nContext : ").append(context);
|
|
|
|
throw new RuntimeException(s.toString());
|
|
|
|
}
|
|
|
|
|
2010-10-08 13:17:16 +00:00
|
|
|
@Override
|
2012-09-12 04:03:44 +00:00
|
|
|
protected void dump(final FileDescriptor fd, final PrintWriter fout, final String[] args) {
|
2009-03-13 22:11:42 +00:00
|
|
|
super.dump(fd, fout, args);
|
2010-01-28 18:09:44 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
final Printer p = new PrintWriterPrinter(fout);
|
|
|
|
p.println("LatinIME state :");
|
2013-12-13 08:09:16 +00:00
|
|
|
p.println(" VersionCode = " + ApplicationUtils.getVersionCode(this));
|
|
|
|
p.println(" VersionName = " + ApplicationUtils.getVersionName(this));
|
2011-12-17 23:36:16 +00:00
|
|
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
2011-12-09 10:53:36 +00:00
|
|
|
final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
|
|
|
|
p.println(" Keyboard mode = " + keyboardMode);
|
2013-01-08 07:35:21 +00:00
|
|
|
final SettingsValues settingsValues = mSettings.getCurrent();
|
2014-02-12 13:53:15 +00:00
|
|
|
p.println(settingsValues.dump());
|
2013-12-20 06:00:44 +00:00
|
|
|
// TODO: Dump all settings values
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2014-04-27 22:39:00 +00:00
|
|
|
|
|
|
|
public boolean shouldSwitchToOtherInputMethods() {
|
|
|
|
// TODO: Revisit here to reorganize the settings. Probably we can/should use different
|
|
|
|
// strategy once the implementation of
|
|
|
|
// {@link InputMethodManager#shouldOfferSwitchingToNextInputMethod} is defined well.
|
|
|
|
final boolean fallbackValue = mSettings.getCurrent().mIncludesOtherImesInLanguageSwitchList;
|
|
|
|
final IBinder token = getWindow().getWindow().getAttributes().token;
|
|
|
|
if (token == null) {
|
|
|
|
return fallbackValue;
|
|
|
|
}
|
|
|
|
return mRichImm.shouldOfferSwitchingToNextInputMethod(token, fallbackValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean shouldShowLanguageSwitchKey() {
|
|
|
|
// TODO: Revisit here to reorganize the settings. Probably we can/should use different
|
|
|
|
// strategy once the implementation of
|
|
|
|
// {@link InputMethodManager#shouldOfferSwitchingToNextInputMethod} is defined well.
|
|
|
|
final boolean fallbackValue = mSettings.getCurrent().isLanguageSwitchKeyEnabled();
|
|
|
|
final IBinder token = getWindow().getWindow().getAttributes().token;
|
|
|
|
if (token == null) {
|
|
|
|
return fallbackValue;
|
|
|
|
}
|
|
|
|
return mRichImm.shouldOfferSwitchingToNextInputMethod(token, fallbackValue);
|
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|