mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Squashed commit of the following: commit 8e86347b024e2460a17264fbcaa20cd6e5fd6018 Author: Chieu Nguyen <cvnguyen@google.com> Date: Tue Nov 10 11:29:44 2015 -0800 Remove check for version code. This was unnecessary and caused multi-codepoint emoji to not show up on any device. Bug: 25369504 Change-Id: Ia1e61c052444aaab824b18463c26b5a8066c65ed commit 1b924816665a3a2c48307dbdd1078f61dd3179f2 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 18:12:58 2015 -0800 Fix Material icons for new tab. Bug: 25369504 Bug: 16185905 Change-Id: I873eb9e8fc1259ac94a974c04a80a4f0d005f9c2 commit 956d5f86d2552d90d2c3240a85d5c1cddf05eda9 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 17:16:10 2015 -0800 Remove extraneous TalkBack descriptions. Bug: 25369504 Bug: 16185905 Change-Id: Iec4f0f46cf9dda169c5827168ef207e56d619096 commit 07357bdec69b5fc118c82401d59b61ad7b802c22 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 16:01:34 2015 -0800 Better checking of whether to display new emoji. Bug: 25369504 Bug: 16185905 Change-Id: I61f1b428e5a805f66eb4e9db346be8756fc84b8f commit 666a92f17034f5a1948e70f40226ed995c72d81f Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 12:54:53 2015 -0800 Fix shading on emoji category icons. Bug: 25369504 Bug: 16185905 Change-Id: I217af3d97120e7910e9850de7ea331a461ae7e56 commit 2712432c0e7a1b90ebb7ed6bde8f87eec7bf1094 Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 19:06:57 2015 -0800 Add new emoji categories to Holo Blue. Bug: 25369504 Bug: 16185905 Change-Id: Ie32af93e68e08b36a4a5861a06de511b2b190dca commit 04c79b1f53912b263d7f7eb8b71ac802ed960a8a Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 18:06:35 2015 -0800 Fix default category, remove xxxhdpi Holo icons. Bug: 25369504 Bug: 16185905 Change-Id: I9bca795675297dceb93777d998e8f2935f7031a6 commit 15c0b578343db2baa873096891a69305398eb830 Merge: 77bc6fc 8604ce3 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 00:59:08 2015 +0000 Merge changes into jb-ub-latinimegoogle commit 77bc6fcfd760232757b5751993c0046f2a43626a Merge: b0380a0 8604ce3 Author: Chieu Nguyen <cvnguyen@google.com> Date: Fri Nov 6 00:59:04 2015 +0000 Merge "Remove Kosovo from flags (no glyph)." into jb-ub-latinimegoogle commit b0380a0744647039278ad6648b7a1bc94eeab623 Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 16:42:24 2015 -0800 Add icons for new emoji categories. Bug: 25369504 Bug: 16185905 Change-Id: I1182e031994332b2e618406ad1cd467cb050766e commit 8604ce3a34b65598101cac37a3ed3e8087fe38ca Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 16:29:33 2015 -0800 Remove Kosovo from flags (no glyph). Bug: 25369504 Bug: 16185905 Change-Id: I92c9ace19d3600cfa1f27678ada0cf45af42d8f5 commit e0489eab47d3a6d138bfa00a668f02bcb473cf88 Author: Chieu Nguyen <cvnguyen@google.com> Date: Thu Nov 5 14:30:58 2015 -0800 Update emoji set to blacklist non-color glyphs. Bug: 25369504 Bug: 16185905 Change-Id: I8b54217fa68da8ddaa1bbcd1845e0123ed106463 commit 9ffdcdff058d6b44cab70e4fb0bb301e39699483 Author: Chieu Nguyen <cvnguyen@google.com> Date: Wed Nov 4 17:18:22 2015 -0800 Add Unicode 8.0 emoji to emoji palette. Currently all emoji category tabs use the flower icon. A future CL will update these once the icons are finalized. If glyphs do not exist for new emoji, the old categories will be shown. Bug: 25369504 Bug: 16185905 Change-Id: Ie3759bfc4c8469a17f3205b45609ce6ef7510121 commit 4a4a042072790b19048a14d2ddab655b1be31a6e Author: Chieu Nguyen <cvnguyen@google.com> Date: Sun Nov 1 18:38:20 2015 -0800 Add description strings for Unicode 8.0 new emoji. Bug: 16185905 Bug: 25369504 Change-Id: I6048609ace715a23db5f82d47fefe4868ccb3d17 Change-Id: I30a043554b14531ab9cf89a1f663b6970d7d6863
272 lines
11 KiB
Java
272 lines
11 KiB
Java
/*
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.inputmethod.keyboard;
|
|
|
|
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
|
|
|
|
import android.text.InputType;
|
|
import android.text.TextUtils;
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
|
import com.android.inputmethod.compat.EditorInfoCompatUtils;
|
|
import com.android.inputmethod.latin.RichInputMethodSubtype;
|
|
import com.android.inputmethod.latin.utils.InputTypeUtils;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Locale;
|
|
|
|
/**
|
|
* Unique identifier for each keyboard type.
|
|
*/
|
|
public final class KeyboardId {
|
|
public static final int MODE_TEXT = 0;
|
|
public static final int MODE_URL = 1;
|
|
public static final int MODE_EMAIL = 2;
|
|
public static final int MODE_IM = 3;
|
|
public static final int MODE_PHONE = 4;
|
|
public static final int MODE_NUMBER = 5;
|
|
public static final int MODE_DATE = 6;
|
|
public static final int MODE_TIME = 7;
|
|
public static final int MODE_DATETIME = 8;
|
|
|
|
public static final int ELEMENT_ALPHABET = 0;
|
|
public static final int ELEMENT_ALPHABET_MANUAL_SHIFTED = 1;
|
|
public static final int ELEMENT_ALPHABET_AUTOMATIC_SHIFTED = 2;
|
|
public static final int ELEMENT_ALPHABET_SHIFT_LOCKED = 3;
|
|
public static final int ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED = 4;
|
|
public static final int ELEMENT_SYMBOLS = 5;
|
|
public static final int ELEMENT_SYMBOLS_SHIFTED = 6;
|
|
public static final int ELEMENT_PHONE = 7;
|
|
public static final int ELEMENT_PHONE_SYMBOLS = 8;
|
|
public static final int ELEMENT_NUMBER = 9;
|
|
public static final int ELEMENT_EMOJI_RECENTS = 10;
|
|
public static final int ELEMENT_EMOJI_CATEGORY1 = 11;
|
|
public static final int ELEMENT_EMOJI_CATEGORY2 = 12;
|
|
public static final int ELEMENT_EMOJI_CATEGORY3 = 13;
|
|
public static final int ELEMENT_EMOJI_CATEGORY4 = 14;
|
|
public static final int ELEMENT_EMOJI_CATEGORY5 = 15;
|
|
public static final int ELEMENT_EMOJI_CATEGORY6 = 16;
|
|
public static final int ELEMENT_EMOJI_CATEGORY7 = 17;
|
|
public static final int ELEMENT_EMOJI_CATEGORY8 = 18;
|
|
public static final int ELEMENT_EMOJI_CATEGORY9 = 19;
|
|
public static final int ELEMENT_EMOJI_CATEGORY10 = 20;
|
|
public static final int ELEMENT_EMOJI_CATEGORY11 = 21;
|
|
public static final int ELEMENT_EMOJI_CATEGORY12 = 22;
|
|
public static final int ELEMENT_EMOJI_CATEGORY13 = 23;
|
|
public static final int ELEMENT_EMOJI_CATEGORY14 = 24;
|
|
public static final int ELEMENT_EMOJI_CATEGORY15 = 25;
|
|
public static final int ELEMENT_EMOJI_CATEGORY16 = 26;
|
|
|
|
public final RichInputMethodSubtype mSubtype;
|
|
public final int mWidth;
|
|
public final int mHeight;
|
|
public final int mMode;
|
|
public final int mElementId;
|
|
public final EditorInfo mEditorInfo;
|
|
public final boolean mClobberSettingsKey;
|
|
public final boolean mLanguageSwitchKeyEnabled;
|
|
public final String mCustomActionLabel;
|
|
public final boolean mHasShortcutKey;
|
|
public final boolean mIsSplitLayout;
|
|
|
|
private final int mHashCode;
|
|
|
|
public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
|
|
mSubtype = params.mSubtype;
|
|
mWidth = params.mKeyboardWidth;
|
|
mHeight = params.mKeyboardHeight;
|
|
mMode = params.mMode;
|
|
mElementId = elementId;
|
|
mEditorInfo = params.mEditorInfo;
|
|
mClobberSettingsKey = params.mNoSettingsKey;
|
|
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
|
|
mCustomActionLabel = (mEditorInfo.actionLabel != null)
|
|
? mEditorInfo.actionLabel.toString() : null;
|
|
mHasShortcutKey = params.mVoiceInputKeyEnabled;
|
|
mIsSplitLayout = params.mIsSplitLayoutEnabled;
|
|
|
|
mHashCode = computeHashCode(this);
|
|
}
|
|
|
|
private static int computeHashCode(final KeyboardId id) {
|
|
return Arrays.hashCode(new Object[] {
|
|
id.mElementId,
|
|
id.mMode,
|
|
id.mWidth,
|
|
id.mHeight,
|
|
id.passwordInput(),
|
|
id.mClobberSettingsKey,
|
|
id.mHasShortcutKey,
|
|
id.mLanguageSwitchKeyEnabled,
|
|
id.isMultiLine(),
|
|
id.imeAction(),
|
|
id.mCustomActionLabel,
|
|
id.navigateNext(),
|
|
id.navigatePrevious(),
|
|
id.mSubtype,
|
|
id.mIsSplitLayout
|
|
});
|
|
}
|
|
|
|
private boolean equals(final KeyboardId other) {
|
|
if (other == this)
|
|
return true;
|
|
return other.mElementId == mElementId
|
|
&& other.mMode == mMode
|
|
&& other.mWidth == mWidth
|
|
&& other.mHeight == mHeight
|
|
&& other.passwordInput() == passwordInput()
|
|
&& other.mClobberSettingsKey == mClobberSettingsKey
|
|
&& other.mHasShortcutKey == mHasShortcutKey
|
|
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
|
|
&& other.isMultiLine() == isMultiLine()
|
|
&& other.imeAction() == imeAction()
|
|
&& TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
|
|
&& other.navigateNext() == navigateNext()
|
|
&& other.navigatePrevious() == navigatePrevious()
|
|
&& other.mSubtype.equals(mSubtype)
|
|
&& other.mIsSplitLayout == mIsSplitLayout;
|
|
}
|
|
|
|
private static boolean isAlphabetKeyboard(final int elementId) {
|
|
return elementId < ELEMENT_SYMBOLS;
|
|
}
|
|
|
|
public boolean isAlphabetKeyboard() {
|
|
return isAlphabetKeyboard(mElementId);
|
|
}
|
|
|
|
public boolean navigateNext() {
|
|
return (mEditorInfo.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0
|
|
|| imeAction() == EditorInfo.IME_ACTION_NEXT;
|
|
}
|
|
|
|
public boolean navigatePrevious() {
|
|
return (mEditorInfo.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS) != 0
|
|
|| imeAction() == EditorInfo.IME_ACTION_PREVIOUS;
|
|
}
|
|
|
|
public boolean passwordInput() {
|
|
final int inputType = mEditorInfo.inputType;
|
|
return InputTypeUtils.isPasswordInputType(inputType)
|
|
|| InputTypeUtils.isVisiblePasswordInputType(inputType);
|
|
}
|
|
|
|
public boolean isMultiLine() {
|
|
return (mEditorInfo.inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0;
|
|
}
|
|
|
|
public int imeAction() {
|
|
return InputTypeUtils.getImeOptionsActionIdFromEditorInfo(mEditorInfo);
|
|
}
|
|
|
|
public Locale getLocale() {
|
|
return mSubtype.getLocale();
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(final Object other) {
|
|
return other instanceof KeyboardId && equals((KeyboardId) other);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return mHashCode;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s%s]",
|
|
elementIdToName(mElementId),
|
|
mSubtype.getLocale(),
|
|
mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
|
mWidth, mHeight,
|
|
modeName(mMode),
|
|
actionName(imeAction()),
|
|
(navigateNext() ? " navigateNext" : ""),
|
|
(navigatePrevious() ? " navigatePrevious" : ""),
|
|
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
|
|
(passwordInput() ? " passwordInput" : ""),
|
|
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
|
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
|
|
(isMultiLine() ? " isMultiLine" : ""),
|
|
(mIsSplitLayout ? " isSplitLayout" : "")
|
|
);
|
|
}
|
|
|
|
public static boolean equivalentEditorInfoForKeyboard(final EditorInfo a, final EditorInfo b) {
|
|
if (a == null && b == null) return true;
|
|
if (a == null || b == null) return false;
|
|
return a.inputType == b.inputType
|
|
&& a.imeOptions == b.imeOptions
|
|
&& TextUtils.equals(a.privateImeOptions, b.privateImeOptions);
|
|
}
|
|
|
|
public static String elementIdToName(final int elementId) {
|
|
switch (elementId) {
|
|
case ELEMENT_ALPHABET: return "alphabet";
|
|
case ELEMENT_ALPHABET_MANUAL_SHIFTED: return "alphabetManualShifted";
|
|
case ELEMENT_ALPHABET_AUTOMATIC_SHIFTED: return "alphabetAutomaticShifted";
|
|
case ELEMENT_ALPHABET_SHIFT_LOCKED: return "alphabetShiftLocked";
|
|
case ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED: return "alphabetShiftLockShifted";
|
|
case ELEMENT_SYMBOLS: return "symbols";
|
|
case ELEMENT_SYMBOLS_SHIFTED: return "symbolsShifted";
|
|
case ELEMENT_PHONE: return "phone";
|
|
case ELEMENT_PHONE_SYMBOLS: return "phoneSymbols";
|
|
case ELEMENT_NUMBER: return "number";
|
|
case ELEMENT_EMOJI_RECENTS: return "emojiRecents";
|
|
case ELEMENT_EMOJI_CATEGORY1: return "emojiCategory1";
|
|
case ELEMENT_EMOJI_CATEGORY2: return "emojiCategory2";
|
|
case ELEMENT_EMOJI_CATEGORY3: return "emojiCategory3";
|
|
case ELEMENT_EMOJI_CATEGORY4: return "emojiCategory4";
|
|
case ELEMENT_EMOJI_CATEGORY5: return "emojiCategory5";
|
|
case ELEMENT_EMOJI_CATEGORY6: return "emojiCategory6";
|
|
case ELEMENT_EMOJI_CATEGORY7: return "emojiCategory7";
|
|
case ELEMENT_EMOJI_CATEGORY8: return "emojiCategory8";
|
|
case ELEMENT_EMOJI_CATEGORY9: return "emojiCategory9";
|
|
case ELEMENT_EMOJI_CATEGORY10: return "emojiCategory10";
|
|
case ELEMENT_EMOJI_CATEGORY11: return "emojiCategory11";
|
|
case ELEMENT_EMOJI_CATEGORY12: return "emojiCategory12";
|
|
case ELEMENT_EMOJI_CATEGORY13: return "emojiCategory13";
|
|
case ELEMENT_EMOJI_CATEGORY14: return "emojiCategory14";
|
|
case ELEMENT_EMOJI_CATEGORY15: return "emojiCategory15";
|
|
case ELEMENT_EMOJI_CATEGORY16: return "emojiCategory16";
|
|
default: return null;
|
|
}
|
|
}
|
|
|
|
public static String modeName(final int mode) {
|
|
switch (mode) {
|
|
case MODE_TEXT: return "text";
|
|
case MODE_URL: return "url";
|
|
case MODE_EMAIL: return "email";
|
|
case MODE_IM: return "im";
|
|
case MODE_PHONE: return "phone";
|
|
case MODE_NUMBER: return "number";
|
|
case MODE_DATE: return "date";
|
|
case MODE_TIME: return "time";
|
|
case MODE_DATETIME: return "datetime";
|
|
default: return null;
|
|
}
|
|
}
|
|
|
|
public static String actionName(final int actionId) {
|
|
return (actionId == InputTypeUtils.IME_ACTION_CUSTOM_LABEL) ? "actionCustomLabel"
|
|
: EditorInfoCompatUtils.imeActionName(actionId);
|
|
}
|
|
}
|