diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
5 files changed, 42 insertions, 32 deletions
diff --git a/java/src/com/android/inputmethod/latin/CollectionUtils.java b/java/src/com/android/inputmethod/latin/CollectionUtils.java index c75f2df5c..a8623cc63 100644 --- a/java/src/com/android/inputmethod/latin/CollectionUtils.java +++ b/java/src/com/android/inputmethod/latin/CollectionUtils.java @@ -27,6 +27,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.TreeMap; import java.util.TreeSet; +import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -39,6 +40,10 @@ public final class CollectionUtils { return new HashMap<K,V>(); } + public static <K, V> WeakHashMap<K, V> newWeakHashMap() { + return new WeakHashMap<K, V>(); + } + public static <K,V> TreeMap<K,V> newTreeMap() { return new TreeMap<K,V>(); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index a48778ab3..fc9953ac0 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -2490,7 +2490,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private void launchSubActivity(final Class<? extends Activity> activityClass) { Intent intent = new Intent(); intent.setClass(LatinIME.this, activityClass); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED + | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } 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())); } } diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java index 26a304ef8..438820d17 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java @@ -19,7 +19,6 @@ package com.android.inputmethod.latin.suggestions; import android.content.Context; import android.util.AttributeSet; -import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.MoreKeysKeyboardView; import com.android.inputmethod.latin.R; @@ -28,7 +27,6 @@ import com.android.inputmethod.latin.R; * key presses and touch movements. */ public final class MoreSuggestionsView extends MoreKeysKeyboardView { - public MoreSuggestionsView(final Context context, final AttributeSet attrs) { this(context, attrs, R.attr.moreSuggestionsViewStyle); } @@ -44,32 +42,15 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView { return pane.mOccupiedWidth / 2; } - @Override - protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { - final Keyboard keyboard = getKeyboard(); - if (keyboard != null) { - final int width = keyboard.mOccupiedWidth + getPaddingLeft() + getPaddingRight(); - final int height = keyboard.mOccupiedHeight + getPaddingTop() + getPaddingBottom(); - setMeasuredDimension(width, height); - } else { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - } - public void updateKeyboardGeometry(final int keyHeight) { mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes); } @Override - public void onCodeInput(final int primaryCode, final int x, final int y) { - final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE; + public void onCodeInput(final int code, final int x, final int y) { + final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE; if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) { mListener.onCustomRequest(index); } } - - @Override - public boolean isShowingInParent() { - return (getContainerView().getParent() != null); - } } diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index 92b96e754..bc51d5d62 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -676,12 +676,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick new MoreKeysPanel.Controller() { @Override public boolean onDismissMoreKeysPanel() { - mMainKeyboardView.dimEntireKeyboard(false /* dimmed */); return mMainKeyboardView.onDismissMoreKeysPanel(); } @Override - public void onShowMoreKeysPanel(MoreKeysPanel panel) { + public void onShowMoreKeysPanel(final MoreKeysPanel panel) { mMainKeyboardView.onShowMoreKeysPanel(panel); } @@ -728,7 +727,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING; mOriginX = mLastX; mOriginY = mLastY; - mMainKeyboardView.dimEntireKeyboard(true /* dimmed */); for (int i = 0; i < params.mSuggestionsCountInStrip; i++) { mWords.get(i).setPressed(false); } |