Remove TextView reference from PointerTracker
Change-Id: If8e65c08ec97f6d57932c9e3412d6fe17b0994eamain
parent
ecfbf4625c
commit
dde36ef343
|
@ -107,6 +107,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
|
|
||||||
// Key preview
|
// Key preview
|
||||||
private final int mKeyPreviewLayoutId;
|
private final int mKeyPreviewLayoutId;
|
||||||
|
private final SparseArray<TextView> mKeyPreviewTexts = CollectionUtils.newSparseArray();
|
||||||
protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
|
protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
|
||||||
private boolean mShowKeyPreviewPopup = true;
|
private boolean mShowKeyPreviewPopup = true;
|
||||||
private int mDelayAfterPreview;
|
private int mDelayAfterPreview;
|
||||||
|
@ -152,7 +153,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
final PointerTracker tracker = (PointerTracker) msg.obj;
|
final PointerTracker tracker = (PointerTracker) msg.obj;
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_DISMISS_KEY_PREVIEW:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +169,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
removeMessages(MSG_DISMISS_KEY_PREVIEW, tracker);
|
removeMessages(MSG_DISMISS_KEY_PREVIEW, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelAllDismissKeyPreviews() {
|
private void cancelAllDismissKeyPreviews() {
|
||||||
removeMessages(MSG_DISMISS_KEY_PREVIEW);
|
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.
|
private TextView getKeyPreviewText(final int pointerId) {
|
||||||
@Override
|
TextView previewText = mKeyPreviewTexts.get(pointerId);
|
||||||
public TextView inflateKeyPreviewText() {
|
if (previewText != null) {
|
||||||
|
return previewText;
|
||||||
|
}
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (mKeyPreviewLayoutId != 0) {
|
if (mKeyPreviewLayoutId != 0) {
|
||||||
return (TextView)LayoutInflater.from(context).inflate(mKeyPreviewLayoutId, null);
|
previewText = (TextView)LayoutInflater.from(context).inflate(mKeyPreviewLayoutId, null);
|
||||||
} else {
|
} 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
|
@Override
|
||||||
|
@ -971,7 +990,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
public void showKeyPreview(PointerTracker tracker) {
|
public void showKeyPreview(PointerTracker tracker) {
|
||||||
if (!mShowKeyPreviewPopup) return;
|
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
|
// If the key preview has no parent view yet, add it to the ViewGroup which can place
|
||||||
// key preview absolutely in SoftInputWindow.
|
// key preview absolutely in SoftInputWindow.
|
||||||
if (previewText.getParent() == null) {
|
if (previewText.getParent() == null) {
|
||||||
|
@ -1082,7 +1101,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closing() {
|
public void closing() {
|
||||||
PointerTracker.dismissAllKeyPreviews();
|
dismissAllKeyPreviews();
|
||||||
cancelAllMessages();
|
cancelAllMessages();
|
||||||
|
|
||||||
mInvalidateAllKeys = true;
|
mInvalidateAllKeys = true;
|
||||||
|
|
|
@ -21,8 +21,6 @@ import android.graphics.Paint;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
import com.android.inputmethod.keyboard.internal.GestureStroke;
|
import com.android.inputmethod.keyboard.internal.GestureStroke;
|
||||||
|
@ -79,7 +77,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
|
|
||||||
public interface DrawingProxy extends MoreKeysPanel.Controller {
|
public interface DrawingProxy extends MoreKeysPanel.Controller {
|
||||||
public void invalidateKey(Key key);
|
public void invalidateKey(Key key);
|
||||||
public TextView inflateKeyPreviewText();
|
|
||||||
public void showKeyPreview(PointerTracker tracker);
|
public void showKeyPreview(PointerTracker tracker);
|
||||||
public void dismissKeyPreview(PointerTracker tracker);
|
public void dismissKeyPreview(PointerTracker tracker);
|
||||||
public void showGestureTrail(PointerTracker tracker);
|
public void showGestureTrail(PointerTracker tracker);
|
||||||
|
@ -140,7 +137,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
|
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
private int mKeyQuarterWidthSquared;
|
private int mKeyQuarterWidthSquared;
|
||||||
private final TextView mKeyPreviewText;
|
|
||||||
|
|
||||||
private boolean mIsAlphabetKeyboard;
|
private boolean mIsAlphabetKeyboard;
|
||||||
private boolean mIsPossibleGesture = false;
|
private boolean mIsPossibleGesture = false;
|
||||||
|
@ -261,11 +257,10 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
updateGestureHandlingMode();
|
updateGestureHandlingMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dismissAllKeyPreviews() {
|
public static void setReleasedKeyGraphicsToAllKeys() {
|
||||||
final int trackersSize = sTrackers.size();
|
final int trackersSize = sTrackers.size();
|
||||||
for (int i = 0; i < trackersSize; ++i) {
|
for (int i = 0; i < trackersSize; ++i) {
|
||||||
final PointerTracker tracker = sTrackers.get(i);
|
final PointerTracker tracker = sTrackers.get(i);
|
||||||
tracker.getKeyPreviewText().setVisibility(View.INVISIBLE);
|
|
||||||
tracker.setReleasedKeyGraphics(tracker.mCurrentKey);
|
tracker.setReleasedKeyGraphics(tracker.mCurrentKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,11 +307,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
mListener = handler.getKeyboardActionListener();
|
mListener = handler.getKeyboardActionListener();
|
||||||
mDrawingProxy = handler.getDrawingProxy();
|
mDrawingProxy = handler.getDrawingProxy();
|
||||||
mTimerProxy = handler.getTimerProxy();
|
mTimerProxy = handler.getTimerProxy();
|
||||||
mKeyPreviewText = mDrawingProxy.inflateKeyPreviewText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextView getKeyPreviewText() {
|
|
||||||
return mKeyPreviewText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if keyboard has been changed by this callback.
|
// Returns true if keyboard has been changed by this callback.
|
||||||
|
|
Loading…
Reference in New Issue