diff options
Diffstat (limited to 'java/src/com/android')
7 files changed, 42 insertions, 151 deletions
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index a1226dc93..e3b1afc53 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -58,6 +58,8 @@ public class Event { final public static int EVENT_TYPE_SUGGESTION_PICKED = 5; // An event corresponding to a string generated by some software process. final public static int EVENT_TYPE_SOFTWARE_GENERATED_STRING = 6; + // An event corresponding to a cursor move + final public static int EVENT_TYPE_CURSOR_MOVE = 7; // 0 is a valid code point, so we use -1 here. final public static int NOT_A_CODE_POINT = -1; @@ -234,6 +236,18 @@ public class Event { } /** + * Creates an input event representing moving the cursor. The relative move amount is stored + * in mX. + * @param moveAmount the relative move amount. + * @return an event for this cursor move. + */ + @Nonnull + public static Event createCursorMovedEvent(final int moveAmount) { + return new Event(EVENT_TYPE_CURSOR_MOVE, null, NOT_A_CODE_POINT, NOT_A_KEY_CODE, + moveAmount, Constants.NOT_A_COORDINATE, null, FLAG_NONE, null); + } + + /** * Creates an event identical to the passed event, but that has already been consumed. * @param source the event to copy the properties of. * @return an identical event marked as consumed. @@ -291,6 +305,7 @@ public class Event { case EVENT_TYPE_MODE_KEY: case EVENT_TYPE_NOT_HANDLED: case EVENT_TYPE_TOGGLE: + case EVENT_TYPE_CURSOR_MOVE: return ""; case EVENT_TYPE_INPUT_KEYPRESS: return StringUtils.newSingleCodePointString(mCodePoint); diff --git a/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java b/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java index 555bbc7d4..c9b6d6b70 100644 --- a/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java +++ b/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java @@ -23,6 +23,8 @@ import com.android.inputmethod.latin.common.StringUtils; import java.util.ArrayList; import java.util.Arrays; +import javax.annotation.Nullable; + /** * The extended {@link SuggestedWords} class to represent punctuation suggestions. * @@ -49,12 +51,16 @@ public final class PunctuationSuggestions extends SuggestedWords { * @return The {@link PunctuationSuggestions} object. */ public static PunctuationSuggestions newPunctuationSuggestions( - final String[] punctuationSpecs) { - final ArrayList<SuggestedWordInfo> puncuationsList = new ArrayList<>(); - for (final String puncSpec : punctuationSpecs) { - puncuationsList.add(newHardCodedWordInfo(puncSpec)); + @Nullable final String[] punctuationSpecs) { + if (punctuationSpecs == null || punctuationSpecs.length == 0) { + return new PunctuationSuggestions(new ArrayList<SuggestedWordInfo>(0)); + } + final ArrayList<SuggestedWordInfo> punctuationList = + new ArrayList<>(punctuationSpecs.length); + for (String spec : punctuationSpecs) { + punctuationList.add(newHardCodedWordInfo(spec)); } - return new PunctuationSuggestions(puncuationsList); + return new PunctuationSuggestions(punctuationList); } /** diff --git a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java index 982d4c690..db5e632ae 100644 --- a/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java +++ b/java/src/com/android/inputmethod/latin/SystemBroadcastReceiver.java @@ -17,16 +17,17 @@ package com.android.inputmethod.latin; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Process; import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; -import com.android.inputmethod.compat.IntentCompatUtils; import com.android.inputmethod.keyboard.KeyboardLayoutSet; -import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager; +import com.android.inputmethod.latin.setup.SetupActivity; import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; /** @@ -34,26 +35,6 @@ import com.android.inputmethod.latin.utils.UncachedInputMethodManagerUtils; * package has been replaced by a newer version of the same package. This class also detects * {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent. * - * If this IME has already been installed in the system image and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver and it - * will hide the setup wizard's icon. - * - * If this IME has already been installed in the data partition and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver but it - * will not hide the setup wizard's icon, and the icon will appear on the launcher. - * - * If this IME hasn't been installed yet and has been newly installed, no - * {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear - * on the launcher. - * - * When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is received by this - * receiver and it checks whether the setup wizard's icon should be appeared or not on the launcher - * depending on which partition this IME is installed. - * - * When a multiuser account has been created, {@link Intent#ACTION_USER_INITIALIZE} is received - * by this receiver and it checks the whether the setup wizard's icon should be appeared or not on - * the launcher depending on which partition this IME is installed. - * * When the system locale has been changed, {@link Intent#ACTION_LOCALE_CHANGED} is received by * this receiver and the {@link KeyboardLayoutSet}'s cache is cleared. */ @@ -71,13 +52,10 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodSubtype[] additionalSubtypes = richImm.getAdditionalSubtypes(); richImm.setAdditionalInputMethodSubtypes(additionalSubtypes); - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); + showAppIcon(context); } else if (Intent.ACTION_BOOT_COMPLETED.equals(intentAction)) { Log.i(TAG, "Boot has been completed"); - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); - } else if (IntentCompatUtils.is_ACTION_USER_INITIALIZE(intentAction)) { - Log.i(TAG, "User initialize"); - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(context); + showAppIcon(context); } else if (Intent.ACTION_LOCALE_CHANGED.equals(intentAction)) { Log.i(TAG, "System locale changed"); KeyboardLayoutSet.onSystemLocaleChanged(); @@ -100,4 +78,13 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver { Process.killProcess(myPid); } } + + private static void showAppIcon(final Context context) { + final ComponentName setupWizardActivity = new ComponentName(context, SetupActivity.class); + final PackageManager pm = context.getPackageManager(); + pm.setComponentEnabledSetting( + setupWizardActivity, + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + } } diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 78860d87d..e605bfe78 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -231,8 +231,6 @@ public final class WordComposer { * @return true if the cursor is still inside the composing word, false otherwise. */ public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount) { - // TODO: should uncommit the composing feedback - mCombinerChain.reset(); int actualMoveAmountWithinWord = 0; int cursorPos = mCursorPositionWithinWord; // TODO: Don't make that copy. We can do this directly from mTypedWordCache. @@ -256,6 +254,8 @@ public final class WordComposer { // so the result would not be inside the composing word. if (actualMoveAmountWithinWord != expectedMoveAmount) return false; mCursorPositionWithinWord = cursorPos; + mCombinerChain.applyProcessedEvent(mCombinerChain.processEvent(mEvents, + Event.createCursorMovedEvent(cursorPos))); return true; } diff --git a/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java index d2c9dbbe9..3dfc743f8 100644 --- a/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AdvancedSettingsFragment.java @@ -23,12 +23,10 @@ import android.media.AudioManager; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; -import android.preference.TwoStatePreference; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.define.ProductionFlags; -import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager; /** * "Advanced" settings sub screen. @@ -89,10 +87,6 @@ public final class AdvancedSettingsFragment extends SubScreenFragment { Settings.readKeyPreviewPopupEnabled(prefs, res)); } - if (!res.getBoolean(R.bool.config_setup_wizard_available)) { - removePreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON); - } - // If metrics logging isn't supported, or account sign in is enabled // don't show the logging preference. // TODO: Eventually when we enable account sign in by default, @@ -121,11 +115,6 @@ public final class AdvancedSettingsFragment extends SubScreenFragment { public void onResume() { super.onResume(); final SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); - final TwoStatePreference showSetupWizardIcon = - (TwoStatePreference)findPreference(Settings.PREF_SHOW_SETUP_WIZARD_ICON); - if (showSetupWizardIcon != null) { - showSetupWizardIcon.setChecked(Settings.readShowSetupWizardIcon(prefs, getActivity())); - } updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); } @@ -135,8 +124,6 @@ public final class AdvancedSettingsFragment extends SubScreenFragment { if (key.equals(Settings.PREF_POPUP_ON)) { setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY, Settings.readKeyPreviewPopupEnabled(prefs, res)); - } else if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) { - LauncherIconVisibilityManager.updateSetupWizardIconVisibility(getActivity()); } updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); refreshEnablingsOfKeypressSoundAndVibrationSettings(); diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 0d3dab57c..77996405b 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -18,7 +18,6 @@ package com.android.inputmethod.latin.settings; import android.content.Context; import android.content.SharedPreferences; -import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; @@ -102,7 +101,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail"; public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "pref_gesture_floating_preview_text"; - public static final String PREF_SHOW_SETUP_WIZARD_ICON = "pref_show_setup_wizard_icon"; public static final String PREF_PHRASE_GESTURE_ENABLED = "pref_gesture_space_aware"; public static final String PREF_INPUT_LANGUAGE = "input_language"; @@ -378,23 +376,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang return res.getBoolean(R.bool.config_use_fullscreen_mode); } - public static boolean readShowSetupWizardIcon(final SharedPreferences prefs, - final Context context) { - final boolean enableSetupWizardByConfig = context.getResources().getBoolean( - R.bool.config_setup_wizard_available); - if (!enableSetupWizardByConfig) { - return false; - } - if (!prefs.contains(PREF_SHOW_SETUP_WIZARD_ICON)) { - final ApplicationInfo appInfo = context.getApplicationInfo(); - final boolean isApplicationInSystemImage = - (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; - // Default value - return !isApplicationInSystemImage; - } - return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false); - } - public static boolean readHasHardwareKeyboard(final Configuration conf) { // The standard way of finding out whether we have a hardware keyboard. This code is taken // from InputMethodService#onEvaluateInputShown, which canonically determines this. diff --git a/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java b/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java deleted file mode 100644 index 3f0b10225..000000000 --- a/java/src/com/android/inputmethod/latin/setup/LauncherIconVisibilityManager.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.setup; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.preference.PreferenceManager; -import android.util.Log; - -import com.android.inputmethod.latin.settings.Settings; - -/** - * This class handles the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME - * package has been replaced by a newer version of the same package. This class also handles - * {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent. - * - * If this IME has already been installed in the system image and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received to this class to hide the - * setup wizard's icon. - * - * If this IME has already been installed in the data partition and a new version of this IME has - * been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is forwarded to this class but it - * will not hide the setup wizard's icon, and the icon will appear on the launcher. - * - * If this IME hasn't been installed yet and has been newly installed, no - * {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear - * on the launcher. - * - * When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is forwarded to this class - * to check whether the setup wizard's icon should be appeared or not on the launcher - * depending on which partition this IME is installed. - * - * When a multiuser account has been created, {@link Intent#ACTION_USER_INITIALIZE} is forwarded to - * this class to check whether the setup wizard's icon should be appeared or not on the launcher - * depending on which partition this IME is installed. - */ -public final class LauncherIconVisibilityManager { - private static final String TAG = LauncherIconVisibilityManager.class.getSimpleName(); - - public static void updateSetupWizardIconVisibility(final Context context) { - final ComponentName setupWizardActivity = new ComponentName(context, SetupActivity.class); - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - final boolean stateHasSet; - if (Settings.readShowSetupWizardIcon(prefs, context)) { - stateHasSet = setActivityState(context, setupWizardActivity, - PackageManager.COMPONENT_ENABLED_STATE_ENABLED); - Log.i(TAG, (stateHasSet ? "Enable activity: " : "Activity has already been enabled: ") - + setupWizardActivity); - } else { - stateHasSet = setActivityState(context, setupWizardActivity, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED); - Log.i(TAG, (stateHasSet ? "Disable activity: " : "Activity has already been disabled: ") - + setupWizardActivity); - } - } - - private static boolean setActivityState(final Context context, - final ComponentName activityComponent, final int activityState) { - final PackageManager pm = context.getPackageManager(); - final int activityComponentState = pm.getComponentEnabledSetting(activityComponent); - if (activityComponentState == activityState) { - return false; - } - pm.setComponentEnabledSetting( - activityComponent, activityState, PackageManager.DONT_KILL_APP); - return true; - } -} |