From ef5dfc480c7a3e3e34a20b7aacc731942e7a0578 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Sun, 17 Jul 2011 15:23:52 -0700 Subject: Remove sliding spacebar language switcher Bug: 4971680 Change-Id: Ia3485ddcf8051bf7b7ba7f7a37fa75c3bc8a4798 --- java/src/com/android/inputmethod/latin/DebugSettings.java | 8 -------- 1 file changed, 8 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/DebugSettings.java') diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java index fd62d61c3..2f1e7c2b8 100644 --- a/java/src/com/android/inputmethod/latin/DebugSettings.java +++ b/java/src/com/android/inputmethod/latin/DebugSettings.java @@ -33,7 +33,6 @@ public class DebugSettings extends PreferenceActivity private boolean mServiceNeedsRestart = false; private CheckBoxPreference mDebugMode; - private CheckBoxPreference mUseSpacebarLanguageSwitch; @Override protected void onCreate(Bundle icicle) { @@ -61,13 +60,6 @@ public class DebugSettings extends PreferenceActivity updateDebugMode(); mServiceNeedsRestart = true; } - } else if (key.equals(SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCH_KEY)) { - if (mUseSpacebarLanguageSwitch != null) { - mUseSpacebarLanguageSwitch.setChecked( - prefs.getBoolean(SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCH_KEY, - getResources().getBoolean( - R.bool.config_use_spacebar_language_switcher))); - } } } -- cgit v1.2.3-83-g751a From 06b7c256b1992f93aab0e2cdb90f57718f0631fd Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 16 Jan 2012 17:18:40 +0900 Subject: Add "force non-distinct multitouch" debug option Change-Id: I9fd6fabf03515011cedb8aaa30fdb7a77f2d4d12 --- java/res/values/donottranslate.xml | 1 + java/res/xml/prefs_for_debug.xml | 6 ++++++ java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java | 7 +++++++ java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java | 6 +++++- java/src/com/android/inputmethod/latin/DebugSettings.java | 3 +++ 5 files changed, 22 insertions(+), 1 deletion(-) (limited to 'java/src/com/android/inputmethod/latin/DebugSettings.java') diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index e6f036d53..8bd25c00d 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -120,6 +120,7 @@ Android keyboard Debug settings Debug Mode + Force non-distinct multitouch Basic diff --git a/java/res/xml/prefs_for_debug.xml b/java/res/xml/prefs_for_debug.xml index 80613a56f..f38b85f0b 100644 --- a/java/res/xml/prefs_for_debug.xml +++ b/java/res/xml/prefs_for_debug.xml @@ -42,4 +42,10 @@ android:defaultValue="false" /> + diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 54d842f09..b36c7eb9e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -28,6 +28,7 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.keyboard.internal.KeyboardState; +import com.android.inputmethod.latin.DebugSettings; import com.android.inputmethod.latin.InputView; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; @@ -53,6 +54,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, private SubtypeSwitcher mSubtypeSwitcher; private SharedPreferences mPrefs; + private boolean mForceNonDistinctMultitouch; private InputView mCurrentInputView; private LatinKeyboardView mKeyboardView; @@ -92,6 +94,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, mState = new KeyboardState(this); setContextThemeWrapper(ims, getKeyboardThemeIndex(ims, prefs)); prefs.registerOnSharedPreferenceChangeListener(this); + mForceNonDistinctMultitouch = prefs.getBoolean( + DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false); } private static int getKeyboardThemeIndex(Context context, SharedPreferences prefs) { @@ -391,6 +395,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, mKeyboardView = (LatinKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view); mKeyboardView.setKeyboardActionListener(mInputMethodService); + if (mForceNonDistinctMultitouch) { + mKeyboardView.setDistinctMultitouch(false); + } // This always needs to be set since the accessibility state can // potentially change without the input view being re-created. diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 4d2aeeccf..8aa7f883b 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -115,7 +115,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke /** Listener for {@link KeyboardActionListener}. */ private KeyboardActionListener mKeyboardActionListener; - private final boolean mHasDistinctMultitouch; + private boolean mHasDistinctMultitouch; private int mOldPointerCount = 1; private Key mOldKey; @@ -371,6 +371,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke return mHasDistinctMultitouch; } + public void setDistinctMultitouch(boolean hasDistinctMultitouch) { + mHasDistinctMultitouch = hasDistinctMultitouch; + } + /** * When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key * codes for adjacent keys. When disabled, only the primary key code will be diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java index 2f1e7c2b8..3805da154 100644 --- a/java/src/com/android/inputmethod/latin/DebugSettings.java +++ b/java/src/com/android/inputmethod/latin/DebugSettings.java @@ -30,6 +30,7 @@ public class DebugSettings extends PreferenceActivity private static final String TAG = "DebugSettings"; private static final String DEBUG_MODE_KEY = "debug_mode"; + public static final String FORCE_NON_DISTINCT_MULTITOUCH_KEY = "force_non_distinct_multitouch"; private boolean mServiceNeedsRestart = false; private CheckBoxPreference mDebugMode; @@ -60,6 +61,8 @@ public class DebugSettings extends PreferenceActivity updateDebugMode(); mServiceNeedsRestart = true; } + } else if (key.equals(FORCE_NON_DISTINCT_MULTITOUCH_KEY)) { + mServiceNeedsRestart = true; } } -- cgit v1.2.3-83-g751a From 3e2d385810ca5a36a21dc6af661381c1ca27cc86 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 8 Mar 2012 15:07:00 +0900 Subject: Restart LatinIME service when keyboard theme is changed Bug: 6023947 Change-Id: I779da32708fca7333aff74929cc98173246ee685 --- .../com/android/inputmethod/keyboard/Keyboard.java | 1 + .../inputmethod/keyboard/KeyboardSwitcher.java | 39 +++------------------- .../android/inputmethod/latin/DebugSettings.java | 5 ++- 3 files changed, 9 insertions(+), 36 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/DebugSettings.java') diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 5660d1942..320b1bea2 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -388,6 +388,7 @@ public class Keyboard { } } + // TODO: Move this method to KeyboardSwitcher. public static String toThemeName(int themeId) { // This should be aligned with theme-*.xml resource files' themeId attribute. switch (themeId) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index ac8dd1b95..efe5aa9cf 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -39,8 +39,7 @@ import com.android.inputmethod.latin.SettingsValues; import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.Utils; -public class KeyboardSwitcher implements KeyboardState.SwitchActions, - SharedPreferences.OnSharedPreferenceChangeListener { +public class KeyboardSwitcher implements KeyboardState.SwitchActions { private static final String TAG = KeyboardSwitcher.class.getSimpleName(); public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916"; @@ -94,7 +93,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mState = new KeyboardState(this); setContextThemeWrapper(ims, getKeyboardThemeIndex(ims, prefs)); - prefs.registerOnSharedPreferenceChangeListener(this); mForceNonDistinctMultitouch = prefs.getBoolean( DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false); } @@ -341,34 +339,26 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, } public View onCreateInputView() { - return createInputView(mThemeIndex, true); - } - - private View createInputView(final int newThemeIndex, final boolean forceRecreate) { - if (mCurrentInputView != null && mThemeIndex == newThemeIndex && !forceRecreate) - return mCurrentInputView; - if (mKeyboardView != null) { mKeyboardView.closing(); } - final int oldThemeIndex = mThemeIndex; Utils.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { - setContextThemeWrapper(mInputMethodService, newThemeIndex); + setContextThemeWrapper(mInputMethodService, mThemeIndex); 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( - oldThemeIndex + "," + newThemeIndex, e); + Keyboard.toThemeName(mThemeIndex), e); } catch (InflateException e) { Log.w(TAG, "load keyboard failed: " + e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait( - oldThemeIndex + "," + newThemeIndex, e); + Keyboard.toThemeName(mThemeIndex), e); } } @@ -385,27 +375,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, return mCurrentInputView; } - private void postSetInputView(final View newInputView) { - final LatinIME latinIme = mInputMethodService; - latinIme.mHandler.post(new Runnable() { - @Override - public void run() { - if (newInputView != null) { - latinIme.setInputView(newInputView); - } - latinIme.updateInputViewShown(); - } - }); - } - - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - if (PREF_KEYBOARD_LAYOUT.equals(key)) { - final int themeIndex = getKeyboardThemeIndex(mInputMethodService, sharedPreferences); - postSetInputView(createInputView(themeIndex, false)); - } - } - public void onNetworkStateChanged() { if (mKeyboardView != null) { mKeyboardView.updateShortcutKey(SubtypeSwitcher.getInstance().isShortcutImeReady()); diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java index 3805da154..870b33f9a 100644 --- a/java/src/com/android/inputmethod/latin/DebugSettings.java +++ b/java/src/com/android/inputmethod/latin/DebugSettings.java @@ -25,6 +25,8 @@ import android.preference.CheckBoxPreference; import android.preference.PreferenceActivity; import android.util.Log; +import com.android.inputmethod.keyboard.KeyboardSwitcher; + public class DebugSettings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -61,7 +63,8 @@ public class DebugSettings extends PreferenceActivity updateDebugMode(); mServiceNeedsRestart = true; } - } else if (key.equals(FORCE_NON_DISTINCT_MULTITOUCH_KEY)) { + } else if (key.equals(FORCE_NON_DISTINCT_MULTITOUCH_KEY) + || key.equals(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT)) { mServiceNeedsRestart = true; } } -- cgit v1.2.3-83-g751a From 9a50777890a370a4982aef9a8b997e53e8827358 Mon Sep 17 00:00:00 2001 From: Kurt Partridge Date: Mon, 19 Mar 2012 16:11:17 +0900 Subject: Fix TAG name Change-Id: Ibea065bc72e6b5e40cfa3ffa2fb6bcdeb107ffc4 --- java/src/com/android/inputmethod/latin/DebugSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/src/com/android/inputmethod/latin/DebugSettings.java') diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java index 870b33f9a..23d63b42a 100644 --- a/java/src/com/android/inputmethod/latin/DebugSettings.java +++ b/java/src/com/android/inputmethod/latin/DebugSettings.java @@ -30,7 +30,7 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher; public class DebugSettings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String TAG = "DebugSettings"; + private static final String TAG = DebugSettings.class.getSimpleName(); private static final String DEBUG_MODE_KEY = "debug_mode"; public static final String FORCE_NON_DISTINCT_MULTITOUCH_KEY = "force_non_distinct_multitouch"; -- cgit v1.2.3-83-g751a From c206d0462354b3bf1ad0cec61534da567829555d Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 13 Apr 2012 19:53:44 +0900 Subject: Use InputMethodSettingsFragment for IME settings Change-Id: Id6d9cd0ddf99c0687b6d3ea4b2f868f6cf2a0eaf --- java/AndroidManifest.xml | 4 +-- java/res/xml/method.xml | 2 +- .../android/inputmethod/latin/DebugSettings.java | 13 +++++--- .../inputmethod/latin/DebugSettingsActivity.java | 36 +++++++++++++++++++++ .../com/android/inputmethod/latin/LatinIME.java | 8 ++--- .../com/android/inputmethod/latin/Settings.java | 37 ++++++++-------------- .../inputmethod/latin/SettingsActivity.java | 36 +++++++++++++++++++++ 7 files changed, 100 insertions(+), 36 deletions(-) create mode 100644 java/src/com/android/inputmethod/latin/DebugSettingsActivity.java create mode 100644 java/src/com/android/inputmethod/latin/SettingsActivity.java (limited to 'java/src/com/android/inputmethod/latin/DebugSettings.java') diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml index 9f62e9779..393bc18b8 100644 --- a/java/AndroidManifest.xml +++ b/java/AndroidManifest.xml @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index ca0b24e19..981f24657 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -68,7 +68,7 @@ settingsClass) { + private void launchSettingsClass(Class settingsClass) { handleClose(); Intent intent = new Intent(); intent.setClass(LatinIME.this, settingsClass); diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 6bc049894..43e7e278f 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -16,9 +16,7 @@ package com.android.inputmethod.latin; -import android.app.Activity; import android.app.AlertDialog; -import android.app.Fragment; import android.app.backup.BackupManager; import android.content.Context; import android.content.DialogInterface; @@ -33,15 +31,16 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; +import android.view.LayoutInflater; import android.view.View; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; import com.android.inputmethod.latin.define.ProductionFlag; -import com.android.inputmethodcommon.InputMethodSettingsActivity; +import com.android.inputmethodcommon.InputMethodSettingsFragment; -public class Settings extends InputMethodSettingsActivity +public class Settings extends InputMethodSettingsFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public static final boolean ENABLE_EXPERIMENTAL_SETTINGS = false; @@ -103,26 +102,16 @@ public class Settings extends InputMethodSettingsActivity } } - public Activity getActivityInternal() { - Object thisObject = (Object) this; - if (thisObject instanceof Activity) { - return (Activity) thisObject; - } else if (thisObject instanceof Fragment) { - return ((Fragment) thisObject).getActivity(); - } else { - return null; - } - } - @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setInputMethodSettingsCategoryTitle(R.string.language_selection_title); setSubtypeEnablerTitle(R.string.select_language); + addPreferencesFromResource(R.xml.prefs); + final Resources res = getResources(); - final Context context = getActivityInternal(); + final Context context = getActivity(); - addPreferencesFromResource(R.xml.prefs); mVoicePreference = (ListPreference) findPreference(PREF_VOICE_MODE); mShowCorrectionSuggestionsPreference = (ListPreference) findPreference(PREF_SHOW_SUGGESTIONS_SETTING); @@ -276,7 +265,7 @@ public class Settings extends InputMethodSettingsActivity @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { - (new BackupManager(getActivityInternal())).dataChanged(); + (new BackupManager(getActivity())).dataChanged(); if (key.equals(PREF_POPUP_ON)) { final ListPreference popupDismissDelay = (ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); @@ -318,7 +307,7 @@ public class Settings extends InputMethodSettingsActivity private void refreshEnablingsOfKeypressSoundAndVibrationSettings( SharedPreferences sp, Resources res) { if (mKeypressVibrationDurationSettingsPref != null) { - final boolean hasVibrator = VibratorUtils.getInstance(this).hasVibrator(); + final boolean hasVibrator = VibratorUtils.getInstance(getActivity()).hasVibrator(); final boolean vibrateOn = hasVibrator && sp.getBoolean(Settings.PREF_VIBRATE_ON, res.getBoolean(R.bool.config_default_vibration_enabled)); mKeypressVibrationDurationSettingsPref.setEnabled(vibrateOn); @@ -342,7 +331,7 @@ public class Settings extends InputMethodSettingsActivity private void showKeypressVibrationDurationSettingsDialog() { final SharedPreferences sp = getPreferenceManager().getSharedPreferences(); - final Activity context = getActivityInternal(); + final Context context = getActivity(); final Resources res = context.getResources(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.prefs_keypress_vibration_duration_settings); @@ -361,7 +350,7 @@ public class Settings extends InputMethodSettingsActivity dialog.dismiss(); } }); - final View v = context.getLayoutInflater().inflate( + final View v = LayoutInflater.from(context).inflate( R.layout.vibration_settings_dialog, null); final int currentMs = SettingsValues.getCurrentVibrationDuration( getPreferenceManager().getSharedPreferences(), getResources()); @@ -398,9 +387,9 @@ public class Settings extends InputMethodSettingsActivity } private void showKeypressSoundVolumeSettingDialog() { - final AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); + final Context context = getActivity(); + final AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); final SharedPreferences sp = getPreferenceManager().getSharedPreferences(); - final Activity context = getActivityInternal(); final Resources res = context.getResources(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.prefs_keypress_sound_volume_settings); @@ -420,7 +409,7 @@ public class Settings extends InputMethodSettingsActivity dialog.dismiss(); } }); - final View v = context.getLayoutInflater().inflate( + final View v = LayoutInflater.from(context).inflate( R.layout.sound_effect_volume_dialog, null); final int currentVolumeInt = (int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100); diff --git a/java/src/com/android/inputmethod/latin/SettingsActivity.java b/java/src/com/android/inputmethod/latin/SettingsActivity.java new file mode 100644 index 000000000..b85a936ad --- /dev/null +++ b/java/src/com/android/inputmethod/latin/SettingsActivity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2012 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.Intent; +import android.os.Bundle; +import android.preference.PreferenceActivity; + +public class SettingsActivity extends PreferenceActivity { + @Override + public Intent getIntent() { + final Intent modIntent = new Intent(super.getIntent()); + modIntent.putExtra(EXTRA_SHOW_FRAGMENT, Settings.class.getName()); + return modIntent; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setTitle(R.string.english_ime_settings); + } +} -- cgit v1.2.3-83-g751a