aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-08 22:21:26 +0900
committerJean Chalard <jchalard@google.com>2011-12-09 16:47:31 +0900
commitc207e0a7dad0bdae054be47cafe878698f9401fc (patch)
tree705a37f6d0a959451578f363b36e8935a2039a05 /java/src
parent284c8a0449f25a750fe132ba4a827bb489fcdb0c (diff)
downloadlatinime-c207e0a7dad0bdae054be47cafe878698f9401fc.tar.gz
latinime-c207e0a7dad0bdae054be47cafe878698f9401fc.tar.xz
latinime-c207e0a7dad0bdae054be47cafe878698f9401fc.zip
Move settings variables to the settings class
Change-Id: Ifa7033a84b08ea626eb44cf6d04ba8e28c250bea
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java19
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java4
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java16
3 files changed, 18 insertions, 21 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 985793ef3..de273b56f 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -221,11 +221,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private long mLastKeyTime;
private AudioManager mAudioManager;
- private float mFxVolume = -1.0f; // default volume
private boolean mSilentModeOn; // System-wide current configuration
private VibratorCompatWrapper mVibrator;
- private long mKeypressVibrationDuration = -1;
// TODO: Move this flag to VoiceProxy
private boolean mConfigurationChanging;
@@ -550,8 +548,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (null == mSubtypeSwitcher) mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mSettingsValues = new SettingsValues(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
- updateSoundEffectVolume();
- updateKeypressVibrationDuration();
}
private void initSuggest() {
@@ -2321,11 +2317,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
};
- // update keypress sound volume
- private void updateSoundEffectVolume() {
- mFxVolume = SettingsValues.getCurrentKeypressSoundVolume(mPrefs, mResources);
- }
-
// update flags for silent mode
private void updateRingerMode() {
if (mAudioManager == null) {
@@ -2335,10 +2326,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSilentModeOn = (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL);
}
- private void updateKeypressVibrationDuration() {
- mKeypressVibrationDuration = SettingsValues.getCurrentVibrationDuration(mPrefs, mResources);
- }
-
private void playKeyClick(int primaryCode) {
// if mAudioManager is null, we don't have the ringer state yet
// mAudioManager will be set by updateRingerMode
@@ -2363,7 +2350,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
sound = AudioManager.FX_KEYPRESS_STANDARD;
break;
}
- mAudioManager.playSoundEffect(sound, mFxVolume);
+ mAudioManager.playSoundEffect(sound, mSettingsValues.mFxVolume);
}
}
@@ -2371,7 +2358,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (!mSettingsValues.mVibrateOn) {
return;
}
- if (mKeypressVibrationDuration < 0) {
+ if (mSettingsValues.mKeypressVibrationDuration < 0) {
// Go ahead with the system default
LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) {
@@ -2380,7 +2367,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
} else if (mVibrator != null) {
- mVibrator.vibrate(mKeypressVibrationDuration);
+ mVibrator.vibrate(mSettingsValues.mKeypressVibrationDuration);
}
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 6558c3ca3..4166e6266 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -543,8 +543,8 @@ public class Settings extends InputMethodSettingsActivity
});
final View v = context.getLayoutInflater().inflate(
R.layout.sound_effect_volume_dialog, null);
- final int currentVolumeInt = (int)(SettingsValues.getCurrentKeypressSoundVolume(
- getPreferenceManager().getSharedPreferences(), getResources()) * 100);
+ final int currentVolumeInt =
+ (int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100);
mKeypressSoundVolumeSettingsTextView =
(TextView)v.findViewById(R.id.sound_effect_volume_value);
final SeekBar sb = (SeekBar)v.findViewById(R.id.sound_effect_volume_bar);
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 50fa69401..62cf4a38e 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -25,7 +25,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.compat.VibratorCompatWrapper;
-import com.android.inputmethod.latin.R.array;
import java.util.Arrays;
import java.util.Locale;
@@ -62,6 +61,10 @@ public class SettingsValues {
private final boolean mVoiceKeyEnabled;
private final boolean mVoiceKeyOnMain;
+ // Deduced settings
+ public final int mKeypressVibrationDuration;
+ public final float mFxVolume;
+
public SettingsValues(final SharedPreferences prefs, final Context context,
final String localeStr) {
final Resources res = context.getResources();
@@ -122,6 +125,9 @@ public class SettingsValues {
mVoiceKeyEnabled = voiceMode != null && !voiceMode.equals(voiceModeOff);
mVoiceKeyOnMain = voiceMode != null && voiceMode.equals(voiceModeMain);
+ mFxVolume = getCurrentKeypressSoundVolume(prefs, res);
+ mKeypressVibrationDuration = getCurrentVibrationDuration(prefs, res);
+
LocaleUtils.setSystemLocale(res, savedLocale);
}
@@ -244,7 +250,9 @@ public class SettingsValues {
return mVoiceKeyOnMain;
}
- public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) {
+ // Accessed from the settings interface, hence public
+ public static float getCurrentKeypressSoundVolume(final SharedPreferences sp,
+ final Resources res) {
final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f);
if (volume >= 0) {
return volume;
@@ -260,7 +268,9 @@ public class SettingsValues {
return -1.0f;
}
- public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) {
+ // Likewise
+ public static int getCurrentVibrationDuration(final SharedPreferences sp,
+ final Resources res) {
final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1);
if (ms >= 0) {
return ms;