mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Update tests to successfully compile again
This commit is contained in:
parent
c3edb7c5ce
commit
65173aa6b2
@ -63,22 +63,6 @@ public final class KeyboardIconsSet {
|
||||
private DynamicThemeProvider provider;
|
||||
public void loadIcons(final TypedArray keyboardAttrs, @Nullable DynamicThemeProvider provider) {
|
||||
this.provider = provider;
|
||||
/*
|
||||
final int size = ATTR_ID_TO_ICON_ID.size();
|
||||
for (int index = 0; index < size; index++) {
|
||||
final int attrId = ATTR_ID_TO_ICON_ID.keyAt(index);
|
||||
try {
|
||||
final Drawable icon = DynamicThemeProvider.Companion.getDrawableOrDefault(attrId, keyboardAttrs, provider);
|
||||
setDefaultBounds(icon);
|
||||
final Integer iconId = ATTR_ID_TO_ICON_ID.get(attrId);
|
||||
mIcons[iconId] = icon;
|
||||
} catch (Resources.NotFoundException e) {
|
||||
Log.w(TAG, "Drawable resource for icon #"
|
||||
+ keyboardAttrs.getResources().getResourceEntryName(attrId)
|
||||
+ " not found");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -53,6 +53,24 @@ data class KeyboardLayoutElement(
|
||||
|
||||
KeyboardLayoutKind.Number -> KeyboardId.ELEMENT_NUMBER
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromElementId(value: Int): KeyboardLayoutElement =
|
||||
when(value) {
|
||||
KeyboardId.ELEMENT_ALPHABET -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Alphabet, page = KeyboardLayoutPage.Base)
|
||||
KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Alphabet, page = KeyboardLayoutPage.Shifted)
|
||||
KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Alphabet, page = KeyboardLayoutPage.Shifted)
|
||||
KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Alphabet, page = KeyboardLayoutPage.ShiftLocked)
|
||||
KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Alphabet, page = KeyboardLayoutPage.ShiftLocked)
|
||||
KeyboardId.ELEMENT_SYMBOLS -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Symbols, page = KeyboardLayoutPage.Base)
|
||||
KeyboardId.ELEMENT_SYMBOLS_SHIFTED -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Symbols, page = KeyboardLayoutPage.Shifted)
|
||||
KeyboardId.ELEMENT_PHONE -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Phone, page = KeyboardLayoutPage.Base)
|
||||
KeyboardId.ELEMENT_PHONE_SYMBOLS -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Phone, page = KeyboardLayoutPage.Shifted)
|
||||
KeyboardId.ELEMENT_NUMBER -> KeyboardLayoutElement(kind = KeyboardLayoutKind.Number, page = KeyboardLayoutPage.Base)
|
||||
else -> throw IllegalArgumentException("Invalid elementId $value")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface SwitchActions {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -88,7 +88,6 @@ import org.futo.inputmethod.latin.touchinputconsumer.GestureConsumer;
|
||||
import org.futo.inputmethod.latin.uix.settings.SettingsActivity;
|
||||
import org.futo.inputmethod.latin.utils.ApplicationUtils;
|
||||
import org.futo.inputmethod.latin.utils.DialogUtils;
|
||||
import org.futo.inputmethod.latin.utils.ImportantNoticeUtils;
|
||||
import org.futo.inputmethod.latin.utils.IntentUtils;
|
||||
import org.futo.inputmethod.latin.utils.JniUtils;
|
||||
import org.futo.inputmethod.latin.utils.LeakGuardHandlerWrapper;
|
||||
@ -1272,7 +1271,6 @@ public class LatinIMELegacy implements KeyboardActionListener,
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(boolean allGranted) {
|
||||
ImportantNoticeUtils.updateContactsNoticeShown(mInputMethodService /* context */);
|
||||
setNeutralSuggestionStrip();
|
||||
}
|
||||
|
||||
@ -1533,15 +1531,11 @@ public class LatinIMELegacy implements KeyboardActionListener,
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean shouldShowImportantNotice =
|
||||
ImportantNoticeUtils.shouldShowImportantNotice(mInputMethodService, currentSettingsValues);
|
||||
final boolean shouldShowImportantNotice = false;
|
||||
final boolean shouldShowSuggestionCandidates =
|
||||
currentSettingsValues.mInputAttributes.mShouldShowSuggestions
|
||||
&& currentSettingsValues.isSuggestionsEnabledPerUserSettings();
|
||||
final boolean shouldShowSuggestionsStripUnlessPassword = shouldShowImportantNotice
|
||||
|| currentSettingsValues.mShowsVoiceInputKey
|
||||
|| shouldShowSuggestionCandidates
|
||||
|| currentSettingsValues.isApplicationSpecifiedCompletionsOn();
|
||||
final boolean shouldShowSuggestionsStripUnlessPassword = currentSettingsValues.mShowsVoiceInputKey || shouldShowSuggestionCandidates || currentSettingsValues.isApplicationSpecifiedCompletionsOn();
|
||||
final boolean shouldShowSuggestionsStrip = shouldShowSuggestionsStripUnlessPassword
|
||||
&& !currentSettingsValues.mInputAttributes.mIsPasswordField;
|
||||
mSuggestionStripController.updateVisibility(shouldShowSuggestionsStrip, mInputMethodService.isFullscreenMode());
|
||||
@ -1557,13 +1551,6 @@ public class LatinIMELegacy implements KeyboardActionListener,
|
||||
|| isEmptyApplicationSpecifiedCompletions;
|
||||
final boolean isBeginningOfSentencePrediction = (suggestedWords.mInputStyle
|
||||
== SuggestedWords.INPUT_STYLE_BEGINNING_OF_SENTENCE_PREDICTION);
|
||||
final boolean noSuggestionsToOverrideImportantNotice = noSuggestionsFromDictionaries
|
||||
|| isBeginningOfSentencePrediction;
|
||||
if (shouldShowImportantNotice && noSuggestionsToOverrideImportantNotice) {
|
||||
if (mSuggestionStripController.maybeShowImportantNoticeTitle()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSettingsValues.isSuggestionsEnabledPerUserSettings()
|
||||
|| currentSettingsValues.isApplicationSpecifiedCompletionsOn()
|
||||
|
@ -180,13 +180,17 @@ object Subtypes {
|
||||
}
|
||||
}
|
||||
|
||||
fun makeSubtype(locale: String, layout: String): InputMethodSubtype =
|
||||
InputMethodSubtypeBuilder()
|
||||
.setSubtypeLocale(locale)
|
||||
.setSubtypeExtraValue("KeyboardLayoutSet=$layout")
|
||||
.build()
|
||||
|
||||
fun addLanguage(context: Context, language: Locale, layout: String) {
|
||||
val value = subtypeToString(
|
||||
InputMethodSubtypeBuilder()
|
||||
.setSubtypeLocale(language.stripExtensionsIfNeeded().toString())
|
||||
.setSubtypeExtraValue("KeyboardLayoutSet=$layout")
|
||||
.build()
|
||||
)
|
||||
val value = subtypeToString(makeSubtype(
|
||||
language.stripExtensionsIfNeeded().toString(), layout
|
||||
))
|
||||
|
||||
val currentSetting = context.getSettingBlocking(SubtypesSetting)
|
||||
|
||||
context.setSettingBlocking(SubtypesSetting.key, currentSetting + setOf(value))
|
||||
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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 org.futo.inputmethod.latin.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.futo.inputmethod.annotations.UsedForTesting;
|
||||
import org.futo.inputmethod.latin.R;
|
||||
import org.futo.inputmethod.latin.permissions.PermissionsUtil;
|
||||
import org.futo.inputmethod.latin.settings.SettingsValues;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class ImportantNoticeUtils {
|
||||
private static final String TAG = ImportantNoticeUtils.class.getSimpleName();
|
||||
|
||||
// {@link SharedPreferences} name to save the last important notice version that has been
|
||||
// displayed to users.
|
||||
private static final String PREFERENCE_NAME = "important_notice_pref";
|
||||
|
||||
private static final String KEY_SUGGEST_CONTACTS_NOTICE = "important_notice_suggest_contacts";
|
||||
|
||||
@UsedForTesting
|
||||
static final String KEY_TIMESTAMP_OF_CONTACTS_NOTICE = "timestamp_of_suggest_contacts_notice";
|
||||
|
||||
@UsedForTesting
|
||||
static final long TIMEOUT_OF_IMPORTANT_NOTICE = TimeUnit.HOURS.toMillis(23);
|
||||
|
||||
// Copy of the hidden {@link Settings.Secure#USER_SETUP_COMPLETE} settings key.
|
||||
// The value is zero until each multiuser completes system setup wizard.
|
||||
// Caveat: This is a hidden API.
|
||||
private static final String Settings_Secure_USER_SETUP_COMPLETE = "user_setup_complete";
|
||||
private static final int USER_SETUP_IS_NOT_COMPLETE = 0;
|
||||
|
||||
private ImportantNoticeUtils() {
|
||||
// This utility class is not publicly instantiable.
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
static boolean isInSystemSetupWizard(final Context context) {
|
||||
try {
|
||||
final int userSetupComplete = Settings.Secure.getInt(
|
||||
context.getContentResolver(), Settings_Secure_USER_SETUP_COMPLETE);
|
||||
return userSetupComplete == USER_SETUP_IS_NOT_COMPLETE;
|
||||
} catch (final SettingNotFoundException e) {
|
||||
Log.w(TAG, "Can't find settings in Settings.Secure: key="
|
||||
+ Settings_Secure_USER_SETUP_COMPLETE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldShowImportantNotice(final Context context,
|
||||
final SettingsValues settingsValues) {
|
||||
// Check to see whether "Use Contacts" is enabled by the user.
|
||||
/*
|
||||
if (!settingsValues.mUseContactsDict) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasContactsNoticeShown(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't show the dialog if we have all the permissions.
|
||||
if (PermissionsUtil.checkAllPermissionsGranted(
|
||||
context, Manifest.permission.READ_CONTACTS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final String importantNoticeTitle = getSuggestContactsNoticeTitle(context);
|
||||
if (TextUtils.isEmpty(importantNoticeTitle)) {
|
||||
return false;
|
||||
}
|
||||
if (isInSystemSetupWizard(context)) {
|
||||
return false;
|
||||
}
|
||||
if (hasContactsNoticeTimeoutPassed(context, System.currentTimeMillis())) {
|
||||
updateContactsNoticeShown(context);
|
||||
return false;
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getSuggestContactsNoticeTitle(final Context context) {
|
||||
return context.getResources().getString(R.string.important_notice_suggest_contact_names);
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
static boolean hasContactsNoticeTimeoutPassed(
|
||||
final Context context, final long currentTimeInMillis) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void updateContactsNoticeShown(final Context context) {
|
||||
|
||||
}
|
||||
}
|
@ -575,9 +575,13 @@ data class LayoutEngine(
|
||||
params.mBaseHeight = totalKeyboardHeight
|
||||
params.mDefaultRowHeight = rowHeightPx.roundToInt()
|
||||
|
||||
val provider = DynamicThemeProvider.obtainFromContext(context)
|
||||
try {
|
||||
val provider = DynamicThemeProvider.obtainFromContext(context)
|
||||
params.mIconsSet.loadIcons(null, provider)
|
||||
} catch(_: IllegalArgumentException) {
|
||||
// May fail during test because provider is unavailable
|
||||
}
|
||||
|
||||
params.mIconsSet.loadIcons(null, provider)
|
||||
params.mThemeId = 3
|
||||
params.mTextsSet.setLocale(params.mId.locale, context)
|
||||
|
||||
|
@ -14,8 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.futo.inputmethod.latin.tests">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
|
||||
|
||||
@ -28,7 +27,7 @@
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="org.futo.inputmethod.latin"
|
||||
android:targetPackage="org.futo.inputmethod.latin.tests"
|
||||
android:label="LatinIME tests">
|
||||
</instrumentation>
|
||||
</manifest>
|
||||
|
@ -21,13 +21,17 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||
import org.futo.inputmethod.keyboard.internal.KeyboardLayoutElement;
|
||||
import org.futo.inputmethod.keyboard.internal.MoreKeySpec;
|
||||
import org.futo.inputmethod.latin.R;
|
||||
import org.futo.inputmethod.latin.RichInputMethodManager;
|
||||
import org.futo.inputmethod.latin.Subtypes;
|
||||
import org.futo.inputmethod.latin.common.Constants;
|
||||
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTestsBase {
|
||||
@ -82,38 +86,38 @@ abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTe
|
||||
final EditorInfo editorInfo = new EditorInfo();
|
||||
editorInfo.inputType = inputType;
|
||||
editorInfo.imeOptions = imeOptions;
|
||||
final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo);
|
||||
final Keyboard keyboard = layoutSet.getKeyboard(elementId);
|
||||
final KeyboardLayoutSetV2 layoutSet = createKeyboardLayoutSet(subtype, editorInfo);
|
||||
final Keyboard keyboard = layoutSet.getKeyboard(KeyboardLayoutElement.fromElementId(elementId));
|
||||
|
||||
final Key actualKey = keyboard.getKey(code);
|
||||
final MoreKeySpec[] actualMoreKeys = actualKey.getMoreKeys();
|
||||
final String tag = actualKey.toString() + " moreKeys=" + Arrays.toString(actualMoreKeys);
|
||||
final List<MoreKeySpec> actualMoreKeys = actualKey.getMoreKeys();
|
||||
final String tag = actualKey.toString() + " moreKeys=" + actualMoreKeys.toString();
|
||||
if (expectedMoreKeys.length == 0) {
|
||||
assertEquals(tag, null, actualMoreKeys);
|
||||
assertEquals(tag, 0, actualMoreKeys.size());
|
||||
return;
|
||||
}
|
||||
if (expectedMoreKeys.length == 1) {
|
||||
assertEquals(tag + " fixedOrder", false, actualKey.isMoreKeysFixedOrder());
|
||||
assertEquals(tag + " fixedColumn", false, actualKey.isMoreKeysFixedColumn());
|
||||
assertFalse(tag + " fixedOrder", actualKey.isMoreKeysFixedOrder());
|
||||
assertFalse(tag + " fixedColumn", actualKey.isMoreKeysFixedColumn());
|
||||
} else {
|
||||
assertEquals(tag + " fixedOrder", true, actualKey.isMoreKeysFixedOrder());
|
||||
assertEquals(tag + " fixedColumn", true, actualKey.isMoreKeysFixedColumn());
|
||||
assertTrue(tag + " fixedOrder", actualKey.isMoreKeysFixedOrder());
|
||||
assertTrue(tag + " fixedColumn", actualKey.isMoreKeysFixedColumn());
|
||||
// TODO: Can't handle multiple rows of more keys.
|
||||
assertEquals(tag + " column",
|
||||
expectedMoreKeys.length, actualKey.getMoreKeysColumnNumber());
|
||||
}
|
||||
assertNotNull(tag + " moreKeys", actualMoreKeys);
|
||||
assertEquals(tag, expectedMoreKeys.length, actualMoreKeys.length);
|
||||
for (int index = 0; index < actualMoreKeys.length; index++) {
|
||||
assertEquals(tag, expectedMoreKeys.length, actualMoreKeys.size());
|
||||
for (int index = 0; index < actualMoreKeys.size(); index++) {
|
||||
final int expectedLabelResId = expectedMoreKeys[index].mLabelResId;
|
||||
if (expectedLabelResId == ExpectedMoreKey.NO_LABEL) {
|
||||
assertEquals(tag + " label " + index, null, actualMoreKeys[index].mLabel);
|
||||
assertEquals(tag + " label " + index, null, actualMoreKeys.get(index).mLabel);
|
||||
} else {
|
||||
final CharSequence expectedLabel = getContext().getText(expectedLabelResId);
|
||||
assertEquals(tag + " label " + index, expectedLabel, actualMoreKeys[index].mLabel);
|
||||
assertEquals(tag + " label " + index, expectedLabel, actualMoreKeys.get(index).mLabel);
|
||||
}
|
||||
final String expectedIconId = expectedMoreKeys[index].mIconId;
|
||||
assertEquals(tag + " icon " + index, expectedIconId, actualMoreKeys[index].mIconId);
|
||||
assertEquals(tag + " icon " + index, expectedIconId, actualMoreKeys.get(index).mIconId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +286,7 @@ abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTe
|
||||
|
||||
public void testMoreKeysOfEnterKey() {
|
||||
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
|
||||
final InputMethodSubtype subtype = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype subtype = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.US.toString(), SubtypeLocaleUtils.QWERTY);
|
||||
|
||||
// Password field.
|
||||
|
@ -33,6 +33,8 @@ import org.futo.inputmethod.latin.settings.Settings;
|
||||
import org.futo.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
||||
import org.futo.inputmethod.latin.utils.ResourceUtils;
|
||||
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2Params;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
@ -79,12 +81,12 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||
AdditionalSubtypeUtils.createAdditionalSubtypesArray(
|
||||
AdditionalSubtypeUtils.createPrefSubtypes(
|
||||
res.getStringArray(R.array.predefined_subtypes)));
|
||||
mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes);
|
||||
//mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes);
|
||||
|
||||
final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById(
|
||||
getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES);
|
||||
setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId));
|
||||
KeyboardLayoutSet.onKeyboardThemeChanged();
|
||||
KeyboardLayoutSetV2.onKeyboardThemeChanged();
|
||||
|
||||
mScreenMetrics = Settings.readScreenMetrics(res);
|
||||
|
||||
@ -98,7 +100,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
// Restore additional subtypes preference.
|
||||
mRichImm.setAdditionalInputMethodSubtypes(mSavedAdditionalSubtypes);
|
||||
//mRichImm.setAdditionalInputMethodSubtypes(mSavedAdditionalSubtypes);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@ -143,25 +145,32 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||
"Unknown subtype: locale=" + locale + " keyboardLayout=" + keyboardLayout);
|
||||
}
|
||||
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo) {
|
||||
return createKeyboardLayoutSet(subtype, editorInfo, false /* voiceInputKeyEnabled */,
|
||||
false /* languageSwitchKeyEnabled */, false /* splitLayoutEnabled */);
|
||||
}
|
||||
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
final Context context = getContext();
|
||||
final Resources res = context.getResources();
|
||||
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
||||
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
||||
final Builder builder = new Builder(context, editorInfo);
|
||||
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
|
||||
.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype))
|
||||
.setVoiceInputKeyEnabled(voiceInputKeyEnabled)
|
||||
.setBottomEmojiKeyEnabled(languageSwitchKeyEnabled)
|
||||
.setSplitLayoutEnabledByUser(splitLayoutEnabled);
|
||||
return builder.build();
|
||||
|
||||
final RichInputMethodSubtype richInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
||||
|
||||
return new KeyboardLayoutSetV2(
|
||||
context,
|
||||
new KeyboardLayoutSetV2Params(
|
||||
keyboardWidth, keyboardHeight,
|
||||
richInputMethodSubtype.getKeyboardLayoutSetName(),
|
||||
richInputMethodSubtype.getLocale(),
|
||||
editorInfo, false,
|
||||
4.0f, splitLayoutEnabled,
|
||||
languageSwitchKeyEnabled ? 1 : null
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -13,69 +13,94 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
package org.futo.inputmethod.keyboard
|
||||
|
||||
package org.futo.inputmethod.keyboard;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import androidx.test.filters.SmallTest
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import org.futo.inputmethod.v2keyboard.KeyVisualStyle
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class KeyboardLayoutTest {
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class KeyboardLayoutTest {
|
||||
@Test
|
||||
public void testNewKeyboardLayout() {
|
||||
KeyboardLayout keyboardLayout = KeyboardLayout
|
||||
.newKeyboardLayout(new ArrayList<Key>(), 11, 12, 13, 14);
|
||||
fun testNewKeyboardLayout() {
|
||||
var keyboardLayout = KeyboardLayout
|
||||
.newKeyboardLayout(ArrayList(), 11, 12, 13, 14)
|
||||
|
||||
assertEquals(11, keyboardLayout.mMostCommonKeyWidth);
|
||||
assertEquals(12, keyboardLayout.mMostCommonKeyHeight);
|
||||
assertEquals(13, keyboardLayout.mKeyboardWidth);
|
||||
assertEquals(14, keyboardLayout.mKeyboardHeight);
|
||||
Assert.assertEquals(11, keyboardLayout.mMostCommonKeyWidth.toLong())
|
||||
Assert.assertEquals(12, keyboardLayout.mMostCommonKeyHeight.toLong())
|
||||
Assert.assertEquals(13, keyboardLayout.mKeyboardWidth.toLong())
|
||||
Assert.assertEquals(14, keyboardLayout.mKeyboardHeight.toLong())
|
||||
|
||||
assertEquals(0, keyboardLayout.getKeyCodes().length);
|
||||
assertEquals(0, keyboardLayout.getKeyWidths().length);
|
||||
assertEquals(0, keyboardLayout.getKeyHeights().length);
|
||||
assertEquals(0, keyboardLayout.getKeyXCoordinates().length);
|
||||
assertEquals(0, keyboardLayout.getKeyYCoordinates().length);
|
||||
Assert.assertEquals(0, keyboardLayout.keyCodes.size.toLong())
|
||||
Assert.assertEquals(0, keyboardLayout.keyWidths.size.toLong())
|
||||
Assert.assertEquals(0, keyboardLayout.keyHeights.size.toLong())
|
||||
Assert.assertEquals(0, keyboardLayout.keyXCoordinates.size.toLong())
|
||||
Assert.assertEquals(0, keyboardLayout.keyYCoordinates.size.toLong())
|
||||
|
||||
Key key1 = new Key("label1", 101, 102, "101", "101hint", 103, 104, 105, 106, 1100, 1101,
|
||||
10, 10);
|
||||
Key key2 = new Key("label2", 201, 103, "201", "201hint", 203, 204, 205, 206, 2100, 2101,
|
||||
10, 10);
|
||||
val key1 = Key(
|
||||
code = 101,
|
||||
label = "label1",
|
||||
hintLabel = "101hint",
|
||||
width = 1100,
|
||||
height = 1101,
|
||||
horizontalGap = 10,
|
||||
verticalGap = 10,
|
||||
actionFlags = 102,
|
||||
labelFlags = 103,
|
||||
visualStyle = KeyVisualStyle.Normal,
|
||||
x = 105,
|
||||
y = 106
|
||||
)
|
||||
|
||||
ArrayList<Key> sortedKeys = new ArrayList<>(2);
|
||||
sortedKeys.add(key1);
|
||||
sortedKeys.add(key2);
|
||||
keyboardLayout = KeyboardLayout.newKeyboardLayout(sortedKeys, 11, 12, 13, 14);
|
||||
assertEquals(2, keyboardLayout.getKeyCodes().length);
|
||||
assertEquals(2, keyboardLayout.getKeyWidths().length);
|
||||
assertEquals(2, keyboardLayout.getKeyHeights().length);
|
||||
assertEquals(2, keyboardLayout.getKeyXCoordinates().length);
|
||||
assertEquals(2, keyboardLayout.getKeyYCoordinates().length);
|
||||
val key2 = Key(
|
||||
code = 201,
|
||||
label = "label2",
|
||||
hintLabel = "201hint",
|
||||
width = 2100,
|
||||
height = 2101,
|
||||
horizontalGap = 10,
|
||||
verticalGap = 10,
|
||||
actionFlags = 202,
|
||||
labelFlags = 203,
|
||||
visualStyle = KeyVisualStyle.Normal,
|
||||
x = 205,
|
||||
y = 206
|
||||
)
|
||||
|
||||
assertEquals(102, keyboardLayout.getKeyCodes()[0]);
|
||||
//Key key1 = new Key("label1", 101, 102, "101", "101hint", 103, 104, 105, 106, 1100, 1101,
|
||||
// 10, 10);
|
||||
//Key key2 = new Key("label2", 201, 103, "201", "201hint", 203, 204, 205, 206, 2100, 2101,
|
||||
// 10, 10);
|
||||
val sortedKeys = ArrayList<Key>(2)
|
||||
sortedKeys.add(key1)
|
||||
sortedKeys.add(key2)
|
||||
keyboardLayout = KeyboardLayout.newKeyboardLayout(sortedKeys, 11, 12, 13, 14)
|
||||
Assert.assertEquals(2, keyboardLayout.keyCodes.size.toLong())
|
||||
Assert.assertEquals(2, keyboardLayout.keyWidths.size.toLong())
|
||||
Assert.assertEquals(2, keyboardLayout.keyHeights.size.toLong())
|
||||
Assert.assertEquals(2, keyboardLayout.keyXCoordinates.size.toLong())
|
||||
Assert.assertEquals(2, keyboardLayout.keyYCoordinates.size.toLong())
|
||||
|
||||
Assert.assertEquals(102, keyboardLayout.keyCodes[0].toLong())
|
||||
// xCo + horizontalGap/2
|
||||
assertEquals(105 + 5, keyboardLayout.getKeyXCoordinates()[0]);
|
||||
assertEquals(106, keyboardLayout.getKeyYCoordinates()[0]);
|
||||
Assert.assertEquals((105 + 5).toLong(), keyboardLayout.keyXCoordinates[0].toLong())
|
||||
Assert.assertEquals(106, keyboardLayout.keyYCoordinates[0].toLong())
|
||||
// width - horizontalGap
|
||||
assertEquals(1100 - 10, keyboardLayout.getKeyWidths()[0]);
|
||||
Assert.assertEquals((1100 - 10).toLong(), keyboardLayout.keyWidths[0].toLong())
|
||||
// height - verticalGap
|
||||
assertEquals(1101 - 10, keyboardLayout.getKeyHeights()[0]);
|
||||
Assert.assertEquals((1101 - 10).toLong(), keyboardLayout.keyHeights[0].toLong())
|
||||
|
||||
assertEquals(103, keyboardLayout.getKeyCodes()[1]);
|
||||
Assert.assertEquals(103, keyboardLayout.keyCodes[1].toLong())
|
||||
// xCo + horizontalGap/2
|
||||
assertEquals(205 + 5, keyboardLayout.getKeyXCoordinates()[1]);
|
||||
assertEquals(206, keyboardLayout.getKeyYCoordinates()[1]);
|
||||
Assert.assertEquals((205 + 5).toLong(), keyboardLayout.keyXCoordinates[1].toLong())
|
||||
Assert.assertEquals(206, keyboardLayout.keyYCoordinates[1].toLong())
|
||||
// width - horizontalGap
|
||||
assertEquals(2100 - 10, keyboardLayout.getKeyWidths()[1]);
|
||||
Assert.assertEquals((2100 - 10).toLong(), keyboardLayout.keyWidths[1].toLong())
|
||||
// height - verticalGap
|
||||
assertEquals(2101 - 10, keyboardLayout.getKeyHeights()[1]);
|
||||
Assert.assertEquals((2101 - 10).toLong(), keyboardLayout.keyHeights[1].toLong())
|
||||
}
|
||||
}
|
||||
|
@ -26,11 +26,13 @@ import org.futo.inputmethod.keyboard.Key;
|
||||
import org.futo.inputmethod.keyboard.Keyboard;
|
||||
import org.futo.inputmethod.keyboard.KeyboardId;
|
||||
import org.futo.inputmethod.keyboard.KeyboardLayoutSetTestsBase;
|
||||
import org.futo.inputmethod.keyboard.internal.KeyboardLayoutElement;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKeyVisual;
|
||||
import org.futo.inputmethod.latin.common.Constants;
|
||||
import org.futo.inputmethod.latin.common.LocaleUtils;
|
||||
import org.futo.inputmethod.latin.utils.RunInLocale;
|
||||
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -74,9 +76,9 @@ abstract class ActionTestsBase extends KeyboardLayoutSetTestsBase {
|
||||
return LocaleUtils.constructLocaleFromString(localeString);
|
||||
}
|
||||
|
||||
private static void assertActionKey(final String tag, final KeyboardLayoutSet layoutSet,
|
||||
private static void assertActionKey(final String tag, final KeyboardLayoutSetV2 layoutSet,
|
||||
final int elementId, final ExpectedActionKey expectedKey) {
|
||||
final Keyboard keyboard = layoutSet.getKeyboard(elementId);
|
||||
final Keyboard keyboard = layoutSet.getKeyboard(KeyboardLayoutElement.fromElementId(elementId));
|
||||
final Key actualKey = keyboard.getKey(Constants.CODE_ENTER);
|
||||
assertNotNull(tag + " enter key on " + keyboard.mId, actualKey);
|
||||
assertEquals(tag + " label " + expectedKey, expectedKey.getLabel(), actualKey.getLabel());
|
||||
@ -94,7 +96,7 @@ abstract class ActionTestsBase extends KeyboardLayoutSetTestsBase {
|
||||
final EditorInfo editorInfo, final ExpectedActionKey expectedKey) {
|
||||
// Test text layouts.
|
||||
editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
|
||||
final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo);
|
||||
final KeyboardLayoutSetV2 layoutSet = createKeyboardLayoutSet(subtype, editorInfo);
|
||||
assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, expectedKey);
|
||||
assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, expectedKey);
|
||||
assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, expectedKey);
|
||||
@ -106,7 +108,7 @@ abstract class ActionTestsBase extends KeyboardLayoutSetTestsBase {
|
||||
// Test number password layout.
|
||||
editorInfo.inputType =
|
||||
InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
|
||||
final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo);
|
||||
final KeyboardLayoutSetV2 passwordSet = createKeyboardLayoutSet(subtype, editorInfo);
|
||||
assertActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, expectedKey);
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,10 @@ import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet;
|
||||
import org.futo.inputmethod.keyboard.internal.KeyboardTextsSet;
|
||||
import org.futo.inputmethod.latin.R;
|
||||
import org.futo.inputmethod.latin.RichInputMethodManager;
|
||||
import org.futo.inputmethod.latin.Subtypes;
|
||||
import org.futo.inputmethod.latin.utils.RunInLocale;
|
||||
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -55,7 +57,7 @@ public class KlpActionLabelTests extends KlpActionTestsBase {
|
||||
final Locale labelLocale, final Locale systemLocale) {
|
||||
// Simulate system locale changing, see {@link SystemBroadcastReceiver}.
|
||||
if (!systemLocale.equals(mSystemLocale)) {
|
||||
KeyboardLayoutSet.onSystemLocaleChanged();
|
||||
KeyboardLayoutSetV2.onSystemLocaleChanged();
|
||||
mSystemLocale = systemLocale;
|
||||
}
|
||||
final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey(
|
||||
@ -87,7 +89,7 @@ public class KlpActionLabelTests extends KlpActionTestsBase {
|
||||
|
||||
public void testActionLabelInOtherLocale() {
|
||||
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
|
||||
final InputMethodSubtype italian = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype italian = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.ITALIAN.toString(), SubtypeLocaleUtils.QWERTY);
|
||||
// An action label should be displayed in subtype's locale regardless of the system locale.
|
||||
doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.US);
|
||||
@ -98,7 +100,7 @@ public class KlpActionLabelTests extends KlpActionTestsBase {
|
||||
|
||||
public void testNoLanguageSubtypeActionLabel() {
|
||||
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
|
||||
final InputMethodSubtype noLanguage = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype noLanguage = Subtypes.INSTANCE.makeSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY);
|
||||
// An action label of no language keyboard should be displayed in the system locale.
|
||||
doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.US, Locale.US);
|
||||
@ -111,7 +113,7 @@ public class KlpActionLabelTests extends KlpActionTestsBase {
|
||||
final Locale labelLocale, final Locale systemLocale) {
|
||||
// Simulate system locale changing, see {@link SystemBroadcastReceiver}.
|
||||
if (!systemLocale.equals(mSystemLocale)) {
|
||||
KeyboardLayoutSet.onSystemLocaleChanged();
|
||||
KeyboardLayoutSetV2.onSystemLocaleChanged();
|
||||
mSystemLocale = systemLocale;
|
||||
}
|
||||
final KeyboardTextsSet textsSet = new KeyboardTextsSet();
|
||||
@ -146,7 +148,7 @@ public class KlpActionLabelTests extends KlpActionTestsBase {
|
||||
public void testHinglishActionLabel() {
|
||||
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
|
||||
final Locale hi_ZZ = new Locale("hi", "ZZ");
|
||||
final InputMethodSubtype hiLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype hiLatn = Subtypes.INSTANCE.makeSubtype(
|
||||
hi_ZZ.toString(), SubtypeLocaleUtils.QWERTY);
|
||||
// This is a preliminary subtype and may not exist.
|
||||
if (hiLatn == null) {
|
||||
@ -163,7 +165,7 @@ public class KlpActionLabelTests extends KlpActionTestsBase {
|
||||
public void testSerbianLatinActionLabel() {
|
||||
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
|
||||
final Locale sr_ZZ = new Locale("sr", "ZZ");
|
||||
final InputMethodSubtype srLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype srLatn = Subtypes.INSTANCE.makeSubtype(
|
||||
sr_ZZ.toString(), "serbian_qwertz");
|
||||
// This is a preliminary subtype and may not exist.
|
||||
if (srLatn == null) {
|
||||
|
@ -94,7 +94,7 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||
* @param afterPress the keyboard state after pressing the key.
|
||||
*/
|
||||
public void pressKey(final int code, final int afterPress) {
|
||||
mSwitcher.expireDoubleTapTimeout();
|
||||
//mSwitcher.expireDoubleTapTimeout();
|
||||
pressKeyWithoutTimerExpire(code, true, afterPress);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class KeyboardStateTestsBase extends AndroidTestCase
|
||||
* @param afterPress the keyboard state after pressing chording key.
|
||||
*/
|
||||
public void chordingPressKey(final int code, final int afterPress) {
|
||||
mSwitcher.expireDoubleTapTimeout();
|
||||
//mSwitcher.expireDoubleTapTimeout();
|
||||
pressKeyWithoutTimerExpire(code, false, afterPress);
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,13 @@ package org.futo.inputmethod.keyboard.internal;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.futo.inputmethod.event.Event;
|
||||
import org.futo.inputmethod.latin.common.Constants;
|
||||
import org.futo.inputmethod.latin.utils.RecapitalizeStatus;
|
||||
|
||||
public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
public class MockKeyboardSwitcher implements SwitchActions {
|
||||
public interface MockConstants {
|
||||
// Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}.
|
||||
public static final boolean NOT_SLIDING = false;
|
||||
@ -54,7 +56,6 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
// Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS.
|
||||
private int mAutoCapsState = MockConstants.CAP_MODE_OFF;
|
||||
|
||||
private boolean mIsInDoubleTapShiftKeyTimeout;
|
||||
private int mLongPressTimeoutCode;
|
||||
|
||||
private final KeyboardState mState = new KeyboardState(this);
|
||||
@ -81,48 +82,9 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
mAutoCapsState = autoCaps;
|
||||
}
|
||||
|
||||
public void expireDoubleTapTimeout() {
|
||||
mIsInDoubleTapShiftKeyTimeout = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlphabetKeyboard() {
|
||||
mLayout = MockConstants.ALPHABET_UNSHIFTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlphabetManualShiftedKeyboard() {
|
||||
mLayout = MockConstants.ALPHABET_MANUAL_SHIFTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlphabetAutomaticShiftedKeyboard() {
|
||||
mLayout = MockConstants.ALPHABET_AUTOMATIC_SHIFTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlphabetShiftLockedKeyboard() {
|
||||
mLayout = MockConstants.ALPHABET_SHIFT_LOCKED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlphabetShiftLockShiftedKeyboard() {
|
||||
mLayout = MockConstants.ALPHABET_SHIFT_LOCK_SHIFTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSymbolsKeyboard() {
|
||||
mLayout = MockConstants.SYMBOLS_UNSHIFTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSymbolsShiftedKeyboard() {
|
||||
mLayout = MockConstants.SYMBOLS_SHIFTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEmojiKeyboard() {
|
||||
// Just ignore.
|
||||
public void setKeyboard(@NonNull KeyboardLayoutElement element) {
|
||||
mLayout = element.getElementId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,27 +93,12 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||
mState.onUpdateShiftState(currentAutoCapsState, currentRecapitalizeState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDoubleTapShiftKeyTimer() {
|
||||
mIsInDoubleTapShiftKeyTimeout = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDoubleTapShiftKeyTimer() {
|
||||
mIsInDoubleTapShiftKeyTimeout = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInDoubleTapShiftKeyTimeout() {
|
||||
return mIsInDoubleTapShiftKeyTimeout;
|
||||
}
|
||||
|
||||
public void updateShiftState() {
|
||||
mState.onUpdateShiftState(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||
}
|
||||
|
||||
public void loadKeyboard() {
|
||||
mState.onLoadKeyboard(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||
mState.onLoadKeyboard(null, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||
}
|
||||
|
||||
public void saveKeyboardState() {
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.futo.inputmethod.keyboard.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
@ -27,8 +28,7 @@ import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.futo.inputmethod.latin.tests.R;
|
||||
|
||||
//import org.futo.inputmethod.latin.tests.R;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -46,8 +46,8 @@ public class MoreKeySpecStringReferenceTests {
|
||||
final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
final Context testContext = instrumentation.getContext();
|
||||
final Resources testRes = testContext.getResources();
|
||||
final String testPackageName = testRes.getResourcePackageName(R.string.empty_string);
|
||||
mTextsSet.setLocale(TEST_LOCALE, testRes, testPackageName);
|
||||
//final String testPackageName = testRes.getResourcePackageName(R.string.empty_string);
|
||||
mTextsSet.setLocale(TEST_LOCALE, testContext);//, testPackageName);
|
||||
}
|
||||
|
||||
private void assertTextArray(final String message, final String value,
|
||||
@ -69,14 +69,12 @@ public class MoreKeySpecStringReferenceTests {
|
||||
|
||||
@Test
|
||||
public void testResolveNullText() {
|
||||
assertEquals("resolve null",
|
||||
mTextsSet.resolveTextReference(null), null);
|
||||
assertNull("resolve null", mTextsSet.resolveTextReference(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveEmptyText() {
|
||||
assertEquals("resolve empty text",
|
||||
mTextsSet.resolveTextReference("!string/empty_string"), null);
|
||||
assertNull("resolve empty text", mTextsSet.resolveTextReference("!string/empty_string"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -29,31 +29,31 @@ public abstract class AbstractLayoutBase {
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object that has the label.
|
||||
public static ExpectedKey key(final String label, final ExpectedKey ... moreKeys) {
|
||||
return ExpectedKey.newInstance(label, moreKeys);
|
||||
return ExpectedKey.newLabelInstance(label, moreKeys);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object that has the label and the output text.
|
||||
public static ExpectedKey key(final String label, final String outputText,
|
||||
final ExpectedKey ... moreKeys) {
|
||||
return ExpectedKey.newInstance(label, outputText, moreKeys);
|
||||
return ExpectedKey.newLabelInstance(label, outputText, moreKeys);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object that has the label and the output code.
|
||||
public static ExpectedKey key(final String label, final int code,
|
||||
final ExpectedKey ... moreKeys) {
|
||||
return ExpectedKey.newInstance(label, code, moreKeys);
|
||||
return ExpectedKey.newLabelInstance(label, code, moreKeys);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object that has the icon and the output text.
|
||||
public static ExpectedKey key(final int iconId, final String outputText,
|
||||
public static ExpectedKey iconKey(final String iconId, final String outputText,
|
||||
final ExpectedKey ... moreKeys) {
|
||||
return ExpectedKey.newInstance(iconId, outputText, moreKeys);
|
||||
return ExpectedKey.newIconInstance(iconId, outputText, moreKeys);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object that has the icon and the output code.
|
||||
public static ExpectedKey key(final int iconId, final int code,
|
||||
public static ExpectedKey iconKey(final String iconId, final int code,
|
||||
final ExpectedKey ... moreKeys) {
|
||||
return ExpectedKey.newInstance(iconId, code, moreKeys);
|
||||
return ExpectedKey.newIconInstance(iconId, code, moreKeys);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object that has new "more keys".
|
||||
@ -72,25 +72,25 @@ public abstract class AbstractLayoutBase {
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label.
|
||||
public static ExpectedKey moreKey(final String label) {
|
||||
return ExpectedKey.newInstance(label);
|
||||
return ExpectedKey.newLabelInstance(label);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
|
||||
// and the output text.
|
||||
public static ExpectedKey moreKey(final String label, final String outputText) {
|
||||
return ExpectedKey.newInstance(label, outputText);
|
||||
return ExpectedKey.newLabelInstance(label, outputText);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
|
||||
// and the output code.
|
||||
public static ExpectedKey moreKey(final String label, final int code) {
|
||||
return ExpectedKey.newInstance(label, code);
|
||||
return ExpectedKey.newLabelInstance(label, code);
|
||||
}
|
||||
|
||||
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the icon
|
||||
// and the output text.
|
||||
public static ExpectedKey moreKey(final int iconId, final String outputText) {
|
||||
return ExpectedKey.newInstance(iconId, outputText);
|
||||
public static ExpectedKey moreIconKey(final String iconId, final String outputText) {
|
||||
return ExpectedKey.newIconInstance(iconId, outputText);
|
||||
}
|
||||
|
||||
// Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey},
|
||||
@ -121,20 +121,20 @@ public abstract class AbstractLayoutBase {
|
||||
private static final String ICON_ZWJ = KeyboardIconsSet.NAME_ZWJ_KEY;
|
||||
|
||||
// Functional keys.
|
||||
protected static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE);
|
||||
protected static final ExpectedKey TAB_KEY = key(ICON_TAB, Constants.CODE_TAB);
|
||||
protected static final ExpectedKey SHORTCUT_KEY = key(ICON_SHORTCUT, Constants.CODE_SHORTCUT);
|
||||
protected static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS);
|
||||
protected static final ExpectedKey LANGUAGE_SWITCH_KEY = key(
|
||||
protected static final ExpectedKey DELETE_KEY = iconKey(ICON_DELETE, Constants.CODE_DELETE);
|
||||
protected static final ExpectedKey TAB_KEY = iconKey(ICON_TAB, Constants.CODE_TAB);
|
||||
protected static final ExpectedKey SHORTCUT_KEY = iconKey(ICON_SHORTCUT, Constants.CODE_SHORTCUT);
|
||||
protected static final ExpectedKey SETTINGS_KEY = iconKey(ICON_SETTINGS, Constants.CODE_SETTINGS);
|
||||
protected static final ExpectedKey LANGUAGE_SWITCH_KEY = iconKey(
|
||||
ICON_LANGUAGE_SWITCH, Constants.CODE_LANGUAGE_SWITCH);
|
||||
protected static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER);
|
||||
protected static final ExpectedKey EMOJI_ACTION_KEY = key(ICON_EMOJI_ACTION, Constants.CODE_EMOJI);
|
||||
protected static final ExpectedKey EMOJI_NORMAL_KEY = key(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI);
|
||||
protected static final ExpectedKey SPACE_KEY = key(ICON_SPACE, Constants.CODE_SPACE);
|
||||
protected static final ExpectedKey ENTER_KEY = iconKey(ICON_ENTER, Constants.CODE_ENTER);
|
||||
protected static final ExpectedKey EMOJI_ACTION_KEY = iconKey(ICON_EMOJI_ACTION, Constants.CODE_EMOJI);
|
||||
protected static final ExpectedKey EMOJI_NORMAL_KEY = iconKey(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI);
|
||||
protected static final ExpectedKey SPACE_KEY = iconKey(ICON_SPACE, Constants.CODE_SPACE);
|
||||
protected static final ExpectedKey CAPSLOCK_MORE_KEY = key(" ", Constants.CODE_CAPSLOCK);
|
||||
protected static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT,
|
||||
protected static final ExpectedKey SHIFT_KEY = iconKey(ICON_SHIFT,
|
||||
Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY);
|
||||
protected static final ExpectedKey SHIFTED_SHIFT_KEY = key(ICON_SHIFTED_SHIFT,
|
||||
protected static final ExpectedKey SHIFTED_SHIFT_KEY = iconKey(ICON_SHIFTED_SHIFT,
|
||||
Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY);
|
||||
protected static final ExpectedKey ALPHABET_KEY = key("ABC", Constants.CODE_SWITCH_ALPHA_SYMBOL);
|
||||
protected static final ExpectedKey SYMBOLS_KEY = key("?123", Constants.CODE_SWITCH_ALPHA_SYMBOL);
|
||||
@ -148,8 +148,8 @@ public abstract class AbstractLayoutBase {
|
||||
key("!", moreKey("\u00A1")), key("?", moreKey("\u00BF")));
|
||||
// U+200C: ZERO WIDTH NON-JOINER
|
||||
// U+200D: ZERO WIDTH JOINER
|
||||
protected static final ExpectedKey ZWNJ_KEY = key(ICON_ZWNJ, "\u200C");
|
||||
protected static final ExpectedKey ZWJ_KEY = key(ICON_ZWJ, "\u200D");
|
||||
protected static final ExpectedKey ZWNJ_KEY = iconKey(ICON_ZWNJ, "\u200C");
|
||||
protected static final ExpectedKey ZWJ_KEY = iconKey(ICON_ZWJ, "\u200D");
|
||||
// Domain key
|
||||
protected static final ExpectedKey DOMAIN_KEY =
|
||||
key(".com", joinMoreKeys(".net", ".org", ".gov", ".edu")).preserveCase();
|
||||
|
@ -24,6 +24,7 @@ import org.futo.inputmethod.latin.common.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -108,10 +109,10 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static String toString(final String label, final int iconId, final String outputText,
|
||||
static String toString(final String label, final String iconId, final String outputText,
|
||||
final int code) {
|
||||
final String visual = (iconId != KeyboardIconsSet.ICON_UNDEFINED)
|
||||
? KeyboardIconsSet.getIconName(iconId) : label;
|
||||
final String visual = (!Objects.equals(iconId, KeyboardIconsSet.ICON_UNDEFINED))
|
||||
? iconId : label;
|
||||
final String output;
|
||||
if (code == Constants.CODE_OUTPUT_TEXT) {
|
||||
output = outputText;
|
||||
@ -142,12 +143,12 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(MoreKeySpecStringizer.toString(
|
||||
key.getLabel(), key.getIconId(), key.getOutputText(), key.getCode()));
|
||||
final MoreKeySpec[] moreKeys = key.getMoreKeys();
|
||||
if (moreKeys == null) {
|
||||
final List<MoreKeySpec> moreKeys = key.getMoreKeys();
|
||||
if (moreKeys.isEmpty()) {
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append("^");
|
||||
sb.append(MoreKeySpecStringizer.STRINGIZER.join(moreKeys));
|
||||
sb.append(MoreKeySpecStringizer.STRINGIZER.join(moreKeys.toArray(new MoreKeySpec[0])));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -21,44 +21,45 @@ import org.futo.inputmethod.keyboard.internal.MoreKeySpec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* This class represents an expected key.
|
||||
*/
|
||||
public class ExpectedKey {
|
||||
static ExpectedKey EMPTY_KEY = newInstance("");
|
||||
static ExpectedKey EMPTY_KEY = newLabelInstance("");
|
||||
|
||||
// A key that has a string label and may have "more keys".
|
||||
static ExpectedKey newInstance(final String label, final ExpectedKey... moreKeys) {
|
||||
return newInstance(label, label, moreKeys);
|
||||
static ExpectedKey newLabelInstance(final String label, final ExpectedKey... moreKeys) {
|
||||
return newLabelInstance(label, label, moreKeys);
|
||||
}
|
||||
|
||||
// A key that has a string label and a different output text and may have "more keys".
|
||||
static ExpectedKey newInstance(final String label, final String outputText,
|
||||
static ExpectedKey newLabelInstance(final String label, final String outputText,
|
||||
final ExpectedKey... moreKeys) {
|
||||
return newInstance(ExpectedKeyVisual.newInstance(label),
|
||||
ExpectedKeyOutput.newInstance(outputText), moreKeys);
|
||||
}
|
||||
|
||||
// A key that has a string label and a code point output and may have "more keys".
|
||||
static ExpectedKey newInstance(final String label, final int code,
|
||||
static ExpectedKey newLabelInstance(final String label, final int code,
|
||||
final ExpectedKey... moreKeys) {
|
||||
return newInstance(ExpectedKeyVisual.newInstance(label),
|
||||
ExpectedKeyOutput.newInstance(code), moreKeys);
|
||||
}
|
||||
|
||||
// A key that has an icon and an output text and may have "more keys".
|
||||
static ExpectedKey newInstance(final int iconId, final String outputText,
|
||||
static ExpectedKey newIconInstance(final String iconId, final String outputText,
|
||||
final ExpectedKey... moreKeys) {
|
||||
return newInstance(ExpectedKeyVisual.newInstance(iconId),
|
||||
return newInstance(ExpectedKeyVisual.newIconInstance(iconId),
|
||||
ExpectedKeyOutput.newInstance(outputText), moreKeys);
|
||||
}
|
||||
|
||||
// A key that has an icon and a code point output and may have "more keys".
|
||||
static ExpectedKey newInstance(final int iconId, final int code,
|
||||
static ExpectedKey newIconInstance(final String iconId, final int code,
|
||||
final ExpectedKey... moreKeys) {
|
||||
return newInstance(ExpectedKeyVisual.newInstance(iconId),
|
||||
return newInstance(ExpectedKeyVisual.newIconInstance(iconId),
|
||||
ExpectedKeyOutput.newInstance(code), moreKeys);
|
||||
}
|
||||
|
||||
@ -276,14 +277,14 @@ public class ExpectedKey {
|
||||
@Override
|
||||
public boolean equalsTo(final Key key) {
|
||||
if (getVisual().hasSameKeyVisual(key) && getOutput().hasSameKeyOutput(key)) {
|
||||
final MoreKeySpec[] moreKeySpecs = key.getMoreKeys();
|
||||
final List<MoreKeySpec> moreKeySpecs = key.getMoreKeys();
|
||||
final ExpectedKey[] moreKeys = getMoreKeys();
|
||||
// This key should have at least one "more key".
|
||||
if (moreKeySpecs == null || moreKeySpecs.length != moreKeys.length) {
|
||||
if (moreKeySpecs == null || moreKeySpecs.size() != moreKeys.length) {
|
||||
return false;
|
||||
}
|
||||
for (int index = 0; index < moreKeySpecs.length; index++) {
|
||||
if (!moreKeys[index].equalsTo(moreKeySpecs[index])) {
|
||||
for (int index = 0; index < moreKeySpecs.size(); index++) {
|
||||
if (!moreKeys[index].equalsTo(moreKeySpecs.get(index))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<Expec
|
||||
} else if (key instanceof ExpectedKey[]) {
|
||||
list.addAll(Arrays.asList((ExpectedKey[])key));
|
||||
} else if (key instanceof String) {
|
||||
list.add(ExpectedKey.newInstance((String)key));
|
||||
list.add(ExpectedKey.newLabelInstance((String)key));
|
||||
} else {
|
||||
throw new RuntimeException("Unknown expected key type: " + key);
|
||||
}
|
||||
@ -160,8 +160,8 @@ public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<Expec
|
||||
* {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}.
|
||||
* @return this builder.
|
||||
*/
|
||||
public ExpectedKeyboardBuilder setMoreKeysOf(final int iconId, final Object ... moreKeys) {
|
||||
setMoreKeysOf(ExpectedKeyVisual.newInstance(iconId), joinKeys(moreKeys));
|
||||
public ExpectedKeyboardBuilder setMoreIconKeysOf(final String iconId, final Object ... moreKeys) {
|
||||
setMoreKeysOf(ExpectedKeyVisual.newIconInstance(iconId), joinKeys(moreKeys));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import org.futo.inputmethod.keyboard.Keyboard;
|
||||
import org.futo.inputmethod.keyboard.KeyboardId;
|
||||
import org.futo.inputmethod.keyboard.KeyboardLayoutSetTestsBase;
|
||||
import org.futo.inputmethod.keyboard.KeyboardTheme;
|
||||
import org.futo.inputmethod.keyboard.internal.KeyboardLayoutElement;
|
||||
import org.futo.inputmethod.keyboard.layout.LayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.AbstractLayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ActualKeyboardBuilder;
|
||||
@ -31,6 +32,7 @@ import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
|
||||
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -41,7 +43,7 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase {
|
||||
private LayoutBase mLayout;
|
||||
private InputMethodSubtype mSubtype;
|
||||
private String mLogTag;
|
||||
private KeyboardLayoutSet mKeyboardLayoutSet;
|
||||
private KeyboardLayoutSetV2 mKeyboardLayoutSet;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@ -138,7 +140,7 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase {
|
||||
}
|
||||
final String tag = mLogTag + "/" + KeyboardId.elementIdToName(elementId);
|
||||
// Create actual keyboard object.
|
||||
final Keyboard keyboard = mKeyboardLayoutSet.getKeyboard(elementId);
|
||||
final Keyboard keyboard = mKeyboardLayoutSet.getKeyboard(KeyboardLayoutElement.fromElementId(elementId));
|
||||
// Create actual keyboard to be compared with the expected keyboard.
|
||||
final Key[][] actualKeyboard = ActualKeyboardBuilder.buildKeyboard(
|
||||
keyboard.getSortedKeys());
|
||||
|
@ -27,6 +27,7 @@ import org.futo.inputmethod.keyboard.layout.LayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.DvorakCustomizer.EnglishDvorakCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.LayoutCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -42,9 +43,9 @@ public class TestsDvorakEmail extends LayoutTestsBase {
|
||||
LayoutBase getLayout() { return LAYOUT; }
|
||||
|
||||
@Override
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
final EditorInfo emailField = new EditorInfo();
|
||||
emailField.inputType =
|
||||
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
|
||||
|
@ -27,6 +27,7 @@ import org.futo.inputmethod.keyboard.layout.LayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.DvorakCustomizer.EnglishDvorakCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.LayoutCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -42,9 +43,9 @@ public class TestsDvorakUrl extends LayoutTestsBase {
|
||||
LayoutBase getLayout() { return LAYOUT; }
|
||||
|
||||
@Override
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
final EditorInfo emailField = new EditorInfo();
|
||||
emailField.inputType =
|
||||
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
|
||||
|
@ -25,6 +25,7 @@ import org.futo.inputmethod.keyboard.layout.LayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.Qwerty;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.EnglishCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -40,9 +41,9 @@ public class TestsQwertyEmail extends LayoutTestsBase {
|
||||
LayoutBase getLayout() { return LAYOUT; }
|
||||
|
||||
@Override
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
final EditorInfo emailField = new EditorInfo();
|
||||
emailField.inputType =
|
||||
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
|
||||
|
@ -25,6 +25,7 @@ import org.futo.inputmethod.keyboard.layout.LayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.Qwerty;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.EnglishCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -40,9 +41,9 @@ public class TestsQwertyUrl extends LayoutTestsBase {
|
||||
LayoutBase getLayout() { return LAYOUT; }
|
||||
|
||||
@Override
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
final EditorInfo emailField = new EditorInfo();
|
||||
emailField.inputType =
|
||||
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
|
||||
|
@ -24,6 +24,7 @@ import org.futo.inputmethod.keyboard.layout.LayoutBase;
|
||||
import org.futo.inputmethod.keyboard.layout.Qwerty;
|
||||
import org.futo.inputmethod.keyboard.layout.customizer.EnglishCustomizer;
|
||||
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey;
|
||||
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@ -36,9 +37,9 @@ public class TestsSplitLayoutQwertyEnglishUS extends LayoutTestsBase {
|
||||
private static final LayoutBase LAYOUT = new Qwerty(new EnglishSplitCustomizer(LOCALE));
|
||||
|
||||
@Override
|
||||
protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
|
||||
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
|
||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||
return super.createKeyboardLayoutSet(subtype, editorInfo, voiceInputKeyEnabled,
|
||||
languageSwitchKeyEnabled, true /* splitLayoutEnabled */);
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||
private static final String TYPE_TEST = "test";
|
||||
private static final PhonyDictionary DICTIONARY_TEST = new PhonyDictionary(TYPE_TEST);
|
||||
|
||||
protected LatinIME mLatinIME;
|
||||
protected LatinIMELegacy mLatinIMELegacy;
|
||||
protected Keyboard mKeyboard;
|
||||
protected MyEditText mEditText;
|
||||
@ -84,6 +85,9 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||
public InputTestsBase(Class<LatinIME> serviceClass) {
|
||||
super(serviceClass);
|
||||
}
|
||||
public InputTestsBase() {
|
||||
super(LatinIME.class);
|
||||
}
|
||||
|
||||
// A helper class to ease span tests
|
||||
public static class SpanGetter {
|
||||
@ -380,7 +384,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||
// TODO: Use {@link InputMethodSubtype.InputMethodSubtypeBuilder} directly or indirectly so
|
||||
// that {@link InputMethodSubtype#isAsciiCapable} can return the correct value.
|
||||
final String EXTRA_VALUE_FOR_TEST =
|
||||
"KeyboardLayoutSet=" + SubtypeLocaleUtils.QWERTY
|
||||
"KeyboardLayoutSetV2=" + SubtypeLocaleUtils.QWERTY
|
||||
+ "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
|
||||
+ "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE
|
||||
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE
|
||||
|
@ -29,7 +29,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||
final String PUNCTUATION_FROM_STRIP = "!";
|
||||
final String EXPECTED_RESULT = "this!! ";
|
||||
final boolean defaultNextWordPredictionOption =
|
||||
mLatinIMELegacy.getResources().getBoolean(R.bool.config_default_next_word_prediction);
|
||||
mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction);
|
||||
final boolean previousNextWordPredictionOption =
|
||||
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false,
|
||||
defaultNextWordPredictionOption);
|
||||
|
@ -93,7 +93,7 @@ public class RichInputMethodSubtypeTests {
|
||||
AdditionalSubtypeUtils.createAdditionalSubtypesArray(
|
||||
AdditionalSubtypeUtils.createPrefSubtypes(
|
||||
mRes.getStringArray(R.array.predefined_subtypes)));
|
||||
mRichImm.setAdditionalInputMethodSubtypes(predefinedAddtionalSubtypes);
|
||||
//mRichImm.setAdditionalInputMethodSubtypes(predefinedAddtionalSubtypes);
|
||||
|
||||
final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
|
||||
final int subtypeCount = imi.getSubtypeCount();
|
||||
@ -102,27 +102,27 @@ public class RichInputMethodSubtypeTests {
|
||||
mSubtypesList.add(new RichInputMethodSubtype(subtype));
|
||||
}
|
||||
|
||||
EN_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
EN_US = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.US.toString(), "qwerty"));
|
||||
EN_GB = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
EN_GB = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.UK.toString(), "qwerty"));
|
||||
ES_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
ES_US = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
"es_US", "spanish"));
|
||||
FR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
FR = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.FRENCH.toString(), "azerty"));
|
||||
FR_CA = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
FR_CA = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.CANADA_FRENCH.toString(), "qwerty"));
|
||||
FR_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
FR_CH = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
"fr_CH", "swiss"));
|
||||
DE = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
DE = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.GERMAN.toString(), "qwertz"));
|
||||
DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
DE_CH = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
"de_CH", "swiss"));
|
||||
HI = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
HI = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
"hi", "hindi"));
|
||||
SR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
SR = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
"sr", "south_slavic"));
|
||||
ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
ZZ = new RichInputMethodSubtype(Subtypes.INSTANCE.makeSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"));
|
||||
DE_QWERTY = new RichInputMethodSubtype(
|
||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
@ -146,7 +146,7 @@ public class RichInputMethodSubtypeTests {
|
||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty"));
|
||||
|
||||
final InputMethodSubtype hiLatn = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype hiLatn = Subtypes.INSTANCE.makeSubtype(
|
||||
"hi_ZZ", "qwerty");
|
||||
if (hiLatn != null) {
|
||||
HI_LATN = new RichInputMethodSubtype(hiLatn);
|
||||
@ -154,7 +154,7 @@ public class RichInputMethodSubtypeTests {
|
||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
"hi_ZZ", "dvorak"));
|
||||
}
|
||||
final InputMethodSubtype srLatn = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype srLatn = Subtypes.INSTANCE.makeSubtype(
|
||||
"sr_ZZ", "serbian_qwertz");
|
||||
if (srLatn != null) {
|
||||
SR_LATN = new RichInputMethodSubtype(srLatn);
|
||||
@ -167,7 +167,7 @@ public class RichInputMethodSubtypeTests {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
// Restore additional subtypes.
|
||||
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
|
||||
//mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,7 +56,7 @@ public class AdditionalSubtypeUtilsTests {
|
||||
* final int SUBTYPE_ID_EN_US_DVORAK = Arrays.hashCode(new Object[] {
|
||||
* "en_US",
|
||||
* "keyboard",
|
||||
* "KeyboardLayoutSet=dvorak"
|
||||
* "KeyboardLayoutSetV2=dvorak"
|
||||
* + ",AsciiCapable"
|
||||
* + ",UntranslatableReplacementStringInSubtypeName=Dvorak"
|
||||
* + ",EmojiCapable"
|
||||
@ -67,16 +67,16 @@ public class AdditionalSubtypeUtilsTests {
|
||||
*/
|
||||
private static int SUBTYPE_ID_EN_US_DVORAK = 0xb3c0cc56;
|
||||
private static String EXTRA_VALUE_EN_US_DVORAK_ICS =
|
||||
"KeyboardLayoutSet=dvorak" +
|
||||
"KeyboardLayoutSetV2=dvorak" +
|
||||
",AsciiCapable" +
|
||||
",isAdditionalSubtype";
|
||||
private static String EXTRA_VALUE_EN_US_DVORAK_JELLY_BEAN =
|
||||
"KeyboardLayoutSet=dvorak" +
|
||||
"KeyboardLayoutSetV2=dvorak" +
|
||||
",AsciiCapable" +
|
||||
",UntranslatableReplacementStringInSubtypeName=Dvorak" +
|
||||
",isAdditionalSubtype";
|
||||
private static String EXTRA_VALUE_EN_US_DVORAK_KITKAT =
|
||||
"KeyboardLayoutSet=dvorak" +
|
||||
"KeyboardLayoutSetV2=dvorak" +
|
||||
",AsciiCapable" +
|
||||
",UntranslatableReplacementStringInSubtypeName=Dvorak" +
|
||||
",EmojiCapable" +
|
||||
@ -90,7 +90,7 @@ public class AdditionalSubtypeUtilsTests {
|
||||
* final int SUBTYPE_ID_ZZ_AZERTY = Arrays.hashCode(new Object[] {
|
||||
* "zz",
|
||||
* "keyboard",
|
||||
* "KeyboardLayoutSet=azerty"
|
||||
* "KeyboardLayoutSetV2=azerty"
|
||||
* + ",AsciiCapable"
|
||||
* + ",EmojiCapable"
|
||||
* + ",isAdditionalSubtype",
|
||||
@ -100,11 +100,11 @@ public class AdditionalSubtypeUtilsTests {
|
||||
*/
|
||||
private static int SUBTYPE_ID_ZZ_AZERTY = 0x5b6be697;
|
||||
private static String EXTRA_VALUE_ZZ_AZERTY_ICS =
|
||||
"KeyboardLayoutSet=azerty" +
|
||||
"KeyboardLayoutSetV2=azerty" +
|
||||
",AsciiCapable" +
|
||||
",isAdditionalSubtype";
|
||||
private static String EXTRA_VALUE_ZZ_AZERTY_KITKAT =
|
||||
"KeyboardLayoutSet=azerty" +
|
||||
"KeyboardLayoutSetV2=azerty" +
|
||||
",AsciiCapable" +
|
||||
",EmojiCapable" +
|
||||
",isAdditionalSubtype";
|
||||
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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 org.futo.inputmethod.latin.utils;
|
||||
|
||||
import static org.futo.inputmethod.latin.utils.ImportantNoticeUtils.KEY_TIMESTAMP_OF_CONTACTS_NOTICE;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.MediumTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.futo.inputmethod.latin.settings.SettingsValues;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@MediumTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ImportantNoticeUtilsTests {
|
||||
|
||||
private ImportantNoticePreferences mImportantNoticePreferences;
|
||||
|
||||
@Mock private SettingsValues mMockSettingsValues;
|
||||
|
||||
private Context getContext() {
|
||||
return InstrumentationRegistry.getTargetContext();
|
||||
}
|
||||
|
||||
private static class ImportantNoticePreferences {
|
||||
private final SharedPreferences mPref;
|
||||
|
||||
private Long mLastTime;
|
||||
|
||||
public ImportantNoticePreferences(final Context context) {
|
||||
mPref = ImportantNoticeUtils.getImportantNoticePreferences(context);
|
||||
}
|
||||
|
||||
private Integer getInt(final String key) {
|
||||
if (mPref.contains(key)) {
|
||||
return mPref.getInt(key, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Long getLong(final String key) {
|
||||
if (mPref.contains(key)) {
|
||||
return mPref.getLong(key, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void putInt(final String key, final Integer value) {
|
||||
if (value == null) {
|
||||
removePreference(key);
|
||||
} else {
|
||||
mPref.edit().putInt(key, value).apply();
|
||||
}
|
||||
}
|
||||
|
||||
private void putLong(final String key, final Long value) {
|
||||
if (value == null) {
|
||||
removePreference(key);
|
||||
} else {
|
||||
mPref.edit().putLong(key, value).apply();
|
||||
}
|
||||
}
|
||||
|
||||
private void removePreference(final String key) {
|
||||
mPref.edit().remove(key).apply();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
mLastTime = getLong(KEY_TIMESTAMP_OF_CONTACTS_NOTICE);
|
||||
}
|
||||
|
||||
public void restore() {
|
||||
putLong(KEY_TIMESTAMP_OF_CONTACTS_NOTICE, mLastTime);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
removePreference(KEY_TIMESTAMP_OF_CONTACTS_NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mImportantNoticePreferences = new ImportantNoticePreferences(getContext());
|
||||
mImportantNoticePreferences.save();
|
||||
when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(true);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
mImportantNoticePreferences.restore();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersonalizationSetting() {
|
||||
mImportantNoticePreferences.clear();
|
||||
|
||||
// Personalization enabled.
|
||||
when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(true);
|
||||
assertEquals("Current boolean with personalization enabled", true,
|
||||
ImportantNoticeUtils.shouldShowImportantNotice(getContext(), mMockSettingsValues));
|
||||
|
||||
// Personalization disabled.
|
||||
when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(false);
|
||||
assertEquals("Current boolean with personalization disabled", false,
|
||||
ImportantNoticeUtils.shouldShowImportantNotice(getContext(), mMockSettingsValues));
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.futo.inputmethod.latin.RichInputMethodManager;
|
||||
import org.futo.inputmethod.latin.RichInputMethodSubtype;
|
||||
import org.futo.inputmethod.latin.Subtypes;
|
||||
import org.futo.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
||||
import org.futo.inputmethod.latin.utils.LanguageOnSpacebarUtils;
|
||||
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||
@ -81,7 +82,7 @@ public class LanguageOnSpacebarUtilsTests {
|
||||
@Nonnull
|
||||
private RichInputMethodSubtype findSubtypeOf(final String localeString,
|
||||
final String keyboardLayoutSetName) {
|
||||
final InputMethodSubtype subtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
final InputMethodSubtype subtype = Subtypes.INSTANCE.makeSubtype(
|
||||
localeString, keyboardLayoutSetName);
|
||||
if (subtype == null) {
|
||||
throw new RuntimeException("Can't find subtype of " + localeString + " with "
|
||||
|
@ -34,6 +34,7 @@ import org.futo.inputmethod.latin.R;
|
||||
import org.futo.inputmethod.latin.RichInputMethodManager;
|
||||
import org.futo.inputmethod.latin.RichInputMethodSubtype;
|
||||
|
||||
import org.futo.inputmethod.latin.Subtypes;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -90,7 +91,7 @@ public class SubtypeLocaleUtilsTests {
|
||||
AdditionalSubtypeUtils.createAdditionalSubtypesArray(
|
||||
AdditionalSubtypeUtils.createPrefSubtypes(
|
||||
mRes.getStringArray(R.array.predefined_subtypes)));
|
||||
mRichImm.setAdditionalInputMethodSubtypes(predefinedAddtionalSubtypes);
|
||||
//mRichImm.setAdditionalInputMethodSubtypes(predefinedAddtionalSubtypes);
|
||||
|
||||
final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
|
||||
final int subtypeCount = imi.getSubtypeCount();
|
||||
@ -99,51 +100,51 @@ public class SubtypeLocaleUtilsTests {
|
||||
mSubtypesList.add(new RichInputMethodSubtype(subtype));
|
||||
}
|
||||
|
||||
EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
EN_US = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.US.toString(), "qwerty");
|
||||
EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
EN_GB = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.UK.toString(), "qwerty");
|
||||
ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
ES_US = Subtypes.INSTANCE.makeSubtype(
|
||||
"es_US", "spanish");
|
||||
FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
FR = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.FRENCH.toString(), "azerty");
|
||||
FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
FR_CA = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.CANADA_FRENCH.toString(), "qwerty");
|
||||
FR_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
FR_CH = Subtypes.INSTANCE.makeSubtype(
|
||||
"fr_CH", "swiss");
|
||||
DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
DE = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.GERMAN.toString(), "qwertz");
|
||||
DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
DE_CH = Subtypes.INSTANCE.makeSubtype(
|
||||
"de_CH", "swiss");
|
||||
HI = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
HI = Subtypes.INSTANCE.makeSubtype(
|
||||
"hi", "hindi");
|
||||
SR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
SR = Subtypes.INSTANCE.makeSubtype(
|
||||
"sr", "south_slavic");
|
||||
ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
ZZ = Subtypes.INSTANCE.makeSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
|
||||
DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
DE_QWERTY = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.GERMAN.toString(), "qwerty");
|
||||
FR_QWERTZ = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
FR_QWERTZ = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.FRENCH.toString(), "qwertz");
|
||||
EN_US_AZERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
EN_US_AZERTY = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.US.toString(), "azerty");
|
||||
EN_UK_DVORAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
EN_UK_DVORAK = Subtypes.INSTANCE.makeSubtype(
|
||||
Locale.UK.toString(), "dvorak");
|
||||
ES_US_COLEMAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
ES_US_COLEMAK = Subtypes.INSTANCE.makeSubtype(
|
||||
"es_US", "colemak");
|
||||
ZZ_AZERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
ZZ_AZERTY = Subtypes.INSTANCE.makeSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
|
||||
ZZ_PC = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
ZZ_PC = Subtypes.INSTANCE.makeSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty");
|
||||
|
||||
HI_LATN = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("hi_ZZ", "qwerty");
|
||||
HI_LATN = Subtypes.INSTANCE.makeSubtype("hi_ZZ", "qwerty");
|
||||
if (HI_LATN != null) {
|
||||
HI_LATN_DVORAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
HI_LATN_DVORAK = Subtypes.INSTANCE.makeSubtype(
|
||||
"hi_ZZ", "dvorak");
|
||||
}
|
||||
SR_LATN = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("sr_ZZ", "serbian_qwertz");
|
||||
SR_LATN = Subtypes.INSTANCE.makeSubtype("sr_ZZ", "serbian_qwertz");
|
||||
if (SR_LATN != null) {
|
||||
SR_LATN_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
SR_LATN_QWERTY = Subtypes.INSTANCE.makeSubtype(
|
||||
"sr_ZZ", "qwerty");
|
||||
}
|
||||
}
|
||||
@ -151,7 +152,7 @@ public class SubtypeLocaleUtilsTests {
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
// Restore additional subtypes.
|
||||
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
|
||||
//mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -473,14 +474,11 @@ public class SubtypeLocaleUtilsTests {
|
||||
@Test
|
||||
public void testIsRtlLanguage() {
|
||||
// Known Right-to-Left language subtypes.
|
||||
final InputMethodSubtype ARABIC = mRichImm
|
||||
.findSubtypeByLocaleAndKeyboardLayoutSet("ar", "arabic");
|
||||
final InputMethodSubtype ARABIC = Subtypes.INSTANCE.makeSubtype("ar", "arabic");
|
||||
assertNotNull("Arabic", ARABIC);
|
||||
final InputMethodSubtype FARSI = mRichImm
|
||||
.findSubtypeByLocaleAndKeyboardLayoutSet("fa", "farsi");
|
||||
final InputMethodSubtype FARSI = Subtypes.INSTANCE.makeSubtype("fa", "farsi");
|
||||
assertNotNull("Farsi", FARSI);
|
||||
final InputMethodSubtype HEBREW = mRichImm
|
||||
.findSubtypeByLocaleAndKeyboardLayoutSet("iw", "hebrew");
|
||||
final InputMethodSubtype HEBREW = Subtypes.INSTANCE.makeSubtype("iw", "hebrew");
|
||||
assertNotNull("Hebrew", HEBREW);
|
||||
|
||||
for (final RichInputMethodSubtype subtype : mSubtypesList) {
|
||||
|
Loading…
Reference in New Issue
Block a user