diff options
author | 2014-10-20 14:48:56 +0900 | |
---|---|---|
committer | 2014-10-21 19:28:37 +0900 | |
commit | 5f00fe09e9a611b647592188316e5999465df4d3 (patch) | |
tree | 954a429256171897c7b9ed56a732e386eec76b2b /java/src/com/android/inputmethod/event/DeadKeyCombiner.java | |
parent | fa1e65cb3a5dcce6299a6dd067cee95720107307 (diff) | |
download | latinime-5f00fe09e9a611b647592188316e5999465df4d3.tar.gz latinime-5f00fe09e9a611b647592188316e5999465df4d3.tar.xz latinime-5f00fe09e9a611b647592188316e5999465df4d3.zip |
Fix some compiler warnings
This CL fixes the following compiler warnings.
- Indirect access to static member
- Access to a non-accessible member of an enclosing type
- Parameter assignment
- Method can be static
- Local variable declaration hides another field or variable
- Value of local variable is not used
- Unused import
- Unused private member
- Unnecessary 'else' statement
- Unnecessary declaration of throw exception
- Redundant type arguments
- Missing '@Override' annotation
- Unused '@SuppressWarning' annotations
Bug: 18003991
Change-Id: Icfebe753e53a2cc621848f769d6a3d7ce501ebc7
Diffstat (limited to 'java/src/com/android/inputmethod/event/DeadKeyCombiner.java')
-rw-r--r-- | java/src/com/android/inputmethod/event/DeadKeyCombiner.java | 106 |
1 files changed, 51 insertions, 55 deletions
diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java index 88c70630d..2e65a08fa 100644 --- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java +++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java @@ -18,7 +18,6 @@ package com.android.inputmethod.event; import android.text.TextUtils; import android.util.SparseIntArray; -import android.view.KeyCharacterMap; import com.android.inputmethod.latin.Constants; @@ -70,8 +69,8 @@ public class DeadKeyCombiner implements Combiner { /** * Maps Unicode combining diacritical to display-form dead key. */ - private static final SparseIntArray sCombiningToAccent = new SparseIntArray(); - private static final SparseIntArray sAccentToCombining = new SparseIntArray(); + static final SparseIntArray sCombiningToAccent = new SparseIntArray(); + static final SparseIntArray sAccentToCombining = new SparseIntArray(); static { // U+0300: COMBINING GRAVE ACCENT addCombining('\u0300', ACCENT_GRAVE); @@ -217,21 +216,20 @@ public class DeadKeyCombiner implements Combiner { final StringBuilder mDeadSequence = new StringBuilder(); @Nonnull - private Event createEventChainFromSequence(final @Nonnull CharSequence text, + private static Event createEventChainFromSequence(final @Nonnull CharSequence text, final Event originalEvent) { if (text.length() <= 0) { return originalEvent; - } else { - Event lastEvent = null; - int codePoint = 0; - for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) { - codePoint = Character.codePointBefore(text, i); - final Event thisEvent = Event.createHardwareKeypressEvent(codePoint, - originalEvent.mKeyCode, lastEvent, false /* isKeyRepeat */); - lastEvent = thisEvent; - } - return lastEvent; } + Event lastEvent = null; + int codePoint = 0; + for (int i = text.length(); i > 0; i -= Character.charCount(codePoint)) { + codePoint = Character.codePointBefore(text, i); + final Event thisEvent = Event.createHardwareKeypressEvent(codePoint, + originalEvent.mKeyCode, lastEvent, false /* isKeyRepeat */); + lastEvent = thisEvent; + } + return lastEvent; } @Override @@ -248,51 +246,49 @@ public class DeadKeyCombiner implements Combiner { // no dead keys at all in the current input, so this combiner has nothing to do and // simply returns the event as is. The majority of events will go through this path. return event; - } else { - if (Character.isWhitespace(event.mCodePoint) - || event.mCodePoint == mDeadSequence.codePointBefore(mDeadSequence.length())) { - // When whitespace or twice the same dead key, we should output the dead sequence - // as is. - final Event resultEvent = createEventChainFromSequence(mDeadSequence.toString(), - event); - mDeadSequence.setLength(0); - return resultEvent; - } else if (event.isFunctionalKeyEvent()) { - if (Constants.CODE_DELETE == event.mKeyCode) { - // Remove the last code point - final int trimIndex = mDeadSequence.length() - Character.charCount( - mDeadSequence.codePointBefore(mDeadSequence.length())); - mDeadSequence.setLength(trimIndex); - return Event.createConsumedEvent(event); - } else { - return event; - } - } else if (event.isDead()) { - mDeadSequence.appendCodePoint(event.mCodePoint); + } + if (Character.isWhitespace(event.mCodePoint) + || event.mCodePoint == mDeadSequence.codePointBefore(mDeadSequence.length())) { + // When whitespace or twice the same dead key, we should output the dead sequence as is. + final Event resultEvent = createEventChainFromSequence(mDeadSequence.toString(), + event); + mDeadSequence.setLength(0); + return resultEvent; + } + if (event.isFunctionalKeyEvent()) { + if (Constants.CODE_DELETE == event.mKeyCode) { + // Remove the last code point + final int trimIndex = mDeadSequence.length() - Character.charCount( + mDeadSequence.codePointBefore(mDeadSequence.length())); + mDeadSequence.setLength(trimIndex); return Event.createConsumedEvent(event); + } + return event; + } + if (event.isDead()) { + mDeadSequence.appendCodePoint(event.mCodePoint); + return Event.createConsumedEvent(event); + } + // Combine normally. + final StringBuilder sb = new StringBuilder(); + sb.appendCodePoint(event.mCodePoint); + int codePointIndex = 0; + while (codePointIndex < mDeadSequence.length()) { + final int deadCodePoint = mDeadSequence.codePointAt(codePointIndex); + final char replacementSpacingChar = + Data.getNonstandardCombination(deadCodePoint, event.mCodePoint); + if (Data.NOT_A_CHAR != replacementSpacingChar) { + sb.setCharAt(0, replacementSpacingChar); } else { - // Combine normally. - final StringBuilder sb = new StringBuilder(); - sb.appendCodePoint(event.mCodePoint); - int codePointIndex = 0; - while (codePointIndex < mDeadSequence.length()) { - final int deadCodePoint = mDeadSequence.codePointAt(codePointIndex); - final char replacementSpacingChar = - Data.getNonstandardCombination(deadCodePoint, event.mCodePoint); - if (Data.NOT_A_CHAR != replacementSpacingChar) { - sb.setCharAt(0, replacementSpacingChar); - } else { - final int combining = Data.sAccentToCombining.get(deadCodePoint); - sb.appendCodePoint(0 == combining ? deadCodePoint : combining); - } - codePointIndex += Character.isSupplementaryCodePoint(deadCodePoint) ? 2 : 1; - } - final String normalizedString = Normalizer.normalize(sb, Normalizer.Form.NFC); - final Event resultEvent = createEventChainFromSequence(normalizedString, event); - mDeadSequence.setLength(0); - return resultEvent; + final int combining = Data.sAccentToCombining.get(deadCodePoint); + sb.appendCodePoint(0 == combining ? deadCodePoint : combining); } + codePointIndex += Character.isSupplementaryCodePoint(deadCodePoint) ? 2 : 1; } + final String normalizedString = Normalizer.normalize(sb, Normalizer.Form.NFC); + final Event resultEvent = createEventChainFromSequence(normalizedString, event); + mDeadSequence.setLength(0); + return resultEvent; } @Override |