mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-28 18:48:09 +00:00
move zwj and zwnj codes from Constants to KeyCode
and support florisboard name half_space for zwnj
This commit is contained in:
parent
cd44d2dc9f
commit
e289e7ef5f
5 changed files with 9 additions and 7 deletions
|
@ -30,6 +30,7 @@ import androidx.annotation.Nullable;
|
||||||
import helium314.keyboard.keyboard.emoji.EmojiPageKeyboardView;
|
import helium314.keyboard.keyboard.emoji.EmojiPageKeyboardView;
|
||||||
import helium314.keyboard.keyboard.internal.KeyDrawParams;
|
import helium314.keyboard.keyboard.internal.KeyDrawParams;
|
||||||
import helium314.keyboard.keyboard.internal.KeyVisualAttributes;
|
import helium314.keyboard.keyboard.internal.KeyVisualAttributes;
|
||||||
|
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode;
|
||||||
import helium314.keyboard.latin.R;
|
import helium314.keyboard.latin.R;
|
||||||
import helium314.keyboard.latin.common.ColorType;
|
import helium314.keyboard.latin.common.ColorType;
|
||||||
import helium314.keyboard.latin.common.Colors;
|
import helium314.keyboard.latin.common.Colors;
|
||||||
|
@ -640,7 +641,7 @@ public class KeyboardView extends View {
|
||||||
} else if (this instanceof PopupKeysKeyboardView) {
|
} else if (this instanceof PopupKeysKeyboardView) {
|
||||||
// set color filter for long press comma key, should not trigger anywhere else
|
// set color filter for long press comma key, should not trigger anywhere else
|
||||||
mColors.setColor(icon, ColorType.KEY_ICON);
|
mColors.setColor(icon, ColorType.KEY_ICON);
|
||||||
} else if (key.getCode() == Constants.CODE_SPACE || key.getCode() == 0x200C) {
|
} else if (key.getCode() == Constants.CODE_SPACE || key.getCode() == KeyCode.ZWNJ) {
|
||||||
// set color of default number pad space bar icon for Holo style, or for zero-width non-joiner (zwnj) on some layouts like nepal
|
// set color of default number pad space bar icon for Holo style, or for zero-width non-joiner (zwnj) on some layouts like nepal
|
||||||
mColors.setColor(icon, ColorType.KEY_ICON);
|
mColors.setColor(icon, ColorType.KEY_ICON);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,8 @@ object KeyCode {
|
||||||
const val KANA_HALF_KATA = -9713
|
const val KANA_HALF_KATA = -9713
|
||||||
|
|
||||||
const val KESHIDA = 1600
|
const val KESHIDA = 1600
|
||||||
const val HALF_SPACE = 8204
|
const val ZWNJ = 8204 // 0x200C, named HALF_SPACE in FlorisBoard
|
||||||
|
const val ZWJ = 8205 // 0x200D
|
||||||
|
|
||||||
const val CJK_SPACE = 12288
|
const val CJK_SPACE = 12288
|
||||||
|
|
||||||
|
@ -154,6 +155,7 @@ object KeyCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** to make sure a FlorisBoard label works when reading a JSON layout */
|
/** to make sure a FlorisBoard label works when reading a JSON layout */
|
||||||
|
// resulting special labels should be names of FunctionalKey enum, case insensitive
|
||||||
fun String.convertFlorisLabel(): String = when (this) {
|
fun String.convertFlorisLabel(): String = when (this) {
|
||||||
"view_characters" -> "alpha"
|
"view_characters" -> "alpha"
|
||||||
"view_symbols" -> "symbol"
|
"view_symbols" -> "symbol"
|
||||||
|
@ -170,6 +172,7 @@ object KeyCode {
|
||||||
"currency_slot_5" -> "$$$4"
|
"currency_slot_5" -> "$$$4"
|
||||||
"currency_slot_6" -> "$$$5"
|
"currency_slot_6" -> "$$$5"
|
||||||
"enter" -> "action"
|
"enter" -> "action"
|
||||||
|
"half_space" -> "zwnj"
|
||||||
else -> this
|
else -> this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ sealed interface KeyData : AbstractKeyData {
|
||||||
|
|
||||||
fun isSpaceKey(): Boolean {
|
fun isSpaceKey(): Boolean {
|
||||||
return type == KeyType.CHARACTER && (code == Constants.CODE_SPACE || code == KeyCode.CJK_SPACE
|
return type == KeyType.CHARACTER && (code == Constants.CODE_SPACE || code == KeyCode.CJK_SPACE
|
||||||
|| code == KeyCode.HALF_SPACE || code == KeyCode.KESHIDA)
|
|| code == KeyCode.ZWNJ || code == KeyCode.KESHIDA)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toKeyParams(params: KeyboardParams, width: Float = params.mDefaultRelativeKeyWidth, additionalLabelFlags: Int = 0): Key.KeyParams {
|
fun toKeyParams(params: KeyboardParams, width: Float = params.mDefaultRelativeKeyWidth, additionalLabelFlags: Int = 0): Key.KeyParams {
|
||||||
|
|
|
@ -191,8 +191,6 @@ public final class Constants {
|
||||||
|
|
||||||
public static final String REGEXP_PERIOD = "\\.";
|
public static final String REGEXP_PERIOD = "\\.";
|
||||||
public static final String STRING_SPACE = " ";
|
public static final String STRING_SPACE = " ";
|
||||||
public static final int CODE_ZWNJ = '\u200C';
|
|
||||||
public static final int CODE_ZWJ = '\u200D';
|
|
||||||
|
|
||||||
public static boolean isLetterCode(final int code) {
|
public static boolean isLetterCode(final int code) {
|
||||||
return code >= CODE_SPACE;
|
return code >= CODE_SPACE;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package helium314.keyboard.latin.common
|
package helium314.keyboard.latin.common
|
||||||
|
|
||||||
|
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
||||||
import helium314.keyboard.latin.common.StringUtils.mightBeEmoji
|
import helium314.keyboard.latin.common.StringUtils.mightBeEmoji
|
||||||
import helium314.keyboard.latin.common.StringUtils.newSingleCodePointString
|
import helium314.keyboard.latin.common.StringUtils.newSingleCodePointString
|
||||||
import helium314.keyboard.latin.settings.SpacingAndPunctuations
|
import helium314.keyboard.latin.settings.SpacingAndPunctuations
|
||||||
|
@ -62,8 +63,7 @@ fun getFullEmojiAtEnd(s: CharSequence): String {
|
||||||
// stop if codepoint can't be emoji
|
// stop if codepoint can't be emoji
|
||||||
if (!mightBeEmoji(codepoint)) return ""
|
if (!mightBeEmoji(codepoint)) return ""
|
||||||
offset -= Character.charCount(codepoint)
|
offset -= Character.charCount(codepoint)
|
||||||
if (offset > 0 && text[offset - 1].code == Constants.CODE_ZWJ) {
|
if (offset > 0 && text[offset - 1].code == KeyCode.ZWJ) {
|
||||||
// continue if ZWJ
|
|
||||||
offset -= 1
|
offset -= 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue