aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/AndroidManifest.xml8
-rw-r--r--java/proguard.flags4
-rw-r--r--java/res/values-sw600dp/config.xml3
-rw-r--r--java/res/values-sw768dp/config.xml1
-rw-r--r--java/res/values/attrs.xml1
-rw-r--r--java/res/values/config.xml5
-rw-r--r--java/res/values/strings.xml9
-rw-r--r--java/res/values/styles.xml2
-rw-r--r--java/res/xml-sw600dp/kbd_rows_russian.xml3
-rw-r--r--java/res/xml/kbd_rows_russian.xml1
-rw-r--r--java/res/xml/prefs.xml4
-rw-r--r--java/res/xml/spell_checker_settings.xml26
-rw-r--r--java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java15
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java2
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java63
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java6
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java24
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java43
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java41
20 files changed, 236 insertions, 30 deletions
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml
index d680f1894..548da1bbb 100644
--- a/java/AndroidManifest.xml
+++ b/java/AndroidManifest.xml
@@ -29,12 +29,20 @@
</intent-filter>
<meta-data android:name="android.view.textservice.scs" android:resource="@xml/spellchecker" />
</service>
+
<activity android:name="Settings" android:label="@string/english_ime_settings">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
+ <activity android:name="com.android.inputmethod.latin.spellcheck.SpellCheckerSettingsActivity"
+ android:label="@string/android_spell_checker_settings">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ </intent-filter>
+ </activity>
+
<activity android:name="DebugSettings" android:label="@string/english_ime_debug_settings">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
diff --git a/java/proguard.flags b/java/proguard.flags
index 395950033..33af890ec 100644
--- a/java/proguard.flags
+++ b/java/proguard.flags
@@ -27,6 +27,10 @@
*;
}
+-keep class com.android.inputmethod.latin.spellcheck.SpellCheckerSettingsFragment {
+ *;
+}
+
-keep class com.android.inputmethod.latin.SettingsActivity {
*;
}
diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml
index ade376a33..d539e0d82 100644
--- a/java/res/values-sw600dp/config.xml
+++ b/java/res/values-sw600dp/config.xml
@@ -20,10 +20,9 @@
<resources>
<bool name="config_enable_show_settings_key_option">true</bool>
- <bool name="config_default_show_settings_key">true</bool>
+ <bool name="config_default_show_settings_key">false</bool>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_enable_show_popup_on_keypress_option">false</bool>
- <bool name="config_enable_show_recorrection_option">false</bool>
<bool name="config_enable_bigram_suggestions_option">false</bool>
<bool name="config_sliding_key_input_enabled">false</bool>
<bool name="config_digit_popup_characters_enabled">false</bool>
diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml
index 091d62e59..0f8f106b7 100644
--- a/java/res/values-sw768dp/config.xml
+++ b/java/res/values-sw768dp/config.xml
@@ -23,7 +23,6 @@
<bool name="config_default_show_settings_key">true</bool>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_enable_show_popup_on_keypress_option">false</bool>
- <bool name="config_enable_show_recorrection_option">false</bool>
<bool name="config_enable_bigram_suggestions_option">false</bool>
<bool name="config_sliding_key_input_enabled">false</bool>
<bool name="config_digit_popup_characters_enabled">false</bool>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 172ca2f25..c2200b5ad 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -107,6 +107,7 @@
</declare-styleable>
<declare-styleable name="CandidateView">
+ <attr name="autoCorrectionVisualFlashEnabled" format="boolean" />
<attr name="autoCorrectHighlight" format="integer">
<flag name="autoCorrectBold" value="0x01" />
<flag name="autoCorrectUnderline" value="0x02" />
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index 731f63f34..6327ede38 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -23,7 +23,7 @@
<bool name="config_default_show_settings_key">false</bool>
<bool name="config_enable_show_voice_key_option">true</bool>
<bool name="config_enable_show_popup_on_keypress_option">true</bool>
- <bool name="config_enable_show_recorrection_option">true</bool>
+ <bool name="config_enable_show_recorrection_option">false</bool>
<bool name="config_enable_bigram_suggestions_option">true</bool>
<bool name="config_enable_usability_study_mode_option">false</bool>
<bool name="config_sliding_key_input_enabled">true</bool>
@@ -36,9 +36,10 @@
<!-- Default value for bigram prediction: after entering a word and a space only, should we look
at input history to suggest a hopefully helpful candidate for the next word? -->
<bool name="config_default_bigram_prediction">false</bool>
- <bool name="config_default_recorrection_enabled">true</bool>
+ <bool name="config_default_compat_recorrection_enabled">true</bool>
<bool name="config_default_sound_enabled">false</bool>
<bool name="config_auto_correction_spacebar_led_enabled">true</bool>
+ <bool name="config_auto_correction_suggestion_strip_visual_flash_enabled">false</bool>
<!-- Showing mini keyboard, just above the touched point if true, aligned to the key if false -->
<bool name="config_show_mini_keyboard_at_touched_point">false</bool>
<!-- The language is never displayed if == 0, always displayed if < 0 -->
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index ed69fc9f0..247bdba41 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -28,6 +28,15 @@
<!-- Title for Latin Keyboard spell checker service -->
<string name="spell_checker_service_name">Android correction</string>
+ <!-- Title for the spell checking service settings screen -->
+ <string name="android_spell_checker_settings">Spell checking settings</string>
+
+ <!-- Title for the "use proximity" option for spell checking [CHAR LIMIT=25] -->
+ <string name="use_proximity_option_title">Use proximity data</string>
+
+ <!-- Description for the "use proximity" option for spell checking [CHAR LIMIT=65] -->
+ <string name="use_proximity_option_summary">Use a keyboard-like proximity algorithm for spell checking</string>
+
<!-- Option to provide vibrate/haptic feedback on keypress -->
<string name="vibrate_on_keypress">Vibrate on keypress</string>
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index 1ebd2cee1..a47eeed12 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -85,6 +85,7 @@
<item name="android:background">@drawable/candidate_feedback_background</item>
</style>
<style name="CandidateViewStyle" parent="SuggestionsStripBackgroundStyle">
+ <item name="autoCorrectionVisualFlashEnabled">@bool/config_auto_correction_suggestion_strip_visual_flash_enabled</item>
<item name="autoCorrectHighlight">autoCorrectBold</item>
<item name="colorTypedWord">#FFFFFFFF</item>
<item name="colorAutoCorrect">#FFFCAE00</item>
@@ -188,6 +189,7 @@
<item name="android:background">@drawable/keyboard_popup_panel_background_holo</item>
</style>
<style name="CandidateViewStyle.IceCreamSandwich" parent="SuggestionsStripBackgroundStyle.IceCreamSandwich">
+ <item name="autoCorrectionVisualFlashEnabled">@bool/config_auto_correction_suggestion_strip_visual_flash_enabled</item>
<item name="autoCorrectHighlight">autoCorrectBold|autoCorrectInvert</item>
<item name="colorTypedWord">#FFFFFFFF</item>
<item name="colorAutoCorrect">#FF3DC8FF</item>
diff --git a/java/res/xml-sw600dp/kbd_rows_russian.xml b/java/res/xml-sw600dp/kbd_rows_russian.xml
index 7588f6ccb..2f4b95e60 100644
--- a/java/res/xml-sw600dp/kbd_rows_russian.xml
+++ b/java/res/xml-sw600dp/kbd_rows_russian.xml
@@ -105,8 +105,7 @@
<Key
latin:keyLabel="т" />
<Key
- latin:keyLabel="ь"
- latin:popupCharacters="@string/alternates_for_cyrillic_soft_sign" />
+ latin:keyLabel="ь" />
<Key
latin:keyLabel="б" />
<Key
diff --git a/java/res/xml/kbd_rows_russian.xml b/java/res/xml/kbd_rows_russian.xml
index 216d74946..3aeb52bcc 100644
--- a/java/res/xml/kbd_rows_russian.xml
+++ b/java/res/xml/kbd_rows_russian.xml
@@ -69,6 +69,7 @@
latin:popupCharacters="0" />
<Key
latin:keyLabel="х"
+ latin:popupCharacters="@string/alternates_for_cyrillic_soft_sign"
latin:keyWidth="fillRight" />
</Row>
<Row
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index 2ff82f93d..6d2218d2f 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -48,12 +48,12 @@
android:title="@string/prefs_enable_recorrection"
android:summary="@string/prefs_enable_recorrection_summary"
android:persistent="true"
- android:defaultValue="@bool/config_default_recorrection_enabled" />
+ android:defaultValue="@bool/config_default_compat_recorrection_enabled" />
<CheckBoxPreference
android:key="show_settings_key"
android:title="@string/prefs_settings_key"
android:persistent="true"
- android:defaultValue="false" />
+ android:defaultValue="@bool/config_default_show_settings_key" />
<ListPreference
android:key="voice_mode"
android:title="@string/voice_input"
diff --git a/java/res/xml/spell_checker_settings.xml b/java/res/xml/spell_checker_settings.xml
new file mode 100644
index 000000000..f402555c9
--- /dev/null
+++ b/java/res/xml/spell_checker_settings.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/android_spell_checker_settings">
+ <CheckBoxPreference
+ android:key="use_proximity"
+ android:title="@string/use_proximity_option_title"
+ android:summary="@string/use_proximity_option_summary"
+ android:persistent="true"
+ android:defaultValue="true" />
+</PreferenceScreen>
diff --git a/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java b/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java
index d40728d25..bf2512d7b 100644
--- a/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java
+++ b/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java
@@ -271,9 +271,10 @@ public class Recorrection implements SharedPreferences.OnSharedPreferenceChangeL
// but always use the default setting defined in the resources.
if (res.getBoolean(R.bool.config_enable_show_recorrection_option)) {
mRecorrectionEnabled = prefs.getBoolean(Settings.PREF_RECORRECTION_ENABLED,
- res.getBoolean(R.bool.config_default_recorrection_enabled));
+ res.getBoolean(R.bool.config_default_compat_recorrection_enabled));
} else {
- mRecorrectionEnabled = res.getBoolean(R.bool.config_default_recorrection_enabled);
+ mRecorrectionEnabled =
+ res.getBoolean(R.bool.config_default_compat_recorrection_enabled);
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 811470c26..21477a992 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -280,7 +280,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mSymbolsKeyboardId = getKeyboardId(editorInfo, true, false, settingsValues);
mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues);
setKeyboard(getKeyboard(mSavedKeyboardState.getKeyboardId()));
- updateShiftState();
} catch (RuntimeException e) {
Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e);
LatinImeLogger.logOnException(mMainKeyboardId.toString(), e);
@@ -331,6 +330,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final boolean localeChanged = (oldKeyboard == null)
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
+ updateShiftState();
}
private int getSwitchState(KeyboardId id) {
@@ -543,11 +543,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
private void setAutomaticTemporaryUpperCase() {
- LatinKeyboard latinKeyboard = getLatinKeyboard();
- if (latinKeyboard != null) {
- latinKeyboard.setAutomaticTemporaryUpperCase();
- mKeyboardView.invalidateAllKeys();
+ if (mKeyboardView == null) return;
+ final Keyboard keyboard = mKeyboardView.getKeyboard();
+ if (keyboard != null) {
+ keyboard.setAutomaticTemporaryUpperCase();
}
+ mKeyboardView.invalidateAllKeys();
}
/**
@@ -559,7 +560,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
Log.d(TAG, "updateShiftState:"
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
- + " shiftKeyState=" + shiftKeyState);
+ + " shiftKeyState=" + shiftKeyState
+ + " isAlphabetMode=" + isAlphabetMode()
+ + " isShiftLocked=" + isShiftLocked());
if (isAlphabetMode()) {
if (!isShiftLocked() && !shiftKeyState.isIgnoring()) {
if (shiftKeyState.isReleasing() && mInputMethodService.getCurrentAutoCapsState()) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
index 0cde4e5b5..fd98456a8 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
@@ -21,7 +21,7 @@ import android.util.Log;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
public class KeyboardShiftState {
- private static final String TAG = "KeyboardShiftState";
+ private static final String TAG = KeyboardShiftState.class.getSimpleName();
private static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
private static final int NORMAL = 0;
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
index 170edad99..360cf21ca 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
@@ -17,6 +17,8 @@
package com.android.inputmethod.latin;
import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
import android.util.Log;
@@ -39,10 +41,27 @@ class BinaryDictionaryGetter {
*/
private static final String TAG = BinaryDictionaryGetter.class.getSimpleName();
+ /**
+ * Name of the common preferences name to know which word list are on and which are off.
+ */
+ private static final String COMMON_PREFERENCES_NAME = "LatinImeDictPrefs";
+
// Prevents this from being instantiated
private BinaryDictionaryGetter() {}
/**
+ * Returns whether we may want to use this character as part of a file name.
+ *
+ * This basically only accepts ascii letters and numbers, and rejects everything else.
+ */
+ private static boolean isFileNameCharacter(int codePoint) {
+ if (codePoint >= 0x30 && codePoint <= 0x39) return true; // Digit
+ if (codePoint >= 0x41 && codePoint <= 0x5A) return true; // Uppercase
+ if (codePoint >= 0x61 && codePoint <= 0x7A) return true; // Lowercase
+ return codePoint == '_'; // Underscore
+ }
+
+ /**
* Escapes a string for any characters that may be suspicious for a file or directory name.
*
* Concretely this does a sort of URL-encoding except it will encode everything that's not
@@ -50,17 +69,35 @@ class BinaryDictionaryGetter {
* we cannot allow here)
*/
// TODO: create a unit test for this method
- private static String replaceFileNameDangerousCharacters(String name) {
+ private static String replaceFileNameDangerousCharacters(final String name) {
// This assumes '%' is fully available as a non-separator, normal
// character in a file name. This is probably true for all file systems.
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < name.length(); ++i) {
final int codePoint = name.codePointAt(i);
- if (Character.isLetterOrDigit(codePoint) || '_' == codePoint) {
+ if (isFileNameCharacter(codePoint)) {
+ sb.appendCodePoint(codePoint);
+ } else {
+ // 6 digits - unicode is limited to 21 bits
+ sb.append(String.format((Locale)null, "%%%1$06x", codePoint));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Reverse escaping done by replaceFileNameDangerousCharacters.
+ */
+ private static String getWordListIdFromFileName(final String fname) {
+ final StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < fname.length(); ++i) {
+ final int codePoint = fname.codePointAt(i);
+ if ('%' != codePoint) {
sb.appendCodePoint(codePoint);
} else {
- sb.append('%');
- sb.append(Integer.toHexString(codePoint));
+ final int encodedCodePoint = Integer.parseInt(fname.substring(i + 1, i + 7), 16);
+ i += 6;
+ sb.appendCodePoint(encodedCodePoint);
}
}
return sb.toString();
@@ -132,10 +169,28 @@ class BinaryDictionaryGetter {
final Context context) {
final String directoryName = getCacheDirectoryForLocale(locale, context);
final File[] cacheFiles = new File(directoryName).listFiles();
+ // TODO: Never return null. Fallback on the built-in dictionary, and if that's
+ // not present or disabled, then return an empty list.
if (null == cacheFiles) return null;
+ final SharedPreferences dictPackSettings;
+ try {
+ final String dictPackName = context.getString(R.string.dictionary_pack_package_name);
+ final Context dictPackContext = context.createPackageContext(dictPackName, 0);
+ dictPackSettings = dictPackContext.getSharedPreferences(COMMON_PREFERENCES_NAME,
+ Context.MODE_WORLD_READABLE | Context.MODE_MULTI_PROCESS);
+ } catch (NameNotFoundException e) {
+ // The dictionary pack is not installed...
+ // TODO: fallback on the built-in dict, see the TODO above
+ Log.e(TAG, "Could not find a dictionary pack");
+ return null;
+ }
+
final ArrayList<AssetFileAddress> fileList = new ArrayList<AssetFileAddress>();
for (File f : cacheFiles) {
+ final String wordListId = getWordListIdFromFileName(f.getName());
+ final boolean isActive = dictPackSettings.getBoolean(wordListId, true);
+ if (!isActive) continue;
if (f.canRead()) {
fileList.add(AssetFileAddress.makeFromFileName(f.getPath()));
} else {
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index d779c8565..0640fd0b1 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -278,6 +278,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>();
+ public final boolean mAutoCorrectionVisualFlashEnabled;
public boolean mMoreSuggestionsAvailable;
public SuggestionsStripParams(Context context, AttributeSet attrs, int defStyle,
@@ -285,6 +286,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
super(words, dividers, infos);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.CandidateView, defStyle, R.style.CandidateViewStyle);
+ mAutoCorrectionVisualFlashEnabled = a.getBoolean(
+ R.styleable.CandidateView_autoCorrectionVisualFlashEnabled, false);
mAutoCorrectHighlight = a.getInt(R.styleable.CandidateView_autoCorrectHighlight, 0);
mColorTypedWord = a.getColor(R.styleable.CandidateView_colorTypedWord, 0);
mColorAutoCorrect = a.getColor(R.styleable.CandidateView_colorAutoCorrect, 0);
@@ -700,6 +703,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
public void onAutoCorrectionInverted(CharSequence autoCorrectedWord) {
+ if (!mStripParams.mAutoCorrectionVisualFlashEnabled) {
+ return;
+ }
final CharSequence inverted = mStripParams.getInvertedText(autoCorrectedWord);
if (inverted == null)
return;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index c28e40d95..a932f03ac 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -190,8 +190,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private long mLastKeyTime;
private AudioManager mAudioManager;
- // Align sound effect volume on music volume
- private static final float FX_VOLUME = -1.0f;
+ private static float mFxVolume = -1.0f; // just a default value to be updated runtime
private boolean mSilentModeOn; // System-wide current configuration
// TODO: Move this flag to VoiceProxy
@@ -510,6 +509,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (null == mSubtypeSwitcher) mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mSettingsValues = new Settings.Values(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
+ updateSoundEffectVolume();
}
private void initSuggest() {
@@ -2068,14 +2068,24 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
};
+ // update sound effect volume
+ private void updateSoundEffectVolume() {
+ if (mAudioManager == null) {
+ mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ if (mAudioManager == null) return;
+ }
+ // This aligns with the current media volume minus 6dB
+ mFxVolume = (float) mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
+ / (float) mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) / 4.0f;
+ }
+
// update flags for silent mode
private void updateRingerMode() {
if (mAudioManager == null) {
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ if (mAudioManager == null) return;
}
- if (mAudioManager != null) {
- mSilentModeOn = (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL);
- }
+ mSilentModeOn = (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL);
}
private void playKeyClick(int primaryCode) {
@@ -2087,8 +2097,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
}
if (isSoundOn()) {
- // FIXME: Volume and enable should come from UI settings
- // FIXME: These should be triggered after auto-repeat logic
int sound = AudioManager.FX_KEYPRESS_STANDARD;
switch (primaryCode) {
case Keyboard.CODE_DELETE:
@@ -2101,7 +2109,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
sound = AudioManager.FX_KEYPRESS_SPACEBAR;
break;
}
- mAudioManager.playSoundEffect(sound, FX_VOLUME);
+ mAudioManager.playSoundEffect(sound, mFxVolume);
}
}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
new file mode 100644
index 000000000..483679a55
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2011 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.spellcheck;
+
+import com.android.inputmethod.latin.R;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+import java.util.List;
+
+/**
+ * Spell checker preference screen.
+ */
+public class SpellCheckerSettingsActivity extends PreferenceActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public Intent getIntent() {
+ final Intent modIntent = new Intent(super.getIntent());
+ modIntent.putExtra(EXTRA_SHOW_FRAGMENT, SpellCheckerSettingsFragment.class.getName());
+ modIntent.putExtra(EXTRA_NO_HEADERS, true);
+ return modIntent;
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java
new file mode 100644
index 000000000..9b821be35
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsFragment.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (C) 2011 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.spellcheck;
+
+import com.android.inputmethod.latin.R;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+/**
+ * Preference screen.
+ */
+public class SpellCheckerSettingsFragment extends PreferenceFragment {
+ private static final String TAG = SpellCheckerSettingsFragment.class.getSimpleName();
+
+ /**
+ * Empty constructor for fragment generation.
+ */
+ public SpellCheckerSettingsFragment() {
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ addPreferencesFromResource(R.xml.spell_checker_settings);
+ }
+}