rename more keys to popup keys

user-facing name is already popup keys, now internal rename is done to avoid confusion and for consistency
This commit is contained in:
Helium314 2024-02-05 09:33:06 +01:00
parent e708c026bc
commit 26809444bd
237 changed files with 1291 additions and 1305 deletions

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á â ä à æ ã å ā
e é è ê ë ę ė ē
i í ì ï î į ī ij

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á â ä à ã æ å ā ą ª ă ả ạ ằ ắ ẳ ẵ ặ ầ ấ ẩ ẫ ậ
e é è ê ë ē ė ę ě ə ẻ ẽ ẹ ề ế ể ễ ệ ĕ
i í ì ï î ī į ı ij ĩ ỉ ị ĭ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ق ڨ
ف ڤ ڢ ڥ
ه |ه

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a â ä á
e ə é
i ı î ï ì í į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
е ё
ь ъ
'

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
и ѝ
[labels]

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ঙ ং %
য য় %
ড ঢ %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ব ভ %
গ ঘ %
দ ধ %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á ä â ã å ą æ ā ª
e è é ë ê ę ė ē
i í ï ì î į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á à â ä æ ã å ā
e é ě è ê ë ę ė ē
i í î ï ì į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a å æ á ä à â ã ā
e é ë
i í ï

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ä â à á æ ã å ā
e é è ê ë ė
o ö ô ò ó õ œ ø ō

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ä â à á æ ã å ā
e é è ê ë ė
o ö ô ò ó õ œ ø ō

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ä % â à á æ ã å ā
e é è ê ë ė
o ö % ô ò ó õ œ ø ō

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ε έ %
υ ύ % ϋ ΰ
ι ί % ϊ ΐ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á â ä æ ã å ā
e é è ê ë ē
i í î ï ī ì

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á à â ä æ ã å ā ă ą ª
e é ě è ê ë ę ė ē
i í î ï ĩ ì į ī ı ij

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á à ä â ã å ą æ ā ª
e é è ë ê ę ė ē
i í ï ì î į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ä ā à á â ã å æ ą
e ē è ė é ê ë ę ě
i ī ì į í î ï ı

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á à ä â ã å ą æ ā ª
e é è ë ê ę ė ē
i í ï ì î į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ه |ه هٔ ة
ی ئ ي ﯨ|ى
ا !fixedColumnOrder!5 ٱ ء آ أ إ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ä å æ à á â ã ā
o ö ø ô ò ó õ œ ō
u ü

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à â % æ á ä ã å ā ª
e é è ê ë % ę ė ē
i î % ï ì í į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á à ä â ã å ą æ ā ª
e é è ë ê ę ė ē
i í ï ì î į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á â ä æ ã å ā
e é è ê ë ē
i í î ï ī ì

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
औ ऒं
ऐ ऐं
आ आं आँ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
s š ś ß
n ñ ń
z ž ź ż

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á
e é
i í

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
punctuation !autoColumnOrder!8 \, ՞ ՜ … ' = / ՝ ՛ ֊ » « ― ) (
? ՞ ¿
! ՜ ¡

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á ä æ å à â ã ā
e é ë è ê ę ė ē
i í ï î ì į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á â ä æ ã å ā ª
e è é ê ë ę ė ē ə
i ì í î ï į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
+ ﬩
ג ג׳
י ײַ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ე ჱ
ი ჲ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ɛ
z ẓ
r ṛ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
у ү ұ
к қ
е ё

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
! !icon/zwj_key|
ៗ !icon/zwnj_key|
" ៑

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ೌ ಔ ೧ %
ೈ ಐ ೨ %
ಾ ಆ ೩ %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
у ү
е ё
н ң

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ą ä ā à á â ã å æ
e ė ę ē è é ê ë ě
i į ī ì í î ï ı

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ā à á â ã ä å æ ą
e ē ė è é ê ë ę ě
i ī į ì í î ï ı

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
е ѐ
и ѝ
'

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
് അ %
ാ ആ %
ി ഇ %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ш щ
ё е
ь ъ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á â ä à ã æ å ā ą ª ă
e é è ê ë ē ė ę ě ə
i í ì ï î ī į ı ij ĩ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ौ औ %
ै ऐ %
ा आ %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
punctuation !autoColumnOrder!9 ၊ . ? ! # ) ( / ; ... ' @ : - " + \% &
[labels]

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a å æ ä à á â ã ā
e é è ê ë ę ė ē
o ø ö ô ò ó õ œ ō

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ट ़
् ऽ
punctuation !autoColumnOrder!9 . \, ? ! # ) ( / ; ' @ : - " + \% &

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á ä â à æ ã å ā
e é ë ê è ę ė ē
i í ï ì î į ī ij

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ą á à â ä æ ã å ā
e ę è é ê ë ė ē
o ó ö ô ò õ œ ø ō

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á ã à â ä å æ ª
e é ê è ę ė ē ë
i í î ì ï į ī

View file

@ -1,2 +1,2 @@
[morekeys]
[popup_keys]
o ò ó ö ô õ œ ø

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ă â ã à á ä æ å ā
i î ï ì í į ī
s ș ß ś š

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
е ё
ь ъ
'

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ඥ ෴
ද ඳ
ඤ ෴

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á ä ā à â ã å æ ą
e é ě ē ė è ê ë ę
i í ī į ì î ï ı

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
s š
c č ć
d đ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
e è
i ì
s š %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
е ѐ
и ѝ
'

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a ä å æ á à â ą ã
c ç ć č
d ð ď

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á â ä æ ã å ā
e è é ê ë ē
i î ï í ī ì

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ஔ ௌ %
ஐ ை %
ஆ ா %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
ౌ ఔ %
ై ఐ %
ా ఆ %

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a á à ä â ã å ą æ ā ª
e é è ë ê ę ė ē
i í ï ì î į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a â ä á
e ə é
i ı î ï ì í į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
г ґ
ь ъ
і ї

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
و ؤ
ر ڑ
ت ٹ

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a â ä á
e ə é
i ı î ï ì í į ī

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á ả ã ạ ă ằ ắ ẳ ẵ ặ â ầ ấ ẩ ẫ ậ
e è é ẻ ẽ ẹ ê ề ế ể ễ ệ
i ì í ỉ ĩ ị

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á â ä æ ã å ā
e é è ê ë ē
i í î ï ī ì

View file

@ -1,4 +1,4 @@
[morekeys]
[popup_keys]
a à á â ã ä å æ ā ă ą ª
e è é ê ë ē ĕ ė ę ě
i ì í î ï ĩ ī ĭ į ı ij

View file

@ -40,7 +40,7 @@
"date": { "label": "/" },
"time": { "label": ":" },
"datetime": { "label": "/ :|/", "popup": { "relevant": [
{ "label": "!noPanelAutoMoreKey!" },
{ "label": "!noPanelAutoPopupKey!" },
{ "label": "," }
] } }
},

View file

@ -19,7 +19,7 @@
],
[
{ "label": "|!code/key_switch_alpha_symbol", "labelFlags": 524432 },
{ "label": "0 +|0", "type": "numeric", "popup": { "relevant": [ { "label": "!noPanelAutoMoreKey!" }, { "label": "+" } ] } },
{ "label": "0 +|0", "type": "numeric", "popup": { "relevant": [ { "label": "!noPanelAutoPopupKey!" }, { "label": "+" } ] } },
{ "label": "." },
{ "label": "action" }
]

View file

