am 0c3b8ce8: Merge "Move settings method from Utils to SettingsValues"
* commit '0c3b8ce842140aad2087b6ec391177999b87cbb4': Move settings method from Utils to SettingsValuesmain
commit
7ce1dc3313
|
@ -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
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
@ -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…
Reference in New Issue