am dde36ef3: Remove TextView reference from PointerTracker

* commit 'dde36ef34329164cf8b8a3985c578dab0343b3eb':
  Remove TextView reference from PointerTracker
main
Tadashi G. Takaoka 2012-08-22 01:03:19 -07:00 committed by Android Git Automerger
commit 50849d4b2d
2 changed files with 29 additions and 20 deletions

View File

@ -107,6 +107,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
// Key preview
private final int mKeyPreviewLayoutId;
private final SparseArray<TextView> mKeyPreviewTexts = CollectionUtils.newSparseArray();
protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
private boolean mShowKeyPreviewPopup = true;
private int mDelayAfterPreview;
@ -152,7 +153,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
final PointerTracker tracker = (PointerTracker) msg.obj;
switch (msg.what) {
case MSG_DISMISS_KEY_PREVIEW:
tracker.getKeyPreviewText().setVisibility(View.INVISIBLE);
final TextView previewText = keyboardView.mKeyPreviewTexts.get(tracker.mPointerId);
if (previewText != null) {
previewText.setVisibility(INVISIBLE);
}
break;
}
}
@ -165,7 +169,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
removeMessages(MSG_DISMISS_KEY_PREVIEW, tracker);
}
public void cancelAllDismissKeyPreviews() {
private void cancelAllDismissKeyPreviews() {
removeMessages(MSG_DISMISS_KEY_PREVIEW);
}
@ -907,15 +911,30 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
}
// Called by {@link PointerTracker} constructor to create a TextView.
@Override
public TextView inflateKeyPreviewText() {
private TextView getKeyPreviewText(final int pointerId) {
TextView previewText = mKeyPreviewTexts.get(pointerId);
if (previewText != null) {
return previewText;
}
final Context context = getContext();
if (mKeyPreviewLayoutId != 0) {
return (TextView)LayoutInflater.from(context).inflate(mKeyPreviewLayoutId, null);
previewText = (TextView)LayoutInflater.from(context).inflate(mKeyPreviewLayoutId, null);
} else {
return new TextView(context);
previewText = new TextView(context);
}
mKeyPreviewTexts.put(pointerId, previewText);
return previewText;
}
private void dismissAllKeyPreviews() {
final int pointerCount = mKeyPreviewTexts.size();
for (int id = 0; id < pointerCount; id++) {
final TextView previewText = mKeyPreviewTexts.get(id);
if (previewText != null) {
previewText.setVisibility(INVISIBLE);
}
}
PointerTracker.setReleasedKeyGraphicsToAllKeys();
}
@Override
@ -971,7 +990,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
public void showKeyPreview(PointerTracker tracker) {
if (!mShowKeyPreviewPopup) return;
final TextView previewText = tracker.getKeyPreviewText();
final TextView previewText = getKeyPreviewText(tracker.mPointerId);
// If the key preview has no parent view yet, add it to the ViewGroup which can place
// key preview absolutely in SoftInputWindow.
if (previewText.getParent() == null) {
@ -1082,7 +1101,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
public void closing() {
PointerTracker.dismissAllKeyPreviews();
dismissAllKeyPreviews();
cancelAllMessages();
mInvalidateAllKeys = true;

View File

@ -21,8 +21,6 @@ import android.graphics.Paint;
import android.os.SystemClock;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.keyboard.internal.GestureStroke;
@ -79,7 +77,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
public interface DrawingProxy extends MoreKeysPanel.Controller {
public void invalidateKey(Key key);
public TextView inflateKeyPreviewText();
public void showKeyPreview(PointerTracker tracker);
public void dismissKeyPreview(PointerTracker tracker);
public void showGestureTrail(PointerTracker tracker);
@ -140,7 +137,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
private Keyboard mKeyboard;
private int mKeyQuarterWidthSquared;
private final TextView mKeyPreviewText;
private boolean mIsAlphabetKeyboard;
private boolean mIsPossibleGesture = false;
@ -261,11 +257,10 @@ public class PointerTracker implements PointerTrackerQueue.Element {
updateGestureHandlingMode();
}
public static void dismissAllKeyPreviews() {
public static void setReleasedKeyGraphicsToAllKeys() {
final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
tracker.getKeyPreviewText().setVisibility(View.INVISIBLE);
tracker.setReleasedKeyGraphics(tracker.mCurrentKey);
}
}
@ -312,11 +307,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
mListener = handler.getKeyboardActionListener();
mDrawingProxy = handler.getDrawingProxy();
mTimerProxy = handler.getTimerProxy();
mKeyPreviewText = mDrawingProxy.inflateKeyPreviewText();
}
public TextView getKeyPreviewText() {
return mKeyPreviewText;
}
// Returns true if keyboard has been changed by this callback.