Remove LatinIME prefix from classes

This change also cleanups preference key string constants

Change-Id: I58510f220a90d00d71a935731abeab87384675bb
main
Tadashi G. Takaoka 2010-12-09 21:06:26 +09:00
parent 55b9d333c5
commit 9502cc177c
14 changed files with 87 additions and 87 deletions

View File

@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<application android:label="@string/english_ime_name" <application android:label="@string/english_ime_name"
android:backupAgent="LatinIMEBackupAgent" android:backupAgent="BackupAgent"
android:killAfterRestore="false"> android:killAfterRestore="false">
<service android:name="LatinIME" <service android:name="LatinIME"
@ -20,13 +20,13 @@
<meta-data android:name="android.view.im" android:resource="@xml/method" /> <meta-data android:name="android.view.im" android:resource="@xml/method" />
</service> </service>
<activity android:name="LatinIMESettings" android:label="@string/english_ime_settings"> <activity android:name="Settings" android:label="@string/english_ime_settings">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="LatinIMEDebugSettings" android:label="@string/english_ime_debug_settings"> <activity android:name="DebugSettings" android:label="@string/english_ime_debug_settings">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
</intent-filter> </intent-filter>

View File

@ -25,7 +25,7 @@
<!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. --> <!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. -->
<!-- TODO: use <lang>_mic icon instead of a common mic icon. --> <!-- TODO: use <lang>_mic icon instead of a common mic icon. -->
<input-method xmlns:android="http://schemas.android.com/apk/res/android" <input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.android.inputmethod.latin.LatinIMESettings" android:settingsActivity="com.android.inputmethod.latin.Settings"
android:isDefault="@bool/im_is_default"> android:isDefault="@bool/im_is_default">
<!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default <!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default
subtype.--> subtype.-->

View File

