public boolean isValidWord(final CharSequence word) { if (word == null || word.length() == 0) { return false; } Log.v( TAG, "Suggest::isValidWord(%s) mMainDictionaryEnabled:%s mAutoTextEnabled: %s user-dictionary-enabled: %s contacts-dictionary-enabled: %s", word, mMainDictionaryEnabled, mAutoTextEnabled, mUserDictionary != null, mContactsDictionary != null); if (mMainDictionaryEnabled || mAutoTextEnabled) { final boolean validFromMain = (mMainDictionaryEnabled && mMainDict != null && mMainDict.isValidWord(word)); final boolean validFromUser = (mUserDictionary != null && mUserDictionary.isValidWord(word)); final boolean validFromContacts = (mContactsDictionary != null && mContactsDictionary.isValidWord(word)); Log.v( TAG, "Suggest::isValidWord(%s)validFromMain: %s validFromUser: %s validFromContacts: %s", word, validFromMain, validFromUser, validFromContacts); return validFromMain || validFromUser || /* validFromAuto || */ validFromContacts; } else { return false; } }
public Row(Context askContext, Resources res, Keyboard parent, XmlResourceParser parser) { this.parent = parent; // some defaults defaultWidth = parent.mDefaultWidth; defaultHeightCode = parent.mDefaultHeightCode; defaultHorizontalGap = parent.mDefaultHorizontalGap; verticalGap = parent.getVerticalGap(); // now reading from the XML SparseIntArray attributeIdMap = parent.attributeIdMap; int[] remoteKeyboardLayoutStyleable = parent.remoteKeyboardLayoutStyleable; TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser), remoteKeyboardLayoutStyleable); int n = a.getIndexCount(); for (int i = 0; i < n; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = attributeIdMap.get(remoteKeyboardLayoutStyleable[remoteIndex]); try { switch (localAttrId) { case android.R.attr.keyWidth: defaultWidth = getDimensionOrFraction( a, remoteIndex, parent.mDisplayWidth, parent.mDefaultWidth); break; case android.R.attr.keyHeight: defaultHeightCode = getKeyHeightCode(a, remoteIndex, parent.mDefaultHeightCode); break; case android.R.attr.horizontalGap: defaultHorizontalGap = getDimensionOrFraction( a, remoteIndex, parent.mDisplayWidth, parent.mDefaultHorizontalGap); break; } } catch (Exception e) { Log.w(TAG, "Failed to set data from XML!", e); } } a.recycle(); int[] remoteKeyboardRowLayoutStyleable = parent.remoteKeyboardRowLayoutStyleable; a = res.obtainAttributes(Xml.asAttributeSet(parser), remoteKeyboardRowLayoutStyleable); n = a.getIndexCount(); for (int i = 0; i < n; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = attributeIdMap.get(remoteKeyboardRowLayoutStyleable[remoteIndex]); try { switch (localAttrId) { case android.R.attr.rowEdgeFlags: rowEdgeFlags = a.getInt(remoteIndex, 0); break; case android.R.attr.keyboardMode: mode = a.getResourceId(remoteIndex, 0); break; } } catch (Exception e) { Log.w(TAG, "Failed to set data from XML!", e); } } a.recycle(); }
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { synchronized (mDbName) { // Please note: don't use class level constants here, since they may // change. // if you upgrade from one version to another, make sure you use the // correct names! Log.d( TAG, "Upgrading WordsSQLiteConnection from version " + oldVersion + " to " + newVersion + "..."); if (oldVersion < 4) { Log.d(TAG, "Upgrading WordsSQLiteConnection to version 4: Adding locale column..."); db.execSQL("ALTER TABLE FALL_BACK_USER_DICTIONARY ADD COLUMN locale TEXT;"); } if (oldVersion < 5) { Log.d( TAG, "Upgrading WordsSQLiteConnection to version 5: Adding _id column and populating..."); db.execSQL("ALTER TABLE FALL_BACK_USER_DICTIONARY ADD COLUMN _id INTEGER;"); db.execSQL("UPDATE FALL_BACK_USER_DICTIONARY SET _id=Id;"); } if (oldVersion < 6) { Log.d( TAG, "Upgrading WordsSQLiteConnection to version 6: Matching schema with Android's User-Dictionary table..."); db.execSQL( "ALTER TABLE FALL_BACK_USER_DICTIONARY RENAME TO tmp_FALL_BACK_USER_DICTIONARY;"); db.execSQL( "CREATE TABLE FALL_BACK_USER_DICTIONARY (" + "_id INTEGER PRIMARY KEY,word TEXT," + "frequency INTEGER,locale TEXT);"); db.execSQL( "INSERT INTO FALL_BACK_USER_DICTIONARY(_id, word, frequency, locale) SELECT _id, Word, Freq, locale FROM tmp_FALL_BACK_USER_DICTIONARY;"); db.execSQL("DROP TABLE tmp_FALL_BACK_USER_DICTIONARY;"); } if (oldVersion < 7) { Log.d(TAG, "Renaming the table's name to a generic one..."); db.execSQL("ALTER TABLE FALL_BACK_USER_DICTIONARY RENAME TO WORDS;"); } } }
public void addWord(String word, int freq) { synchronized (mDbName) { SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put(Words._ID, word.hashCode()); // ensuring that any word is inserted once values.put(Words.WORD, word); values.put(Words.FREQUENCY, freq); values.put(Words.LOCALE, mCurrentLocale); long res = db.insert(TABLE_NAME, null, values); if (res < 0) { Log.e( TAG, "Unable to insert '" + word + "' to SQLite storage (" + mCurrentLocale + "@" + mDbName + ")! Result:" + res); } db.close(); } }
protected void sendCrashReportViaEmail() { Intent callingIntent = getIntent(); Intent sendMail = new Intent(); sendMail.setAction(Intent.ACTION_SEND); sendMail.setType("plain/text"); sendMail.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"}); sendMail.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_name) + " crashed!"); sendMail.putExtra(Intent.EXTRA_TEXT, callingIntent.getStringExtra(CRASH_REPORT_TEXT)); try { Intent sender = Intent.createChooser(sendMail, "Send bug report"); sender.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"}); sender.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_name) + " crashed!"); sender.putExtra(Intent.EXTRA_TEXT, callingIntent.getStringExtra(CRASH_REPORT_TEXT)); Log.i(TAG, "Will send crash report using " + sender); startActivity(sender); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText( getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG) .show(); } finish(); }
public static int[] parseCSV(String value) { int count = 0; int lastIndex = 0; if (value.length() > 0) { count++; while ((lastIndex = value.indexOf(",", lastIndex + 1)) > 0) { count++; } } int[] values = new int[count]; count = 0; StringTokenizer st = new StringTokenizer(value, ","); while (st.hasMoreTokens()) { String nextToken = st.nextToken(); try { // Issue 395 // default behavior if (nextToken.length() != 1) { values[count++] = Integer.parseInt(nextToken); } else { // length == 1, assume a char! values[count++] = (int) nextToken.charAt(0); } } catch (NumberFormatException nfe) { Log.e(TAG, "Error parsing keycodes " + value); } } return values; }
@Override public boolean setValueFromTheme( TypedArray remoteTypedArray, int[] padding, int localAttrId, int remoteTypedArrayIndex) { switch (localAttrId) { case R.attr.previewGestureTextSize: mGesturePreviewTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0); Log.d(TAG, "AnySoftKeyboardTheme_previewGestureTextSize " + mGesturePreviewTextSize); break; case R.attr.previewGestureTextColor: mGesturePreviewTextColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFF); Log.d(TAG, "AnySoftKeyboardTheme_previewGestureTextColor " + mGesturePreviewTextColor); default: return super.setValueFromTheme( remoteTypedArray, padding, localAttrId, remoteTypedArrayIndex); } return true; }
@Override protected boolean onLongPress( AddOn keyboardAddOn, Key key, boolean isSticky, boolean requireSlideInto) { if (mAnimationLevel == AnimationsLevel.None) { mMiniKeyboardPopup.setAnimationStyle(0); } else if (mExtensionVisible && mMiniKeyboardPopup.getAnimationStyle() != R.style.ExtensionKeyboardAnimation) { Log.d(TAG, "Switching mini-keyboard animation to ExtensionKeyboardAnimation"); mMiniKeyboardPopup.setAnimationStyle(R.style.ExtensionKeyboardAnimation); } else if (!mExtensionVisible && mMiniKeyboardPopup.getAnimationStyle() != R.style.MiniKeyboardAnimation) { Log.d(TAG, "Switching mini-keyboard animation to MiniKeyboardAnimation"); mMiniKeyboardPopup.setAnimationStyle(R.style.MiniKeyboardAnimation); } return super.onLongPress(keyboardAddOn, key, isSticky, requireSlideInto); }
@Override public boolean addWord( final char[] word, final int offset, final int length, final int freq, final Dictionary from) { if (from == mAbbreviationDictionary) { mExplodedAbbreviations.add(new String(word, offset, length)); return true; } int pos = 0; final int[] priorities = mPriorities; final int prefMaxSuggestions = mPrefMaxSuggestions; // Check if it's the same word, only caps are different if (compareCaseInsensitive(mLowerOriginalWord, word, offset, length)) { Log.v(TAG, "Suggest::addWord - forced at position 0."); pos = 0; } else { // Check the last one's priority and bail if (priorities[prefMaxSuggestions - 1] >= freq) return true; while (pos < prefMaxSuggestions) { if (priorities[pos] < freq || (priorities[pos] == freq && length < mSuggestions.get(pos).length())) { break; } pos++; } } if (pos >= prefMaxSuggestions) { return true; } System.arraycopy(priorities, pos, priorities, pos + 1, prefMaxSuggestions - pos - 1); priorities[pos] = freq; int poolSize = mStringPool.size(); StringBuilder sb = poolSize > 0 ? (StringBuilder) mStringPool.remove(poolSize - 1) : new StringBuilder(32); sb.setLength(0); if (mIsAllUpperCase) { sb.append(new String(word, offset, length).toUpperCase(mLocale)); } else if (mIsFirstCharCapitalized) { sb.append(Character.toUpperCase(word[offset])); if (length > 1) { sb.append(word, offset + 1, length - 1); } } else { sb.append(word, offset, length); } mSuggestions.add(pos, sb); if (mSuggestions.size() > prefMaxSuggestions) { CharSequence garbage = mSuggestions.remove(prefMaxSuggestions); if (garbage instanceof StringBuilder) { mStringPool.add(garbage); } } return true; }
public Drawable getIcon() { try { if (mIconResId != INVALID_RES_ID) { return getPackageContext().getResources().getDrawable(mIconResId); } else { return null; } } catch (Resources.NotFoundException n) { Log.w(TAG, "Failed to load pack ICON! ResId: " + mIconResId); return null; } }
public void onClick(View view) { try { String tag = getKey(); Intent search = new Intent(Intent.ACTION_VIEW); search.setData(Uri.parse("market://search?q=AnySoftKeyboard " + tag)); search.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(search); } catch (Exception ex) { Log.e(TAG, "Could not launch Store search!", ex); mStoreNotFoundView.setVisibility(View.VISIBLE); } }
@Override public void onDraw(Canvas canvas) { final boolean keyboardChanged = mKeyboardChanged; super.onDraw(canvas); // switching animation if (mAnimationLevel != AnimationsLevel.None && keyboardChanged && (mInAnimation != null)) { startAnimation(mInAnimation); mInAnimation = null; } // text pop out animation if (mPopOutText != null && mAnimationLevel != AnimationsLevel.None) { final int maxVerticalTravel = getHeight() / 2; final long animationDuration = 1200; final long currentAnimationTime = SystemClock.elapsedRealtime() - mPopOutTime; if (currentAnimationTime > animationDuration) { mPopOutText = null; } else { final float animationProgress = ((float) currentAnimationTime) / ((float) animationDuration); final float animationFactoredProgress = getPopOutAnimationInterpolator(animationProgress); final int y = mPopOutStartPoint.y - (int) (maxVerticalTravel * animationFactoredProgress); final int x = mPopOutStartPoint.x; final int alpha = 255 - (int) (255 * animationProgress); if (FeaturesSet.DEBUG_LOG) Log.d( TAG, "Drawing text popout '" + mPopOutText + "' at " + x + "," + y + " with alpha " + alpha + ". Animation progress is " + animationProgress + ", and factor progress is " + animationFactoredProgress); // drawing setPaintToKeyText(mPaint); // will disappear over time mPaint.setAlpha(alpha); mPaint.setShadowLayer(5, 0, 0, Color.BLACK); // will grow over time mPaint.setTextSize(mPaint.getTextSize() * (1.0f + animationFactoredProgress)); canvas.translate(x, y); canvas.drawText(mPopOutText, 0, mPopOutText.length(), 0, 0, mPaint); canvas.translate(-x, -y); // next frame postInvalidateDelayed(1000 / 50); // doing 50 frames per second; } } }
@NonNull public static int[] getKeyCodesFromTypedArray(TypedArray typedArray, int index) { TypedValue codesValue = new TypedValue(); typedArray.getValue(index, codesValue); if (codesValue.type == TypedValue.TYPE_INT_DEC || codesValue.type == TypedValue.TYPE_INT_HEX) { return new int[] {codesValue.data}; } else if (codesValue.type == TypedValue.TYPE_STRING) { return parseCSV(codesValue.string.toString()); } else { Log.w(TAG, "Unknown codes values!"); return new int[0]; } }
@Nullable public Drawable getScreenshot() { try { if (mThemeScreenshotResId != INVALID_RES_ID) { Context packageContext = getPackageContext(); if (packageContext == null) return null; return packageContext.getResources().getDrawable(mThemeScreenshotResId); } else { return null; } } catch (Resources.NotFoundException n) { Log.w(TAG, "Failed to load pack Screenshot! ResId:" + mThemeScreenshotResId); return null; } }
protected static int getKeyHeightCode(TypedArray a, int remoteIndex, int defaultHeightCode) { TypedValue value = a.peekValue(remoteIndex); if (value == null) { // means that it was not provided. So I take my parent's return defaultHeightCode; } else if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT && value.data <= 0 && value.data >= -3) { return value.data; } else { Log.w(TAG, "Key height attribute is incorrectly set! Defaulting to regular height."); return -1; } }
/** Sets an optional contacts dictionary resource to be loaded. */ public void setContactsDictionary(Context context, boolean enabled) { if (!enabled && mContactsDictionary != null) { // had one, but now config says it should be off Log.i(TAG, "Contacts dictionary has been disabled! Closing resources."); mContactsDictionary.close(); mContactsDictionary = null; } else if (enabled && mContactsDictionary == null) { // config says it should be on, but I have none. mContactsDictionary = mDictionaryFactory.createContactsDictionary(context); if (mContactsDictionary != null) { // not all devices has contacts-dictionary DictionaryASyncLoader loader = new DictionaryASyncLoader(null); loader.execute(mContactsDictionary); } } }
private void collectGarbage() { int poolSize = mStringPool.size(); int garbageSize = mSuggestions.size(); while (poolSize < mPrefMaxSuggestions && garbageSize > 0) { CharSequence garbage = mSuggestions.get(garbageSize - 1); if (garbage != null && garbage instanceof StringBuilder) { mStringPool.add(garbage); poolSize++; } garbageSize--; } if (poolSize == mPrefMaxSuggestions + 1) { Log.w(TAG, "String pool got too big: " + poolSize); } mSuggestions.clear(); }
public void popTextOutOfKey(CharSequence text) { if (TextUtils.isEmpty(text)) { Log.w(TAG, "Call for popTextOutOfKey with missing text argument!"); return; } if (!AnyApplication.getConfig().workaround_alwaysUseDrawText()) return; // not doing it with StaticLayout // performing "toString" so we'll have a separate copy of the CharSequence, // and not the original object which I fear is a reference copy (hence may be changed). mPopOutText = text.toString(); mPopOutTime = SystemClock.elapsedRealtime(); mPopOutStartPoint.x = mFirstTouchPoint.x; mPopOutStartPoint.y = mFirstTouchPoint.y; // it is ok to wait for the next loop. postInvalidate(); }
public void setMainDictionary( Context askContext, @Nullable DictionaryAddOnAndBuilder dictionaryBuilder) { Log.d( TAG, "Suggest: Got main dictionary! Type: " + ((dictionaryBuilder == null) ? "NULL" : dictionaryBuilder.getName())); if (mMainDict != null) { mMainDict.close(); mMainDict = null; } mLocale = CompatUtils.getLocaleForLanguageTag( dictionaryBuilder == null ? null : dictionaryBuilder.getLanguage()); if (mAbbreviationDictionary != null) { mAbbreviationDictionary.close(); mAbbreviationDictionary = null; } if (dictionaryBuilder == null) { mMainDict = null; mAutoText = null; mAbbreviationDictionary = null; mLocaleSpecificPunctuations = null; } else { try { System.gc(); mMainDict = dictionaryBuilder.createDictionary(); DictionaryASyncLoader loader = new DictionaryASyncLoader(null); loader.execute(mMainDict); } catch (Exception e) { e.printStackTrace(); } mAutoText = dictionaryBuilder.createAutoText(); mLocaleSpecificPunctuations = dictionaryBuilder.createInitialSuggestions(); mAbbreviationDictionary = new AbbreviationsDictionary(askContext, dictionaryBuilder.getLanguage()); DictionaryASyncLoader loader = new DictionaryASyncLoader(null); loader.execute(mAbbreviationDictionary); } }
public static void newSession(Context context) { sSessionCount++; sAutoSuggestCount = 0; sBackspaceCount = 0; sAutoSuggestUndoneCount = 0; sManualSuggestCount = 0; sWordNotInDictionaryCount = 0; sTypedChars = 0; sActualChars = 0; sState = State.START; if (LOGGING) { try { sKeyLocationFile = context.openFileOutput("key.txt", Context.MODE_APPEND); sUserActionFile = context.openFileOutput("action.txt", Context.MODE_APPEND); } catch (IOException ioe) { Log.e("TextEntryState", "Couldn't open file for output: " + ioe); } } }
private void parseKeyboardAttributes( Context askContext, Resources res, XmlResourceParser parser) { TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser), remoteKeyboardLayoutStyleable); Resources askRes = askContext.getResources(); // some defaults mDefaultWidth = mDisplayWidth / 10; mDefaultHeightCode = -1; mDefaultHorizontalGap = 0; mDefaultVerticalGap = askRes.getDimensionPixelOffset(R.dimen.default_key_vertical_gap); // now reading from XML int n = a.getIndexCount(); for (int i = 0; i < n; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = attributeIdMap.get(remoteKeyboardLayoutStyleable[remoteIndex]); try { switch (localAttrId) { case android.R.attr.keyWidth: mDefaultWidth = getDimensionOrFraction(a, remoteIndex, mDisplayWidth, mDisplayWidth / 10); break; case android.R.attr.keyHeight: mDefaultHeightCode = getKeyHeightCode(a, remoteIndex, -1); break; case android.R.attr.horizontalGap: mDefaultHorizontalGap = getDimensionOrFraction(a, remoteIndex, mDisplayWidth, 0); break; case android.R.attr.verticalGap: mDefaultVerticalGap = getDimensionOrFraction(a, remoteIndex, mDisplayWidth, mDefaultVerticalGap); break; } } catch (Exception e) { Log.w(TAG, "Failed to set data from XML!", e); } } a.recycle(); mProximityThreshold = (int) (mDefaultWidth * SEARCH_DISTANCE); // Square it for comparison mProximityThreshold = mProximityThreshold * mProximityThreshold; }
private void setDataFromTypedArray( Row parent, KeyboardDimens keyboardDimens, Resources askResources, TypedArray a, int remoteIndex, int localAttrId) { try { switch (localAttrId) { case android.R.attr.keyWidth: width = getDimensionOrFraction(a, remoteIndex, keyboard.mDisplayWidth, parent.defaultWidth); width = Math.min(keyboardDimens.getKeyMaxWidth(), width); break; case android.R.attr.keyHeight: int heightCode = getKeyHeightCode(a, remoteIndex, parent.defaultHeightCode); height = KeyboardSupport.getKeyHeightFromHeightCode( keyboardDimens, heightCode, askResources.getConfiguration().orientation); break; case android.R.attr.horizontalGap: gap = getDimensionOrFraction( a, remoteIndex, keyboard.mDisplayWidth, parent.defaultHorizontalGap); break; case android.R.attr.codes: codes = KeyboardSupport.getKeyCodesFromTypedArray(a, remoteIndex); break; case android.R.attr.iconPreview: iconPreview = a.getDrawable(remoteIndex); KeyboardSupport.updateDrawableBounds(iconPreview); break; case android.R.attr.popupCharacters: popupCharacters = a.getText(remoteIndex); break; case android.R.attr.popupKeyboard: popupResId = a.getResourceId(remoteIndex, 0); break; case android.R.attr.isRepeatable: repeatable = a.getBoolean(remoteIndex, false); break; case R.attr.showPreview: showPreview = a.getBoolean(remoteIndex, true); break; case R.attr.keyDynamicEmblem: dynamicEmblem = a.getInt(remoteIndex, KEY_EMBLEM_NONE); break; case android.R.attr.isModifier: modifier = a.getBoolean(remoteIndex, false); break; case android.R.attr.isSticky: sticky = a.getBoolean(remoteIndex, false); break; case android.R.attr.keyEdgeFlags: edgeFlags = a.getInt(remoteIndex, 0); edgeFlags |= parent.rowEdgeFlags; break; case android.R.attr.keyIcon: icon = a.getDrawable(remoteIndex); KeyboardSupport.updateDrawableBounds(icon); break; case android.R.attr.keyLabel: label = a.getText(remoteIndex); break; case android.R.attr.keyOutputText: text = a.getText(remoteIndex); break; } } catch (Exception e) { Log.w(TAG, "Failed to load keyboard layout! ", e); } }
public void loadKeyboard(final KeyboardDimens keyboardDimens) { mDisplayWidth = keyboardDimens.getKeyboardMaxWidth(); final float rowVerticalGap = keyboardDimens.getRowVerticalGap(); final float keyHorizontalGap = keyboardDimens.getKeyHorizontalGap(); mDefaultHorizontalGap = 0; mDefaultWidth = mDisplayWidth / 10; mDefaultHeightCode = -1; XmlResourceParser parser = mKeyboardContext.getResources().getXml(mLayoutResId); boolean inKey = false; boolean inRow = false; boolean inUnknown = false; int row = 0; float x = 0; float y = rowVerticalGap; // starts with a gap int rowHeight = 0; Key key = null; Row currentRow = null; Resources res = mKeyboardContext.getResources(); boolean skipRow = false; int lastVerticalGap = 0; try { int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { String tag = parser.getName(); if (TAG_ROW.equals(tag)) { inRow = true; x = 0; rowHeight = 0; currentRow = createRowFromXml(mASKContext, res, parser); skipRow = currentRow.mode != 0 && currentRow.mode != mKeyboardMode; if (skipRow) { skipToEndOfRow(parser); inRow = false; } } else if (TAG_KEY.equals(tag)) { inKey = true; x += (keyHorizontalGap / 2); key = createKeyFromXml( mASKContext, res, currentRow, keyboardDimens, (int) x, (int) y, parser); rowHeight = Math.max(rowHeight, key.height); key.width -= keyHorizontalGap; // the gap is on both // sides mKeys.add(key); if (key.codes[0] == KeyCodes.SHIFT) { mShiftKey = key; mShiftKeyIndex = mKeys.size() - 1; mModifierKeys.add(key); } else if (key.codes[0] == KeyCodes.ALT) { mModifierKeys.add(key); } } else if (TAG_KEYBOARD.equals(tag)) { parseKeyboardAttributes(mASKContext, res, parser); } else { inUnknown = true; onUnknownTagStart(mKeyboardContext, res, tag, parser); } } else if (event == XmlResourceParser.END_TAG) { if (inKey) { inKey = false; x += key.gap + key.width; x += (keyHorizontalGap / 2); if (x > mTotalWidth) { mTotalWidth = (int) x; } } else if (inRow) { inRow = false; lastVerticalGap = currentRow.verticalGap; y += currentRow.verticalGap; y += rowHeight; y += rowVerticalGap; row++; } else if (inUnknown) { inUnknown = false; onUnknownTagEnd(); } } } } catch (Exception e) { Log.e(TAG, "Parse error:" + e); e.printStackTrace(); } mTotalHeight = (int) (y - lastVerticalGap); }
private static void displayState() { if (DBG) { Log.d(TAG, "State = " + sState); } }
public static State getState() { if (DBG) { Log.d(TAG, "Returning state = " + sState); } return sState; }