Fix NPE observed only by monkey test
Bug: 7258660 Change-Id: I286c704b32efeada8505d953438f2595166f7e8f
This commit is contained in:
parent
c3a7d483ca
commit
7339a62a13
2 changed files with 36 additions and 34 deletions
|
@ -22,7 +22,6 @@ import android.graphics.drawable.Drawable;
|
|||
|
||||
import com.android.inputmethod.keyboard.Key;
|
||||
import com.android.inputmethod.keyboard.Keyboard;
|
||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||
|
@ -175,11 +174,11 @@ public final class MoreSuggestions extends Keyboard {
|
|||
}
|
||||
|
||||
public Builder layout(final SuggestedWords suggestions, final int fromPos,
|
||||
final int maxWidth, final int minWidth, final int maxRow) {
|
||||
final Keyboard keyboard = KeyboardSwitcher.getInstance().getKeyboard();
|
||||
final int maxWidth, final int minWidth, final int maxRow,
|
||||
final Keyboard parentKeyboard) {
|
||||
final int xmlId = R.xml.kbd_suggestions_pane_template;
|
||||
load(xmlId, keyboard.mId);
|
||||
mParams.mVerticalGap = mParams.mTopPadding = keyboard.mVerticalGap / 2;
|
||||
load(xmlId, parentKeyboard.mId);
|
||||
mParams.mVerticalGap = mParams.mTopPadding = parentKeyboard.mVerticalGap / 2;
|
||||
|
||||
final int count = mParams.layout(suggestions, fromPos, maxWidth, minWidth, maxRow,
|
||||
mPaneView);
|
||||
|
|
|
@ -52,7 +52,9 @@ import android.widget.PopupWindow;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.inputmethod.keyboard.Keyboard;
|
||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import com.android.inputmethod.keyboard.KeyboardView;
|
||||
import com.android.inputmethod.keyboard.MoreKeysPanel;
|
||||
import com.android.inputmethod.keyboard.PointerTracker;
|
||||
|
@ -751,36 +753,37 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
|||
}
|
||||
|
||||
private boolean showMoreSuggestions() {
|
||||
final SuggestionStripViewParams params = mParams;
|
||||
if (params.mMoreSuggestionsAvailable) {
|
||||
final int stripWidth = getWidth();
|
||||
final View container = mMoreSuggestionsContainer;
|
||||
final int maxWidth = stripWidth - container.getPaddingLeft()
|
||||
- container.getPaddingRight();
|
||||
final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
|
||||
builder.layout(mSuggestedWords, params.mSuggestionsCountInStrip, maxWidth,
|
||||
(int)(maxWidth * params.mMinMoreSuggestionsWidth),
|
||||
params.getMaxMoreSuggestionsRow());
|
||||
mMoreSuggestionsView.setKeyboard(builder.build());
|
||||
container.measure(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
|
||||
final int pointX = stripWidth / 2;
|
||||
final int pointY = -params.mMoreSuggestionsBottomGap;
|
||||
moreKeysPanel.showMoreKeysPanel(
|
||||
this, mMoreSuggestionsController, pointX, pointY,
|
||||
mMoreSuggestionsWindow, mMoreSuggestionsListener);
|
||||
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
|
||||
mOriginX = mLastX;
|
||||
mOriginY = mLastY;
|
||||
mKeyboardView.dimEntireKeyboard(true);
|
||||
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
|
||||
mWords.get(i).setPressed(false);
|
||||
}
|
||||
return true;
|
||||
final Keyboard parentKeyboard = KeyboardSwitcher.getInstance().getKeyboard();
|
||||
if (parentKeyboard == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
final SuggestionStripViewParams params = mParams;
|
||||
if (!params.mMoreSuggestionsAvailable) {
|
||||
return false;
|
||||
}
|
||||
final int stripWidth = getWidth();
|
||||
final View container = mMoreSuggestionsContainer;
|
||||
final int maxWidth = stripWidth - container.getPaddingLeft() - container.getPaddingRight();
|
||||
final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
|
||||
builder.layout(mSuggestedWords, params.mSuggestionsCountInStrip, maxWidth,
|
||||
(int)(maxWidth * params.mMinMoreSuggestionsWidth),
|
||||
params.getMaxMoreSuggestionsRow(), parentKeyboard);
|
||||
mMoreSuggestionsView.setKeyboard(builder.build());
|
||||
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
|
||||
final int pointX = stripWidth / 2;
|
||||
final int pointY = -params.mMoreSuggestionsBottomGap;
|
||||
moreKeysPanel.showMoreKeysPanel(this, mMoreSuggestionsController, pointX, pointY,
|
||||
mMoreSuggestionsWindow, mMoreSuggestionsListener);
|
||||
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
|
||||
mOriginX = mLastX;
|
||||
mOriginY = mLastY;
|
||||
mKeyboardView.dimEntireKeyboard(true);
|
||||
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
|
||||
mWords.get(i).setPressed(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Working variables for onLongClick and dispatchTouchEvent.
|
||||
|
|
Loading…
Reference in a new issue