2009-03-13 22:11:42 +00:00
|
|
|
/*
|
2011-09-01 05:54:28 +00:00
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
2010-12-06 12:26:38 +00:00
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2010-12-06 12:26:38 +00:00
|
|
|
*
|
2013-01-21 12:52:57 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2010-12-06 12:26:38 +00:00
|
|
|
*
|
2009-03-13 22:11:42 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
2013-01-21 12:52:57 +00:00
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-03-13 22:11:42 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-16 02:26:14 +00:00
|
|
|
package com.android.inputmethod.latin.suggestions;
|
2009-03-13 22:11:42 +00:00
|
|
|
|
|
|
|
import android.content.Context;
|
2010-02-11 01:45:35 +00:00
|
|
|
import android.content.res.Resources;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.util.AttributeSet;
|
2011-09-20 10:17:19 +00:00
|
|
|
import android.view.GestureDetector;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.view.LayoutInflater;
|
2011-08-24 05:44:46 +00:00
|
|
|
import android.view.MotionEvent;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.view.View;
|
2010-12-06 12:26:38 +00:00
|
|
|
import android.view.View.OnClickListener;
|
2011-08-06 07:45:58 +00:00
|
|
|
import android.view.View.OnLongClickListener;
|
2010-12-10 06:24:28 +00:00
|
|
|
import android.view.ViewGroup;
|
2011-09-05 07:15:28 +00:00
|
|
|
import android.widget.RelativeLayout;
|
2009-03-13 22:11:42 +00:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
2012-10-01 05:26:38 +00:00
|
|
|
import com.android.inputmethod.keyboard.Keyboard;
|
|
|
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
2013-01-21 05:41:33 +00:00
|
|
|
import com.android.inputmethod.keyboard.MainKeyboardView;
|
2011-08-24 05:44:46 +00:00
|
|
|
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
2013-05-21 22:32:08 +00:00
|
|
|
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
|
2012-10-15 20:59:35 +00:00
|
|
|
import com.android.inputmethod.latin.Constants;
|
2011-12-16 02:26:14 +00:00
|
|
|
import com.android.inputmethod.latin.LatinImeLogger;
|
|
|
|
import com.android.inputmethod.latin.R;
|
|
|
|
import com.android.inputmethod.latin.SuggestedWords;
|
2013-04-04 08:45:21 +00:00
|
|
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
2012-04-09 17:53:17 +00:00
|
|
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
2013-05-01 08:02:27 +00:00
|
|
|
import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
|
2013-06-23 16:11:32 +00:00
|
|
|
import com.android.inputmethod.latin.utils.CollectionUtils;
|
2012-07-20 18:02:39 +00:00
|
|
|
import com.android.inputmethod.research.ResearchLogger;
|
2011-06-06 08:23:18 +00:00
|
|
|
|
2010-09-29 05:30:01 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2012-09-27 09:16:16 +00:00
|
|
|
public final class SuggestionStripView extends RelativeLayout implements OnClickListener,
|
2011-09-05 07:15:28 +00:00
|
|
|
OnLongClickListener {
|
2011-06-09 05:22:37 +00:00
|
|
|
public interface Listener {
|
2012-12-13 12:59:13 +00:00
|
|
|
public void addWordToUserDictionary(String word);
|
2013-04-04 08:45:21 +00:00
|
|
|
public void pickSuggestionManually(int index, SuggestedWordInfo word);
|
2011-06-09 05:22:37 +00:00
|
|
|
}
|
|
|
|
|
2011-06-14 07:28:57 +00:00
|
|
|
// The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
|
2011-08-24 05:44:46 +00:00
|
|
|
public static final int MAX_SUGGESTIONS = 18;
|
2009-03-13 22:11:42 +00:00
|
|
|
|
2011-12-16 02:26:14 +00:00
|
|
|
static final boolean DBG = LatinImeLogger.sDBG;
|
2011-01-19 08:29:27 +00:00
|
|
|
|
2011-09-01 05:54:28 +00:00
|
|
|
private final ViewGroup mSuggestionsStrip;
|
2013-01-21 05:41:33 +00:00
|
|
|
MainKeyboardView mMainKeyboardView;
|
2011-06-30 01:09:21 +00:00
|
|
|
|
2011-08-24 05:44:46 +00:00
|
|
|
private final View mMoreSuggestionsContainer;
|
|
|
|
private final MoreSuggestionsView mMoreSuggestionsView;
|
|
|
|
private final MoreSuggestions.Builder mMoreSuggestionsBuilder;
|
|
|
|
|
2013-05-30 10:44:26 +00:00
|
|
|
private final ArrayList<TextView> mWordViews = CollectionUtils.newArrayList();
|
|
|
|
private final ArrayList<TextView> mDebugInfoViews = CollectionUtils.newArrayList();
|
|
|
|
private final ArrayList<View> mDividerViews = CollectionUtils.newArrayList();
|
2011-06-30 01:09:21 +00:00
|
|
|
|
2012-10-03 05:46:47 +00:00
|
|
|
Listener mListener;
|
2013-05-01 08:02:27 +00:00
|
|
|
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
|
2010-02-03 23:35:49 +00:00
|
|
|
|
2013-05-30 10:31:55 +00:00
|
|
|
private final SuggestionStripLayoutHelper mLayoutHelper;
|
2011-06-30 01:09:21 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
/**
|
2012-07-23 06:28:28 +00:00
|
|
|
* Construct a {@link SuggestionStripView} for showing suggestions to be picked by the user.
|
2009-03-13 22:11:42 +00:00
|
|
|
* @param context
|
|
|
|
* @param attrs
|
|
|
|
*/
|
2012-10-03 05:46:47 +00:00
|
|
|
public SuggestionStripView(final Context context, final AttributeSet attrs) {
|
2012-07-23 06:28:28 +00:00
|
|
|
this(context, attrs, R.attr.suggestionStripViewStyle);
|
2011-06-15 02:49:57 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 05:46:47 +00:00
|
|
|
public SuggestionStripView(final Context context, final AttributeSet attrs,
|
|
|
|
final int defStyle) {
|
2011-09-05 07:15:28 +00:00
|
|
|
super(context, attrs, defStyle);
|
2009-03-13 22:11:42 +00:00
|
|
|
|
2011-08-04 09:18:45 +00:00
|
|
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
2011-09-01 05:54:28 +00:00
|
|
|
inflater.inflate(R.layout.suggestions_strip, this);
|
2011-06-14 07:28:57 +00:00
|
|
|
|
2011-09-01 05:54:28 +00:00
|
|
|
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
|
2011-08-05 09:54:52 +00:00
|
|
|
for (int pos = 0; pos < MAX_SUGGESTIONS; pos++) {
|
2011-09-01 05:54:28 +00:00
|
|
|
final TextView word = (TextView)inflater.inflate(R.layout.suggestion_word, null);
|
2011-06-24 05:19:59 +00:00
|
|
|
word.setOnClickListener(this);
|
2011-08-06 07:45:58 +00:00
|
|
|
word.setOnLongClickListener(this);
|
2013-05-30 10:44:26 +00:00
|
|
|
mWordViews.add(word);
|
2011-09-01 05:54:28 +00:00
|
|
|
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
2011-07-28 21:15:24 +00:00
|
|
|
divider.setOnClickListener(this);
|
2013-05-30 10:44:26 +00:00
|
|
|
mDividerViews.add(divider);
|
|
|
|
mDebugInfoViews.add((TextView)inflater.inflate(R.layout.suggestion_info, null));
|
2010-09-30 03:10:03 +00:00
|
|
|
}
|
2010-09-29 05:30:01 +00:00
|
|
|
|
2013-05-30 10:31:55 +00:00
|
|
|
mLayoutHelper = new SuggestionStripLayoutHelper(
|
2013-05-30 10:44:26 +00:00
|
|
|
context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);
|
2011-08-24 05:44:46 +00:00
|
|
|
|
|
|
|
mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
|
|
|
|
mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
|
|
|
|
.findViewById(R.id.more_suggestions_view);
|
2013-04-11 03:08:36 +00:00
|
|
|
mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);
|
2011-09-29 05:11:21 +00:00
|
|
|
|
2011-09-06 02:37:51 +00:00
|
|
|
final Resources res = context.getResources();
|
|
|
|
mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset(
|
|
|
|
R.dimen.more_suggestions_modal_tolerance);
|
2011-09-20 10:17:19 +00:00
|
|
|
mMoreSuggestionsSlidingDetector = new GestureDetector(
|
|
|
|
context, mMoreSuggestionsSlidingListener);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2010-09-30 03:10:03 +00:00
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
/**
|
2011-06-09 05:22:37 +00:00
|
|
|
* A connection back to the input method.
|
2009-03-13 22:11:42 +00:00
|
|
|
* @param listener
|
|
|
|
*/
|
2012-10-03 05:46:47 +00:00
|
|
|
public void setListener(final Listener listener, final View inputView) {
|
2011-06-09 05:22:37 +00:00
|
|
|
mListener = listener;
|
2013-01-21 05:41:33 +00:00
|
|
|
mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 05:46:47 +00:00
|
|
|
public void setSuggestions(final SuggestedWords suggestedWords) {
|
2010-12-06 12:26:38 +00:00
|
|
|
clear();
|
2012-03-05 13:08:16 +00:00
|
|
|
mSuggestedWords = suggestedWords;
|
2013-05-30 10:44:26 +00:00
|
|
|
mLayoutHelper.layout(mSuggestedWords, mSuggestionsStrip, this);
|
2013-03-18 09:21:18 +00:00
|
|
|
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
2012-07-23 06:28:28 +00:00
|
|
|
ResearchLogger.suggestionStripView_setSuggestions(mSuggestedWords);
|
2012-04-09 17:53:17 +00:00
|
|
|
}
|
2011-08-04 09:18:45 +00:00
|
|
|
}
|
2011-06-30 01:09:21 +00:00
|
|
|
|
2013-08-08 07:13:17 +00:00
|
|
|
public void setMoreSuggestionsHeight(final int remainingHeight) {
|
|
|
|
mLayoutHelper.setMoreSuggestionsHeight(remainingHeight);
|
2012-03-07 06:30:16 +00:00
|
|
|
}
|
2011-06-25 18:00:51 +00:00
|
|
|
|
2010-08-26 19:22:58 +00:00
|
|
|
public boolean isShowingAddToDictionaryHint() {
|
2011-09-01 05:54:28 +00:00
|
|
|
return mSuggestionsStrip.getChildCount() > 0
|
2013-05-30 10:31:55 +00:00
|
|
|
&& mLayoutHelper.isAddToDictionaryShowing(mSuggestionsStrip.getChildAt(0));
|
2010-08-26 19:22:58 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 06:19:43 +00:00
|
|
|
public void showAddToDictionaryHint(final String word, final CharSequence hintText) {
|
2011-08-26 06:13:30 +00:00
|
|
|
clear();
|
2013-05-30 10:31:55 +00:00
|
|
|
mLayoutHelper.layoutAddToDictionaryHint(
|
|
|
|
word, mSuggestionsStrip, getWidth(), hintText, this);
|
2010-02-11 01:45:35 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 18:47:42 +00:00
|
|
|
public boolean dismissAddToDictionaryHint() {
|
2011-08-26 06:13:30 +00:00
|
|
|
if (isShowingAddToDictionaryHint()) {
|
|
|
|
clear();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-08-03 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
2009-03-13 22:11:42 +00:00
|
|
|
public void clear() {
|
2011-09-01 05:54:28 +00:00
|
|
|
mSuggestionsStrip.removeAllViews();
|
2011-09-05 07:15:28 +00:00
|
|
|
removeAllViews();
|
|
|
|
addView(mSuggestionsStrip);
|
2013-07-25 08:03:16 +00:00
|
|
|
mMoreSuggestionsView.dismissMoreKeysPanel();
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 08:02:27 +00:00
|
|
|
private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() {
|
2011-08-24 05:44:46 +00:00
|
|
|
@Override
|
2013-05-01 08:02:27 +00:00
|
|
|
public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) {
|
2013-04-04 08:45:21 +00:00
|
|
|
mListener.pickSuggestionManually(index, wordInfo);
|
2013-07-25 08:03:16 +00:00
|
|
|
mMoreSuggestionsView.dismissMoreKeysPanel();
|
2011-08-24 05:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCancelInput() {
|
2013-07-25 08:03:16 +00:00
|
|
|
mMoreSuggestionsView.dismissMoreKeysPanel();
|
2011-08-24 05:44:46 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
private final MoreKeysPanel.Controller mMoreSuggestionsController =
|
|
|
|
new MoreKeysPanel.Controller() {
|
|
|
|
@Override
|
2013-07-25 09:07:46 +00:00
|
|
|
public void onDismissMoreKeysPanel(final MoreKeysPanel panel) {
|
|
|
|
mMainKeyboardView.onDismissMoreKeysPanel(panel);
|
2012-12-03 06:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-01-22 05:32:47 +00:00
|
|
|
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
|
2013-01-21 05:41:33 +00:00
|
|
|
mMainKeyboardView.onShowMoreKeysPanel(panel);
|
2011-08-24 05:44:46 +00:00
|
|
|
}
|
2012-12-10 20:38:29 +00:00
|
|
|
|
|
|
|
@Override
|
2013-07-25 09:07:46 +00:00
|
|
|
public void onCancelMoreKeysPanel(final MoreKeysPanel panel) {
|
2013-07-25 08:03:16 +00:00
|
|
|
mMoreSuggestionsView.dismissMoreKeysPanel();
|
2012-12-10 20:38:29 +00:00
|
|
|
}
|
2011-08-24 05:44:46 +00:00
|
|
|
};
|
|
|
|
|
2011-08-06 07:45:58 +00:00
|
|
|
@Override
|
2012-10-03 05:46:47 +00:00
|
|
|
public boolean onLongClick(final View view) {
|
2013-05-21 22:32:08 +00:00
|
|
|
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(
|
|
|
|
Constants.NOT_A_CODE, this);
|
2011-09-20 10:17:19 +00:00
|
|
|
return showMoreSuggestions();
|
|
|
|
}
|
|
|
|
|
2012-10-03 05:46:47 +00:00
|
|
|
boolean showMoreSuggestions() {
|
2012-10-01 05:26:38 +00:00
|
|
|
final Keyboard parentKeyboard = KeyboardSwitcher.getInstance().getKeyboard();
|
|
|
|
if (parentKeyboard == null) {
|
|
|
|
return false;
|
2011-08-06 07:45:58 +00:00
|
|
|
}
|
2013-05-30 10:31:55 +00:00
|
|
|
final SuggestionStripLayoutHelper layoutHelper = mLayoutHelper;
|
|
|
|
if (!layoutHelper.mMoreSuggestionsAvailable) {
|
2012-10-01 05:26:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final int stripWidth = getWidth();
|
|
|
|
final View container = mMoreSuggestionsContainer;
|
|
|
|
final int maxWidth = stripWidth - container.getPaddingLeft() - container.getPaddingRight();
|
|
|
|
final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
|
2013-05-30 10:31:55 +00:00
|
|
|
builder.layout(mSuggestedWords, layoutHelper.mSuggestionsCountInStrip, maxWidth,
|
|
|
|
(int)(maxWidth * layoutHelper.mMinMoreSuggestionsWidth),
|
|
|
|
layoutHelper.getMaxMoreSuggestionsRow(), parentKeyboard);
|
2012-10-01 05:26:38 +00:00
|
|
|
mMoreSuggestionsView.setKeyboard(builder.build());
|
|
|
|
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
|
|
|
final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
|
|
|
|
final int pointX = stripWidth / 2;
|
2013-05-30 10:31:55 +00:00
|
|
|
final int pointY = -layoutHelper.mMoreSuggestionsBottomGap;
|
2012-10-01 05:26:38 +00:00
|
|
|
moreKeysPanel.showMoreKeysPanel(this, mMoreSuggestionsController, pointX, pointY,
|
2012-12-03 06:49:10 +00:00
|
|
|
mMoreSuggestionsListener);
|
2012-10-01 05:26:38 +00:00
|
|
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
|
|
|
|
mOriginX = mLastX;
|
|
|
|
mOriginY = mLastY;
|
2013-05-30 10:31:55 +00:00
|
|
|
for (int i = 0; i < layoutHelper.mSuggestionsCountInStrip; i++) {
|
2013-05-30 10:44:26 +00:00
|
|
|
mWordViews.get(i).setPressed(false);
|
2012-10-01 05:26:38 +00:00
|
|
|
}
|
|
|
|
return true;
|
2011-08-06 07:45:58 +00:00
|
|
|
}
|
|
|
|
|
2011-09-06 02:37:51 +00:00
|
|
|
// Working variables for onLongClick and dispatchTouchEvent.
|
2011-09-16 09:24:03 +00:00
|
|
|
private int mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_MODAL_MODE;
|
|
|
|
private static final int MORE_SUGGESTIONS_IN_MODAL_MODE = 0;
|
|
|
|
private static final int MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING = 1;
|
|
|
|
private static final int MORE_SUGGESTIONS_IN_SLIDING_MODE = 2;
|
2011-09-06 02:37:51 +00:00
|
|
|
private int mLastX;
|
|
|
|
private int mLastY;
|
|
|
|
private int mOriginX;
|
|
|
|
private int mOriginY;
|
|
|
|
private final int mMoreSuggestionsModalTolerance;
|
2011-09-20 10:17:19 +00:00
|
|
|
private final GestureDetector mMoreSuggestionsSlidingDetector;
|
|
|
|
private final GestureDetector.OnGestureListener mMoreSuggestionsSlidingListener =
|
|
|
|
new GestureDetector.SimpleOnGestureListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onScroll(MotionEvent down, MotionEvent me, float deltaX, float deltaY) {
|
|
|
|
final float dy = me.getY() - down.getY();
|
|
|
|
if (deltaY > 0 && dy < 0) {
|
|
|
|
return showMoreSuggestions();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2011-09-06 02:37:51 +00:00
|
|
|
|
2010-12-06 12:26:38 +00:00
|
|
|
@Override
|
2012-10-03 05:46:47 +00:00
|
|
|
public boolean dispatchTouchEvent(final MotionEvent me) {
|
2013-04-15 03:57:10 +00:00
|
|
|
if (!mMoreSuggestionsView.isShowingInParent()) {
|
2011-09-06 02:37:51 +00:00
|
|
|
mLastX = (int)me.getX();
|
|
|
|
mLastY = (int)me.getY();
|
2011-09-20 10:17:19 +00:00
|
|
|
if (mMoreSuggestionsSlidingDetector.onTouchEvent(me)) {
|
|
|
|
return true;
|
|
|
|
}
|
2011-08-24 05:44:46 +00:00
|
|
|
return super.dispatchTouchEvent(me);
|
|
|
|
}
|
2011-09-06 06:25:58 +00:00
|
|
|
|
2011-08-24 05:44:46 +00:00
|
|
|
final int action = me.getAction();
|
|
|
|
final int index = me.getActionIndex();
|
2011-09-06 06:25:58 +00:00
|
|
|
final int x = (int)me.getX(index);
|
|
|
|
final int y = (int)me.getY(index);
|
|
|
|
|
2011-09-16 09:24:03 +00:00
|
|
|
if (mMoreSuggestionsMode == MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING) {
|
2011-09-13 03:50:12 +00:00
|
|
|
if (Math.abs(x - mOriginX) >= mMoreSuggestionsModalTolerance
|
|
|
|
|| mOriginY - y >= mMoreSuggestionsModalTolerance) {
|
|
|
|
// Decided to be in the sliding input mode only when the touch point has been moved
|
|
|
|
// upward.
|
2011-09-16 09:24:03 +00:00
|
|
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_SLIDING_MODE;
|
2011-09-06 02:37:51 +00:00
|
|
|
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
|
|
|
|
// Decided to be in the modal input mode
|
2011-09-16 09:24:03 +00:00
|
|
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_IN_MODAL_MODE;
|
2013-04-15 03:57:10 +00:00
|
|
|
mMoreSuggestionsView.adjustVerticalCorrectionForModalMode();
|
2011-09-06 02:37:51 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-16 09:24:03 +00:00
|
|
|
// MORE_SUGGESTIONS_IN_SLIDING_MODE
|
2013-08-01 07:55:55 +00:00
|
|
|
me.setLocation(mMoreSuggestionsView.translateX(x), mMoreSuggestionsView.translateY(y));
|
|
|
|
mMoreSuggestionsView.onTouchEvent(me);
|
2011-08-24 05:44:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-10-03 05:46:47 +00:00
|
|
|
public void onClick(final View view) {
|
2013-05-30 10:31:55 +00:00
|
|
|
if (mLayoutHelper.isAddToDictionaryShowing(view)) {
|
2013-06-21 01:44:14 +00:00
|
|
|
mListener.addWordToUserDictionary(mLayoutHelper.getAddToDictionaryWord());
|
2011-06-27 07:57:18 +00:00
|
|
|
clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-06-14 07:28:57 +00:00
|
|
|
final Object tag = view.getTag();
|
2013-06-21 01:44:14 +00:00
|
|
|
// Integer tag is set at
|
|
|
|
// {@link SuggestionStripLayoutHelper#setupWordViewsTextAndColor(SuggestedWords,int)} and
|
|
|
|
// {@link SuggestionStripLayoutHelper#layoutPunctuationSuggestions(SuggestedWords,ViewGroup}
|
2013-05-30 10:44:26 +00:00
|
|
|
if (!(tag instanceof Integer)) {
|
2011-06-14 07:28:57 +00:00
|
|
|
return;
|
2013-05-30 10:44:26 +00:00
|
|
|
}
|
2011-06-14 07:28:57 +00:00
|
|
|
final int index = (Integer) tag;
|
2013-05-30 10:44:26 +00:00
|
|
|
if (index >= mSuggestedWords.size()) {
|
2011-06-10 00:53:27 +00:00
|
|
|
return;
|
2013-05-30 10:44:26 +00:00
|
|
|
}
|
2011-06-14 07:28:57 +00:00
|
|
|
|
2013-04-04 08:45:21 +00:00
|
|
|
final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
|
|
|
|
mListener.pickSuggestionManually(index, wordInfo);
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|
2011-01-18 08:22:01 +00:00
|
|
|
|
2009-03-31 21:50:26 +00:00
|
|
|
@Override
|
2011-09-27 06:18:02 +00:00
|
|
|
protected void onDetachedFromWindow() {
|
2009-03-31 21:50:26 +00:00
|
|
|
super.onDetachedFromWindow();
|
2013-07-25 08:03:16 +00:00
|
|
|
mMoreSuggestionsView.dismissMoreKeysPanel();
|
2009-03-31 21:50:26 +00:00
|
|
|
}
|
2009-03-13 22:11:42 +00:00
|
|
|
}
|