am 4077a7e5: Merge "Remove SubtypeSwitcher"
* commit '4077a7e52f4016484de914cbfb26e58fe06f3b65': Remove SubtypeSwitchermain
commit
7d7dc07c27
|
@ -34,7 +34,6 @@ import com.android.inputmethod.latin.InputView;
|
||||||
import com.android.inputmethod.latin.LatinIME;
|
import com.android.inputmethod.latin.LatinIME;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.RichInputMethodManager;
|
import com.android.inputmethod.latin.RichInputMethodManager;
|
||||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlags;
|
import com.android.inputmethod.latin.define.ProductionFlags;
|
||||||
import com.android.inputmethod.latin.settings.Settings;
|
import com.android.inputmethod.latin.settings.Settings;
|
||||||
|
@ -50,8 +49,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
NetworkConnectivityUtils.NetworkStateChangeListener {
|
NetworkConnectivityUtils.NetworkStateChangeListener {
|
||||||
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
|
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
|
||||||
|
|
||||||
private SubtypeSwitcher mSubtypeSwitcher;
|
|
||||||
|
|
||||||
private InputView mCurrentInputView;
|
private InputView mCurrentInputView;
|
||||||
private View mMainKeyboardFrame;
|
private View mMainKeyboardFrame;
|
||||||
private MainKeyboardView mKeyboardView;
|
private MainKeyboardView mKeyboardView;
|
||||||
|
@ -86,7 +83,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
private void initInternal(final LatinIME latinIme) {
|
private void initInternal(final LatinIME latinIme) {
|
||||||
mLatinIME = latinIme;
|
mLatinIME = latinIme;
|
||||||
mRichImm = RichInputMethodManager.getInstance();
|
mRichImm = RichInputMethodManager.getInstance();
|
||||||
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
|
||||||
mState = new KeyboardState(this);
|
mState = new KeyboardState(this);
|
||||||
mIsHardwareAcceleratedDrawingEnabled =
|
mIsHardwareAcceleratedDrawingEnabled =
|
||||||
InputMethodServiceCompatUtils.enableHardwareAcceleration(mLatinIME);
|
InputMethodServiceCompatUtils.enableHardwareAcceleration(mLatinIME);
|
||||||
|
|
|
@ -166,7 +166,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
private RichInputMethodManager mRichImm;
|
private RichInputMethodManager mRichImm;
|
||||||
@UsedForTesting final KeyboardSwitcher mKeyboardSwitcher;
|
@UsedForTesting final KeyboardSwitcher mKeyboardSwitcher;
|
||||||
final SubtypeSwitcher mSubtypeSwitcher;
|
|
||||||
private final SubtypeState mSubtypeState = new SubtypeState();
|
private final SubtypeState mSubtypeState = new SubtypeState();
|
||||||
private final EmojiAltPhysicalKeyDetector mEmojiAltPhysicalKeyDetector =
|
private final EmojiAltPhysicalKeyDetector mEmojiAltPhysicalKeyDetector =
|
||||||
new EmojiAltPhysicalKeyDetector();
|
new EmojiAltPhysicalKeyDetector();
|
||||||
|
@ -563,7 +562,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
public LatinIME() {
|
public LatinIME() {
|
||||||
super();
|
super();
|
||||||
mSettings = Settings.getInstance();
|
mSettings = Settings.getInstance();
|
||||||
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
|
||||||
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
|
||||||
mStatsUtilsManager = StatsUtilsManager.getInstance();
|
mStatsUtilsManager = StatsUtilsManager.getInstance();
|
||||||
mIsHardwareAcceleratedDrawingEnabled =
|
mIsHardwareAcceleratedDrawingEnabled =
|
||||||
|
@ -577,7 +575,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this));
|
DebugFlags.init(PreferenceManager.getDefaultSharedPreferences(this));
|
||||||
RichInputMethodManager.init(this);
|
RichInputMethodManager.init(this);
|
||||||
mRichImm = RichInputMethodManager.getInstance();
|
mRichImm = RichInputMethodManager.getInstance();
|
||||||
SubtypeSwitcher.init(this);
|
|
||||||
KeyboardSwitcher.init(this);
|
KeyboardSwitcher.init(this);
|
||||||
AudioAndHapticFeedbackManager.init(this);
|
AudioAndHapticFeedbackManager.init(this);
|
||||||
AccessibilityUtils.init(this);
|
AccessibilityUtils.init(this);
|
||||||
|
@ -877,7 +874,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
|
// 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.
|
// is not guaranteed. It may even be called at the same time on a different thread.
|
||||||
mRichImm.onSubtypeChanged(subtype);
|
mRichImm.onSubtypeChanged(subtype);
|
||||||
mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentSubtype());
|
|
||||||
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype),
|
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype),
|
||||||
mSettings.getCurrent());
|
mSettings.getCurrent());
|
||||||
loadKeyboard();
|
loadKeyboard();
|
||||||
|
@ -894,7 +890,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// also wouldn't be consuming gesture data.
|
// also wouldn't be consuming gesture data.
|
||||||
mGestureConsumer = GestureConsumer.NULL_GESTURE_CONSUMER;
|
mGestureConsumer = GestureConsumer.NULL_GESTURE_CONSUMER;
|
||||||
mRichImm.refreshSubtypeCaches();
|
mRichImm.refreshSubtypeCaches();
|
||||||
mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentSubtype());
|
|
||||||
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
final KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
switcher.updateKeyboardTheme();
|
switcher.updateKeyboardTheme();
|
||||||
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
|
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
|
||||||
|
@ -956,10 +951,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
Settings.getInstance().getCurrent().mDisplayOrientation,
|
Settings.getInstance().getCurrent().mDisplayOrientation,
|
||||||
!isDifferentTextField);
|
!isDifferentTextField);
|
||||||
|
|
||||||
if (isDifferentTextField) {
|
|
||||||
mSubtypeSwitcher.updateParametersOnStartInputView();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The EditorInfo might have a flag that affects fullscreen mode.
|
// The EditorInfo might have a flag that affects fullscreen mode.
|
||||||
// Note: This call should be done by InputMethodService?
|
// Note: This call should be done by InputMethodService?
|
||||||
updateFullscreenMode();
|
updateFullscreenMode();
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
||||||
import com.android.inputmethod.latin.settings.AdditionalFeaturesSettingUtils;
|
import com.android.inputmethod.latin.settings.AdditionalFeaturesSettingUtils;
|
||||||
import com.android.inputmethod.latin.settings.Settings;
|
import com.android.inputmethod.latin.settings.Settings;
|
||||||
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
||||||
|
import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
|
||||||
import com.android.inputmethod.latin.utils.NetworkConnectivityUtils;
|
import com.android.inputmethod.latin.utils.NetworkConnectivityUtils;
|
||||||
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
|
|
||||||
|
@ -513,6 +514,15 @@ public class RichInputMethodManager {
|
||||||
+ (mShortcutSubtype == null ? "<null>" : (
|
+ (mShortcutSubtype == null ? "<null>" : (
|
||||||
mShortcutSubtype.getLocale() + ", " + mShortcutSubtype.getMode())));
|
mShortcutSubtype.getLocale() + ", " + mShortcutSubtype.getMode())));
|
||||||
}
|
}
|
||||||
|
final RichInputMethodSubtype richSubtype = mCurrentRichInputMethodSubtype;
|
||||||
|
final boolean implicitlyEnabledSubtype = checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(
|
||||||
|
richSubtype.getRawSubtype());
|
||||||
|
final Locale systemLocale = mContext.getResources().getConfiguration().locale;
|
||||||
|
LanguageOnSpacebarUtils.onSubtypeChanged(
|
||||||
|
richSubtype, implicitlyEnabledSubtype, systemLocale);
|
||||||
|
LanguageOnSpacebarUtils.setEnabledSubtypes(getMyEnabledInputMethodSubtypeList(
|
||||||
|
true /* allowsImplicitlySelectedSubtypes */));
|
||||||
|
|
||||||
// TODO: Update an icon for shortcut IME
|
// TODO: Update an icon for shortcut IME
|
||||||
final Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts =
|
final Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts =
|
||||||
getInputMethodManager().getShortcutInputMethodsAndSubtypes();
|
getInputMethodManager().getShortcutInputMethodsAndSubtypes();
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2010 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
|
||||||
|
|
||||||
import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
|
|
||||||
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public final class SubtypeSwitcher {
|
|
||||||
private static final SubtypeSwitcher sInstance = new SubtypeSwitcher();
|
|
||||||
|
|
||||||
private /* final */ RichInputMethodManager mRichImm;
|
|
||||||
private /* final */ Resources mResources;
|
|
||||||
|
|
||||||
public static SubtypeSwitcher getInstance() {
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(final Context context) {
|
|
||||||
SubtypeLocaleUtils.init(context);
|
|
||||||
RichInputMethodManager.init(context);
|
|
||||||
sInstance.initialize(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SubtypeSwitcher() {
|
|
||||||
// Intentional empty constructor for singleton.
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialize(final Context context) {
|
|
||||||
if (mResources != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mResources = context.getResources();
|
|
||||||
mRichImm = RichInputMethodManager.getInstance();
|
|
||||||
|
|
||||||
onSubtypeChanged(mRichImm.getCurrentSubtype());
|
|
||||||
updateParametersOnStartInputView();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update parameters which are changed outside LatinIME. This parameters affect UI so that they
|
|
||||||
* should be updated every time onStartInputView is called.
|
|
||||||
*/
|
|
||||||
public void updateParametersOnStartInputView() {
|
|
||||||
final List<InputMethodSubtype> enabledSubtypesOfThisIme =
|
|
||||||
mRichImm.getMyEnabledInputMethodSubtypeList(true);
|
|
||||||
LanguageOnSpacebarUtils.setEnabledSubtypes(enabledSubtypesOfThisIme);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
|
|
||||||
public void onSubtypeChanged(@Nonnull final RichInputMethodSubtype richSubtype) {
|
|
||||||
final boolean implicitlyEnabledSubtype = mRichImm
|
|
||||||
.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(richSubtype.getRawSubtype());
|
|
||||||
LanguageOnSpacebarUtils.onSubtypeChanged(
|
|
||||||
richSubtype, implicitlyEnabledSubtype, mResources.getConfiguration().locale);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -33,9 +33,8 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
|
||||||
import com.android.inputmethod.latin.accounts.LoginAccountUtils;
|
|
||||||
import com.android.inputmethod.latin.accounts.AccountStateChangedListener;
|
import com.android.inputmethod.latin.accounts.AccountStateChangedListener;
|
||||||
|
import com.android.inputmethod.latin.accounts.LoginAccountUtils;
|
||||||
import com.android.inputmethod.latin.define.ProductionFlags;
|
import com.android.inputmethod.latin.define.ProductionFlags;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -66,12 +65,6 @@ public final class AccountsSettingsFragment extends SubScreenFragment {
|
||||||
addPreferencesFromResource(R.xml.prefs_screen_accounts);
|
addPreferencesFromResource(R.xml.prefs_screen_accounts);
|
||||||
|
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
final Context context = getActivity();
|
|
||||||
|
|
||||||
// When we are called from the Settings application but we are not already running, some
|
|
||||||
// singleton and utility classes may not have been initialized. We have to call
|
|
||||||
// initialization method of these classes here. See {@link LatinIME#onCreate()}.
|
|
||||||
SubtypeSwitcher.init(context);
|
|
||||||
|
|
||||||
if (ProductionFlags.IS_METRICS_LOGGING_SUPPORTED) {
|
if (ProductionFlags.IS_METRICS_LOGGING_SUPPORTED) {
|
||||||
final Preference enableMetricsLogging =
|
final Preference enableMetricsLogging =
|
||||||
|
|
Loading…
Reference in New Issue