@ -66,7 +66,7 @@ public class ProximityInfo {
mSortedKeys = sortedKeys;
mGridNeighbors = new List[mGridSize];
if (minWidth == 0 || height == 0) {
// No proximity required. Keyboard might be more keys keyboard.
// No proximity required. Keyboard might be popup keys keyboard.
return;
}
computeNearestNeighbors();

View file

@ -12,7 +12,7 @@ import android.os.Message
import helium314.keyboard.keyboard.Key
import helium314.keyboard.latin.R
// Handling long press timer to show a more keys keyboard.
// Handling long press timer to show a popup keys keyboard.
internal class AccessibilityLongPressTimer(private val mCallback: LongPressTimerCallback,
context: Context) : Handler() {
interface LongPressTimerCallback {

View file

@ -221,12 +221,12 @@ class MainKeyboardAccessibilityDelegate(
downEvent.recycle()
// Invoke {@link PointerTracker#onLongPressed()} as if a long press timeout has passed.
tracker.onLongPressed()
// If {@link Key#hasNoPanelAutoMoreKeys()} is true (such as "0 +" key on the phone layout)
// If {@link Key#hasNoPanelAutoPopupKeys()} is true (such as "0 +" key on the phone layout)
// or a key invokes IME switcher dialog, we should just ignore the next
// {@link #onRegisterHoverKey(Key,MotionEvent)}. It can be determined by whether
// {@link PointerTracker} is in operation or not.
if (tracker.isInOperation) {
// This long press shows a more keys keyboard and further hover events should be
// This long press shows a popup keys keyboard and further hover events should be
// handled.
mBoundsToIgnoreHoverEvent.setEmpty()
return
@ -234,12 +234,12 @@ class MainKeyboardAccessibilityDelegate(
// This long press has handled at {@link MainKeyboardView#onLongPress(PointerTracker)}.
// We should ignore further hover events on this key.
mBoundsToIgnoreHoverEvent.set(key.hitBox)
if (key.hasNoPanelAutoMoreKey()) {
// This long press has registered a code point without showing a more keys keyboard.
if (key.hasNoPanelAutoPopupKey()) {
// This long press has registered a code point without showing a popup keys keyboard.
// We should talk back the code point if possible.
val codePointOfNoPanelAutoMoreKey = key.moreKeys?.get(0)?.mCode ?: return
val codePointOfNoPanelAutoPopupKey = key.popupKeys?.get(0)?.mCode ?: return
val text: String = KeyCodeDescriptionMapper.instance.getDescriptionForCodePoint(
mKeyboardView.context, codePointOfNoPanelAutoMoreKey) ?: return
mKeyboardView.context, codePointOfNoPanelAutoPopupKey) ?: return
sendWindowStateChanged(text)
}
}

View file

@ -10,18 +10,18 @@ import android.graphics.Rect
import helium314.keyboard.latin.utils.Log
import android.view.MotionEvent
import helium314.keyboard.keyboard.KeyDetector
import helium314.keyboard.keyboard.MoreKeysKeyboardView
import helium314.keyboard.keyboard.PopupKeysKeyboardView
import helium314.keyboard.keyboard.PointerTracker
/**
* This class represents a delegate that can be registered in [MoreKeysKeyboardView] to
* This class represents a delegate that can be registered in [PopupKeysKeyboardView] to
* enhance accessibility support via composition rather via inheritance.
*/
class MoreKeysKeyboardAccessibilityDelegate(
moreKeysKeyboardView: MoreKeysKeyboardView,
class PopupKeysKeyboardAccessibilityDelegate(
popupKeysKeyboardView: PopupKeysKeyboardView,
keyDetector: KeyDetector
) : KeyboardAccessibilityDelegate<MoreKeysKeyboardView>(moreKeysKeyboardView, keyDetector) {
private val mMoreKeysKeyboardValidBounds = Rect()
) : KeyboardAccessibilityDelegate<PopupKeysKeyboardView>(popupKeysKeyboardView, keyDetector) {
private val mPopupKeysKeyboardValidBounds = Rect()
private var mOpenAnnounceResId = 0
private var mCloseAnnounceResId = 0
fun setOpenAnnounce(resId: Int) {
@ -32,11 +32,11 @@ class MoreKeysKeyboardAccessibilityDelegate(
mCloseAnnounceResId = resId
}
fun onShowMoreKeysKeyboard() {
fun onShowPopupKeysKeyboard() {
sendWindowStateChanged(mOpenAnnounceResId)
}
fun onDismissMoreKeysKeyboard() {
fun onDismissPopupKeysKeyboard() {
sendWindowStateChanged(mCloseAnnounceResId)
}
@ -77,27 +77,27 @@ class MoreKeysKeyboardAccessibilityDelegate(
val y = event.getY(actionIndex).toInt()
val pointerId = event.getPointerId(actionIndex)
val eventTime = event.eventTime
// A hover exit event at one pixel width or height area on the edges of more keys keyboard
// A hover exit event at one pixel width or height area on the edges of popup keys keyboard
// are treated as closing.
mMoreKeysKeyboardValidBounds[0, 0, mKeyboardView.width] = mKeyboardView.height
mMoreKeysKeyboardValidBounds.inset(CLOSING_INSET_IN_PIXEL, CLOSING_INSET_IN_PIXEL)
if (mMoreKeysKeyboardValidBounds.contains(x, y)) {
// Invoke {@link MoreKeysKeyboardView#onUpEvent(int,int,int,long)} as if this hover
mPopupKeysKeyboardValidBounds[0, 0, mKeyboardView.width] = mKeyboardView.height
mPopupKeysKeyboardValidBounds.inset(CLOSING_INSET_IN_PIXEL, CLOSING_INSET_IN_PIXEL)
if (mPopupKeysKeyboardValidBounds.contains(x, y)) {
// Invoke {@link PopupKeysKeyboardView#onUpEvent(int,int,int,long)} as if this hover
// exit event selects a key.
mKeyboardView.onUpEvent(x, y, pointerId, eventTime)
// TODO: Should fix this reference. This is a hack to clear the state of
// {@link PointerTracker}.
PointerTracker.dismissAllMoreKeysPanels()
PointerTracker.dismissAllPopupKeysPanels()
return
}
// Close the more keys keyboard.
// Close the popup keys keyboard.
// TODO: Should fix this reference. This is a hack to clear the state of
// {@link PointerTracker}.
PointerTracker.dismissAllMoreKeysPanels()
PointerTracker.dismissAllPopupKeysPanels()
}
companion object {
private val TAG = MoreKeysKeyboardAccessibilityDelegate::class.java.simpleName
private val TAG = PopupKeysKeyboardAccessibilityDelegate::class.java.simpleName
private const val CLOSING_INSET_IN_PIXEL = 1
}
}

View file

@ -16,11 +16,11 @@ import helium314.keyboard.keyboard.internal.KeySpecParser;
import helium314.keyboard.keyboard.internal.KeyVisualAttributes;
import helium314.keyboard.keyboard.internal.KeyboardIconsSet;
import helium314.keyboard.keyboard.internal.KeyboardParams;
import helium314.keyboard.keyboard.internal.MoreKeySpec;
import helium314.keyboard.keyboard.internal.PopupKeySpec;
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.PopupSet;
import helium314.keyboard.latin.common.Constants;
import helium314.keyboard.latin.common.StringUtils;
import helium314.keyboard.latin.utils.MoreKeysUtilsKt;
import helium314.keyboard.latin.utils.PopupKeysUtilsKt;
import java.util.Arrays;
import java.util.Locale;
@ -81,7 +81,7 @@ public class Key implements Comparable<Key> {
public static final int LABEL_FLAGS_FOLLOW_FUNCTIONAL_TEXT_COLOR = 0x80000;
public static final int LABEL_FLAGS_KEEP_BACKGROUND_ASPECT_RATIO = 0x100000;
public static final int LABEL_FLAGS_DISABLE_HINT_LABEL = 0x40000000;
public static final int LABEL_FLAGS_DISABLE_ADDITIONAL_MORE_KEYS = 0x80000000;
public static final int LABEL_FLAGS_DISABLE_ADDITIONAL_POPUP_KEYS = 0x80000000;
/** Icon to display instead of a label. Icon takes precedence over a label */
private final int mIconId;
@ -108,33 +108,31 @@ public class Key implements Comparable<Key> {
@NonNull
private final Rect mHitBox = new Rect();
/** More keys. It is guaranteed that this is null or an array of one or more elements */
/** Popup keys. It is guaranteed that this is null or an array of one or more elements */
@Nullable
private final MoreKeySpec[] mMoreKeys;
/** More keys column number and flags */
private final int mMoreKeysColumnAndFlags;
private static final int MORE_KEYS_COLUMN_NUMBER_MASK = 0x000000ff;
// If this flag is specified, more keys keyboard should have the specified number of columns.
// Otherwise more keys keyboard should have less than or equal to the specified maximum number
private final PopupKeySpec[] mPopupKeys;
/** Popup keys column number and flags */
private final int mPopupKeysColumnAndFlags;
private static final int POPUP_KEYS_COLUMN_NUMBER_MASK = 0x000000ff;
// If this flag is specified, popup keys keyboard should have the specified number of columns.
// Otherwise popup keys keyboard should have less than or equal to the specified maximum number
// of columns.
private static final int MORE_KEYS_FLAGS_FIXED_COLUMN = 0x00000100;
// If this flag is specified, the order of more keys is determined by the order in the more
// keys' specification. Otherwise the order of more keys is automatically determined.
private static final int MORE_KEYS_FLAGS_FIXED_ORDER = 0x00000200;
private static final int MORE_KEYS_MODE_MAX_COLUMN_WITH_AUTO_ORDER = 0;
private static final int MORE_KEYS_MODE_FIXED_COLUMN_WITH_AUTO_ORDER =
MORE_KEYS_FLAGS_FIXED_COLUMN;
private static final int MORE_KEYS_MODE_FIXED_COLUMN_WITH_FIXED_ORDER =
(MORE_KEYS_FLAGS_FIXED_COLUMN | MORE_KEYS_FLAGS_FIXED_ORDER);
private static final int MORE_KEYS_FLAGS_HAS_LABELS = 0x40000000;
private static final int MORE_KEYS_FLAGS_NEEDS_DIVIDERS = 0x20000000;
private static final int MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY = 0x10000000;
private static final int POPUP_KEYS_FLAGS_FIXED_COLUMN = 0x00000100;
// If this flag is specified, the order of popup keys is determined by the order in the popup
// keys' specification. Otherwise the order of popup keys is automatically determined.
private static final int POPUP_KEYS_FLAGS_FIXED_ORDER = 0x00000200;
private static final int POPUP_KEYS_MODE_MAX_COLUMN_WITH_AUTO_ORDER = 0;
private static final int POPUP_KEYS_MODE_FIXED_COLUMN_WITH_AUTO_ORDER = POPUP_KEYS_FLAGS_FIXED_COLUMN;
private static final int POPUP_KEYS_MODE_FIXED_COLUMN_WITH_FIXED_ORDER = (POPUP_KEYS_FLAGS_FIXED_COLUMN | POPUP_KEYS_FLAGS_FIXED_ORDER);
private static final int POPUP_KEYS_FLAGS_HAS_LABELS = 0x40000000;
private static final int POPUP_KEYS_FLAGS_NEEDS_DIVIDERS = 0x20000000;
private static final int POPUP_KEYS_FLAGS_NO_PANEL_AUTO_POPUP_KEY = 0x10000000;
// TODO: Rename these specifiers to !autoOrder! and !fixedOrder! respectively.
public static final String MORE_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
public static final String MORE_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
public static final String MORE_KEYS_HAS_LABELS = "!hasLabels!";
private static final String MORE_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
private static final String MORE_KEYS_NO_PANEL_AUTO_MORE_KEY = "!noPanelAutoMoreKey!";
public static final String POPUP_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
public static final String POPUP_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
public static final String POPUP_KEYS_HAS_LABELS = "!hasLabels!";
private static final String POPUP_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
private static final String POPUP_KEYS_NO_PANEL_AUTO_POPUP_KEY = "!noPanelAutoPopupKey!";
/** Background type that represents different key background visual than normal one. */
private final int mBackgroundType;
@ -197,7 +195,7 @@ public class Key implements Comparable<Key> {
private boolean mEnabled = true;
/**
* Constructor for a key on <code>MoreKeyKeyboard</code> and on <code>MoreSuggestions</code>.
* Constructor for a key on <code>PopupKeyKeyboard</code> and on <code>MoreSuggestions</code>.
*/
public Key(@Nullable final String label, final int iconId, final int code,
@Nullable final String outputText, @Nullable final String hintLabel,
@ -212,8 +210,8 @@ public class Key implements Comparable<Key> {
mBackgroundType = backgroundType;
// TODO: Pass keyActionFlags as an argument.
mActionFlags = ACTION_FLAGS_NO_KEY_PREVIEW;
mMoreKeys = null;
mMoreKeysColumnAndFlags = 0;
mPopupKeys = null;
mPopupKeysColumnAndFlags = 0;
mLabel = label;
mOptionalAttributes = OptionalAttributes.newInstance(outputText, CODE_UNSPECIFIED,
ICON_UNDEFINED, 0 /* visualInsetsLeft */, 0 /* visualInsetsRight */);
@ -233,11 +231,11 @@ public class Key implements Comparable<Key> {
* Copy constructor for DynamicGridKeyboard.GridKey.
*
* @param key the original key.
* @param moreKeys the more keys that should be assigned to this key.
* @param popupKeys the popup keys that should be assigned to this key.
* @param labelHint the label hint that should be assigned to this key.
* @param backgroundType the background type that should be assigned to this key.
*/
protected Key(@NonNull final Key key, @Nullable final MoreKeySpec[] moreKeys,
protected Key(@NonNull final Key key, @Nullable final PopupKeySpec[] popupKeys,
@Nullable final String labelHint, final int backgroundType) {
// Final attributes.
mCode = key.mCode;
@ -252,8 +250,8 @@ public class Key implements Comparable<Key> {
mX = key.mX;
mY = key.mY;
mHitBox.set(key.mHitBox);
mMoreKeys = moreKeys;
mMoreKeysColumnAndFlags = key.mMoreKeysColumnAndFlags;
mPopupKeys = popupKeys;
mPopupKeysColumnAndFlags = key.mPopupKeysColumnAndFlags;
mBackgroundType = backgroundType;
mActionFlags = key.mActionFlags;
mKeyVisualAttributes = key.mKeyVisualAttributes;
@ -265,7 +263,7 @@ public class Key implements Comparable<Key> {
}
/** constructor for creating emoji recent keys when there is no keyboard to take keys from */
public Key(@NonNull final Key key, @Nullable final MoreKeySpec[] moreKeys,
public Key(@NonNull final Key key, @Nullable final PopupKeySpec[] popupKeys,
@Nullable final String labelHint, final int backgroundType, final int code, @Nullable final String outputText) {
// Final attributes.
mCode = outputText == null ? code : CODE_OUTPUT_TEXT;
@ -280,8 +278,8 @@ public class Key implements Comparable<Key> {
mX = key.mX;
mY = key.mY;
mHitBox.set(key.mHitBox);
mMoreKeys = moreKeys;
mMoreKeysColumnAndFlags = key.mMoreKeysColumnAndFlags;
mPopupKeys = popupKeys;
mPopupKeysColumnAndFlags = key.mPopupKeysColumnAndFlags;
mBackgroundType = backgroundType;
mActionFlags = key.mActionFlags;
mKeyVisualAttributes = key.mKeyVisualAttributes;
@ -300,8 +298,8 @@ public class Key implements Comparable<Key> {
mHintLabel = keyParams.mHintLabel;
mLabelFlags = keyParams.mLabelFlags;
mIconId = keyParams.mIconId;
mMoreKeys = keyParams.mMoreKeys;
mMoreKeysColumnAndFlags = keyParams.mMoreKeysColumnAndFlags;
mPopupKeys = keyParams.mPopupKeys;
mPopupKeysColumnAndFlags = keyParams.mPopupKeysColumnAndFlags;
mBackgroundType = keyParams.mBackgroundType;
mActionFlags = keyParams.mActionFlags;
mKeyVisualAttributes = keyParams.mKeyVisualAttributes;
@ -328,7 +326,7 @@ public class Key implements Comparable<Key> {
mHashCode = computeHashCode(this);
}
private Key(@NonNull final Key key, @Nullable final MoreKeySpec[] moreKeys) {
private Key(@NonNull final Key key, @Nullable final PopupKeySpec[] popupKeys) {
// Final attributes.
mCode = key.mCode;
mLabel = key.mLabel;
@ -342,10 +340,10 @@ public class Key implements Comparable<Key> {
mX = key.mX;
mY = key.mY;
mHitBox.set(key.mHitBox);
mMoreKeys = moreKeys;
mMoreKeysColumnAndFlags = key.mMoreKeysColumnAndFlags;
mPopupKeys = popupKeys;
mPopupKeysColumnAndFlags = key.mPopupKeysColumnAndFlags;
mBackgroundType = key.mBackgroundType;
if (moreKeys == null && mCode > Constants.CODE_SPACE && (key.mActionFlags & ACTION_FLAGS_ENABLE_LONG_PRESS) != 0)
if (popupKeys == null && mCode > Constants.CODE_SPACE && (key.mActionFlags & ACTION_FLAGS_ENABLE_LONG_PRESS) != 0)
mActionFlags = key.mActionFlags - ACTION_FLAGS_ENABLE_LONG_PRESS;
else
mActionFlags = key.mActionFlags;
@ -358,12 +356,12 @@ public class Key implements Comparable<Key> {
}
@NonNull
public static Key removeRedundantMoreKeys(@NonNull final Key key,
@NonNull final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout) {
final MoreKeySpec[] moreKeys = key.getMoreKeys();
final MoreKeySpec[] filteredMoreKeys = MoreKeySpec.removeRedundantMoreKeys(
moreKeys, lettersOnBaseLayout);
return (filteredMoreKeys == moreKeys) ? key : new Key(key, filteredMoreKeys);
public static Key removeRedundantPopupKeys(@NonNull final Key key,
@NonNull final PopupKeySpec.LettersOnBaseLayout lettersOnBaseLayout) {
final PopupKeySpec[] popupKeys = key.getPopupKeys();
final PopupKeySpec[] filteredPopupKeys = PopupKeySpec.removeRedundantPopupKeys(
popupKeys, lettersOnBaseLayout);
return (filteredPopupKeys == popupKeys) ? key : new Key(key, filteredPopupKeys);
}
private static boolean needsToUpcase(final int labelFlags, final int keyboardElementId) {
@ -386,7 +384,7 @@ public class Key implements Comparable<Key> {
key.mHintLabel,
key.mIconId,
key.mBackgroundType,
Arrays.hashCode(key.mMoreKeys),
Arrays.hashCode(key.mPopupKeys),
key.getOutputText(),
key.mActionFlags,
key.mLabelFlags,
@ -398,7 +396,7 @@ public class Key implements Comparable<Key> {
// key.mVerticalGap,
// key.mOptionalAttributes.mVisualInsetLeft,
// key.mOptionalAttributes.mVisualInsetRight,
// key.mMaxMoreKeysColumn,
// key.mMaxPopupKeysColumn,
});
}
@ -413,7 +411,7 @@ public class Key implements Comparable<Key> {
&& TextUtils.equals(o.mHintLabel, mHintLabel)
&& o.mIconId == mIconId
&& o.mBackgroundType == mBackgroundType
&& Arrays.equals(o.mMoreKeys, mMoreKeys)
&& Arrays.equals(o.mPopupKeys, mPopupKeys)
&& TextUtils.equals(o.getOutputText(), getOutputText())
&& o.mActionFlags == mActionFlags
&& o.mLabelFlags == mLabelFlags;
@ -486,8 +484,8 @@ public class Key implements Comparable<Key> {
}
@Nullable
public MoreKeySpec[] getMoreKeys() {
return mMoreKeys;
public PopupKeySpec[] getPopupKeys() {
return mPopupKeys;
}
public void markAsLeftEdge(final KeyboardParams params) {
@ -592,8 +590,8 @@ public class Key implements Comparable<Key> {
return params.mHintLetterColor;
}
public final int selectMoreKeyTextSize(final KeyDrawParams params) {
return hasLabelsInMoreKeys() ? params.mLabelSize : params.mLetterSize;
public final int selectPopupKeyTextSize(final KeyDrawParams params) {
return hasLabelsInPopupKeys() ? params.mLabelSize : params.mLetterSize;
}
public final String getPreviewLabel() {
@ -666,35 +664,35 @@ public class Key implements Comparable<Key> {
&& !TextUtils.isEmpty(mHintLabel);
}
public final int getMoreKeysColumnNumber() {
return mMoreKeysColumnAndFlags & MORE_KEYS_COLUMN_NUMBER_MASK;
public final int getPopupKeysColumnNumber() {
return mPopupKeysColumnAndFlags & POPUP_KEYS_COLUMN_NUMBER_MASK;
}
public final boolean isMoreKeysFixedColumn() {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_FIXED_COLUMN) != 0;
public final boolean isPopupKeysFixedColumn() {
return (mPopupKeysColumnAndFlags & POPUP_KEYS_FLAGS_FIXED_COLUMN) != 0;
}
public final boolean isMoreKeysFixedOrder() {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_FIXED_ORDER) != 0;
public final boolean isPopupKeysFixedOrder() {
return (mPopupKeysColumnAndFlags & POPUP_KEYS_FLAGS_FIXED_ORDER) != 0;
}
public final boolean hasLabelsInMoreKeys() {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_HAS_LABELS) != 0;
public final boolean hasLabelsInPopupKeys() {
return (mPopupKeysColumnAndFlags & POPUP_KEYS_FLAGS_HAS_LABELS) != 0;
}
public final int getMoreKeyLabelFlags() {
final int labelSizeFlag = hasLabelsInMoreKeys()
public final int getPopupKeyLabelFlags() {
final int labelSizeFlag = hasLabelsInPopupKeys()
? LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO
: LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO;
return labelSizeFlag | LABEL_FLAGS_AUTO_X_SCALE;
}
public final boolean needsDividersInMoreKeys() {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
public final boolean needsDividersInPopupKeys() {
return (mPopupKeysColumnAndFlags & POPUP_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
}
public final boolean hasNoPanelAutoMoreKey() {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY) != 0;
public final boolean hasNoPanelAutoPopupKey() {
return (mPopupKeysColumnAndFlags & POPUP_KEYS_FLAGS_NO_PANEL_AUTO_POPUP_KEY) != 0;
}
@Nullable
@ -945,7 +943,7 @@ public class Key implements Comparable<Key> {
}
/**
* This constructor is being used only for divider in more keys keyboard.
* This constructor is being used only for divider in popup keys keyboard.
*/
protected Spacer(final KeyboardParams params, final int x, final int y, final int width,
final int height) {
@ -977,8 +975,8 @@ public class Key implements Comparable<Key> {
@Nullable public final String mHintLabel;
public final int mLabelFlags;
public final int mIconId;
@Nullable public MoreKeySpec[] mMoreKeys;
public final int mMoreKeysColumnAndFlags;
@Nullable public PopupKeySpec[] mPopupKeys;
public final int mPopupKeysColumnAndFlags;
public int mBackgroundType;
public final int mActionFlags;
@Nullable public final KeyVisualAttributes mKeyVisualAttributes;
@ -1003,7 +1001,7 @@ public class Key implements Comparable<Key> {
if (!isSpacer && mRelativeWidth == 0)
mRelativeWidth = mKeyboardParams.mDefaultRelativeKeyWidth;
if (mRelativeHeight < 0)
// todo (later): deal with it properly when it needs to be adjusted, i.e. when changing moreKeys or moreSuggestions
// todo (later): deal with it properly when it needs to be adjusted, i.e. when changing popupKeys or moreSuggestions
throw new IllegalStateException("can't (yet) deal with absolute height");
xPos = newX;
yPos = newY;
@ -1023,28 +1021,28 @@ public class Key implements Comparable<Key> {
}
}
private static int getMoreKeysColumnAndFlagsAndSetNullInArray(final KeyboardParams params, final String[] moreKeys) {
private static int getPopupKeysColumnAndFlagsAndSetNullInArray(final KeyboardParams params, final String[] popupKeys) {
// Get maximum column order number and set a relevant mode value.
int moreKeysColumnAndFlags = MORE_KEYS_MODE_MAX_COLUMN_WITH_AUTO_ORDER | params.mMaxMoreKeysKeyboardColumn;
int popupKeysColumnAndFlags = POPUP_KEYS_MODE_MAX_COLUMN_WITH_AUTO_ORDER | params.mMaxPopupKeysKeyboardColumn;
int value;
if ((value = MoreKeySpec.getIntValue(moreKeys, MORE_KEYS_AUTO_COLUMN_ORDER, -1)) > 0) {
if ((value = PopupKeySpec.getIntValue(popupKeys, POPUP_KEYS_AUTO_COLUMN_ORDER, -1)) > 0) {
// Override with fixed column order number and set a relevant mode value.
moreKeysColumnAndFlags = MORE_KEYS_MODE_FIXED_COLUMN_WITH_AUTO_ORDER | (value & MORE_KEYS_COLUMN_NUMBER_MASK);
popupKeysColumnAndFlags = POPUP_KEYS_MODE_FIXED_COLUMN_WITH_AUTO_ORDER | (value & POPUP_KEYS_COLUMN_NUMBER_MASK);
}
if ((value = MoreKeySpec.getIntValue(moreKeys, MORE_KEYS_FIXED_COLUMN_ORDER, -1)) > 0) {
if ((value = PopupKeySpec.getIntValue(popupKeys, POPUP_KEYS_FIXED_COLUMN_ORDER, -1)) > 0) {
// Override with fixed column order number and set a relevant mode value.
moreKeysColumnAndFlags = MORE_KEYS_MODE_FIXED_COLUMN_WITH_FIXED_ORDER | (value & MORE_KEYS_COLUMN_NUMBER_MASK);
popupKeysColumnAndFlags = POPUP_KEYS_MODE_FIXED_COLUMN_WITH_FIXED_ORDER | (value & POPUP_KEYS_COLUMN_NUMBER_MASK);
}
if (MoreKeySpec.getBooleanValue(moreKeys, MORE_KEYS_HAS_LABELS)) {
moreKeysColumnAndFlags |= MORE_KEYS_FLAGS_HAS_LABELS;
if (PopupKeySpec.getBooleanValue(popupKeys, POPUP_KEYS_HAS_LABELS)) {
popupKeysColumnAndFlags |= POPUP_KEYS_FLAGS_HAS_LABELS;
}
if (MoreKeySpec.getBooleanValue(moreKeys, MORE_KEYS_NEEDS_DIVIDERS)) {
moreKeysColumnAndFlags |= MORE_KEYS_FLAGS_NEEDS_DIVIDERS;
if (PopupKeySpec.getBooleanValue(popupKeys, POPUP_KEYS_NEEDS_DIVIDERS)) {
popupKeysColumnAndFlags |= POPUP_KEYS_FLAGS_NEEDS_DIVIDERS;
}
if (MoreKeySpec.getBooleanValue(moreKeys, MORE_KEYS_NO_PANEL_AUTO_MORE_KEY)) {
moreKeysColumnAndFlags |= MORE_KEYS_FLAGS_NO_PANEL_AUTO_MORE_KEY;
if (PopupKeySpec.getBooleanValue(popupKeys, POPUP_KEYS_NO_PANEL_AUTO_POPUP_KEY)) {
popupKeysColumnAndFlags |= POPUP_KEYS_FLAGS_NO_PANEL_AUTO_POPUP_KEY;
}
return moreKeysColumnAndFlags;
return popupKeysColumnAndFlags;
}
public KeyParams(
@ -1101,18 +1099,18 @@ public class Key implements Comparable<Key> {
: label;
}
// moreKeys
final String[] moreKeys = MoreKeysUtilsKt.createMoreKeysArray(popupSet, mKeyboardParams, label != null ? label : keySpec);
mMoreKeysColumnAndFlags = getMoreKeysColumnAndFlagsAndSetNullInArray(params, moreKeys);
final String[] finalMoreKeys = moreKeys == null ? null : MoreKeySpec.filterOutEmptyString(moreKeys);
if (finalMoreKeys != null) {
// popupKeys
final String[] popupKeys = PopupKeysUtilsKt.createPopupKeysArray(popupSet, mKeyboardParams, label != null ? label : keySpec);
mPopupKeysColumnAndFlags = getPopupKeysColumnAndFlagsAndSetNullInArray(params, popupKeys);
final String[] finalPopupKeys = popupKeys == null ? null : PopupKeySpec.filterOutEmptyString(popupKeys);
if (finalPopupKeys != null) {
actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS;
mMoreKeys = new MoreKeySpec[finalMoreKeys.length];
for (int i = 0; i < finalMoreKeys.length; i++) {
mMoreKeys[i] = new MoreKeySpec(finalMoreKeys[i], needsToUpcase, localeForUpcasing);
mPopupKeys = new PopupKeySpec[finalPopupKeys.length];
for (int i = 0; i < finalPopupKeys.length; i++) {
mPopupKeys[i] = new PopupKeySpec(finalPopupKeys[i], needsToUpcase, localeForUpcasing);
}
} else {
mMoreKeys = null;
mPopupKeys = null;
}
// hint label
@ -1120,7 +1118,7 @@ public class Key implements Comparable<Key> {
mHintLabel = null;
} else {
// maybe also always null for comma and period keys
final String hintLabel = MoreKeysUtilsKt.getHintLabel(popupSet, params, keySpec);
final String hintLabel = PopupKeysUtilsKt.getHintLabel(popupSet, params, keySpec);
mHintLabel = needsToUpcase
? StringUtils.toTitleCaseOfKeyLabel(hintLabel, localeForUpcasing)
: hintLabel;
@ -1191,33 +1189,33 @@ public class Key implements Comparable<Key> {
/** constructor for emoji parser */
public KeyParams(@Nullable final String label, final int code, @Nullable final String hintLabel,
@Nullable final String moreKeySpecs, final int labelFlags, final KeyboardParams params) {
@Nullable final String popupKeySpecs, final int labelFlags, final KeyboardParams params) {
mKeyboardParams = params;
mHintLabel = hintLabel;
mLabelFlags = labelFlags;
mBackgroundType = BACKGROUND_TYPE_EMPTY;
if (moreKeySpecs != null) {
String[] moreKeys = MoreKeySpec.splitKeySpecs(moreKeySpecs);
mMoreKeysColumnAndFlags = getMoreKeysColumnAndFlagsAndSetNullInArray(params, moreKeys);
if (popupKeySpecs != null) {
String[] popupKeys = PopupKeySpec.splitKeySpecs(popupKeySpecs);
mPopupKeysColumnAndFlags = getPopupKeysColumnAndFlagsAndSetNullInArray(params, popupKeys);
moreKeys = MoreKeySpec.insertAdditionalMoreKeys(moreKeys, null);
popupKeys = PopupKeySpec.insertAdditionalPopupKeys(popupKeys, null);
int actionFlags = 0;
if (moreKeys != null) {
if (popupKeys != null) {
actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS;
mMoreKeys = new MoreKeySpec[moreKeys.length];
for (int i = 0; i < moreKeys.length; i++) {
mMoreKeys[i] = new MoreKeySpec(moreKeys[i], false, Locale.getDefault());
mPopupKeys = new PopupKeySpec[popupKeys.length];
for (int i = 0; i < popupKeys.length; i++) {
mPopupKeys[i] = new PopupKeySpec(popupKeys[i], false, Locale.getDefault());
}
} else {
mMoreKeys = null;
mPopupKeys = null;
}
mActionFlags = actionFlags;
} else {
// TODO: Pass keyActionFlags as an argument.
mActionFlags = ACTION_FLAGS_NO_KEY_PREVIEW;
mMoreKeys = null;
mMoreKeysColumnAndFlags = 0;
mPopupKeys = null;
mPopupKeysColumnAndFlags = 0;
}
mLabel = label;
@ -1243,8 +1241,8 @@ public class Key implements Comparable<Key> {
mIconId = KeyboardIconsSet.ICON_UNDEFINED;
mBackgroundType = BACKGROUND_TYPE_NORMAL;
mActionFlags = ACTION_FLAGS_NO_KEY_PREVIEW;
mMoreKeys = null;
mMoreKeysColumnAndFlags = 0;
mPopupKeys = null;
mPopupKeysColumnAndFlags = 0;
mLabelFlags = LABEL_FLAGS_FONT_NORMAL;
mEnabled = true;
}
@ -1265,8 +1263,8 @@ public class Key implements Comparable<Key> {
mIconId = keyParams.mIconId;
mFullWidth = keyParams.mFullWidth;
mFullHeight = keyParams.mFullHeight;
mMoreKeys = keyParams.mMoreKeys;
mMoreKeysColumnAndFlags = keyParams.mMoreKeysColumnAndFlags;
mPopupKeys = keyParams.mPopupKeys;
mPopupKeysColumnAndFlags = keyParams.mPopupKeysColumnAndFlags;
mBackgroundType = keyParams.mBackgroundType;
mActionFlags = keyParams.mActionFlags;
mKeyVisualAttributes = keyParams.mKeyVisualAttributes;

View file

@ -67,11 +67,11 @@ public class Keyboard {
public final int mMostCommonKeyHeight;
public final int mMostCommonKeyWidth;
/** More keys keyboard template */
public final int mMoreKeysTemplate;
/** Popup keys keyboard template */
public final int mPopupKeysTemplate;
/** Maximum column for more keys keyboard */
public final int mMaxMoreKeysKeyboardColumn;
/** Maximum column for popup keys keyboard */
public final int mMaxPopupKeysKeyboardColumn;
/** List of keys in this keyboard */
@NonNull
@ -101,8 +101,8 @@ public class Keyboard {
mBaseWidth = params.mBaseWidth;
mMostCommonKeyHeight = params.mMostCommonKeyHeight;
mMostCommonKeyWidth = params.mMostCommonKeyWidth;
mMoreKeysTemplate = params.mMoreKeysTemplate;
mMaxMoreKeysKeyboardColumn = params.mMaxMoreKeysKeyboardColumn;
mPopupKeysTemplate = params.mPopupKeysTemplate;
mMaxPopupKeysKeyboardColumn = params.mMaxPopupKeysKeyboardColumn;
mKeyVisualAttributes = params.mKeyVisualAttributes;
mTopPadding = params.mTopPadding;
mVerticalGap = params.mVerticalGap;
@ -129,8 +129,8 @@ public class Keyboard {
mBaseWidth = keyboard.mBaseWidth;
mMostCommonKeyHeight = keyboard.mMostCommonKeyHeight;
mMostCommonKeyWidth = keyboard.mMostCommonKeyWidth;
mMoreKeysTemplate = keyboard.mMoreKeysTemplate;
mMaxMoreKeysKeyboardColumn = keyboard.mMaxMoreKeysKeyboardColumn;
mPopupKeysTemplate = keyboard.mPopupKeysTemplate;
mMaxPopupKeysKeyboardColumn = keyboard.mMaxPopupKeysKeyboardColumn;
mKeyVisualAttributes = keyboard.mKeyVisualAttributes;
mTopPadding = keyboard.mTopPadding;
mVerticalGap = keyboard.mVerticalGap;

View file

@ -503,11 +503,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
return mClipboardHistoryView != null && mClipboardHistoryView.isShown();
}
public boolean isShowingMoreKeysPanel() {
public boolean isShowingPopupKeysPanel() {
if (isShowingEmojiPalettes() || isShowingClipboardHistory()) {
return false;
}
return mKeyboardView.isShowingMoreKeysPanel();
return mKeyboardView.isShowingPopupKeysPanel();
}
public View getVisibleKeyboardView() {

View file

@ -37,7 +37,7 @@ import helium314.keyboard.latin.common.Constants;
import helium314.keyboard.latin.common.StringUtils;
import helium314.keyboard.latin.settings.Settings;
import helium314.keyboard.latin.suggestions.MoreSuggestions;
import helium314.keyboard.latin.suggestions.MoreSuggestionsView;
import helium314.keyboard.latin.suggestions.PopupSuggestionsView;
import helium314.keyboard.latin.utils.TypefaceUtils;
import java.util.HashSet;
@ -134,17 +134,17 @@ public class KeyboardView extends View {
final TypedArray keyboardViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
if (this instanceof EmojiPageKeyboardView || this instanceof MoreSuggestionsView)
if (this instanceof EmojiPageKeyboardView || this instanceof PopupSuggestionsView)
mKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.BACKGROUND);
else if (this instanceof MoreKeysKeyboardView)
mKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.MORE_KEYS_BACKGROUND);
else if (this instanceof PopupKeysKeyboardView)
mKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.POPUP_KEYS_BACKGROUND);
else
mKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.KEY_BACKGROUND);
mKeyBackground.getPadding(mKeyBackgroundPadding);
mFunctionalKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.FUNCTIONAL_KEY_BACKGROUND);
mSpacebarBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.SPACE_BAR_BACKGROUND);
if (this instanceof MoreKeysKeyboardView)
mActionKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.ACTION_KEY_MORE_KEYS_BACKGROUND);
if (this instanceof PopupKeysKeyboardView)
mActionKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.ACTION_KEY_POPUP_KEYS_BACKGROUND);
else
mActionKeyBackground = mColors.selectAndColorDrawable(keyboardViewAttr, ColorType.ACTION_KEY_BACKGROUND);
@ -201,8 +201,8 @@ public class KeyboardView extends View {
public void setKeyboard(@NonNull final Keyboard keyboard) {
if (keyboard instanceof MoreSuggestions) {
mColors.setBackground(this, ColorType.MORE_SUGGESTIONS_BACKGROUND);
} else if (keyboard instanceof MoreKeysKeyboard) {
mColors.setBackground(this, ColorType.MORE_KEYS_BACKGROUND);
} else if (keyboard instanceof PopupKeysKeyboard) {
mColors.setBackground(this, ColorType.POPUP_KEYS_BACKGROUND);
} else {
// actual background color/drawable is applied to main_keyboard_frame
setBackgroundColor(Color.TRANSPARENT);
@ -530,7 +530,7 @@ public class KeyboardView extends View {
drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);
}
if (key.hasPopupHint() && key.getMoreKeys() != null) {
if (key.hasPopupHint() && key.getPopupKeys() != null) {
drawKeyPopupHint(key, canvas, paint, params);
}
}
@ -637,7 +637,7 @@ public class KeyboardView extends View {
mColors.setColor(icon, ColorType.KEY_ICON); // normal key if not shifted
} else if (key.getBackgroundType() != Key.BACKGROUND_TYPE_NORMAL) {
mColors.setColor(icon, ColorType.KEY_ICON);
} else if (this instanceof MoreKeysKeyboardView) {
} else if (this instanceof PopupKeysKeyboardView) {
// set color filter for long press comma key, should not trigger anywhere else
mColors.setColor(icon, ColorType.KEY_ICON);
} else if (key.getCode() == Constants.CODE_SPACE || key.getCode() == 0x200C) {

View file

@ -38,7 +38,7 @@ import helium314.keyboard.keyboard.internal.KeyDrawParams;
import helium314.keyboard.keyboard.internal.KeyPreviewChoreographer;
import helium314.keyboard.keyboard.internal.KeyPreviewDrawParams;
import helium314.keyboard.keyboard.internal.KeyPreviewView;
import helium314.keyboard.keyboard.internal.MoreKeySpec;
import helium314.keyboard.keyboard.internal.PopupKeySpec;
import helium314.keyboard.keyboard.internal.NonDistinctMultitouchHelper;
import helium314.keyboard.keyboard.internal.SlidingKeyInputDrawingPreview;
import helium314.keyboard.keyboard.internal.TimerHandler;
@ -83,10 +83,10 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_keyPreviewLayout
* @attr ref R.styleable#MainKeyboardView_keyPreviewOffset
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardForActionLayout
* @attr ref R.styleable#MainKeyboardView_popupKeysKeyboardLayout
* @attr ref R.styleable#MainKeyboardView_popupKeysKeyboardForActionLayout
* @attr ref R.styleable#MainKeyboardView_backgroundDimAlpha
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
* @attr ref R.styleable#MainKeyboardView_showPopupKeysKeyboardAtTouchPoint
* @attr ref R.styleable#MainKeyboardView_gestureFloatingPreviewTextLingerTimeout
* @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping
* @attr ref R.styleable#MainKeyboardView_gestureDetectFastMoveSpeedThreshold
@ -101,7 +101,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration
*/
public final class MainKeyboardView extends KeyboardView implements DrawingProxy,
MoreKeysPanel.Controller {
PopupKeysPanel.Controller {
private static final String TAG = MainKeyboardView.class.getSimpleName();
/** Listener for {@link KeyboardActionListener}. */
@ -142,13 +142,13 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
// More keys keyboard
private final Paint mBackgroundDimAlphaPaint = new Paint();
private final View mMoreKeysKeyboardContainer;
private final View mMoreKeysKeyboardForActionContainer;
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = new WeakHashMap<>();
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
// More keys panel (used by both more keys keyboard and more suggestions view)
// TODO: Consider extending to support multiple more keys panels
private MoreKeysPanel mMoreKeysPanel;
private final View mPopupKeysKeyboardContainer;
private final View mPopupKeysKeyboardForActionContainer;
private final WeakHashMap<Key, Keyboard> mPopupKeysKeyboardCache = new WeakHashMap<>();
private final boolean mConfigShowPopupKeysKeyboardAtTouchedPoint;
// More keys panel (used by both popup keys keyboard and more suggestions view)
// TODO: Consider extending to support multiple popup keys panels
private PopupKeysPanel mPopupKeysPanel;
// Gesture floating preview text
// TODO: Make this parameter customizable by user via settings.
@ -220,13 +220,13 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mKeyPreviewDrawParams = new KeyPreviewDrawParams(mainKeyboardViewAttr);
mKeyPreviewChoreographer = new KeyPreviewChoreographer(mKeyPreviewDrawParams);
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
final int moreKeysKeyboardForActionLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardForActionLayout,
moreKeysKeyboardLayoutId);
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
final int popupKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_popupKeysKeyboardLayout, 0);
final int popupKeysKeyboardForActionLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_popupKeysKeyboardForActionLayout,
popupKeysKeyboardLayoutId);
mConfigShowPopupKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showPopupKeysKeyboardAtTouchedPoint, false);
mGestureFloatingPreviewTextLingerTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextLingerTimeout, 0);
@ -244,8 +244,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mDrawingPreviewPlacerView = drawingPreviewPlacerView;
final LayoutInflater inflater = LayoutInflater.from(getContext());
mMoreKeysKeyboardContainer = inflater.inflate(moreKeysKeyboardLayoutId, null);
mMoreKeysKeyboardForActionContainer = inflater.inflate(moreKeysKeyboardForActionLayoutId, null);
mPopupKeysKeyboardContainer = inflater.inflate(popupKeysKeyboardLayoutId, null);
mPopupKeysKeyboardForActionContainer = inflater.inflate(popupKeysKeyboardForActionLayoutId, null);
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(languageOnSpacebarFadeoutAnimatorResId, this);
if (mLanguageOnSpacebarFadeoutAnimator != null)
mLanguageOnSpacebarFadeoutAnimator.setIntValues(255, mLanguageOnSpacebarFinalAlpha);
@ -344,7 +344,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mKeyDetector.setKeyboard(
keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection());
PointerTracker.setKeyDetector(mKeyDetector);
mMoreKeysKeyboardCache.clear();
mPopupKeysKeyboardCache.clear();
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
@ -513,94 +513,94 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mDrawingPreviewPlacerView.removeAllViews();
}
// Implements {@link DrawingProxy@showMoreKeysKeyboard(Key,PointerTracker)}.
// Implements {@link DrawingProxy@showPopupKeysKeyboard(Key,PointerTracker)}.
@Override
@Nullable
public MoreKeysPanel showMoreKeysKeyboard(@NonNull final Key key,
@NonNull final PointerTracker tracker) {
final MoreKeySpec[] moreKeys = key.getMoreKeys();
if (moreKeys == null) {
public PopupKeysPanel showPopupKeysKeyboard(@NonNull final Key key,
@NonNull final PointerTracker tracker) {
final PopupKeySpec[] popupKeys = key.getPopupKeys();
if (popupKeys == null) {
return null;
}
Keyboard moreKeysKeyboard = mMoreKeysKeyboardCache.get(key);
if (moreKeysKeyboard == null) {
Keyboard popupKeysKeyboard = mPopupKeysKeyboardCache.get(key);
if (popupKeysKeyboard == null) {
// {@link KeyPreviewDrawParams#mPreviewVisibleWidth} should have been set at
// {@link KeyPreviewChoreographer#placeKeyPreview(Key,TextView,KeyboardIconsSet,KeyDrawParams,int,int[]},
// though there may be some chances that the value is zero. <code>width == 0</code>
// will cause zero-division error at
// {@link MoreKeysKeyboardParams#setParameters(int,int,int,int,int,int,boolean,int)}.
final boolean isSingleMoreKeyWithPreview = mKeyPreviewDrawParams.isPopupEnabled()
&& !key.noKeyPreview() && moreKeys.length == 1
// {@link PopupKeysKeyboardParams#setParameters(int,int,int,int,int,int,boolean,int)}.
final boolean isSinglePopupKeyWithPreview = mKeyPreviewDrawParams.isPopupEnabled()
&& !key.noKeyPreview() && popupKeys.length == 1
&& mKeyPreviewDrawParams.getVisibleWidth() > 0;
final MoreKeysKeyboard.Builder builder = new MoreKeysKeyboard.Builder(
getContext(), key, getKeyboard(), isSingleMoreKeyWithPreview,
final PopupKeysKeyboard.Builder builder = new PopupKeysKeyboard.Builder(
getContext(), key, getKeyboard(), isSinglePopupKeyWithPreview,
mKeyPreviewDrawParams.getVisibleWidth(),
mKeyPreviewDrawParams.getVisibleHeight(), newLabelPaint(key));
moreKeysKeyboard = builder.build();
mMoreKeysKeyboardCache.put(key, moreKeysKeyboard);
popupKeysKeyboard = builder.build();
mPopupKeysKeyboardCache.put(key, popupKeysKeyboard);
}
final View container = key.isActionKey() ? mMoreKeysKeyboardForActionContainer
: mMoreKeysKeyboardContainer;
final MoreKeysKeyboardView moreKeysKeyboardView =
container.findViewById(R.id.more_keys_keyboard_view);
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
final View container = key.isActionKey() ? mPopupKeysKeyboardForActionContainer
: mPopupKeysKeyboardContainer;
final PopupKeysKeyboardView popupKeysKeyboardView =
container.findViewById(R.id.popup_keys_keyboard_view);
popupKeysKeyboardView.setKeyboard(popupKeysKeyboard);
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int[] lastCoords = CoordinateUtils.newInstance();
tracker.getLastCoordinates(lastCoords);
final boolean keyPreviewEnabled = mKeyPreviewDrawParams.isPopupEnabled()
&& !key.noKeyPreview();
// The more keys keyboard is usually horizontally aligned with the center of the parent key.
// If showMoreKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
// The popup keys keyboard is usually horizontally aligned with the center of the parent key.
// If showPopupKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
// keys keyboard is placed at the touch point of the parent key.
final int pointX = (mConfigShowMoreKeysKeyboardAtTouchedPoint && !keyPreviewEnabled)
final int pointX = (mConfigShowPopupKeysKeyboardAtTouchedPoint && !keyPreviewEnabled)
? CoordinateUtils.x(lastCoords)
: key.getX() + key.getWidth() / 2;
// The more keys keyboard is usually vertically aligned with the top edge of the parent key
// (plus vertical gap). If the key preview is enabled, the more keys keyboard is vertically
// The popup keys keyboard is usually vertically aligned with the top edge of the parent key
// (plus vertical gap). If the key preview is enabled, the popup keys keyboard is vertically
// aligned with the bottom edge of the visible part of the key preview.
// {@code mPreviewVisibleOffset} has been set appropriately in
// {@link KeyboardView#showKeyPreview(PointerTracker)}.
final int pointY = key.getY() + mKeyPreviewDrawParams.getVisibleOffset();
moreKeysKeyboardView.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener);
return moreKeysKeyboardView;
popupKeysKeyboardView.showPopupKeysPanel(this, this, pointX, pointY, mKeyboardActionListener);
return popupKeysKeyboardView;
}
public boolean isInDraggingFinger() {
if (isShowingMoreKeysPanel()) {
if (isShowingPopupKeysPanel()) {
return true;
}
return PointerTracker.isAnyInDraggingFinger();
}
@Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
public void onShowPopupKeysPanel(final PopupKeysPanel panel) {
locatePreviewPlacerView();
// Dismiss another {@link MoreKeysPanel} that may be being showed.
onDismissMoreKeysPanel();
// Dismiss another {@link PopupKeysPanel} that may be being showed.
onDismissPopupKeysPanel();
// Dismiss all key previews that may be being showed.
PointerTracker.setReleasedKeyGraphicsToAllKeys();
// Dismiss sliding key input preview that may be being showed.
mSlidingKeyInputDrawingPreview.dismissSlidingKeyInputPreview();
panel.showInParent(mDrawingPreviewPlacerView);
mMoreKeysPanel = panel;
mPopupKeysPanel = panel;
}
public boolean isShowingMoreKeysPanel() {
return mMoreKeysPanel != null && mMoreKeysPanel.isShowingInParent();
public boolean isShowingPopupKeysPanel() {
return mPopupKeysPanel != null && mPopupKeysPanel.isShowingInParent();
}
@Override
public void onCancelMoreKeysPanel() {
PointerTracker.dismissAllMoreKeysPanels();
public void onCancelPopupKeysPanel() {
PointerTracker.dismissAllPopupKeysPanels();
}
@Override
public void onDismissMoreKeysPanel() {
if (isShowingMoreKeysPanel()) {
mMoreKeysPanel.removeFromParent();
mMoreKeysPanel = null;
public void onDismissPopupKeysPanel() {
if (isShowingPopupKeysPanel()) {
mPopupKeysPanel.removeFromParent();
mPopupKeysPanel = null;
}
}
@ -623,7 +623,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
}
if (mNonDistinctMultitouchHelper != null) {
if (event.getPointerCount() > 1 && mTimerHandler.isInKeyRepeat()) {
// Key repeating timer will be canceled if 2 or more keys are in action.
// Key repeating timer will be canceled if 2 or popup keys are in action.
mTimerHandler.cancelKeyRepeatTimers();
}
// Non distinct multitouch screen support
@ -637,9 +637,9 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
final int index = event.getActionIndex();
final int id = event.getPointerId(index);
final PointerTracker tracker = PointerTracker.getPointerTracker(id);
// When a more keys panel is showing, we should ignore other fingers' single touch events
// other than the finger that is showing the more keys panel.
if (isShowingMoreKeysPanel() && !tracker.isShowingMoreKeysPanel()
// When a popup keys panel is showing, we should ignore other fingers' single touch events
// other than the finger that is showing the popup keys panel.
if (isShowingPopupKeysPanel() && !tracker.isShowingPopupKeysPanel()
&& PointerTracker.getActivePointerTrackerCount() == 1) {
return true;
}
@ -652,17 +652,17 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
PointerTracker.setReleasedKeyGraphicsToAllKeys();
mGestureFloatingTextDrawingPreview.dismissGestureFloatingPreviewText();
mSlidingKeyInputDrawingPreview.dismissSlidingKeyInputPreview();
PointerTracker.dismissAllMoreKeysPanels();
PointerTracker.dismissAllPopupKeysPanels();
PointerTracker.cancelAllPointerTrackers();
}
public void closing() {
cancelAllOngoingEvents();
mMoreKeysKeyboardCache.clear();
mPopupKeysKeyboardCache.clear();
}
public void onHideWindow() {
onDismissMoreKeysPanel();
onDismissPopupKeysPanel();
final MainKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
if (accessibilityDelegate != null
&& AccessibilityUtils.Companion.getInstance().isAccessibilityEnabled()) {

View file

@ -139,8 +139,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// true if this pointer is no longer triggering any action because it has been canceled.
private boolean mIsTrackingForActionDisabled;
// the more keys panel currently being shown. equals null if no panel is active.
private MoreKeysPanel mMoreKeysPanel;
// the popup keys panel currently being shown. equals null if no panel is active.
private PopupKeysPanel mPopupKeysPanel;
private static final int MULTIPLIER_FOR_LONG_PRESS_TIMEOUT_IN_SLIDING_INPUT = 3;
// true if this pointer is in the dragging finger mode.
@ -231,11 +231,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
}
}
public static void dismissAllMoreKeysPanels() {
public static void dismissAllPopupKeysPanels() {
final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i);
tracker.dismissMoreKeysPanel();
tracker.dismissPopupKeysPanel();
}
}
@ -521,7 +521,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
Log.d(TAG, String.format(Locale.US, "[%d] onStartBatchInput", mPointerId));
}
sListener.onStartBatchInput();
dismissAllMoreKeysPanels();
dismissAllPopupKeysPanels();
sTimerProxy.cancelLongPressTimersOf(this);
}
@ -585,10 +585,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int action = me.getActionMasked();
final long eventTime = me.getEventTime();
if (action == MotionEvent.ACTION_MOVE) {
// When this pointer is the only active pointer and is showing a more keys panel,
// When this pointer is the only active pointer and is showing a popup keys panel,
// we should ignore other pointers' motion event.
final boolean shouldIgnoreOtherPointers =
isShowingMoreKeysPanel() && getActivePointerTrackerCount() == 1;
isShowingPopupKeysPanel() && getActivePointerTrackerCount() == 1;
final int pointerCount = me.getPointerCount();
for (int index = 0; index < pointerCount; index++) {
final int id = me.getPointerId(index);
@ -661,14 +661,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
}
}
/* package */ boolean isShowingMoreKeysPanel() {
return (mMoreKeysPanel != null);
/* package */ boolean isShowingPopupKeysPanel() {
return (mPopupKeysPanel != null);
}
private void dismissMoreKeysPanel() {
if (isShowingMoreKeysPanel()) {
mMoreKeysPanel.dismissMoreKeysPanel();
mMoreKeysPanel = null;
private void dismissPopupKeysPanel() {
if (isShowingPopupKeysPanel()) {
mPopupKeysPanel.dismissPopupKeysPanel();
mPopupKeysPanel = null;
}
}
@ -677,7 +677,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// Key selection by dragging finger is allowed when 1) key selection by dragging finger is
// enabled by configuration, 2) this pointer starts dragging from modifier key, or 3) this
// pointer's KeyDetector always allows key selection by dragging finger, such as
// {@link MoreKeysKeyboard}.
// {@link PopupKeysKeyboard}.
mIsAllowedDraggingFinger = sParams.mKeySelectionByDraggingFinger
|| (key != null && key.isModifier())
|| mKeyDetector.alwaysAllowsKeySelectionByDraggingFinger();
@ -733,9 +733,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
}
mGestureStrokeDrawingPoints.onMoveEvent(
x, y, mBatchInputArbiter.getElapsedTimeSinceFirstDown(eventTime));
// If the MoreKeysPanel is showing then do not attempt to enter gesture mode. However,
// If the PopupKeysPanel is showing then do not attempt to enter gesture mode. However,
// the gestured touch points are still being recorded in case the panel is dismissed.
if (isShowingMoreKeysPanel()) {
if (isShowingPopupKeysPanel()) {
return;
}
if (!sInGesture && key != null && Character.isLetter(key.getCode())
@ -770,10 +770,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
}
}
if (isShowingMoreKeysPanel()) {
final int translatedX = mMoreKeysPanel.translateX(x);
final int translatedY = mMoreKeysPanel.translateY(y);
mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
if (isShowingPopupKeysPanel()) {
final int translatedX = mPopupKeysPanel.translateX(x);
final int translatedY = mPopupKeysPanel.translateY(y);
mPopupKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
onMoveKey(x, y);
if (mIsInSlidingKeyInput) {
sDrawingProxy.showSlidingKeyInputPreview(this);
@ -1027,13 +1027,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
sListener.onUpWithDeletePointerActive();
}
if (isShowingMoreKeysPanel()) {
if (isShowingPopupKeysPanel()) {
if (!mIsTrackingForActionDisabled) {
final int translatedX = mMoreKeysPanel.translateX(x);
final int translatedY = mMoreKeysPanel.translateY(y);
mMoreKeysPanel.onUpEvent(translatedX, translatedY, mPointerId, eventTime);
final int translatedX = mPopupKeysPanel.translateX(x);
final int translatedY = mPopupKeysPanel.translateY(y);
mPopupKeysPanel.onUpEvent(translatedX, translatedY, mPointerId, eventTime);
}
dismissMoreKeysPanel();
dismissPopupKeysPanel();
if (isInSlidingKeyInput)
callListenerOnFinishSlidingInput();
return;
@ -1072,7 +1072,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
@Override
public void cancelTrackingForAction() {
if (isShowingMoreKeysPanel()) {
if (isShowingPopupKeysPanel()) {
return;
}
mIsTrackingForActionDisabled = true;
@ -1084,7 +1084,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
public void onLongPressed() {
sTimerProxy.cancelLongPressTimersOf(this);
if (isShowingMoreKeysPanel()) {
if (isShowingPopupKeysPanel()) {
return;
}
if(mCursorMoved) {
@ -1094,12 +1094,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (key == null) {
return;
}
if (key.hasNoPanelAutoMoreKey()) {
if (key.hasNoPanelAutoPopupKey()) {
cancelKeyTracking();
final int moreKeyCode = key.getMoreKeys()[0].mCode;
sListener.onPressKey(moreKeyCode, 0, true);
sListener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
sListener.onReleaseKey(moreKeyCode, false);
final int popupKeyCode = key.getPopupKeys()[0].mCode;
sListener.onPressKey(popupKeyCode, 0, true);
sListener.onCodeInput(popupKeyCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
sListener.onReleaseKey(popupKeyCode, false);
return;
}
final int code = key.getCode();
@ -1119,14 +1119,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
}
setReleasedKeyGraphics(key, false);
final MoreKeysPanel moreKeysPanel = sDrawingProxy.showMoreKeysKeyboard(key, this);
if (moreKeysPanel == null) {
final PopupKeysPanel popupKeysPanel = sDrawingProxy.showPopupKeysKeyboard(key, this);
if (popupKeysPanel == null) {
return;
}
final int translatedX = moreKeysPanel.translateX(mLastX);
final int translatedY = moreKeysPanel.translateY(mLastY);
moreKeysPanel.onDownEvent(translatedX, translatedY, mPointerId, SystemClock.uptimeMillis());
mMoreKeysPanel = moreKeysPanel;
final int translatedX = popupKeysPanel.translateX(mLastX);
final int translatedY = popupKeysPanel.translateY(mLastY);
popupKeysPanel.onDownEvent(translatedX, translatedY, mPointerId, SystemClock.uptimeMillis());
mPopupKeysPanel = popupKeysPanel;
}
private void cancelKeyTracking() {
@ -1151,7 +1151,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
sTimerProxy.cancelKeyTimersOf(this);
setReleasedKeyGraphics(mCurrentKey, true);
resetKeySelectionByDraggingFinger();
dismissMoreKeysPanel();
dismissPopupKeysPanel();
}
private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime,
@ -1195,11 +1195,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (key == null) return;
if (!key.isLongPressEnabled()) return;
// Caveat: Please note that isLongPressEnabled() can be true even if the current key
// doesn't have its more keys. (e.g. spacebar, globe key) If we are in the dragging finger
// doesn't have its popup keys. (e.g. spacebar, globe key) If we are in the dragging finger
// mode, we will disable long press timer of such key.
// We always need to start the long press timer if the key has its more keys regardless of
// We always need to start the long press timer if the key has its popup keys regardless of
// whether or not we are in the dragging finger mode.
if (mIsInDraggingFinger && key.getMoreKeys() == null) return;
if (mIsInDraggingFinger && key.getPopupKeys() == null) return;
final int delay = getLongPressTimeout(key.getCode());
if (delay <= 0) return;

View file

@ -6,11 +6,11 @@
package helium314.keyboard.keyboard;
public final class MoreKeysDetector extends KeyDetector {
public final class PopupKeysDetector extends KeyDetector {
private final int mSlideAllowanceSquare;
private final int mSlideAllowanceSquareTop;
public MoreKeysDetector(float slideAllowance) {
public PopupKeysDetector(float slideAllowance) {
super();
mSlideAllowanceSquare = (int)(slideAllowance * slideAllowance);
// Top slide allowance is slightly longer (sqrt(2) times) than other edges.

View file

@ -13,15 +13,15 @@ import androidx.annotation.NonNull;
import helium314.keyboard.keyboard.internal.KeyboardBuilder;
import helium314.keyboard.keyboard.internal.KeyboardParams;
import helium314.keyboard.keyboard.internal.MoreKeySpec;
import helium314.keyboard.keyboard.internal.PopupKeySpec;
import helium314.keyboard.latin.R;
import helium314.keyboard.latin.common.StringUtils;
import helium314.keyboard.latin.utils.TypefaceUtils;
public final class MoreKeysKeyboard extends Keyboard {
public final class PopupKeysKeyboard extends Keyboard {
private final int mDefaultKeyCoordX;
MoreKeysKeyboard(final MoreKeysKeyboardParams params) {
PopupKeysKeyboard(final PopupKeysKeyboardParams params) {
super(params);
mDefaultKeyCoordX = params.getDefaultKeyCoordX() + params.mDefaultKeyWidth / 2;
}
@ -30,8 +30,8 @@ public final class MoreKeysKeyboard extends Keyboard {
return mDefaultKeyCoordX;
}
static class MoreKeysKeyboardParams extends KeyboardParams {
public boolean mIsMoreKeysFixedOrder;
static class PopupKeysKeyboardParams extends KeyboardParams {
public boolean mIsPopupKeysFixedOrder;
/* package */int mTopRowAdjustment;
public int mNumRows;
public int mNumColumns;
@ -41,41 +41,41 @@ public final class MoreKeysKeyboard extends Keyboard {
public int mDividerWidth;
public int mColumnWidth;
public MoreKeysKeyboardParams() {
public PopupKeysKeyboardParams() {
super();
}
/**
* Set keyboard parameters of more keys keyboard.
* Set keyboard parameters of popup keys keyboard.
*
* @param numKeys number of keys in this more keys keyboard.
* @param numColumn number of columns of this more keys keyboard.
* @param keyWidth more keys keyboard key width in pixel, including horizontal gap.
* @param rowHeight more keys keyboard row height in pixel, including vertical gap.
* @param numKeys number of keys in this popup keys keyboard.
* @param numColumn number of columns of this popup keys keyboard.
* @param keyWidth popup keys keyboard key width in pixel, including horizontal gap.
* @param rowHeight popup keys keyboard row height in pixel, including vertical gap.
* @param coordXInParent coordinate x of the key preview in parent keyboard.
* @param parentKeyboardWidth parent keyboard width in pixel.
* @param isMoreKeysFixedColumn true if more keys keyboard should have
* <code>numColumn</code> columns. Otherwise more keys keyboard should have
* @param isPopupKeysFixedColumn true if popup keys keyboard should have
* <code>numColumn</code> columns. Otherwise popup keys keyboard should have
* <code>numColumn</code> columns at most.
* @param isMoreKeysFixedOrder true if the order of more keys is determined by the order in
* the more keys' specification. Otherwise the order of more keys is automatically
* @param isPopupKeysFixedOrder true if the order of popup keys is determined by the order in
* the popup keys' specification. Otherwise the order of popup keys is automatically
* determined.
* @param dividerWidth width of divider, zero for no dividers.
*/
public void setParameters(final int numKeys, final int numColumn, final int keyWidth,
final int rowHeight, final int coordXInParent, final int parentKeyboardWidth,
final boolean isMoreKeysFixedColumn, final boolean isMoreKeysFixedOrder,
final boolean isPopupKeysFixedColumn, final boolean isPopupKeysFixedOrder,
final int dividerWidth) {
mIsMoreKeysFixedOrder = isMoreKeysFixedOrder;
mIsPopupKeysFixedOrder = isPopupKeysFixedOrder;
if (parentKeyboardWidth / keyWidth < Math.min(numKeys, numColumn)) {
throw new IllegalArgumentException("Keyboard is too small to hold more keys: "
throw new IllegalArgumentException("Keyboard is too small to hold popup keys: "
+ parentKeyboardWidth + " " + keyWidth + " " + numKeys + " " + numColumn);
}
mDefaultKeyWidth = keyWidth;
mDefaultRowHeight = rowHeight;
mNumRows = (numKeys + numColumn - 1) / numColumn;
final int numColumns = isMoreKeysFixedColumn ? Math.min(numKeys, numColumn)
final int numColumns = isPopupKeysFixedColumn ? Math.min(numKeys, numColumn)
: getOptimizedColumns(numKeys, numColumn);
mNumColumns = numColumns;
final int topKeys = numKeys % numColumns;
@ -97,13 +97,13 @@ public final class MoreKeysKeyboard extends Keyboard {
leftKeys = numLeftKeys;
rightKeys = numRightKeys;
}
// If the left keys fill the left side of the parent key, entire more keys keyboard
// If the left keys fill the left side of the parent key, entire popup keys keyboard
// should be shifted to the right unless the parent key is on the left edge.
if (maxLeftKeys == leftKeys && leftKeys > 0) {
leftKeys--;
rightKeys++;
}
// If the right keys fill the right side of the parent key, entire more keys
// If the right keys fill the right side of the parent key, entire popup keys
// should be shifted to the left unless the parent key is on the right edge.
if (maxRightKeys == rightKeys - 1 && rightKeys > 1) {
leftKeys++;
@ -113,7 +113,7 @@ public final class MoreKeysKeyboard extends Keyboard {
mRightKeys = rightKeys;
// Adjustment of the top row.
mTopRowAdjustment = isMoreKeysFixedOrder ? getFixedOrderTopRowAdjustment()
mTopRowAdjustment = isPopupKeysFixedOrder ? getFixedOrderTopRowAdjustment()
: getAutoOrderTopRowAdjustment();
mDividerWidth = dividerWidth;
mColumnWidth = mDefaultKeyWidth + mDividerWidth;
@ -141,7 +141,7 @@ public final class MoreKeysKeyboard extends Keyboard {
// Return key position according to column count (0 is default).
/* package */int getColumnPos(final int n) {
return mIsMoreKeysFixedOrder ? getFixedOrderColumnPos(n) : getAutomaticColumnPos(n);
return mIsPopupKeysFixedOrder ? getFixedOrderColumnPos(n) : getAutomaticColumnPos(n);
}
private int getFixedOrderColumnPos(final int n) {
@ -242,42 +242,42 @@ public final class MoreKeysKeyboard extends Keyboard {
}
}
public static class Builder extends KeyboardBuilder<MoreKeysKeyboardParams> {
public static class Builder extends KeyboardBuilder<PopupKeysKeyboardParams> {
private final Key mParentKey;
private static final float LABEL_PADDING_RATIO = 0.2f;
private static final float DIVIDER_RATIO = 0.2f;
/**
* The builder of MoreKeysKeyboard.
* @param context the context of {@link MoreKeysKeyboardView}.
* @param key the {@link Key} that invokes more keys keyboard.
* The builder of PopupKeysKeyboard.
* @param context the context of {@link PopupKeysKeyboardView}.
* @param key the {@link Key} that invokes popup keys keyboard.
* @param keyboard the {@link Keyboard} that contains the parentKey.
* @param isSingleMoreKeyWithPreview true if the <code>key</code> has just a single
* "more key" and its key popup preview is enabled.
* @param isSinglePopupKeyWithPreview true if the <code>key</code> has just a single
* "popup key" and its key popup preview is enabled.
* @param keyPreviewVisibleWidth the width of visible part of key popup preview.
* @param keyPreviewVisibleHeight the height of visible part of key popup preview
* @param paintToMeasure the {@link Paint} object to measure a "more key" width
* @param paintToMeasure the {@link Paint} object to measure a "popup key" width
*/
public Builder(final Context context, final Key key, final Keyboard keyboard,
final boolean isSingleMoreKeyWithPreview, final int keyPreviewVisibleWidth,
final boolean isSinglePopupKeyWithPreview, final int keyPreviewVisibleWidth,
final int keyPreviewVisibleHeight, final Paint paintToMeasure) {
super(context, new MoreKeysKeyboardParams());
super(context, new PopupKeysKeyboardParams());
mParams.mId = keyboard.mId;
readAttributes(keyboard.mMoreKeysTemplate);
readAttributes(keyboard.mPopupKeysTemplate);
// TODO: More keys keyboard's vertical gap is currently calculated heuristically.
// TODO: Popup keys keyboard's vertical gap is currently calculated heuristically.
// Should revise the algorithm.
mParams.mVerticalGap = keyboard.mVerticalGap / 2;
// This {@link MoreKeysKeyboard} is invoked from the <code>key</code>.
// This {@link PopupKeysKeyboard} is invoked from the <code>key</code>.
mParentKey = key;
final int keyWidth, rowHeight;
if (isSingleMoreKeyWithPreview) {
// Use pre-computed width and height if this more keys keyboard has only one key to
// mitigate visual flicker between key preview and more keys keyboard.
if (isSinglePopupKeyWithPreview) {
// Use pre-computed width and height if this popup keys keyboard has only one key to
// mitigate visual flicker between key preview and popup keys keyboard.
// Caveats for the visual assets: To achieve this effect, both the key preview
// backgrounds and the more keys keyboard panel background have the exact same
// backgrounds and the popup keys keyboard panel background have the exact same
// left/right/top paddings. The bottom paddings of both backgrounds don't need to
// be considered because the vertical positions of both backgrounds were already
// adjusted with their bottom paddings deducted.
@ -285,33 +285,33 @@ public final class MoreKeysKeyboard extends Keyboard {
rowHeight = keyPreviewVisibleHeight + mParams.mVerticalGap;
} else {
final float padding = context.getResources().getDimension(
R.dimen.config_more_keys_keyboard_key_horizontal_padding)
+ (key.hasLabelsInMoreKeys()
R.dimen.config_popup_keys_keyboard_key_horizontal_padding)
+ (key.hasLabelsInPopupKeys()
? mParams.mDefaultKeyWidth * LABEL_PADDING_RATIO : 0.0f);
keyWidth = getMaxKeyWidth(key, mParams.mDefaultKeyWidth, padding, paintToMeasure);
rowHeight = keyboard.mMostCommonKeyHeight;
}
final int dividerWidth;
if (key.needsDividersInMoreKeys()) {
if (key.needsDividersInPopupKeys()) {
dividerWidth = (int)(keyWidth * DIVIDER_RATIO);
} else {
dividerWidth = 0;
}
final MoreKeySpec[] moreKeys = key.getMoreKeys();
final int defaultColumns = key.getMoreKeysColumnNumber();
final PopupKeySpec[] popupKeys = key.getPopupKeys();
final int defaultColumns = key.getPopupKeysColumnNumber();
final int spaceForKeys = keyboard.mId.mWidth / keyWidth;
final int finalNumColumns = spaceForKeys >= Math.min(moreKeys.length, defaultColumns)
final int finalNumColumns = spaceForKeys >= Math.min(popupKeys.length, defaultColumns)
? defaultColumns
: (spaceForKeys > 0 ? spaceForKeys : defaultColumns); // in last case setParameters will throw an exception
mParams.setParameters(moreKeys.length, finalNumColumns, keyWidth,
mParams.setParameters(popupKeys.length, finalNumColumns, keyWidth,
rowHeight, key.getX() + key.getWidth() / 2, keyboard.mId.mWidth,
key.isMoreKeysFixedColumn(), key.isMoreKeysFixedOrder(), dividerWidth);
key.isPopupKeysFixedColumn(), key.isPopupKeysFixedOrder(), dividerWidth);
}
private static int getMaxKeyWidth(final Key parentKey, final int minKeyWidth,
final float padding, final Paint paint) {
int maxWidth = minKeyWidth;
for (final MoreKeySpec spec : parentKey.getMoreKeys()) {
for (final PopupKeySpec spec : parentKey.getPopupKeys()) {
final String label = spec.mLabel;
// If the label is single letter, minKeyWidth is enough to hold the label.
if (label != null && StringUtils.codePointCount(label) > 1) {
@ -324,16 +324,16 @@ public final class MoreKeysKeyboard extends Keyboard {
@Override
@NonNull
public MoreKeysKeyboard build() {
final MoreKeysKeyboardParams params = mParams;
final int moreKeyFlags = mParentKey.getMoreKeyLabelFlags();
final MoreKeySpec[] moreKeys = mParentKey.getMoreKeys();
for (int n = 0; n < moreKeys.length; n++) {
final MoreKeySpec moreKeySpec = moreKeys[n];
public PopupKeysKeyboard build() {
final PopupKeysKeyboardParams params = mParams;
final int popupKeyFlags = mParentKey.getPopupKeyLabelFlags();
final PopupKeySpec[] popupKeys = mParentKey.getPopupKeys();
for (int n = 0; n < popupKeys.length; n++) {
final PopupKeySpec popupKeySpec = popupKeys[n];
final int row = n / params.mNumColumns;
final int x = params.getX(n, row);
final int y = params.getY(row);
final Key key = moreKeySpec.buildKey(x, y, moreKeyFlags, params);
final Key key = popupKeySpec.buildKey(x, y, popupKeyFlags, params);
params.markAsEdgeKey(key, row);
params.onAddKey(key);
@ -343,18 +343,18 @@ public final class MoreKeysKeyboard extends Keyboard {
if (params.mDividerWidth > 0 && pos != 0) {
final int dividerX = (pos > 0) ? x - params.mDividerWidth
: x + params.mDefaultKeyWidth;
final Key divider = new MoreKeyDivider(
final Key divider = new PopupKeyDivider(
params, dividerX, y, params.mDividerWidth, params.mDefaultRowHeight);
params.onAddKey(divider);
}
}
return new MoreKeysKeyboard(params);
return new PopupKeysKeyboard(params);
}
}
// Used as a divider maker. A divider is drawn by {@link MoreKeysKeyboardView}.
public static class MoreKeyDivider extends Key.Spacer {
public MoreKeyDivider(final KeyboardParams params, final int x, final int y,
// Used as a divider maker. A divider is drawn by {@link PopupKeysKeyboardView}.
public static class PopupKeyDivider extends Key.Spacer {
public PopupKeyDivider(final KeyboardParams params, final int x, final int y,
final int width, final int height) {
super(params, x, y, width, height);
}

View file

@ -19,7 +19,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import helium314.keyboard.accessibility.AccessibilityUtils;
import helium314.keyboard.accessibility.MoreKeysKeyboardAccessibilityDelegate;
import helium314.keyboard.accessibility.PopupKeysKeyboardAccessibilityDelegate;
import helium314.keyboard.keyboard.emoji.OnKeyEventListener;
import helium314.keyboard.keyboard.internal.KeyDrawParams;
import helium314.keyboard.latin.R;
@ -27,10 +27,10 @@ import helium314.keyboard.latin.common.Constants;
import helium314.keyboard.latin.common.CoordinateUtils;
/**
* A view that renders a virtual {@link MoreKeysKeyboard}. It handles rendering of keys and
* A view that renders a virtual {@link PopupKeysKeyboard}. It handles rendering of keys and
* detecting key presses and touch movements.
*/
public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel {
public class PopupKeysKeyboardView extends KeyboardView implements PopupKeysPanel {
private final int[] mCoordinates = CoordinateUtils.newInstance();
private final Drawable mDivider;
@ -44,21 +44,21 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
private int mActivePointerId;
protected MoreKeysKeyboardAccessibilityDelegate mAccessibilityDelegate;
protected PopupKeysKeyboardAccessibilityDelegate mAccessibilityDelegate;
public MoreKeysKeyboardView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.moreKeysKeyboardViewStyle);
public PopupKeysKeyboardView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.popupKeysKeyboardViewStyle);
}
public MoreKeysKeyboardView(final Context context, final AttributeSet attrs,
final int defStyle) {
public PopupKeysKeyboardView(final Context context, final AttributeSet attrs,
final int defStyle) {
super(context, attrs, defStyle);
final TypedArray moreKeysKeyboardViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.MoreKeysKeyboardView, defStyle, R.style.MoreKeysKeyboardView);
mDivider = moreKeysKeyboardViewAttr.getDrawable(R.styleable.MoreKeysKeyboardView_divider);
moreKeysKeyboardViewAttr.recycle();
mKeyDetector = new MoreKeysDetector(getResources().getDimension(
R.dimen.config_more_keys_keyboard_slide_allowance));
final TypedArray popupKeysKeyboardViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.PopupKeysKeyboardView, defStyle, R.style.PopupKeysKeyboardView);
mDivider = popupKeysKeyboardViewAttr.getDrawable(R.styleable.PopupKeysKeyboardView_divider);
popupKeysKeyboardViewAttr.recycle();
mKeyDetector = new PopupKeysDetector(getResources().getDimension(
R.dimen.config_popup_keys_keyboard_slide_allowance));
}
@Override
@ -76,7 +76,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
@Override
protected void onDrawKeyTopVisuals(@NonNull final Key key, @NonNull final Canvas canvas,
@NonNull final Paint paint, @NonNull final KeyDrawParams params) {
if (!key.isSpacer() || !(key instanceof MoreKeysKeyboard.MoreKeyDivider)
if (!key.isSpacer() || !(key instanceof PopupKeysKeyboard.PopupKeyDivider)
|| mDivider == null) {
super.onDrawKeyTopVisuals(key, canvas, paint, params);
return;
@ -97,10 +97,10 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection());
if (AccessibilityUtils.Companion.getInstance().isAccessibilityEnabled()) {
if (mAccessibilityDelegate == null) {
mAccessibilityDelegate = new MoreKeysKeyboardAccessibilityDelegate(
mAccessibilityDelegate = new PopupKeysKeyboardAccessibilityDelegate(
this, mKeyDetector);
mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_keys_keyboard);
mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_more_keys_keyboard);
mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_popup_keys_keyboard);
mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_popup_keys_keyboard);
}
mAccessibilityDelegate.setKeyboard(keyboard);
} else {
@ -112,25 +112,25 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
* {@inheritDoc}
*/
@Override
public void showMoreKeysPanel(final View parentView, final Controller controller,
public void showPopupKeysPanel(final View parentView, final Controller controller,
final int pointX, final int pointY, final KeyboardActionListener listener) {
mListener = listener;
mKeyEventListener = null;
showMoreKeysPanelInternal(parentView, controller, pointX, pointY);
showPopupKeysPanelInternal(parentView, controller, pointX, pointY);
}
/**
* {@inheritDoc}
*/
@Override
public void showMoreKeysPanel(final View parentView, final Controller controller,
public void showPopupKeysPanel(final View parentView, final Controller controller,
final int pointX, final int pointY, final OnKeyEventListener listener) {
mListener = null;
mKeyEventListener = listener;
showMoreKeysPanelInternal(parentView, controller, pointX, pointY);
showPopupKeysPanelInternal(parentView, controller, pointX, pointY);
}
private void showMoreKeysPanelInternal(final View parentView, final Controller controller,
private void showPopupKeysPanelInternal(final View parentView, final Controller controller,
final int pointX, final int pointY) {
mController = controller;
final View container = getContainerView();
@ -150,11 +150,11 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
mOriginX = x + container.getPaddingLeft();
mOriginY = y + container.getPaddingTop();
controller.onShowMoreKeysPanel(this);
final MoreKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
controller.onShowPopupKeysPanel(this);
final PopupKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
if (accessibilityDelegate != null
&& AccessibilityUtils.Companion.getInstance().isAccessibilityEnabled()) {
accessibilityDelegate.onShowMoreKeysKeyboard();
accessibilityDelegate.onShowPopupKeysKeyboard();
}
}
@ -162,7 +162,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
* Returns the default x coordinate for showing this panel.
*/
protected int getDefaultCoordX() {
return ((MoreKeysKeyboard)getKeyboard()).getDefaultCoordX();
return ((PopupKeysKeyboard)getKeyboard()).getDefaultCoordX();
}
@Override
@ -179,8 +179,8 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
final boolean hasOldKey = (mCurrentKey != null);
mCurrentKey = detectKey(x, y);
if (hasOldKey && mCurrentKey == null) {
// A more keys keyboard is canceled when detecting no key.
mController.onCancelMoreKeysPanel();
// A popup keys keyboard is canceled when detecting no key.
mController.onCancelPopupKeysPanel();
}
}
@ -249,16 +249,16 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
}
@Override
public void dismissMoreKeysPanel() {
public void dismissPopupKeysPanel() {
if (!isShowingInParent()) {
return;
}
final MoreKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
final PopupKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
if (accessibilityDelegate != null
&& AccessibilityUtils.Companion.getInstance().isAccessibilityEnabled()) {
accessibilityDelegate.onDismissMoreKeysKeyboard();
accessibilityDelegate.onDismissPopupKeysKeyboard();
}
mController.onDismissMoreKeysPanel();
mController.onDismissPopupKeysPanel();
}
@Override
@ -300,7 +300,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
*/
@Override
public boolean onHoverEvent(final MotionEvent event) {
final MoreKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
final PopupKeysKeyboardAccessibilityDelegate accessibilityDelegate = mAccessibilityDelegate;
if (accessibilityDelegate != null
&& AccessibilityUtils.Companion.getInstance().isTouchExplorationEnabled()) {
return accessibilityDelegate.onHoverEvent(event);

View file

@ -10,77 +10,77 @@ import android.view.View;
import android.view.ViewGroup;
import helium314.keyboard.keyboard.emoji.OnKeyEventListener;
public interface MoreKeysPanel {
public interface PopupKeysPanel {
interface Controller {
/**
* Add the {@link MoreKeysPanel} to the target view.
* Add the {@link PopupKeysPanel} to the target view.
* @param panel the panel to be shown.
*/
void onShowMoreKeysPanel(final MoreKeysPanel panel);
void onShowPopupKeysPanel(final PopupKeysPanel panel);
/**
* Remove the current {@link MoreKeysPanel} from the target view.
* Remove the current {@link PopupKeysPanel} from the target view.
*/
void onDismissMoreKeysPanel();
void onDismissPopupKeysPanel();
/**
* Instructs the parent to cancel the panel (e.g., when entering a different input mode).
*/
void onCancelMoreKeysPanel();
void onCancelPopupKeysPanel();
}
Controller EMPTY_CONTROLLER = new Controller() {
@Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {}
public void onShowPopupKeysPanel(final PopupKeysPanel panel) {}
@Override
public void onDismissMoreKeysPanel() {}
public void onDismissPopupKeysPanel() {}
@Override
public void onCancelMoreKeysPanel() {}
public void onCancelPopupKeysPanel() {}
};
/**
* Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the
* controller's onShowMoreKeysPanel to add the panel's container view.
* Initializes the layout and event handling of this {@link PopupKeysPanel} and calls the
* controller's onShowPopupKeysPanel to add the panel's container view.
*
* @param parentView the parent view of this {@link MoreKeysPanel}
* @param controller the controller that can dismiss this {@link MoreKeysPanel}
* @param pointX x coordinate of this {@link MoreKeysPanel}
* @param pointY y coordinate of this {@link MoreKeysPanel}
* @param parentView the parent view of this {@link PopupKeysPanel}
* @param controller the controller that can dismiss this {@link PopupKeysPanel}
* @param pointX x coordinate of this {@link PopupKeysPanel}
* @param pointY y coordinate of this {@link PopupKeysPanel}
* @param listener the listener that will receive keyboard action from this
* {@link MoreKeysPanel}.
* {@link PopupKeysPanel}.
*/
// TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent.
// Consider the simpler approach of placing the MoreKeysPanel itself into the parent view.
void showMoreKeysPanel(View parentView, Controller controller, int pointX,
// TODO: Currently the PopupKeysPanel is inside a container view that is added to the parent.
// Consider the simpler approach of placing the PopupKeysPanel itself into the parent view.
void showPopupKeysPanel(View parentView, Controller controller, int pointX,
int pointY, KeyboardActionListener listener);
/**
*
* Initializes the layout and event handling of this {@link MoreKeysPanel} and calls the
* controller's onShowMoreKeysPanel to add the panel's container view.
* Same as {@link MoreKeysPanel#showMoreKeysPanel(View, Controller, int, int, KeyboardActionListener)},
* Initializes the layout and event handling of this {@link PopupKeysPanel} and calls the
* controller's onShowPopupKeysPanel to add the panel's container view.
* Same as {@link PopupKeysPanel#showPopupKeysPanel(View, Controller, int, int, KeyboardActionListener)},
* but with a {@link OnKeyEventListener}.
*
* @param parentView the parent view of this {@link MoreKeysPanel}
* @param controller the controller that can dismiss this {@link MoreKeysPanel}
* @param pointX x coordinate of this {@link MoreKeysPanel}
* @param pointY y coordinate of this {@link MoreKeysPanel}
* @param parentView the parent view of this {@link PopupKeysPanel}
* @param controller the controller that can dismiss this {@link PopupKeysPanel}
* @param pointX x coordinate of this {@link PopupKeysPanel}
* @param pointY y coordinate of this {@link PopupKeysPanel}
* @param listener the listener that will receive keyboard action from this
* {@link MoreKeysPanel}.
* {@link PopupKeysPanel}.
*/
// TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent.
// Consider the simpler approach of placing the MoreKeysPanel itself into the parent view.
void showMoreKeysPanel(View parentView, Controller controller, int pointX,
// TODO: Currently the PopupKeysPanel is inside a container view that is added to the parent.
// Consider the simpler approach of placing the PopupKeysPanel itself into the parent view.
void showPopupKeysPanel(View parentView, Controller controller, int pointX,
int pointY, OnKeyEventListener listener);
/**
* Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove
* Dismisses the popup keys panel and calls the controller's onDismissPopupKeysPanel to remove
* the panel's container view.
*/
void dismissMoreKeysPanel();
void dismissPopupKeysPanel();
/**
* Process a move event on the more keys panel.
* Process a move event on the popup keys panel.
*
* @param x translated x coordinate of the touch point
* @param y translated y coordinate of the touch point
@ -90,7 +90,7 @@ public interface MoreKeysPanel {
void onMoveEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Process a down event on the more keys panel.
* Process a down event on the popup keys panel.
*
* @param x translated x coordinate of the touch point
* @param y translated y coordinate of the touch point
@ -100,7 +100,7 @@ public interface MoreKeysPanel {
void onDownEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Process an up event on the more keys panel.
* Process an up event on the popup keys panel.
*
* @param x translated x coordinate of the touch point
* @param y translated y coordinate of the touch point
@ -111,31 +111,31 @@ public interface MoreKeysPanel {
/**
* Translate X-coordinate of touch event to the local X-coordinate of this
* {@link MoreKeysPanel}.
* {@link PopupKeysPanel}.
*
* @param x the global X-coordinate
* @return the local X-coordinate to this {@link MoreKeysPanel}
* @return the local X-coordinate to this {@link PopupKeysPanel}
*/
int translateX(int x);
/**
* Translate Y-coordinate of touch event to the local Y-coordinate of this
* {@link MoreKeysPanel}.
* {@link PopupKeysPanel}.
*
* @param y the global Y-coordinate
* @return the local Y-coordinate to this {@link MoreKeysPanel}
* @return the local Y-coordinate to this {@link PopupKeysPanel}
*/
int translateY(int y);
/**
* Show this {@link MoreKeysPanel} in the parent view.
* Show this {@link PopupKeysPanel} in the parent view.
*
* @param parentView the {@link ViewGroup} that hosts this {@link MoreKeysPanel}.
* @param parentView the {@link ViewGroup} that hosts this {@link PopupKeysPanel}.
*/
void showInParent(ViewGroup parentView);
/**
* Remove this {@link MoreKeysPanel} from the parent view.
* Remove this {@link PopupKeysPanel} from the parent view.
*/
void removeFromParent();

View file

@ -17,7 +17,7 @@ import androidx.annotation.Nullable;
import helium314.keyboard.keyboard.Key;
import helium314.keyboard.keyboard.Keyboard;
import helium314.keyboard.keyboard.internal.MoreKeySpec;
import helium314.keyboard.keyboard.internal.PopupKeySpec;
import helium314.keyboard.latin.settings.Settings;
import helium314.keyboard.latin.utils.JsonUtils;
@ -151,14 +151,14 @@ final class DynamicGridKeyboard extends Keyboard {
}
synchronized (mLock) {
mCachedGridKeys = null;
// When a key is added to recents keyboard, we don't want to keep its more keys
// When a key is added to recents keyboard, we don't want to keep its popup keys
// neither its hint label. Also, we make sure its background type is matching our keyboard
// if key comes from another keyboard (ie. a {@link MoreKeysKeyboard}).
final boolean dropMoreKeys = mIsRecents;
// Check if hint was a more emoji indicator and prevent its copy if more keys aren't copied
final boolean dropHintLabel = dropMoreKeys && EMOJI_HINT_LABEL.equals(usedKey.getHintLabel());
// if key comes from another keyboard (ie. a {@link PopupKeysKeyboard}).
final boolean dropPopupKeys = mIsRecents;
// Check if hint was a more emoji indicator and prevent its copy if popup keys aren't copied
final boolean dropHintLabel = dropPopupKeys && EMOJI_HINT_LABEL.equals(usedKey.getHintLabel());
final GridKey key = new GridKey(usedKey,
dropMoreKeys ? null : usedKey.getMoreKeys(),
dropPopupKeys ? null : usedKey.getPopupKeys(),
dropHintLabel ? null : usedKey.getHintLabel(),
mIsRecents ? Key.BACKGROUND_TYPE_EMPTY : usedKey.getBackgroundType());
while (mGridKeys.remove(key)) {
@ -289,9 +289,9 @@ final class DynamicGridKeyboard extends Keyboard {
private int mCurrentX;
private int mCurrentY;
public GridKey(@NonNull final Key originalKey, @Nullable final MoreKeySpec[] moreKeys,
public GridKey(@NonNull final Key originalKey, @Nullable final PopupKeySpec[] popupKeys,
@Nullable final String labelHint, final int backgroundType) {
super(originalKey, moreKeys, labelHint, backgroundType);
super(originalKey, popupKeys, labelHint, backgroundType);
}
public void updateCoordinates(final int x0, final int y0, final int x1, final int y1) {

View file

@ -32,10 +32,10 @@ import helium314.keyboard.keyboard.Key;
import helium314.keyboard.keyboard.KeyDetector;
import helium314.keyboard.keyboard.Keyboard;
import helium314.keyboard.keyboard.KeyboardView;
import helium314.keyboard.keyboard.MoreKeysKeyboard;
import helium314.keyboard.keyboard.MoreKeysKeyboardView;
import helium314.keyboard.keyboard.MoreKeysPanel;
import helium314.keyboard.keyboard.internal.MoreKeySpec;
import helium314.keyboard.keyboard.PopupKeysKeyboard;
import helium314.keyboard.keyboard.PopupKeysKeyboardView;
import helium314.keyboard.keyboard.PopupKeysPanel;
import helium314.keyboard.keyboard.internal.PopupKeySpec;
import helium314.keyboard.latin.R;
import helium314.keyboard.latin.common.CoordinateUtils;
import helium314.keyboard.latin.settings.Settings;
@ -47,7 +47,7 @@ import java.util.WeakHashMap;
* Multi-touch unsupported. No gesture support.
*/
public final class EmojiPageKeyboardView extends KeyboardView implements
MoreKeysPanel.Controller {
PopupKeysPanel.Controller {
private static final String TAG = "EmojiPageKeyboardView";
private static final boolean LOG = false;
private static final long KEY_PRESS_DELAY_TIME = 250; // msec
@ -73,13 +73,13 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
private final Handler mHandler;
// More keys keyboard
private final View mMoreKeysKeyboardContainer;
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = new WeakHashMap<>();
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
private final ViewGroup mMoreKeysPlacerView;
// More keys panel (used by more keys keyboard view)
// TODO: Consider extending to support multiple more keys panels
private MoreKeysPanel mMoreKeysPanel;
private final View mPopupKeysKeyboardContainer;
private final WeakHashMap<Key, Keyboard> mPopupKeysKeyboardCache = new WeakHashMap<>();
private final boolean mConfigShowPopupKeysKeyboardAtTouchedPoint;
private final ViewGroup mPopupKeysPlacerView;
// More keys panel (used by popup keys keyboard view)
// TODO: Consider extending to support multiple popup keys panels
private PopupKeysPanel mPopupKeysPanel;
public EmojiPageKeyboardView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.keyboardViewStyle);
@ -90,18 +90,18 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
super(context, attrs, defStyle);
mHandler = new Handler();
mMoreKeysPlacerView = new FrameLayout(context, attrs);
mPopupKeysPlacerView = new FrameLayout(context, attrs);
final TypedArray keyboardViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
final int moreKeysKeyboardLayoutId = keyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
mConfigShowMoreKeysKeyboardAtTouchedPoint = keyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
final int popupKeysKeyboardLayoutId = keyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_popupKeysKeyboardLayout, 0);
mConfigShowPopupKeysKeyboardAtTouchedPoint = keyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showPopupKeysKeyboardAtTouchedPoint, false);
keyboardViewAttr.recycle();
final LayoutInflater inflater = LayoutInflater.from(getContext());
mMoreKeysKeyboardContainer = inflater.inflate(moreKeysKeyboardLayoutId, null);
mPopupKeysKeyboardContainer = inflater.inflate(popupKeysKeyboardLayoutId, null);
}
@Override
@ -123,10 +123,10 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
if (!enabled) return;
final Paint layerPaint = new Paint();
layerPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
mMoreKeysPlacerView.setLayerType(LAYER_TYPE_HARDWARE, layerPaint);
mPopupKeysPlacerView.setLayerType(LAYER_TYPE_HARDWARE, layerPaint);
}
private void installMoreKeysPlacerView(final boolean uninstall) {
private void installPopupKeysPlacerView(final boolean uninstall) {
final View rootView = getRootView();
if (rootView == null) {
Log.w(TAG, "Cannot find root view");
@ -140,9 +140,9 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
}
if (uninstall) {
windowContentView.removeView(mMoreKeysPlacerView);
windowContentView.removeView(mPopupKeysPlacerView);
} else {
windowContentView.addView(mMoreKeysPlacerView);
windowContentView.addView(mPopupKeysPlacerView);
}
}
@ -157,7 +157,7 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
public void setKeyboard(@NonNull final Keyboard keyboard) {
super.setKeyboard(keyboard);
mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */);
mMoreKeysKeyboardCache.clear();
mPopupKeysKeyboardCache.clear();
if (AccessibilityUtils.Companion.getInstance().isAccessibilityEnabled()) {
if (mAccessibilityDelegate == null) {
mAccessibilityDelegate = new KeyboardAccessibilityDelegate<>(this, mKeyDetector);
@ -169,68 +169,68 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
}
@Nullable
public MoreKeysPanel showMoreKeysKeyboard(@NonNull final Key key, final int lastX, final int lastY) {
final MoreKeySpec[] moreKeys = key.getMoreKeys();
if (moreKeys == null) {
public PopupKeysPanel showPopupKeysKeyboard(@NonNull final Key key, final int lastX, final int lastY) {
final PopupKeySpec[] popupKeys = key.getPopupKeys();
if (popupKeys == null) {
return null;
}
Keyboard moreKeysKeyboard = mMoreKeysKeyboardCache.get(key);
if (moreKeysKeyboard == null) {
final MoreKeysKeyboard.Builder builder = new MoreKeysKeyboard.Builder(
Keyboard popupKeysKeyboard = mPopupKeysKeyboardCache.get(key);
if (popupKeysKeyboard == null) {
final PopupKeysKeyboard.Builder builder = new PopupKeysKeyboard.Builder(
getContext(), key, getKeyboard(), false, 0, 0, newLabelPaint(key));
moreKeysKeyboard = builder.build();
mMoreKeysKeyboardCache.put(key, moreKeysKeyboard);
popupKeysKeyboard = builder.build();
mPopupKeysKeyboardCache.put(key, popupKeysKeyboard);
}
final View container = mMoreKeysKeyboardContainer;
final MoreKeysKeyboardView moreKeysKeyboardView = container.findViewById(R.id.more_keys_keyboard_view);
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
final View container = mPopupKeysKeyboardContainer;
final PopupKeysKeyboardView popupKeysKeyboardView = container.findViewById(R.id.popup_keys_keyboard_view);
popupKeysKeyboardView.setKeyboard(popupKeysKeyboard);
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int[] lastCoords = CoordinateUtils.newCoordinateArray(1, lastX, lastY);
// The more keys keyboard is usually horizontally aligned with the center of the parent key.
// If showMoreKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
// The popup keys keyboard is usually horizontally aligned with the center of the parent key.
// If showPopupKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
// keys keyboard is placed at the touch point of the parent key.
final int pointX = mConfigShowMoreKeysKeyboardAtTouchedPoint
final int pointX = mConfigShowPopupKeysKeyboardAtTouchedPoint
? CoordinateUtils.x(lastCoords)
: key.getX() + key.getWidth() / 2;
final int pointY = key.getY();
moreKeysKeyboardView.showMoreKeysPanel(this, this, pointX, pointY, mListener);
return moreKeysKeyboardView;
popupKeysKeyboardView.showPopupKeysPanel(this, this, pointX, pointY, mListener);
return popupKeysKeyboardView;
}
private void dismissMoreKeysPanel() {
if (isShowingMoreKeysPanel()) {
mMoreKeysPanel.dismissMoreKeysPanel();
private void dismissPopupKeysPanel() {
if (isShowingPopupKeysPanel()) {
mPopupKeysPanel.dismissPopupKeysPanel();
}
}
public boolean isShowingMoreKeysPanel() {
return mMoreKeysPanel != null;
public boolean isShowingPopupKeysPanel() {
return mPopupKeysPanel != null;
}
@Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
public void onShowPopupKeysPanel(final PopupKeysPanel panel) {
// install placer view only when needed instead of when this
// view is attached to window
installMoreKeysPlacerView(false /* uninstall */);
panel.showInParent(mMoreKeysPlacerView);
mMoreKeysPanel = panel;
installPopupKeysPlacerView(false /* uninstall */);
panel.showInParent(mPopupKeysPlacerView);
mPopupKeysPanel = panel;
}
@Override
public void onDismissMoreKeysPanel() {
if (isShowingMoreKeysPanel()) {
mMoreKeysPanel.removeFromParent();
mMoreKeysPanel = null;
installMoreKeysPlacerView(true /* uninstall */);
public void onDismissPopupKeysPanel() {
if (isShowingPopupKeysPanel()) {
mPopupKeysPanel.removeFromParent();
mPopupKeysPanel = null;
installPopupKeysPlacerView(true /* uninstall */);
}
}
@Override
public void onCancelMoreKeysPanel() {
if (isShowingMoreKeysPanel()) {
dismissMoreKeysPanel();
public void onCancelPopupKeysPanel() {
if (isShowingPopupKeysPanel()) {
dismissPopupKeysPanel();
}
}
@ -281,7 +281,7 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
}
private void onLongPressed(final Key key) {
if (isShowingMoreKeysPanel()) {
if (isShowingPopupKeysPanel()) {
return;
}
@ -292,11 +292,11 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
final int x = mLastX;
final int y = mLastY;
final MoreKeysPanel moreKeysPanel = showMoreKeysKeyboard(key, x, y);
if (moreKeysPanel != null) {
final int translatedX = moreKeysPanel.translateX(x);
final int translatedY = moreKeysPanel.translateY(y);
moreKeysPanel.onDownEvent(translatedX, translatedY, mPointerId, 0 /* nor used for now */);
final PopupKeysPanel popupKeysPanel = showPopupKeysKeyboard(key, x, y);
if (popupKeysPanel != null) {
final int translatedX = popupKeysPanel.translateX(x);
final int translatedY = popupKeysPanel.translateY(y);
popupKeysPanel.onDownEvent(translatedX, translatedY, mPointerId, 0 /* nor used for now */);
// No need of re-allowing parent later as we don't
// want any scroll to append during this entire input.
disallowParentInterceptTouchEvent(true);
@ -371,13 +371,13 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
final Key currentKey = mCurrentKey;
releaseCurrentKey(false /* withKeyRegistering */);
final boolean isShowingMoreKeysPanel = isShowingMoreKeysPanel();
if (isShowingMoreKeysPanel) {
final boolean isShowingPopupKeysPanel = isShowingPopupKeysPanel();
if (isShowingPopupKeysPanel) {
final long eventTime = e.getEventTime();
final int translatedX = mMoreKeysPanel.translateX(x);
final int translatedY = mMoreKeysPanel.translateY(y);
mMoreKeysPanel.onUpEvent(translatedX, translatedY, mPointerId, eventTime);
dismissMoreKeysPanel();
final int translatedX = mPopupKeysPanel.translateX(x);
final int translatedY = mPopupKeysPanel.translateY(y);
mPopupKeysPanel.onUpEvent(translatedX, translatedY, mPointerId, eventTime);
dismissPopupKeysPanel();
} else if (key == currentKey && pendingKeyDown != null) {
pendingKeyDown.run();
// Trigger key-release event a little later so that a user can see visual feedback.
@ -392,7 +392,7 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
public boolean onCancel(final MotionEvent e) {
releaseCurrentKey(false);
dismissMoreKeysPanel();
dismissPopupKeysPanel();
cancelLongPress();
return true;
}
@ -401,11 +401,11 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
final int x = (int)e.getX();
final int y = (int)e.getY();
final Key key = getKey(x, y);
final boolean isShowingMoreKeysPanel = isShowingMoreKeysPanel();
final boolean isShowingPopupKeysPanel = isShowingPopupKeysPanel();
// Touched key has changed, release previous key's callbacks and
// re-register them for the new key.
if (key != mCurrentKey && !isShowingMoreKeysPanel) {
if (key != mCurrentKey && !isShowingPopupKeysPanel) {
releaseCurrentKey(false);
mCurrentKey = key;
if (key == null) {
@ -417,11 +417,11 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
registerLongPress(key);
}
if (isShowingMoreKeysPanel) {
if (isShowingPopupKeysPanel) {
final long eventTime = e.getEventTime();
final int translatedX = mMoreKeysPanel.translateX(x);
final int translatedY = mMoreKeysPanel.translateY(y);
mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
final int translatedX = mPopupKeysPanel.translateX(x);
final int translatedY = mPopupKeysPanel.translateY(y);
mPopupKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
}
mLastX = x;

View file

@ -18,7 +18,7 @@ public interface OnKeyEventListener {
/**
* Called when a key is released.
* This may be called without any prior call to {@link OnKeyEventListener#onPressKey(Key)},
* for example when a key from a more keys keyboard is selected by releasing touch on it.
* for example when a key from a popup keys keyboard is selected by releasing touch on it.
*/
void onReleaseKey(Key key);
}

View file

@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import helium314.keyboard.keyboard.Key;
import helium314.keyboard.keyboard.MoreKeysPanel;
import helium314.keyboard.keyboard.PopupKeysPanel;
import helium314.keyboard.keyboard.PointerTracker;
public interface DrawingProxy {
@ -29,14 +29,13 @@ public interface DrawingProxy {
void onKeyReleased(@NonNull Key key, boolean withAnimation);
/**
* Start showing more keys keyboard of a key that is being long pressed.
* @param key the {@link Key} that is being long pressed and showing more keys keyboard.
* Start showing popup keys keyboard of a key that is being long pressed.
* @param key the {@link Key} that is being long pressed and showing popup keys keyboard.
* @param tracker the {@link PointerTracker} that detects this long pressing.
* @return {@link MoreKeysPanel} that is being shown. null if there is no need to show more keys
* keyboard.
* @return {@link PopupKeysPanel} that is being shown. null if there is no need to show popup keys keyboard.
*/
@Nullable
MoreKeysPanel showMoreKeysKeyboard(@NonNull Key key, @NonNull PointerTracker tracker);
PopupKeysPanel showPopupKeysKeyboard(@NonNull Key key, @NonNull PointerTracker tracker);
/**
* Start a while-typing-animation.

View file

@ -105,8 +105,8 @@ public final class KeyPreviewChoreographer {
} else {
keyPreviewPosition = KeyPreviewView.POSITION_MIDDLE;
}
final boolean hasMoreKeys = (key.getMoreKeys() != null);
keyPreviewView.setPreviewBackground(hasMoreKeys, keyPreviewPosition);
final boolean hasPopupKeys = (key.getPopupKeys() != null);
keyPreviewView.setPreviewBackground(hasPopupKeys, keyPreviewPosition);
final Colors colors = Settings.getInstance().getCurrent().mColors;
colors.setBackground(keyPreviewView, ColorType.KEY_PREVIEW);

View file

@ -33,13 +33,13 @@ public final class KeyPreviewDrawParams {
// | key|
// +-------+
// The background of a {@link TextView} being used for a key preview may have invisible
// paddings. To align the more keys keyboard panel's visible part with the visible part of
// paddings. To align the popup keys keyboard panel's visible part with the visible part of
// the background, we need to record the width and height of key preview that don't include
// invisible paddings.
private int mVisibleWidth;
private int mVisibleHeight;
// The key preview may have an arbitrary offset and its background that may have a bottom
// padding. To align the more keys keyboard and the key preview we also need to record the
// padding. To align the popup keys keyboard and the key preview we also need to record the
// offset between the top edge of parent key and the bottom of the visible part of key
// preview background.
private int mVisibleOffset;

View file

@ -110,26 +110,26 @@ public class KeyPreviewView extends AppCompatTextView {
private static final int[][][] KEY_PREVIEW_BACKGROUND_STATE_TABLE = {
{ // POSITION_MIDDLE
{},
{ R.attr.state_has_morekeys }
{ R.attr.state_has_popup_keys}
},
{ // POSITION_LEFT
{ R.attr.state_left_edge },
{ R.attr.state_left_edge, R.attr.state_has_morekeys }
{ R.attr.state_left_edge, R.attr.state_has_popup_keys}
},
{ // POSITION_RIGHT
{ R.attr.state_right_edge },
{ R.attr.state_right_edge, R.attr.state_has_morekeys }
{ R.attr.state_right_edge, R.attr.state_has_popup_keys}
}
};
private static final int STATE_NORMAL = 0;
private static final int STATE_HAS_MOREKEYS = 1;
private static final int STATE_HAS_POPUPKEYS = 1;
public void setPreviewBackground(final boolean hasMoreKeys, final int position) {
public void setPreviewBackground(final boolean hasPopupKeys, final int position) {
final Drawable background = getBackground();
if (background == null) {
return;
}
final int hasMoreKeysState = hasMoreKeys ? STATE_HAS_MOREKEYS : STATE_NORMAL;
background.setState(KEY_PREVIEW_BACKGROUND_STATE_TABLE[position][hasMoreKeysState]);
final int hasPopupKeysState = hasPopupKeys ? STATE_HAS_POPUPKEYS : STATE_NORMAL;
background.setState(KEY_PREVIEW_BACKGROUND_STATE_TABLE[position][hasPopupKeysState]);
}
}

View file

@ -30,7 +30,7 @@ import androidx.annotation.Nullable;
* - Code point presented by hexadecimal string prefixed with "0x"
* - Code reference represented by (!code/code_name), see {@link KeyboardCodesSet}.
* Special character, comma ',' backslash '\', and bar '|' can be escaped by '\' character.
* Note that the '\' is also parsed by XML parser and {@link MoreKeySpec#splitKeySpecs(String)}
* Note that the '\' is also parsed by XML parser and {@link PopupKeySpec#splitKeySpecs(String)}
* as well.
*/
// TODO: Rename to KeySpec and make this class to the key specification object.

View file

@ -42,23 +42,23 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
mParams.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height)
}
fun setAllowRedundantMoreKeys(enabled: Boolean) {
mParams.mAllowRedundantMoreKeys = enabled
fun setAllowRedundantPopupKeys(enabled: Boolean) {
mParams.mAllowRedundantPopupKeys = enabled
}
fun load(id: KeyboardId): KeyboardBuilder<KP> {
mParams.mId = id
if (id.isEmojiKeyboard) {
setAllowRedundantMoreKeys(true)
setAllowRedundantPopupKeys(true)
readAttributes(R.xml.kbd_emoji)
keysInRows = EmojiParser(mParams, mContext).parse()
} else {
try {
val sv = Settings.getInstance().current
addLocaleKeyTextsToParams(mContext, mParams, sv.mShowMoreMoreKeys)
mParams.mMoreKeyTypes.addAll(sv.mMoreKeyTypes)
// add label source only if moreKey type enabled
sv.mMoreKeyLabelSources.forEach { if (it in sv.mMoreKeyTypes) mParams.mMoreKeyLabelSources.add(it) }
addLocaleKeyTextsToParams(mContext, mParams, sv.mShowMorePopupKeys)
mParams.mPopupKeyTypes.addAll(sv.mPopupKeyTypes)
// add label source only if popup key type enabled
sv.mPopupKeyLabelSources.forEach { if (it in sv.mPopupKeyTypes) mParams.mPopupKeyLabelSources.add(it) }
keysInRows = KeyboardParser.parseLayout(mParams, mContext)
determineAbsoluteValues()
} catch (e: Exception) {
@ -259,7 +259,7 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
}
private fun endKeyboard() {
mParams.removeRedundantMoreKeys()
mParams.removeRedundantPopupKeys()
// {@link #parseGridRows(XmlPullParser,boolean)} may populate keyboard rows higher than
// previously expected.
// todo (low priority): mCurrentY may end up too high with the new parser and 4 row keyboards in landscape mode

View file

@ -64,8 +64,8 @@ public class KeyboardParams {
public int mHorizontalGap;
public int mVerticalGap;
public int mMoreKeysTemplate;
public int mMaxMoreKeysKeyboardColumn;
public int mPopupKeysTemplate;
public int mMaxPopupKeysKeyboardColumn;
public int GRID_WIDTH;
public int GRID_HEIGHT;
@ -81,12 +81,12 @@ public class KeyboardParams {
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
@NonNull // todo: not good, this only works because params are currently always created for the active subtype
public final List<Locale> mSecondaryLocales = Settings.getInstance().getCurrent().mSecondaryLocales;
public final ArrayList<String> mMoreKeyTypes = new ArrayList<>();
public final ArrayList<String> mMoreKeyLabelSources = new ArrayList<>();
public final ArrayList<String> mPopupKeyTypes = new ArrayList<>();
public final ArrayList<String> mPopupKeyLabelSources = new ArrayList<>();
@NonNull
private final UniqueKeysCache mUniqueKeysCache;
public boolean mAllowRedundantMoreKeys;
public boolean mAllowRedundantPopupKeys;
@NonNull
public LocaleKeyTexts mLocaleKeyTexts;
@ -142,19 +142,19 @@ public class KeyboardParams {
}
}
public void removeRedundantMoreKeys() {
if (mAllowRedundantMoreKeys) {
public void removeRedundantPopupKeys() {
if (mAllowRedundantPopupKeys) {
return;
}
final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout =
new MoreKeySpec.LettersOnBaseLayout();
final PopupKeySpec.LettersOnBaseLayout lettersOnBaseLayout =
new PopupKeySpec.LettersOnBaseLayout();
for (final Key key : mSortedKeys) {
lettersOnBaseLayout.addLetter(key);
}
final ArrayList<Key> allKeys = new ArrayList<>(mSortedKeys);
mSortedKeys.clear();
for (final Key key : allKeys) {
final Key filteredKey = Key.removeRedundantMoreKeys(key, lettersOnBaseLayout);
final Key filteredKey = Key.removeRedundantPopupKeys(key, lettersOnBaseLayout);
mSortedKeys.add(mUniqueKeysCache.getUniqueKey(filteredKey));
}
}
@ -199,7 +199,7 @@ public class KeyboardParams {
// when attr is null, default attributes will be loaded
// these are good for basic keyboards already, but have wrong/unsuitable sizes e.g. for emojis,
// moreKeys and moreSuggestions
// popupKeys and moreSuggestions
public void readAttributes(final Context context, @Nullable final AttributeSet attr) {
final TypedArray keyboardAttr = context.obtainStyledAttributes(
attr, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
@ -260,8 +260,8 @@ public class KeyboardParams {
mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);
mMoreKeysTemplate = keyboardAttr.getResourceId(R.styleable.Keyboard_moreKeysTemplate, 0);
mMaxMoreKeysKeyboardColumn = keyAttr.getInt(R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);
mPopupKeysTemplate = keyboardAttr.getResourceId(R.styleable.Keyboard_popupKeysTemplate, 0);
mMaxPopupKeysKeyboardColumn = keyAttr.getInt(R.styleable.Keyboard_Key_maxPopupKeysColumn, 5);
mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
mIconsSet.loadIcons(keyboardAttr);

View file

@ -627,7 +627,7 @@ public final class KeyboardState {
}
}
} else {
// In symbol mode, just toggle symbol and symbol more keyboard.
// In symbol mode, just toggle symbol and symbol popup keyboard.
toggleShiftInSymbols();
mSwitchState = SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE;
mShiftKeyState.onPress();

View file

@ -17,7 +17,7 @@ import helium314.keyboard.latin.common.StringUtils;
* The string parser of moreCodesArray specification for <GridRows />. The attribute moreCodesArray is an
* array of string.
* The more codes array specification is semicolon separated "codes array specification" each of which represents one
* "more key".
* "popup key".
* Each element of the array defines a sequence of key labels specified as hexadecimal strings
* representing code points separated by a vertical bar.
*

View file

@ -22,18 +22,18 @@ import java.util.HashSet;
import java.util.Locale;
/**
* The more key specification object. The more keys are an array of {@link MoreKeySpec}.
*
* The more keys specification is comma separated "key specification" each of which represents one
* "more key".
* The popup key specification object. The popup keys are an array of {@link PopupKeySpec}.
* <p>
* The popup keys specification is comma separated "key specification" each of which represents one
* "popup key".
* The key specification might have label or string resource reference in it. These references are
* expanded before parsing comma.
* Special character, comma ',' backslash '\' can be escaped by '\' character.
* Note that the '\' is also parsed by XML parser and {@link MoreKeySpec#splitKeySpecs(String)}
* Note that the '\' is also parsed by XML parser and {@link PopupKeySpec#splitKeySpecs(String)}
* as well.
*/
// TODO: Should extend the key specification object.
public final class MoreKeySpec {
public final class PopupKeySpec {
public final int mCode;
@Nullable
public final String mLabel;
@ -41,14 +41,14 @@ public final class MoreKeySpec {
public final String mOutputText;
public final int mIconId;
public MoreKeySpec(@NonNull final String moreKeySpec, boolean needsToUpperCase,
@NonNull final Locale locale) {
if (moreKeySpec.isEmpty()) {
throw new KeySpecParser.KeySpecParserError("Empty more key spec");
public PopupKeySpec(@NonNull final String popupKeySpec, boolean needsToUpperCase,
@NonNull final Locale locale) {
if (popupKeySpec.isEmpty()) {
throw new KeySpecParser.KeySpecParserError("Empty popup key spec");
}
final String label = KeySpecParser.getLabel(moreKeySpec);
final String label = KeySpecParser.getLabel(popupKeySpec);
mLabel = needsToUpperCase ? StringUtils.toTitleCaseOfKeyLabel(label, locale) : label;
final int codeInSpec = KeySpecParser.getCode(moreKeySpec);
final int codeInSpec = KeySpecParser.getCode(popupKeySpec);
final int code = needsToUpperCase ? StringUtils.toTitleCaseOfKeyCode(codeInSpec, locale)
: codeInSpec;
if (code == Constants.CODE_UNSPECIFIED) {
@ -58,11 +58,11 @@ public final class MoreKeySpec {
mOutputText = mLabel;
} else {
mCode = code;
final String outputText = KeySpecParser.getOutputText(moreKeySpec);
final String outputText = KeySpecParser.getOutputText(popupKeySpec);
mOutputText = needsToUpperCase
? StringUtils.toTitleCaseOfKeyLabel(outputText, locale) : outputText;
}
mIconId = KeySpecParser.getIconId(moreKeySpec);
mIconId = KeySpecParser.getIconId(popupKeySpec);
}
@NonNull
@ -89,8 +89,8 @@ public final class MoreKeySpec {
if (this == o) {
return true;
}
if (o instanceof MoreKeySpec) {
final MoreKeySpec other = (MoreKeySpec)o;
if (o instanceof PopupKeySpec) {
final PopupKeySpec other = (PopupKeySpec)o;
return mCode == other.mCode
&& mIconId == other.mIconId
&& TextUtils.equals(mLabel, other.mLabel)
@ -124,40 +124,40 @@ public final class MoreKeySpec {
}
}
public boolean contains(@NonNull final MoreKeySpec moreKey) {
final int code = moreKey.mCode;
public boolean contains(@NonNull final PopupKeySpec popupKey) {
final int code = popupKey.mCode;
if (mCodes.indexOfKey(code) >= 0) {
return true;
} else return code == Constants.CODE_OUTPUT_TEXT && mTexts.contains(moreKey.mOutputText);
} else return code == Constants.CODE_OUTPUT_TEXT && mTexts.contains(popupKey.mOutputText);
}
}
@Nullable
public static MoreKeySpec[] removeRedundantMoreKeys(@Nullable final MoreKeySpec[] moreKeys,
public static PopupKeySpec[] removeRedundantPopupKeys(@Nullable final PopupKeySpec[] popupKeys,
@NonNull final LettersOnBaseLayout lettersOnBaseLayout) {
if (moreKeys == null) {
if (popupKeys == null) {
return null;
}
final ArrayList<MoreKeySpec> filteredMoreKeys = new ArrayList<>();
for (final MoreKeySpec moreKey : moreKeys) {
if (!lettersOnBaseLayout.contains(moreKey)) {
filteredMoreKeys.add(moreKey);
final ArrayList<PopupKeySpec> filteredPopupKeys = new ArrayList<>();
for (final PopupKeySpec popupKey : popupKeys) {
if (!lettersOnBaseLayout.contains(popupKey)) {
filteredPopupKeys.add(popupKey);
}
}
final int size = filteredMoreKeys.size();
if (size == moreKeys.length) {
return moreKeys;
final int size = filteredPopupKeys.size();
if (size == popupKeys.length) {
return popupKeys;
}
if (size == 0) {
return null;
}
return filteredMoreKeys.toArray(new MoreKeySpec[size]);
return filteredPopupKeys.toArray(new PopupKeySpec[size]);
}
// Constants for parsing.
private static final char COMMA = Constants.CODE_COMMA;
private static final char BACKSLASH = Constants.CODE_BACKSLASH;
private static final String ADDITIONAL_MORE_KEY_MARKER =
private static final String ADDITIONAL_POPUP_KEY_MARKER =
StringUtils.newSingleCodePointString(Constants.CODE_PERCENT);
/**
@ -239,55 +239,55 @@ public final class MoreKeySpec {
return out.toArray(new String[0]);
}
public static String[] insertAdditionalMoreKeys(@Nullable final String[] moreKeySpecs,
@Nullable final String[] additionalMoreKeySpecs) {
final String[] moreKeys = filterOutEmptyString(moreKeySpecs);
final String[] additionalMoreKeys = filterOutEmptyString(additionalMoreKeySpecs);
final int moreKeysCount = moreKeys.length;
final int additionalCount = additionalMoreKeys.length;
public static String[] insertAdditionalPopupKeys(@Nullable final String[] popupKeySpecs,
@Nullable final String[] additionalPopupKeySpecs) {
final String[] popupKeys = filterOutEmptyString(popupKeySpecs);
final String[] additionalPopupKeys = filterOutEmptyString(additionalPopupKeySpecs);
final int popupKeysCount = popupKeys.length;
final int additionalCount = additionalPopupKeys.length;
ArrayList<String> out = null;
int additionalIndex = 0;
for (int moreKeyIndex = 0; moreKeyIndex < moreKeysCount; moreKeyIndex++) {
final String moreKeySpec = moreKeys[moreKeyIndex];
if (moreKeySpec.equals(ADDITIONAL_MORE_KEY_MARKER)) {
for (int popupKeyIndex = 0; popupKeyIndex < popupKeysCount; popupKeyIndex++) {
final String popupKeySpec = popupKeys[popupKeyIndex];
if (popupKeySpec.equals(ADDITIONAL_POPUP_KEY_MARKER)) {
if (additionalIndex < additionalCount) {
// Replace '%' marker with additional more key specification.
final String additionalMoreKey = additionalMoreKeys[additionalIndex];
// Replace '%' marker with additional popup key specification.
final String additionalPopupKey = additionalPopupKeys[additionalIndex];
if (out != null) {
out.add(additionalMoreKey);
out.add(additionalPopupKey);
} else {
moreKeys[moreKeyIndex] = additionalMoreKey;
popupKeys[popupKeyIndex] = additionalPopupKey;
}
additionalIndex++;
} else {
// Filter out excessive '%' marker.
if (out == null) {
out = CollectionUtils.arrayAsList(moreKeys, 0, moreKeyIndex);
out = CollectionUtils.arrayAsList(popupKeys, 0, popupKeyIndex);
}
}
} else {
if (out != null) {
out.add(moreKeySpec);
out.add(popupKeySpec);
}
}
}
if (additionalCount > 0 && additionalIndex == 0) {
// No '%' marker is found in more keys.
// Insert all additional more keys to the head of more keys.
out = CollectionUtils.arrayAsList(additionalMoreKeys, additionalIndex, additionalCount);
for (int i = 0; i < moreKeysCount; i++) {
out.add(moreKeys[i]);
// No '%' marker is found in popup keys.
// Insert all additional popup keys to the head of popup keys.
out = CollectionUtils.arrayAsList(additionalPopupKeys, additionalIndex, additionalCount);
for (int i = 0; i < popupKeysCount; i++) {
out.add(popupKeys[i]);
}
} else if (additionalIndex < additionalCount) {
// The number of '%' markers are less than additional more keys.
// Append remained additional more keys to the tail of more keys.
out = CollectionUtils.arrayAsList(moreKeys, 0, moreKeysCount);
// The number of '%' markers are less than additional popup keys.
// Append remained additional popup keys to the tail of popup keys.
out = CollectionUtils.arrayAsList(popupKeys, 0, popupKeysCount);
for (int i = additionalIndex; i < additionalCount; i++) {
out.add(additionalMoreKeys[i]);
out.add(additionalPopupKeys[i]);
}
}
if (out == null && moreKeysCount > 0) {
return moreKeys;
if (out == null && popupKeysCount > 0) {
return popupKeys;
} else if (out != null && out.size() > 0) {
return out.toArray(new String[0]);
} else {
@ -295,44 +295,44 @@ public final class MoreKeySpec {
}
}
public static int getIntValue(@Nullable final String[] moreKeys, final String key,
public static int getIntValue(@Nullable final String[] popupKeys, final String key,
final int defaultValue) {
if (moreKeys == null) {
if (popupKeys == null) {
return defaultValue;
}
final int keyLen = key.length();
boolean foundValue = false;
int value = defaultValue;
for (int i = 0; i < moreKeys.length; i++) {
final String moreKeySpec = moreKeys[i];
if (moreKeySpec == null || !moreKeySpec.startsWith(key)) {
for (int i = 0; i < popupKeys.length; i++) {
final String popupKeySpec = popupKeys[i];
if (popupKeySpec == null || !popupKeySpec.startsWith(key)) {
continue;
}
moreKeys[i] = null;
popupKeys[i] = null;
try {
if (!foundValue) {
value = Integer.parseInt(moreKeySpec.substring(keyLen));
value = Integer.parseInt(popupKeySpec.substring(keyLen));
foundValue = true;
}
} catch (NumberFormatException e) {
throw new RuntimeException(
"integer should follow after " + key + ": " + moreKeySpec);
"integer should follow after " + key + ": " + popupKeySpec);
}
}
return value;
}
public static boolean getBooleanValue(@Nullable final String[] moreKeys, final String key) {
if (moreKeys == null) {
public static boolean getBooleanValue(@Nullable final String[] popupKeys, final String key) {
if (popupKeys == null) {
return false;
}
boolean value = false;
for (int i = 0; i < moreKeys.length; i++) {
final String moreKeySpec = moreKeys[i];
if (moreKeySpec == null || !moreKeySpec.equals(key)) {
for (int i = 0; i < popupKeys.length; i++) {
final String popupKeySpec = popupKeys[i];
if (popupKeySpec == null || !popupKeySpec.equals(key)) {
continue;
}
moreKeys[i] = null;
popupKeys[i] = null;
value = true;
}
return value;

Some files were not shown because too many files have changed in this diff Show more