Loading java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +12 −27 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.util.Log; import android.view.ContextThemeWrapper; import android.view.InflateException; import android.view.LayoutInflater; import android.view.View; import android.view.inputmethod.EditorInfo; Loading @@ -38,7 +37,6 @@ import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SettingsValues; import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.WordComposer; public class KeyboardSwitcher implements KeyboardState.SwitchActions { Loading @@ -47,24 +45,24 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916"; static class KeyboardTheme { public final String mName; public final int mThemeId; public final int mStyleId; public KeyboardTheme(String name, int themeId, int styleId) { mName = name; // Note: The themeId should be aligned with "themeId" attribute of Keyboard style // in values/style.xml. public KeyboardTheme(int themeId, int styleId) { mThemeId = themeId; mStyleId = styleId; } } private static final KeyboardTheme[] KEYBOARD_THEMES = { new KeyboardTheme("Basic", 0, R.style.KeyboardTheme), new KeyboardTheme("HighContrast", 1, R.style.KeyboardTheme_HighContrast), new KeyboardTheme("Stone", 6, R.style.KeyboardTheme_Stone), new KeyboardTheme("Stone.Bold", 7, R.style.KeyboardTheme_Stone_Bold), new KeyboardTheme("GingerBread", 8, R.style.KeyboardTheme_Gingerbread), new KeyboardTheme("IceCreamSandwich", 5, R.style.KeyboardTheme_IceCreamSandwich), new KeyboardTheme(0, R.style.KeyboardTheme), new KeyboardTheme(1, R.style.KeyboardTheme_HighContrast), new KeyboardTheme(6, R.style.KeyboardTheme_Stone), new KeyboardTheme(7, R.style.KeyboardTheme_Stone_Bold), new KeyboardTheme(8, R.style.KeyboardTheme_Gingerbread), new KeyboardTheme(5, R.style.KeyboardTheme_IceCreamSandwich), }; private SubtypeSwitcher mSubtypeSwitcher; Loading Loading @@ -355,22 +353,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardView.closing(); } Utils.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { setContextThemeWrapper(mLatinIME, mKeyboardTheme); mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate( R.layout.input_view, null); tryGC = false; } catch (OutOfMemoryError e) { Log.w(TAG, "load keyboard failed: " + e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait(mKeyboardTheme.mName, e); } catch (InflateException e) { Log.w(TAG, "load keyboard failed: " + e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait(mKeyboardTheme.mName, e); } } mKeyboardView = (MainKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view); if (isHardwareAcceleratedDrawingEnabled) { Loading java/src/com/android/inputmethod/latin/LatinIME.java +1 −12 Original line number Diff line number Diff line Loading @@ -381,18 +381,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImfUtils.setAdditionalInputMethodSubtypes(this, mCurrentSettings.getAdditionalSubtypes()); Utils.GCUtils.getInstance().reset(); boolean tryGC = true; // Shouldn't this be removed? I think that from Honeycomb on, the GC is now actually working // as expected and this code is useless. for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(); tryGC = false; } catch (OutOfMemoryError e) { tryGC = Utils.GCUtils.getInstance().tryGCOrWait("InitSuggest", e); } } mDisplayOrientation = res.getConfiguration().orientation; Loading java/src/com/android/inputmethod/latin/Utils.java +0 −38 Original line number Diff line number Diff line Loading @@ -65,44 +65,6 @@ public class Utils { } } public static class GCUtils { private static final String GC_TAG = GCUtils.class.getSimpleName(); public static final int GC_TRY_COUNT = 2; // GC_TRY_LOOP_MAX is used for the hard limit of GC wait, // GC_TRY_LOOP_MAX should be greater than GC_TRY_COUNT. public static final int GC_TRY_LOOP_MAX = 5; private static final long GC_INTERVAL = DateUtils.SECOND_IN_MILLIS; private static GCUtils sInstance = new GCUtils(); private int mGCTryCount = 0; public static GCUtils getInstance() { return sInstance; } public void reset() { mGCTryCount = 0; } public boolean tryGCOrWait(String metaData, Throwable t) { if (mGCTryCount == 0) { System.gc(); } if (++mGCTryCount > GC_TRY_COUNT) { LatinImeLogger.logOnException(metaData, t); return false; } else { try { Thread.sleep(GC_INTERVAL); return true; } catch (InterruptedException e) { Log.e(GC_TAG, "Sleep was interrupted."); LatinImeLogger.logOnException(metaData, t); return false; } } } } /* package */ static class RingCharBuffer { private static RingCharBuffer sRingCharBuffer = new RingCharBuffer(); private static final char PLACEHOLDER_DELIMITER_CHAR = '\uFFFC'; Loading Loading
java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +12 −27 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.util.Log; import android.view.ContextThemeWrapper; import android.view.InflateException; import android.view.LayoutInflater; import android.view.View; import android.view.inputmethod.EditorInfo; Loading @@ -38,7 +37,6 @@ import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SettingsValues; import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.WordComposer; public class KeyboardSwitcher implements KeyboardState.SwitchActions { Loading @@ -47,24 +45,24 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916"; static class KeyboardTheme { public final String mName; public final int mThemeId; public final int mStyleId; public KeyboardTheme(String name, int themeId, int styleId) { mName = name; // Note: The themeId should be aligned with "themeId" attribute of Keyboard style // in values/style.xml. public KeyboardTheme(int themeId, int styleId) { mThemeId = themeId; mStyleId = styleId; } } private static final KeyboardTheme[] KEYBOARD_THEMES = { new KeyboardTheme("Basic", 0, R.style.KeyboardTheme), new KeyboardTheme("HighContrast", 1, R.style.KeyboardTheme_HighContrast), new KeyboardTheme("Stone", 6, R.style.KeyboardTheme_Stone), new KeyboardTheme("Stone.Bold", 7, R.style.KeyboardTheme_Stone_Bold), new KeyboardTheme("GingerBread", 8, R.style.KeyboardTheme_Gingerbread), new KeyboardTheme("IceCreamSandwich", 5, R.style.KeyboardTheme_IceCreamSandwich), new KeyboardTheme(0, R.style.KeyboardTheme), new KeyboardTheme(1, R.style.KeyboardTheme_HighContrast), new KeyboardTheme(6, R.style.KeyboardTheme_Stone), new KeyboardTheme(7, R.style.KeyboardTheme_Stone_Bold), new KeyboardTheme(8, R.style.KeyboardTheme_Gingerbread), new KeyboardTheme(5, R.style.KeyboardTheme_IceCreamSandwich), }; private SubtypeSwitcher mSubtypeSwitcher; Loading Loading @@ -355,22 +353,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { mKeyboardView.closing(); } Utils.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { setContextThemeWrapper(mLatinIME, mKeyboardTheme); mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate( R.layout.input_view, null); tryGC = false; } catch (OutOfMemoryError e) { Log.w(TAG, "load keyboard failed: " + e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait(mKeyboardTheme.mName, e); } catch (InflateException e) { Log.w(TAG, "load keyboard failed: " + e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait(mKeyboardTheme.mName, e); } } mKeyboardView = (MainKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view); if (isHardwareAcceleratedDrawingEnabled) { Loading
java/src/com/android/inputmethod/latin/LatinIME.java +1 −12 Original line number Diff line number Diff line Loading @@ -381,18 +381,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImfUtils.setAdditionalInputMethodSubtypes(this, mCurrentSettings.getAdditionalSubtypes()); Utils.GCUtils.getInstance().reset(); boolean tryGC = true; // Shouldn't this be removed? I think that from Honeycomb on, the GC is now actually working // as expected and this code is useless. for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(); tryGC = false; } catch (OutOfMemoryError e) { tryGC = Utils.GCUtils.getInstance().tryGCOrWait("InitSuggest", e); } } mDisplayOrientation = res.getConfiguration().orientation; Loading
java/src/com/android/inputmethod/latin/Utils.java +0 −38 Original line number Diff line number Diff line Loading @@ -65,44 +65,6 @@ public class Utils { } } public static class GCUtils { private static final String GC_TAG = GCUtils.class.getSimpleName(); public static final int GC_TRY_COUNT = 2; // GC_TRY_LOOP_MAX is used for the hard limit of GC wait, // GC_TRY_LOOP_MAX should be greater than GC_TRY_COUNT. public static final int GC_TRY_LOOP_MAX = 5; private static final long GC_INTERVAL = DateUtils.SECOND_IN_MILLIS; private static GCUtils sInstance = new GCUtils(); private int mGCTryCount = 0; public static GCUtils getInstance() { return sInstance; } public void reset() { mGCTryCount = 0; } public boolean tryGCOrWait(String metaData, Throwable t) { if (mGCTryCount == 0) { System.gc(); } if (++mGCTryCount > GC_TRY_COUNT) { LatinImeLogger.logOnException(metaData, t); return false; } else { try { Thread.sleep(GC_INTERVAL); return true; } catch (InterruptedException e) { Log.e(GC_TAG, "Sleep was interrupted."); LatinImeLogger.logOnException(metaData, t); return false; } } } } /* package */ static class RingCharBuffer { private static RingCharBuffer sRingCharBuffer = new RingCharBuffer(); private static final char PLACEHOLDER_DELIMITER_CHAR = '\uFFFC'; Loading