Search in sources :

Example 1 with Keyboard

use of com.android.inputmethod.keyboard.Keyboard in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class EmojiCategory method getKeyboard.

public DynamicGridKeyboard getKeyboard(final int categoryId, final int id) {
    synchronized (mCategoryKeyboardMap) {
        final Long categoryKeyboardMapKey = getCategoryKeyboardMapKey(categoryId, id);
        if (mCategoryKeyboardMap.containsKey(categoryKeyboardMapKey)) {
            return mCategoryKeyboardMap.get(categoryKeyboardMapKey);
        }
        if (categoryId == EmojiCategory.ID_RECENTS) {
            final DynamicGridKeyboard kbd = new DynamicGridKeyboard(mPrefs, mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS), mMaxPageKeyCount, categoryId);
            mCategoryKeyboardMap.put(categoryKeyboardMapKey, kbd);
            return kbd;
        }
        final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
        final Key[][] sortedKeys = sortKeysIntoPages(keyboard.getSortedKeys(), mMaxPageKeyCount);
        for (int pageId = 0; pageId < sortedKeys.length; ++pageId) {
            final DynamicGridKeyboard tempKeyboard = new DynamicGridKeyboard(mPrefs, mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS), mMaxPageKeyCount, categoryId);
            for (final Key emojiKey : sortedKeys[pageId]) {
                if (emojiKey == null) {
                    break;
                }
                tempKeyboard.addKeyLast(emojiKey);
            }
            mCategoryKeyboardMap.put(getCategoryKeyboardMapKey(categoryId, pageId), tempKeyboard);
        }
        return mCategoryKeyboardMap.get(categoryKeyboardMapKey);
    }
}
Also used : Keyboard(com.android.inputmethod.keyboard.Keyboard) Paint(android.graphics.Paint) Key(com.android.inputmethod.keyboard.Key)

Example 2 with Keyboard

use of com.android.inputmethod.keyboard.Keyboard in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class EmojiPalettesAdapter method instantiateItem.

@Override
public Object instantiateItem(final ViewGroup container, final int position) {
    if (DEBUG_PAGER) {
        Log.d(TAG, "instantiate item: " + position);
    }
    final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(position);
    if (oldKeyboardView != null) {
        oldKeyboardView.deallocateMemory();
        // This may be redundant but wanted to be safer..
        mActiveKeyboardViews.remove(position);
    }
    final Keyboard keyboard = mEmojiCategory.getKeyboardFromPagePosition(position);
    final LayoutInflater inflater = LayoutInflater.from(container.getContext());
    final EmojiPageKeyboardView keyboardView = (EmojiPageKeyboardView) inflater.inflate(R.layout.emoji_keyboard_page, container, false);
    keyboardView.setKeyboard(keyboard);
    keyboardView.setOnKeyEventListener(mListener);
    container.addView(keyboardView);
    mActiveKeyboardViews.put(position, keyboardView);
    return keyboardView;
}
Also used : Keyboard(com.android.inputmethod.keyboard.Keyboard) LayoutInflater(android.view.LayoutInflater)

Example 3 with Keyboard

use of com.android.inputmethod.keyboard.Keyboard in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class ActionTestsBase method assertActionKey.

private static void assertActionKey(final String tag, final KeyboardLayoutSet layoutSet, final int elementId, final ExpectedActionKey expectedKey) {
    final Keyboard keyboard = layoutSet.getKeyboard(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());
    assertEquals(tag + " icon " + expectedKey, expectedKey.getIconId(), actualKey.getIconId());
}
Also used : Keyboard(com.android.inputmethod.keyboard.Keyboard) Key(com.android.inputmethod.keyboard.Key)

Example 4 with Keyboard

use of com.android.inputmethod.keyboard.Keyboard in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class LatinIME method dump.

@Override
protected void dump(final FileDescriptor fd, final PrintWriter fout, final String[] args) {
    super.dump(fd, fout, args);
    final Printer p = new PrintWriterPrinter(fout);
    p.println("LatinIME state :");
    p.println("  VersionCode = " + ApplicationUtils.getVersionCode(this));
    p.println("  VersionName = " + ApplicationUtils.getVersionName(this));
    final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
    final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
    p.println("  Keyboard mode = " + keyboardMode);
    final SettingsValues settingsValues = mSettings.getCurrent();
    p.println(settingsValues.dump());
    p.println(mDictionaryFacilitator.dump(this));
// TODO: Dump all settings values
}
Also used : PrintWriterPrinter(android.util.PrintWriterPrinter) SettingsValues(com.android.inputmethod.latin.settings.SettingsValues) Keyboard(com.android.inputmethod.keyboard.Keyboard) PrintWriterPrinter(android.util.PrintWriterPrinter) Printer(android.util.Printer)

Example 5 with Keyboard

use of com.android.inputmethod.keyboard.Keyboard in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class SuggestionStripView method showMoreSuggestions.

boolean showMoreSuggestions() {
    final Keyboard parentKeyboard = mMainKeyboardView.getKeyboard();
    if (parentKeyboard == null) {
        return false;
    }
    final SuggestionStripLayoutHelper layoutHelper = mLayoutHelper;
    if (mSuggestedWords.size() <= mStartIndexOfMoreSuggestions) {
        return false;
    }
    final int stripWidth = getWidth();
    final View container = mMoreSuggestionsContainer;
    final int maxWidth = stripWidth - container.getPaddingLeft() - container.getPaddingRight();
    final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
    builder.layout(mSuggestedWords, mStartIndexOfMoreSuggestions, maxWidth, (int) (maxWidth * layoutHelper.mMinMoreSuggestionsWidth), layoutHelper.getMaxMoreSuggestionsRow(), parentKeyboard);
    mMoreSuggestionsView.setKeyboard(builder.build());
    container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
    final int pointX = stripWidth / 2;
    final int pointY = -layoutHelper.mMoreSuggestionsBottomGap;
    moreKeysPanel.showMoreKeysPanel(this, mMoreSuggestionsController, pointX, pointY, mMoreSuggestionsListener);
    mOriginX = mLastX;
    mOriginY = mLastY;
    for (int i = 0; i < mStartIndexOfMoreSuggestions; i++) {
        mWordViews.get(i).setPressed(false);
    }
    return true;
}
Also used : MoreKeysPanel(com.android.inputmethod.keyboard.MoreKeysPanel) Keyboard(com.android.inputmethod.keyboard.Keyboard) View(android.view.View) TextView(android.widget.TextView) MainKeyboardView(com.android.inputmethod.keyboard.MainKeyboardView)

Aggregations

Keyboard (com.android.inputmethod.keyboard.Keyboard)10 Key (com.android.inputmethod.keyboard.Key)3 Paint (android.graphics.Paint)1 PrintWriterPrinter (android.util.PrintWriterPrinter)1 Printer (android.util.Printer)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 SuggestionsInfo (android.view.textservice.SuggestionsInfo)1 TextView (android.widget.TextView)1 MainKeyboardView (com.android.inputmethod.keyboard.MainKeyboardView)1 MoreKeysPanel (com.android.inputmethod.keyboard.MoreKeysPanel)1 ExpectedKey (com.android.inputmethod.keyboard.layout.expected.ExpectedKey)1 ExpectedAdditionalMoreKey (com.android.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey)1 SuggestedWords (com.android.inputmethod.latin.SuggestedWords)1 WordComposer (com.android.inputmethod.latin.WordComposer)1 SettingsValues (com.android.inputmethod.latin.settings.SettingsValues)1 MoreSuggestionKey (com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionKey)1 SuggestionResults (com.android.inputmethod.latin.utils.SuggestionResults)1