aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java23
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java4
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java38
4 files changed, 47 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 29c65f19b..32cee734a 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -30,8 +30,7 @@ public final class ProximityInfo {
private static final String TAG = ProximityInfo.class.getSimpleName();
private static final boolean DEBUG = false;
- /** MAX_PROXIMITY_CHARS_SIZE must be the same as MAX_PROXIMITY_CHARS_SIZE_INTERNAL
- * in defines.h */
+ // Must be equal to MAX_PROXIMITY_CHARS_SIZE in native/jni/src/defines.h
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
/** Number of key widths from current touch point to search for nearest keys. */
private static final float SEARCH_DISTANCE = 1.2f;
@@ -88,9 +87,13 @@ public final class ProximityInfo {
final int rowSize, final int gridWidth, final int gridHeight) {
final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
spellCheckerProximityInfo.mNativeProximityInfo =
- spellCheckerProximityInfo.setProximityInfoNative("",
- rowSize, gridWidth, gridHeight, gridWidth, gridHeight,
- 1, proximityCharsArray, 0, null, null, null, null, null, null, null, null);
+ spellCheckerProximityInfo.setProximityInfoNative("" /* locale */,
+ gridWidth /* displayWidth */, gridHeight /* displayHeight */,
+ gridWidth, gridHeight, 1 /* mostCommonKeyWidth */, proximityCharsArray,
+ 0 /* keyCount */, null /*keyXCoordinates */, null /* keyYCoordinates */,
+ null /* keyWidths */, null /* keyHeights */, null /* keyCharCodes */,
+ null /* sweetSpotCenterXs */, null /* sweetSpotCenterYs */,
+ null /* sweetSpotRadii */);
return spellCheckerProximityInfo;
}
@@ -100,11 +103,11 @@ public final class ProximityInfo {
}
// TODO: Stop passing proximityCharsArray
- private static native long setProximityInfoNative(String locale, int maxProximityCharsSize,
+ private static native long setProximityInfoNative(String locale,
int displayWidth, int displayHeight, int gridWidth, int gridHeight,
int mostCommonKeyWidth, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates,
int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes,
- float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii);
+ float[] sweetSpotCenterXs, float[] sweetSpotCenterYs, float[] sweetSpotRadii);
private static native void releaseProximityInfoNative(long nativeProximityInfo);
@@ -230,9 +233,9 @@ public final class ProximityInfo {
}
// TODO: Stop passing proximityCharsArray
- return setProximityInfoNative(mLocaleStr, MAX_PROXIMITY_CHARS_SIZE, mKeyboardMinWidth,
- mKeyboardHeight, mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray,
- keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
+ return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight,
+ mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray, keyCount,
+ keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
}
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 59d51b0b9..ad3163347 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -35,9 +35,9 @@ public final class BinaryDictionary extends Dictionary {
public static final String DICTIONARY_PACK_AUTHORITY =
"com.android.inputmethod.latin.dictionarypack";
- // Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h
+ // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
- // Must be identical to MAX_RESULTS in native/jni/src/defines.h
+ // Must be equal to MAX_RESULTS in native/jni/src/defines.h
private static final int MAX_RESULTS = 18;
private long mNativeDict;
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
index 748900b3a..85cc55232 100644
--- a/java/src/com/android/inputmethod/latin/Constants.java
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -127,7 +127,7 @@ public final class Constants {
}
public static final class Dictionary {
- // Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h
+ // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
public static final int MAX_WORD_LENGTH = 48;
private Dictionary() {
diff --git a/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java b/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java
index 604156408..9819a02ef 100644
--- a/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java
+++ b/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java
@@ -37,6 +37,8 @@ public final class SeekBarDialogPreference extends DialogPreference
private final int mValueFormatResId;
private final int mMaxValue;
+ private final int mMinValue;
+ private final int mStepValue;
private TextView mValueView;
private SeekBar mSeekBar;
@@ -49,6 +51,8 @@ public final class SeekBarDialogPreference extends DialogPreference
attrs, R.styleable.SeekBarDialogPreference, 0, 0);
mValueFormatResId = a.getResourceId(R.styleable.SeekBarDialogPreference_valueFormatText, 0);
mMaxValue = a.getInt(R.styleable.SeekBarDialogPreference_maxValue, 0);
+ mMinValue = a.getInt(R.styleable.SeekBarDialogPreference_minValue, 0);
+ mStepValue = a.getInt(R.styleable.SeekBarDialogPreference_stepValue, 0);
a.recycle();
setDialogLayoutResource(R.layout.seek_bar_dialog);
}
@@ -70,22 +74,42 @@ public final class SeekBarDialogPreference extends DialogPreference
protected View onCreateDialogView() {
final View view = super.onCreateDialogView();
mSeekBar = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar);
- mSeekBar.setMax(mMaxValue);
+ mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
mValueView = (TextView)view.findViewById(R.id.seek_bar_dialog_value);
return view;
}
+ private int getProgressFromValue(final int value) {
+ return value - mMinValue;
+ }
+
+ private int getValueFromProgress(final int progress) {
+ return progress + mMinValue;
+ }
+
+ private int clipValue(final int value) {
+ final int clippedValue = Math.min(mMaxValue, Math.max(mMinValue, value));
+ if (mStepValue <= 1) {
+ return clippedValue;
+ }
+ return clippedValue - (clippedValue % mStepValue);
+ }
+
+ private int getClippedValueFromProgress(final int progress) {
+ return clipValue(getValueFromProgress(progress));
+ }
+
private void setValue(final int value, final boolean fromUser) {
mValueView.setText(getValueText(value));
if (!fromUser) {
- mSeekBar.setProgress(value);
+ mSeekBar.setProgress(getProgressFromValue(value));
}
}
@Override
protected void onBindDialogView(final View view) {
- setValue(mValueProxy.readValue(getKey()), false /* fromUser */);
+ setValue(clipValue(mValueProxy.readValue(getKey())), false /* fromUser */);
}
@Override
@@ -99,18 +123,18 @@ public final class SeekBarDialogPreference extends DialogPreference
public void onClick(final DialogInterface dialog, final int which) {
super.onClick(dialog, which);
if (which == DialogInterface.BUTTON_NEUTRAL) {
- setValue(mValueProxy.readDefaultValue(getKey()), false /* fromUser */);
+ setValue(clipValue(mValueProxy.readDefaultValue(getKey())), false /* fromUser */);
}
if (which != DialogInterface.BUTTON_NEGATIVE) {
setSummary(mValueView.getText());
- mValueProxy.writeValue(mSeekBar.getProgress(), getKey());
+ mValueProxy.writeValue(getClippedValueFromProgress(mSeekBar.getProgress()), getKey());
}
}
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress,
final boolean fromUser) {
- setValue(progress, fromUser);
+ setValue(getClippedValueFromProgress(progress), fromUser);
}
@Override
@@ -118,6 +142,6 @@ public final class SeekBarDialogPreference extends DialogPreference
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
- mValueProxy.feedbackValue(seekBar.getProgress());
+ mValueProxy.feedbackValue(getClippedValueFromProgress(seekBar.getProgress()));
}
}