@ -17,8 +17,8 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinIMESettings; import com.android.inputmethod.latin.Settings;
import com.android.inputmethod.latin.LatinIMEUtil; import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
@ -562,20 +562,20 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
newLayout = Integer.valueOf(DEFAULT_LAYOUT_ID); newLayout = Integer.valueOf(DEFAULT_LAYOUT_ID);
} }
LatinIMEUtil.GCUtils.getInstance().reset(); Utils.GCUtils.getInstance().reset();
boolean tryGC = true; boolean tryGC = true;
for (int i = 0; i < LatinIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try { try {
mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater( mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater(
).inflate(THEMES[newLayout], null); ).inflate(THEMES[newLayout], null);
tryGC = false; tryGC = false;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
Log.w(TAG, "load keyboard failed: " + e); Log.w(TAG, "load keyboard failed: " + e);
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait( tryGC = Utils.GCUtils.getInstance().tryGCOrWait(
mLayoutId + "," + newLayout, e); mLayoutId + "," + newLayout, e);
} catch (InflateException e) { } catch (InflateException e) {
Log.w(TAG, "load keyboard failed: " + e); Log.w(TAG, "load keyboard failed: " + e);
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait( tryGC = Utils.GCUtils.getInstance().tryGCOrWait(
mLayoutId + "," + newLayout, e); mLayoutId + "," + newLayout, e);
} }
} }
@ -603,7 +603,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
sharedPreferences.getString(key, DEFAULT_LAYOUT_ID)); sharedPreferences.getString(key, DEFAULT_LAYOUT_ID));
createInputViewInternal(layoutId, false); createInputViewInternal(layoutId, false);
postSetInputView(); postSetInputView();
} else if (LatinIMESettings.PREF_SETTINGS_KEY.equals(key)) { } else if (Settings.PREF_SETTINGS_KEY.equals(key)) {
mHasSettingsKey = getSettingsKeyMode(sharedPreferences, mInputMethodService); mHasSettingsKey = getSettingsKeyMode(sharedPreferences, mInputMethodService);
createInputViewInternal(mLayoutId, true); createInputViewInternal(mLayoutId, true);
postSetInputView(); postSetInputView();
@ -629,13 +629,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final boolean showSettingsKeyOption = resources.getBoolean( final boolean showSettingsKeyOption = resources.getBoolean(
R.bool.config_enable_show_settings_key_option); R.bool.config_enable_show_settings_key_option);
if (showSettingsKeyOption) { if (showSettingsKeyOption) {
final String settingsKeyMode = prefs.getString(LatinIMESettings.PREF_SETTINGS_KEY, final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
resources.getString(DEFAULT_SETTINGS_KEY_MODE)); resources.getString(DEFAULT_SETTINGS_KEY_MODE));
// We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or // We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or
// 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system // 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system
if (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW)) if (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))
|| (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO)) || (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO))
&& LatinIMEUtil.hasMultipleEnabledIMEsOrSubtypes( && Utils.hasMultipleEnabledIMEsOrSubtypes(
((InputMethodManager) context.getSystemService( ((InputMethodManager) context.getSystemService(
Context.INPUT_METHOD_SERVICE))))) { Context.INPUT_METHOD_SERVICE))))) {
return true; return true;

View File

@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import com.android.inputmethod.latin.LatinIMEUtil; import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.voice.VoiceIMEConnector; import com.android.inputmethod.voice.VoiceIMEConnector;
import android.content.Context; import android.content.Context;
@ -330,14 +330,14 @@ public class LatinKeyboardView extends KeyboardView {
@Override @Override
public void draw(Canvas c) { public void draw(Canvas c) {
LatinIMEUtil.GCUtils.getInstance().reset(); Utils.GCUtils.getInstance().reset();
boolean tryGC = true; boolean tryGC = true;
for (int i = 0; i < LatinIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try { try {
super.draw(c); super.draw(c);
tryGC = false; tryGC = false;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait("LatinKeyboardView", e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait("LatinKeyboardView", e);
} }
} }
if (DEBUG_AUTO_PLAY) { if (DEBUG_AUTO_PLAY) {

View File

@ -22,7 +22,7 @@ import android.app.backup.SharedPreferencesBackupHelper;
/** /**
* Backs up the Latin IME shared preferences. * Backs up the Latin IME shared preferences.
*/ */
public class LatinIMEBackupAgent extends BackupAgentHelper { public class BackupAgent extends BackupAgentHelper {
@Override @Override
public void onCreate() { public void onCreate() {

View File

@ -24,10 +24,10 @@ import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.util.Log; import android.util.Log;
public class LatinIMEDebugSettings extends PreferenceActivity public class DebugSettings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "LatinIMEDebugSettings"; private static final String TAG = "DebugSettings";
private static final String DEBUG_MODE_KEY = "debug_mode"; private static final String DEBUG_MODE_KEY = "debug_mode";
private CheckBoxPreference mDebugMode; private CheckBoxPreference mDebugMode;

View File

@ -69,7 +69,7 @@ public class InputLanguageSelection extends PreferenceActivity {
addPreferencesFromResource(R.xml.language_prefs); addPreferencesFromResource(R.xml.language_prefs);
// Get the settings preferences // Get the settings preferences
mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mSelectedLanguages = mPrefs.getString(LatinIME.PREF_SELECTED_LANGUAGES, ""); mSelectedLanguages = mPrefs.getString(Settings.PREF_SELECTED_LANGUAGES, "");
String[] languageList = mSelectedLanguages.split(","); String[] languageList = mSelectedLanguages.split(",");
mAvailableLanguages = getUniqueLocales(); mAvailableLanguages = getUniqueLocales();
PreferenceGroup parent = getPreferenceScreen(); PreferenceGroup parent = getPreferenceScreen();
@ -143,7 +143,7 @@ public class InputLanguageSelection extends PreferenceActivity {
} }
if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
Editor editor = mPrefs.edit(); Editor editor = mPrefs.edit();
editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages); editor.putString(Settings.PREF_SELECTED_LANGUAGES, checkedLanguages);
SharedPreferencesCompat.apply(editor); SharedPreferencesCompat.apply(editor);
} }

View File

@ -52,8 +52,8 @@ public class LanguageSwitcher {
* @return whether there was any change * @return whether there was any change
*/ */
public boolean loadLocales(SharedPreferences sp) { public boolean loadLocales(SharedPreferences sp) {
String selectedLanguages = sp.getString(LatinIME.PREF_SELECTED_LANGUAGES, null); String selectedLanguages = sp.getString(Settings.PREF_SELECTED_LANGUAGES, null);
String currentLanguage = sp.getString(LatinIME.PREF_INPUT_LANGUAGE, null); String currentLanguage = sp.getString(Settings.PREF_INPUT_LANGUAGE, null);
if (selectedLanguages == null || selectedLanguages.length() < 1) { if (selectedLanguages == null || selectedLanguages.length() < 1) {
loadDefaults(); loadDefaults();
if (mLocales.size() == 0) { if (mLocales.size() == 0) {
@ -187,7 +187,7 @@ public class LanguageSwitcher {
public void persist(SharedPreferences prefs) { public void persist(SharedPreferences prefs) {
Editor editor = prefs.edit(); Editor editor = prefs.edit();
editor.putString(LatinIME.PREF_INPUT_LANGUAGE, getInputLanguage()); editor.putString(Settings.PREF_INPUT_LANGUAGE, getInputLanguage());
SharedPreferencesCompat.apply(editor); SharedPreferencesCompat.apply(editor);
} }
} }

View File

@ -22,7 +22,7 @@ import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboardView; import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.latin.LatinIMEUtil.RingCharBuffer; import com.android.inputmethod.latin.Utils.RingCharBuffer;
import com.android.inputmethod.voice.VoiceIMEConnector; import com.android.inputmethod.voice.VoiceIMEConnector;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
@ -88,18 +88,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final boolean TRACE = false; private static final boolean TRACE = false;
private static final String PREF_SOUND_ON = "sound_on";
private static final String PREF_POPUP_ON = "popup_on";
private static final String PREF_AUTO_CAP = "auto_cap";
private static final String PREF_QUICK_FIXES = "quick_fixes";
private static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
private static final String PREF_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold";
private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
public static final String PREF_INPUT_LANGUAGE = "input_language";
private static final String PREF_RECORRECTION_ENABLED = "recorrection_enabled";
private static final int DELAY_UPDATE_SUGGESTIONS = 180; private static final int DELAY_UPDATE_SUGGESTIONS = 180;
private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300; private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300;
private static final int DELAY_UPDATE_SHIFT_STATE = 300; private static final int DELAY_UPDATE_SHIFT_STATE = 300;
@ -346,17 +334,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final Configuration conf = mResources.getConfiguration(); final Configuration conf = mResources.getConfiguration();
mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED, mReCorrectionEnabled = prefs.getBoolean(Settings.PREF_RECORRECTION_ENABLED,
getResources().getBoolean(R.bool.default_recorrection_enabled)); getResources().getBoolean(R.bool.default_recorrection_enabled));
LatinIMEUtil.GCUtils.getInstance().reset(); Utils.GCUtils.getInstance().reset();
boolean tryGC = true; boolean tryGC = true;
for (int i = 0; i < LatinIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try { try {
initSuggest(); initSuggest();
tryGC = false; tryGC = false;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait("InitSuggest", e); tryGC = Utils.GCUtils.getInstance().tryGCOrWait("InitSuggest", e);
} }
} }
@ -419,7 +407,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mSuggest.close(); mSuggest.close();
} }
final SharedPreferences prefs = mPrefs; final SharedPreferences prefs = mPrefs;
mQuickFixes = prefs.getBoolean(PREF_QUICK_FIXES, true); mQuickFixes = prefs.getBoolean(Settings.PREF_QUICK_FIXES, true);
int[] dictionaries = getDictionary(orig); int[] dictionaries = getDictionary(orig);
mSuggest = new Suggest(this, dictionaries); mSuggest = new Suggest(this, dictionaries);
@ -1063,7 +1051,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void onSettingsKeyPressed() { private void onSettingsKeyPressed() {
if (!isShowingOptionDialog()) { if (!isShowingOptionDialog()) {
if (LatinIMEUtil.hasMultipleEnabledIMEsOrSubtypes(mImm)) { if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm)) {
showOptionsMenu(); showOptionsMenu();
} else { } else {
launchSettings(); launchSettings();
@ -1073,7 +1061,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void onSettingsKeyLongPressed() { private void onSettingsKeyLongPressed() {
if (!isShowingOptionDialog()) { if (!isShowingOptionDialog()) {
if (LatinIMEUtil.hasMultipleEnabledIMEsOrSubtypes(mImm)) { if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm)) {
mImm.showInputMethodPicker(); mImm.showInputMethodPicker();
} else { } else {
launchSettings(); launchSettings();
@ -1898,10 +1886,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) { String key) {
mSubtypeSwitcher.onSharedPreferenceChanged(sharedPreferences, key); mSubtypeSwitcher.onSharedPreferenceChanged(sharedPreferences, key);
if (PREF_SELECTED_LANGUAGES.equals(key)) { if (Settings.PREF_SELECTED_LANGUAGES.equals(key)) {
mRefreshKeyboardRequired = true; mRefreshKeyboardRequired = true;
} else if (PREF_RECORRECTION_ENABLED.equals(key)) { } else if (Settings.PREF_RECORRECTION_ENABLED.equals(key)) {
mReCorrectionEnabled = sharedPreferences.getBoolean(PREF_RECORRECTION_ENABLED, mReCorrectionEnabled = sharedPreferences.getBoolean(
Settings.PREF_RECORRECTION_ENABLED,
getResources().getBoolean(R.bool.default_recorrection_enabled)); getResources().getBoolean(R.bool.default_recorrection_enabled));
} }
} }
@ -2071,8 +2060,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void updateSuggestionVisibility(SharedPreferences prefs) { private void updateSuggestionVisibility(SharedPreferences prefs) {
final String suggestionVisiblityStr = prefs.getString( final String suggestionVisiblityStr = prefs.getString(
PREF_SHOW_SUGGESTIONS_SETTING, mResources.getString( Settings.PREF_SHOW_SUGGESTIONS_SETTING,
R.string.prefs_suggestion_visibility_default_value)); mResources.getString(R.string.prefs_suggestion_visibility_default_value));
for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) { for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) {
if (suggestionVisiblityStr.equals(mResources.getString(visibility))) { if (suggestionVisiblityStr.equals(mResources.getString(visibility))) {
mSuggestionVisibility = visibility; mSuggestionVisibility = visibility;
@ -2082,11 +2071,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
protected void launchSettings() { protected void launchSettings() {
launchSettings(LatinIMESettings.class); launchSettings(Settings.class);
} }
public void launchDebugSettings() { public void launchDebugSettings() {
launchSettings(LatinIMEDebugSettings.class); launchSettings(DebugSettings.class);
} }
protected void launchSettings(Class<? extends PreferenceActivity> settingsClass) { protected void launchSettings(Class<? extends PreferenceActivity> settingsClass) {
@ -2102,12 +2091,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final SharedPreferences prefs = mPrefs; final SharedPreferences prefs = mPrefs;
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mVibrateOn = vibrator != null && vibrator.hasVibrator() mVibrateOn = vibrator != null && vibrator.hasVibrator()
&& prefs.getBoolean(LatinIMESettings.PREF_VIBRATE_ON, false); && prefs.getBoolean(Settings.PREF_VIBRATE_ON, false);
mSoundOn = prefs.getBoolean(PREF_SOUND_ON, false); mSoundOn = prefs.getBoolean(Settings.PREF_SOUND_ON, false);
mPopupOn = prefs.getBoolean(PREF_POPUP_ON, mPopupOn = prefs.getBoolean(Settings.PREF_POPUP_ON,
mResources.getBoolean(R.bool.default_popup_preview)); mResources.getBoolean(R.bool.default_popup_preview));
mAutoCap = prefs.getBoolean(PREF_AUTO_CAP, true); mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
mQuickFixes = prefs.getBoolean(PREF_QUICK_FIXES, true); mQuickFixes = prefs.getBoolean(Settings.PREF_QUICK_FIXES, true);
mAutoCorrectEnabled = isAutoCorrectEnabled(prefs); mAutoCorrectEnabled = isAutoCorrectEnabled(prefs);
mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs); mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs);
@ -2131,7 +2120,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// When auto completion setting is turned off, the threshold is ignored. // When auto completion setting is turned off, the threshold is ignored.
if (!isAutoCorrectEnabled(sp)) return; if (!isAutoCorrectEnabled(sp)) return;
final String currentAutoCompletionSetting = sp.getString(PREF_AUTO_COMPLETION_THRESHOLD, final String currentAutoCompletionSetting = sp.getString(
Settings.PREF_AUTO_COMPLETION_THRESHOLD,
mResources.getString(R.string.auto_completion_threshold_mode_value_modest)); mResources.getString(R.string.auto_completion_threshold_mode_value_modest));
final String[] autoCompletionThresholdValues = mResources.getStringArray( final String[] autoCompletionThresholdValues = mResources.getStringArray(
R.array.auto_complete_threshold_values); R.array.auto_complete_threshold_values);
@ -2159,7 +2149,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
private boolean isAutoCorrectEnabled(SharedPreferences sp) { private boolean isAutoCorrectEnabled(SharedPreferences sp) {
final String currentAutoCompletionSetting = sp.getString(PREF_AUTO_COMPLETION_THRESHOLD, final String currentAutoCompletionSetting = sp.getString(
Settings.PREF_AUTO_COMPLETION_THRESHOLD,
mResources.getString(R.string.auto_completion_threshold_mode_value_modest)); mResources.getString(R.string.auto_completion_threshold_mode_value_modest));
final String autoCompletionOff = mResources.getString( final String autoCompletionOff = mResources.getString(
R.string.auto_completion_threshold_mode_value_off); R.string.auto_completion_threshold_mode_value_off);
@ -2168,7 +2159,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean isBigramSuggestionEnabled(SharedPreferences sp) { private boolean isBigramSuggestionEnabled(SharedPreferences sp) {
// TODO: Define default value instead of 'true'. // TODO: Define default value instead of 'true'.
return sp.getBoolean(PREF_BIGRAM_SUGGESTIONS, true); return sp.getBoolean(Settings.PREF_BIGRAM_SUGGESTIONS, true);
} }
private void initSuggestPuncList() { private void initSuggestPuncList() {

View File

@ -39,19 +39,26 @@ import android.widget.TextView;
import java.util.Locale; import java.util.Locale;
public class LatinIMESettings extends PreferenceActivity public class Settings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener, implements SharedPreferences.OnSharedPreferenceChangeListener,
DialogInterface.OnDismissListener { DialogInterface.OnDismissListener {
private static final String TAG = "Settings";
private static final String QUICK_FIXES_KEY = "quick_fixes"; public static final String PREF_VIBRATE_ON = "vibrate_on";
private static final String PREDICTION_SETTINGS_KEY = "prediction_settings"; public static final String PREF_SOUND_ON = "sound_on";
private static final String VOICE_SETTINGS_KEY = "voice_mode"; public static final String PREF_POPUP_ON = "popup_on";
private static final String PREF_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold"; public static final String PREF_RECORRECTION_ENABLED = "recorrection_enabled";
private static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion"; public static final String PREF_AUTO_CAP = "auto_cap";
public static final String PREF_SETTINGS_KEY = "settings_key"; public static final String PREF_SETTINGS_KEY = "settings_key";
/* package */ static final String PREF_VIBRATE_ON = "vibrate_on"; public static final String PREF_VOICE_SETTINGS_KEY = "voice_mode";
public static final String PREF_INPUT_LANGUAGE = "input_language";
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
private static final String TAG = "LatinIMESettings"; public static final String PREF_PREDICTION_SETTINGS_KEY = "prediction_settings";
public static final String PREF_QUICK_FIXES = "quick_fixes";
public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
public static final String PREF_AUTO_COMPLETION_THRESHOLD = "auto_completion_threshold";
public static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
// Dialog ids // Dialog ids
private static final int VOICE_INPUT_CONFIRM_DIALOG = 0; private static final int VOICE_INPUT_CONFIRM_DIALOG = 0;
@ -80,14 +87,15 @@ public class LatinIMESettings extends PreferenceActivity
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs); addPreferencesFromResource(R.xml.prefs);
mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY); mQuickFixes = (CheckBoxPreference) findPreference(PREF_QUICK_FIXES);
mVoicePreference = (ListPreference) findPreference(VOICE_SETTINGS_KEY); mVoicePreference = (ListPreference) findPreference(PREF_VOICE_SETTINGS_KEY);
mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY); mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY);
SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
prefs.registerOnSharedPreferenceChangeListener(this); prefs.registerOnSharedPreferenceChangeListener(this);
mVoiceModeOff = getString(R.string.voice_mode_off); mVoiceModeOff = getString(R.string.voice_mode_off);
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff)); mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
.equals(mVoiceModeOff));
mLogger = VoiceInputLogger.getLogger(this); mLogger = VoiceInputLogger.getLogger(this);
mAutoCompletionThreshold = (ListPreference) findPreference(PREF_AUTO_COMPLETION_THRESHOLD); mAutoCompletionThreshold = (ListPreference) findPreference(PREF_AUTO_COMPLETION_THRESHOLD);
@ -118,7 +126,7 @@ public class LatinIMESettings extends PreferenceActivity
super.onResume(); super.onResume();
int autoTextSize = AutoText.getSize(getListView()); int autoTextSize = AutoText.getSize(getListView());
if (autoTextSize < 1) { if (autoTextSize < 1) {
((PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY)) ((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY))
.removePreference(mQuickFixes); .removePreference(mQuickFixes);
} }
if (!VoiceIMEConnector.VOICE_INSTALLED if (!VoiceIMEConnector.VOICE_INSTALLED
@ -141,14 +149,15 @@ public class LatinIMESettings extends PreferenceActivity
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
(new BackupManager(this)).dataChanged(); (new BackupManager(this)).dataChanged();
// If turning on voice input, show dialog // If turning on voice input, show dialog
if (key.equals(VOICE_SETTINGS_KEY) && !mVoiceOn) { if (key.equals(PREF_VOICE_SETTINGS_KEY) && !mVoiceOn) {
if (!prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff) if (!prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
.equals(mVoiceModeOff)) { .equals(mVoiceModeOff)) {
showVoiceConfirmation(); showVoiceConfirmation();
} }
} }
ensureConsistencyOfAutoCompletionSettings(); ensureConsistencyOfAutoCompletionSettings();
mVoiceOn = !(prefs.getString(VOICE_SETTINGS_KEY, mVoiceModeOff).equals(mVoiceModeOff)); mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
.equals(mVoiceModeOff));
updateVoiceModeSummary(); updateVoiceModeSummary();
updateSettingsKeySummary(); updateSettingsKeySummary();
} }

View File

@ -316,7 +316,7 @@ public class SubtypeSwitcher {
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (USE_SPACEBAR_LANGUAGE_SWITCHER) { if (USE_SPACEBAR_LANGUAGE_SWITCHER) {
if (LatinIME.PREF_SELECTED_LANGUAGES.equals(key)) { if (Settings.PREF_SELECTED_LANGUAGES.equals(key)) {
mLanguageSwitcher.loadLocales(sharedPreferences); mLanguageSwitcher.loadLocales(sharedPreferences);
} }
} }

View File

@ -284,7 +284,7 @@ public class Suggest implements Dictionary.WordCallback {
&& mSuggestions.size() > 0 && mPriorities.length > 0) { && mSuggestions.size() > 0 && mPriorities.length > 0) {
// TODO: when the normalized score of the first suggestion is nearly equals to // TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive. // the normalized score of the second suggestion, behave less aggressive.
final double normalizedScore = LatinIMEUtil.calcNormalizedScore( final double normalizedScore = Utils.calcNormalizedScore(
mOriginalWord, mSuggestions.get(0), mPriorities[0]); mOriginalWord, mSuggestions.get(0), mPriorities[0]);
if (LatinImeLogger.sDBG) { if (LatinImeLogger.sDBG) {
Log.d(TAG, "Normalized " + mOriginalWord + "," + mSuggestions.get(0) + "," Log.d(TAG, "Normalized " + mOriginalWord + "," + mSuggestions.get(0) + ","

View File

@ -35,7 +35,7 @@ import java.io.PrintWriter;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class LatinIMEUtil { public class Utils {
/** /**
* Cancel an {@link AsyncTask}. * Cancel an {@link AsyncTask}.

View File

@ -37,7 +37,7 @@ public class EditDistanceTests extends AndroidTestCase {
* sitting * sitting
*/ */
public void testExample1() { public void testExample1() {
final int dist = LatinIMEUtil.editDistance("kitten", "sitting"); final int dist = Utils.editDistance("kitten", "sitting");
assertEquals("edit distance between 'kitten' and 'sitting' is 3", assertEquals("edit distance between 'kitten' and 'sitting' is 3",
3, dist); 3, dist);
} }
@ -50,26 +50,26 @@ public class EditDistanceTests extends AndroidTestCase {
* S--unday * S--unday
*/ */
public void testExample2() { public void testExample2() {
final int dist = LatinIMEUtil.editDistance("Saturday", "Sunday"); final int dist = Utils.editDistance("Saturday", "Sunday");
assertEquals("edit distance between 'Saturday' and 'Sunday' is 3", assertEquals("edit distance between 'Saturday' and 'Sunday' is 3",
3, dist); 3, dist);
} }
public void testBothEmpty() { public void testBothEmpty() {
final int dist = LatinIMEUtil.editDistance("", ""); final int dist = Utils.editDistance("", "");
assertEquals("when both string are empty, no edits are needed", assertEquals("when both string are empty, no edits are needed",
0, dist); 0, dist);
} }
public void testFirstArgIsEmpty() { public void testFirstArgIsEmpty() {
final int dist = LatinIMEUtil.editDistance("", "aaaa"); final int dist = Utils.editDistance("", "aaaa");
assertEquals("when only one string of the arguments is empty," assertEquals("when only one string of the arguments is empty,"
+ " the edit distance is the length of the other.", + " the edit distance is the length of the other.",
4, dist); 4, dist);
} }
public void testSecoondArgIsEmpty() { public void testSecoondArgIsEmpty() {
final int dist = LatinIMEUtil.editDistance("aaaa", ""); final int dist = Utils.editDistance("aaaa", "");
assertEquals("when only one string of the arguments is empty," assertEquals("when only one string of the arguments is empty,"
+ " the edit distance is the length of the other.", + " the edit distance is the length of the other.",
4, dist); 4, dist);
@ -78,27 +78,27 @@ public class EditDistanceTests extends AndroidTestCase {
public void testSameStrings() { public void testSameStrings() {
final String arg1 = "The quick brown fox jumps over the lazy dog."; final String arg1 = "The quick brown fox jumps over the lazy dog.";
final String arg2 = "The quick brown fox jumps over the lazy dog."; final String arg2 = "The quick brown fox jumps over the lazy dog.";
final int dist = LatinIMEUtil.editDistance(arg1, arg2); final int dist = Utils.editDistance(arg1, arg2);
assertEquals("when same strings are passed, distance equals 0.", assertEquals("when same strings are passed, distance equals 0.",
0, dist); 0, dist);
} }
public void testSameReference() { public void testSameReference() {
final String arg = "The quick brown fox jumps over the lazy dog."; final String arg = "The quick brown fox jumps over the lazy dog.";
final int dist = LatinIMEUtil.editDistance(arg, arg); final int dist = Utils.editDistance(arg, arg);
assertEquals("when same string references are passed, the distance equals 0.", assertEquals("when same string references are passed, the distance equals 0.",
0, dist); 0, dist);
} }
public void testNullArg() { public void testNullArg() {
try { try {
LatinIMEUtil.editDistance(null, "aaa"); Utils.editDistance(null, "aaa");
fail("IllegalArgumentException should be thrown."); fail("IllegalArgumentException should be thrown.");
} catch (Exception e) { } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);
} }
try { try {
LatinIMEUtil.editDistance("aaa", null); Utils.editDistance("aaa", null);
fail("IllegalArgumentException should be thrown."); fail("IllegalArgumentException should be thrown.");
} catch (Exception e) { } catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException); assertTrue(e instanceof IllegalArgumentException);