Merge "Fix issues with long-press access to more suggestions"

main
Ken Wakasa 2011-08-08 04:37:09 -07:00 committed by Android (Google) Code Review
commit 44beeab4a4
1 changed files with 11 additions and 5 deletions

View File

@ -387,7 +387,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final int countInStrip = mCandidateCountInStrip; final int countInStrip = mCandidateCountInStrip;
setupTexts(suggestions, countInStrip); setupTexts(suggestions, countInStrip);
mMoreSuggestionsAvailable = (suggestions.size() > countInStrip);
int x = 0; int x = 0;
for (int index = 0; index < countInStrip; index++) { for (int index = 0; index < countInStrip; index++) {
final int pos = getWordPosition(index, suggestions); final int pos = getWordPosition(index, suggestions);
@ -400,14 +400,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final CharSequence styled = mTexts.get(pos); final CharSequence styled = mTexts.get(pos);
final TextView word = mWords.get(pos); final TextView word = mWords.get(pos);
if (index == mCenterCandidateIndex && suggestions.size() > countInStrip) { if (index == mCenterCandidateIndex && mMoreSuggestionsAvailable) {
// TODO: This "more suggestions hint" should have nicely designed icon. // TODO: This "more suggestions hint" should have nicely designed icon.
word.setCompoundDrawablesWithIntrinsicBounds( word.setCompoundDrawablesWithIntrinsicBounds(
null, null, null, mMoreCandidateHint); null, null, null, mMoreCandidateHint);
mMoreSuggestionsAvailable = true;
} else { } else {
word.setCompoundDrawables(null, null, null, null); word.setCompoundDrawables(null, null, null, null);
mMoreSuggestionsAvailable = false;
} }
// Disable this candidate if the suggestion is null or empty. // Disable this candidate if the suggestion is null or empty.
@ -693,6 +691,14 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mKeyboardView.setVisibility(VISIBLE); mKeyboardView.setVisibility(VISIBLE);
} }
private void toggleCandidatesPane() {
if (mCandidatesPaneContainer.getVisibility() == VISIBLE) {
closeCandidatesPane();
} else {
expandCandidatesPane();
}
}
public void onAutoCorrectionInverted(CharSequence autoCorrectedWord) { public void onAutoCorrectionInverted(CharSequence autoCorrectedWord) {
final CharSequence inverted = mStripParams.getInvertedText(autoCorrectedWord); final CharSequence inverted = mStripParams.getInvertedText(autoCorrectedWord);
if (inverted == null) if (inverted == null)
@ -770,7 +776,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
@Override @Override
public boolean onLongClick(View view) { public boolean onLongClick(View view) {
if (mStripParams.mMoreSuggestionsAvailable) { if (mStripParams.mMoreSuggestionsAvailable) {
expandCandidatesPane(); toggleCandidatesPane();
return true; return true;
} }
return false; return false;