mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
am 4905d832
: Merge "Release and register current key when emoji palette is hidden"
* commit '4905d83270720ce9b9121595277dae6ba8102f16': Release and register current key when emoji palette is hidden
This commit is contained in:
commit
de471d02c7
@ -102,7 +102,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||||||
}
|
}
|
||||||
final Key key = getKey(e);
|
final Key key = getKey(e);
|
||||||
if (key != null && key != mCurrentKey) {
|
if (key != null && key != mCurrentKey) {
|
||||||
releaseCurrentKey();
|
releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||||||
return mKeyDetector.detectHitKey(x, y);
|
return mKeyDetector.detectHitKey(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseCurrentKey() {
|
public void releaseCurrentKey(final boolean withKeyRegistering) {
|
||||||
mHandler.removeCallbacks(mPendingKeyDown);
|
mHandler.removeCallbacks(mPendingKeyDown);
|
||||||
mPendingKeyDown = null;
|
mPendingKeyDown = null;
|
||||||
final Key currentKey = mCurrentKey;
|
final Key currentKey = mCurrentKey;
|
||||||
@ -128,13 +128,16 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||||||
}
|
}
|
||||||
currentKey.onReleased();
|
currentKey.onReleased();
|
||||||
invalidateKey(currentKey);
|
invalidateKey(currentKey);
|
||||||
|
if (withKeyRegistering) {
|
||||||
|
mListener.onReleaseKey(currentKey);
|
||||||
|
}
|
||||||
mCurrentKey = null;
|
mCurrentKey = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDown(final MotionEvent e) {
|
public boolean onDown(final MotionEvent e) {
|
||||||
final Key key = getKey(e);
|
final Key key = getKey(e);
|
||||||
releaseCurrentKey();
|
releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
mCurrentKey = key;
|
mCurrentKey = key;
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -163,7 +166,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||||||
final Key key = getKey(e);
|
final Key key = getKey(e);
|
||||||
final Runnable pendingKeyDown = mPendingKeyDown;
|
final Runnable pendingKeyDown = mPendingKeyDown;
|
||||||
final Key currentKey = mCurrentKey;
|
final Key currentKey = mCurrentKey;
|
||||||
releaseCurrentKey();
|
releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -189,14 +192,14 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||||||
@Override
|
@Override
|
||||||
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
|
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
|
||||||
final float distanceY) {
|
final float distanceY) {
|
||||||
releaseCurrentKey();
|
releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX,
|
public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX,
|
||||||
final float velocityY) {
|
final float velocityY) {
|
||||||
releaseCurrentKey();
|
releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,18 @@ final class EmojiPalettesAdapter extends PagerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onPageScrolled() {
|
public void onPageScrolled() {
|
||||||
|
releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void releaseCurrentKey(final boolean withKeyRegistering) {
|
||||||
// Make sure the delayed key-down event (highlight effect and haptic feedback) will be
|
// Make sure the delayed key-down event (highlight effect and haptic feedback) will be
|
||||||
// canceled.
|
// canceled.
|
||||||
final EmojiPageKeyboardView currentKeyboardView =
|
final EmojiPageKeyboardView currentKeyboardView =
|
||||||
mActiveKeyboardViews.get(mActivePosition);
|
mActiveKeyboardViews.get(mActivePosition);
|
||||||
if (currentKeyboardView != null) {
|
if (currentKeyboardView == null) {
|
||||||
currentKeyboardView.releaseCurrentKey();
|
return;
|
||||||
}
|
}
|
||||||
|
currentKeyboardView.releaseCurrentKey(withKeyRegistering);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,7 +95,7 @@ final class EmojiPalettesAdapter extends PagerAdapter {
|
|||||||
}
|
}
|
||||||
final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(mActivePosition);
|
final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(mActivePosition);
|
||||||
if (oldKeyboardView != null) {
|
if (oldKeyboardView != null) {
|
||||||
oldKeyboardView.releaseCurrentKey();
|
oldKeyboardView.releaseCurrentKey(false /* withKeyRegistering */);
|
||||||
oldKeyboardView.deallocateMemory();
|
oldKeyboardView.deallocateMemory();
|
||||||
}
|
}
|
||||||
mActivePosition = position;
|
mActivePosition = position;
|
||||||
|
@ -380,6 +380,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stopEmojiPalettes() {
|
public void stopEmojiPalettes() {
|
||||||
|
mEmojiPalettesAdapter.releaseCurrentKey(true /* withKeyRegistering */);
|
||||||
mEmojiPalettesAdapter.flushPendingRecentKeys();
|
mEmojiPalettesAdapter.flushPendingRecentKeys();
|
||||||
mEmojiPager.setAdapter(null);
|
mEmojiPager.setAdapter(null);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user