Loading java/src/com/android/inputmethod/latin/LatinIME.java +2 −2 Original line number Diff line number Diff line Loading @@ -2323,7 +2323,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // update keypress sound volume private void updateSoundEffectVolume() { mFxVolume = Utils.getCurrentKeypressSoundVolume(mPrefs, mResources); mFxVolume = SettingsValues.getCurrentKeypressSoundVolume(mPrefs, mResources); } // update flags for silent mode Loading @@ -2336,7 +2336,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void updateKeypressVibrationDuration() { mKeypressVibrationDuration = Utils.getCurrentVibrationDuration(mPrefs, mResources); mKeypressVibrationDuration = SettingsValues.getCurrentVibrationDuration(mPrefs, mResources); } private void playKeyClick(int primaryCode) { Loading java/src/com/android/inputmethod/latin/Settings.java +5 −5 Original line number Diff line number Diff line Loading @@ -456,7 +456,7 @@ public class Settings extends InputMethodSettingsActivity SharedPreferences sp, Resources res) { if (mKeypressVibrationDurationSettingsPref != null) { mKeypressVibrationDurationSettingsPref.setSummary( Utils.getCurrentVibrationDuration(sp, res) SettingsValues.getCurrentVibrationDuration(sp, res) + res.getString(R.string.settings_ms)); } } Loading Loading @@ -484,7 +484,7 @@ public class Settings extends InputMethodSettingsActivity }); final View v = context.getLayoutInflater().inflate( R.layout.vibration_settings_dialog, null); final int currentMs = Utils.getCurrentVibrationDuration( final int currentMs = SettingsValues.getCurrentVibrationDuration( getPreferenceManager().getSharedPreferences(), getResources()); mKeypressVibrationDurationSettingsTextView = (TextView)v.findViewById(R.id.vibration_value); final SeekBar sb = (SeekBar)v.findViewById(R.id.vibration_settings); Loading Loading @@ -513,8 +513,8 @@ public class Settings extends InputMethodSettingsActivity private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) { if (mKeypressSoundVolumeSettingsPref != null) { mKeypressSoundVolumeSettingsPref.setSummary( String.valueOf((int)(Utils.getCurrentKeypressSoundVolume(sp, res) * 100))); mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf( (int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100))); } } Loading Loading @@ -543,7 +543,7 @@ public class Settings extends InputMethodSettingsActivity }); final View v = context.getLayoutInflater().inflate( R.layout.sound_effect_volume_dialog, null); final int currentVolumeInt = (int)(Utils.getCurrentKeypressSoundVolume( final int currentVolumeInt = (int)(SettingsValues.getCurrentKeypressSoundVolume( getPreferenceManager().getSharedPreferences(), getResources()) * 100); mKeypressSoundVolumeSettingsTextView = (TextView)v.findViewById(R.id.sound_effect_volume_value); Loading java/src/com/android/inputmethod/latin/SettingsValues.java +35 −1 Original line number Diff line number Diff line Loading @@ -19,11 +19,13 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; import android.util.Log; 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; Loading Loading @@ -241,4 +243,36 @@ public class SettingsValues { public boolean isVoiceKeyOnMain() { return mVoiceKeyOnMain; } public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) { final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f); if (volume >= 0) { return volume; } final String[] volumePerHardwareList = res.getStringArray(R.array.keypress_volumes); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : volumePerHardwareList) { if (element.startsWith(hardwarePrefix)) { return Float.parseFloat(element.substring(element.lastIndexOf(',') + 1)); } } return -1.0f; } public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) { final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1); if (ms >= 0) { return ms; } final String[] durationPerHardwareList = res.getStringArray( R.array.keypress_vibration_durations); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : durationPerHardwareList) { if (element.startsWith(hardwarePrefix)) { return (int)Long.parseLong(element.substring(element.lastIndexOf(',') + 1)); } } return -1; } } java/src/com/android/inputmethod/latin/Utils.java +0 −34 Original line number Diff line number Diff line Loading @@ -17,11 +17,9 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.inputmethodservice.InputMethodService; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.Process; Loading Loading @@ -778,38 +776,6 @@ public class Utils { return s.toUpperCase(locale).charAt(0) + s.substring(1); } public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) { final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1); if (ms >= 0) { return ms; } final String[] durationPerHardwareList = res.getStringArray( R.array.keypress_vibration_durations); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : durationPerHardwareList) { if (element.startsWith(hardwarePrefix)) { return (int)Long.parseLong(element.substring(element.lastIndexOf(',') + 1)); } } return -1; } public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) { final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f); if (volume >= 0) { return volume; } final String[] volumePerHardwareList = res.getStringArray(R.array.keypress_volumes); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : volumePerHardwareList) { if (element.startsWith(hardwarePrefix)) { return Float.parseFloat(element.substring(element.lastIndexOf(',') + 1)); } } return -1.0f; } public static boolean willAutoCorrect(SuggestedWords suggestions) { return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate && !suggestions.shouldBlockAutoCorrection(); Loading Loading
java/src/com/android/inputmethod/latin/LatinIME.java +2 −2 Original line number Diff line number Diff line Loading @@ -2323,7 +2323,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // update keypress sound volume private void updateSoundEffectVolume() { mFxVolume = Utils.getCurrentKeypressSoundVolume(mPrefs, mResources); mFxVolume = SettingsValues.getCurrentKeypressSoundVolume(mPrefs, mResources); } // update flags for silent mode Loading @@ -2336,7 +2336,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void updateKeypressVibrationDuration() { mKeypressVibrationDuration = Utils.getCurrentVibrationDuration(mPrefs, mResources); mKeypressVibrationDuration = SettingsValues.getCurrentVibrationDuration(mPrefs, mResources); } private void playKeyClick(int primaryCode) { Loading
java/src/com/android/inputmethod/latin/Settings.java +5 −5 Original line number Diff line number Diff line Loading @@ -456,7 +456,7 @@ public class Settings extends InputMethodSettingsActivity SharedPreferences sp, Resources res) { if (mKeypressVibrationDurationSettingsPref != null) { mKeypressVibrationDurationSettingsPref.setSummary( Utils.getCurrentVibrationDuration(sp, res) SettingsValues.getCurrentVibrationDuration(sp, res) + res.getString(R.string.settings_ms)); } } Loading Loading @@ -484,7 +484,7 @@ public class Settings extends InputMethodSettingsActivity }); final View v = context.getLayoutInflater().inflate( R.layout.vibration_settings_dialog, null); final int currentMs = Utils.getCurrentVibrationDuration( final int currentMs = SettingsValues.getCurrentVibrationDuration( getPreferenceManager().getSharedPreferences(), getResources()); mKeypressVibrationDurationSettingsTextView = (TextView)v.findViewById(R.id.vibration_value); final SeekBar sb = (SeekBar)v.findViewById(R.id.vibration_settings); Loading Loading @@ -513,8 +513,8 @@ public class Settings extends InputMethodSettingsActivity private void updateKeypressSoundVolumeSummary(SharedPreferences sp, Resources res) { if (mKeypressSoundVolumeSettingsPref != null) { mKeypressSoundVolumeSettingsPref.setSummary( String.valueOf((int)(Utils.getCurrentKeypressSoundVolume(sp, res) * 100))); mKeypressSoundVolumeSettingsPref.setSummary(String.valueOf( (int)(SettingsValues.getCurrentKeypressSoundVolume(sp, res) * 100))); } } Loading Loading @@ -543,7 +543,7 @@ public class Settings extends InputMethodSettingsActivity }); final View v = context.getLayoutInflater().inflate( R.layout.sound_effect_volume_dialog, null); final int currentVolumeInt = (int)(Utils.getCurrentKeypressSoundVolume( final int currentVolumeInt = (int)(SettingsValues.getCurrentKeypressSoundVolume( getPreferenceManager().getSharedPreferences(), getResources()) * 100); mKeypressSoundVolumeSettingsTextView = (TextView)v.findViewById(R.id.sound_effect_volume_value); Loading
java/src/com/android/inputmethod/latin/SettingsValues.java +35 −1 Original line number Diff line number Diff line Loading @@ -19,11 +19,13 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Build; import android.util.Log; 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; Loading Loading @@ -241,4 +243,36 @@ public class SettingsValues { public boolean isVoiceKeyOnMain() { return mVoiceKeyOnMain; } public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) { final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f); if (volume >= 0) { return volume; } final String[] volumePerHardwareList = res.getStringArray(R.array.keypress_volumes); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : volumePerHardwareList) { if (element.startsWith(hardwarePrefix)) { return Float.parseFloat(element.substring(element.lastIndexOf(',') + 1)); } } return -1.0f; } public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) { final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1); if (ms >= 0) { return ms; } final String[] durationPerHardwareList = res.getStringArray( R.array.keypress_vibration_durations); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : durationPerHardwareList) { if (element.startsWith(hardwarePrefix)) { return (int)Long.parseLong(element.substring(element.lastIndexOf(',') + 1)); } } return -1; } }
java/src/com/android/inputmethod/latin/Utils.java +0 −34 Original line number Diff line number Diff line Loading @@ -17,11 +17,9 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.inputmethodservice.InputMethodService; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.Process; Loading Loading @@ -778,38 +776,6 @@ public class Utils { return s.toUpperCase(locale).charAt(0) + s.substring(1); } public static int getCurrentVibrationDuration(SharedPreferences sp, Resources res) { final int ms = sp.getInt(Settings.PREF_KEYPRESS_VIBRATION_DURATION_SETTINGS, -1); if (ms >= 0) { return ms; } final String[] durationPerHardwareList = res.getStringArray( R.array.keypress_vibration_durations); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : durationPerHardwareList) { if (element.startsWith(hardwarePrefix)) { return (int)Long.parseLong(element.substring(element.lastIndexOf(',') + 1)); } } return -1; } public static float getCurrentKeypressSoundVolume(SharedPreferences sp, Resources res) { final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f); if (volume >= 0) { return volume; } final String[] volumePerHardwareList = res.getStringArray(R.array.keypress_volumes); final String hardwarePrefix = Build.HARDWARE + ","; for (final String element : volumePerHardwareList) { if (element.startsWith(hardwarePrefix)) { return Float.parseFloat(element.substring(element.lastIndexOf(',') + 1)); } } return -1.0f; } public static boolean willAutoCorrect(SuggestedWords suggestions) { return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate && !suggestions.shouldBlockAutoCorrection(); Loading