Cosmetic source code formating change
Change-Id: I3a53b49afab70dfb13f12027070635da6001eb79main
parent
01f6a61e51
commit
20dd1bc090
|
@ -24,8 +24,6 @@ import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
|
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
|
||||||
* consists of rows of keys.
|
* consists of rows of keys.
|
||||||
|
|
|
@ -204,7 +204,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
private void startKeyRepeatTimer(final PointerTracker tracker, final long delay) {
|
private void startKeyRepeatTimer(final PointerTracker tracker, final long delay) {
|
||||||
final Key key = tracker.getKey();
|
final Key key = tracker.getKey();
|
||||||
if (key == null) return;
|
if (key == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, key.mCode, 0, tracker), delay);
|
sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, key.mCode, 0, tracker), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +411,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
|
|
||||||
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
|
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
|
||||||
if (resId == 0) return null;
|
if (resId == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
|
final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
|
||||||
getContext(), resId);
|
getContext(), resId);
|
||||||
if (animator != null) {
|
if (animator != null) {
|
||||||
|
@ -557,21 +561,25 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we are already displaying popup panel.
|
// Check if we are already displaying popup panel.
|
||||||
if (mMoreKeysPanel != null)
|
if (mMoreKeysPanel != null) {
|
||||||
return false;
|
return false;
|
||||||
if (parentKey == null)
|
}
|
||||||
|
if (parentKey == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return onLongPress(parentKey, tracker);
|
return onLongPress(parentKey, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This default implementation returns a more keys panel.
|
// This default implementation returns a more keys panel.
|
||||||
protected MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
|
protected MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
|
||||||
if (parentKey.mMoreKeys == null)
|
if (parentKey.mMoreKeys == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final View container = LayoutInflater.from(getContext()).inflate(mMoreKeysLayout, null);
|
final View container = LayoutInflater.from(getContext()).inflate(mMoreKeysLayout, null);
|
||||||
if (container == null)
|
if (container == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
final MoreKeysKeyboardView moreKeysKeyboardView =
|
final MoreKeysKeyboardView moreKeysKeyboardView =
|
||||||
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
|
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
|
||||||
|
@ -632,8 +640,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
|
MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
|
||||||
if (moreKeysPanel == null) {
|
if (moreKeysPanel == null) {
|
||||||
moreKeysPanel = onCreateMoreKeysPanel(parentKey);
|
moreKeysPanel = onCreateMoreKeysPanel(parentKey);
|
||||||
if (moreKeysPanel == null)
|
if (moreKeysPanel == null) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
mMoreKeysPanelCache.put(parentKey, moreKeysPanel);
|
mMoreKeysPanelCache.put(parentKey, moreKeysPanel);
|
||||||
}
|
}
|
||||||
if (mMoreKeysWindow == null) {
|
if (mMoreKeysWindow == null) {
|
||||||
|
@ -669,9 +678,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
public boolean isInSlidingKeyInput() {
|
public boolean isInSlidingKeyInput() {
|
||||||
if (mMoreKeysPanel != null) {
|
if (mMoreKeysPanel != null) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return PointerTracker.isAnyInSlidingKeyInput();
|
|
||||||
}
|
}
|
||||||
|
return PointerTracker.isAnyInSlidingKeyInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPointerCount() {
|
public int getPointerCount() {
|
||||||
|
@ -844,14 +852,14 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dismissMoreKeysPanel() {
|
public boolean dismissMoreKeysPanel() {
|
||||||
if (mMoreKeysWindow != null && mMoreKeysWindow.isShowing()) {
|
if (mMoreKeysWindow == null || !mMoreKeysWindow.isShowing()) {
|
||||||
mMoreKeysWindow.dismiss();
|
return false;
|
||||||
mMoreKeysPanel = null;
|
|
||||||
mMoreKeysPanelPointerTrackerId = -1;
|
|
||||||
dimEntireKeyboard(false);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
mMoreKeysWindow.dismiss();
|
||||||
|
mMoreKeysPanel = null;
|
||||||
|
mMoreKeysPanelPointerTrackerId = -1;
|
||||||
|
dimEntireKeyboard(false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -874,16 +882,22 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
public void updateShortcutKey(final boolean available) {
|
public void updateShortcutKey(final boolean available) {
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (keyboard == null) return;
|
if (keyboard == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Key shortcutKey = keyboard.getKey(Constants.CODE_SHORTCUT);
|
final Key shortcutKey = keyboard.getKey(Constants.CODE_SHORTCUT);
|
||||||
if (shortcutKey == null) return;
|
if (shortcutKey == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
shortcutKey.setEnabled(available);
|
shortcutKey.setEnabled(available);
|
||||||
invalidateKey(shortcutKey);
|
invalidateKey(shortcutKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAltCodeKeyWhileTyping() {
|
private void updateAltCodeKeyWhileTyping() {
|
||||||
final Keyboard keyboard = getKeyboard();
|
final Keyboard keyboard = getKeyboard();
|
||||||
if (keyboard == null) return;
|
if (keyboard == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (final Key key : keyboard.mAltCodeKeysWhileTyping) {
|
for (final Key key : keyboard.mAltCodeKeysWhileTyping) {
|
||||||
invalidateKey(key);
|
invalidateKey(key);
|
||||||
}
|
}
|
||||||
|
@ -913,7 +927,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAutoCorrectionState(final boolean isAutoCorrection) {
|
public void updateAutoCorrectionState(final boolean isAutoCorrection) {
|
||||||
if (!mAutoCorrectionSpacebarLedEnabled) return;
|
if (!mAutoCorrectionSpacebarLedEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mAutoCorrectionSpacebarLedOn = isAutoCorrection;
|
mAutoCorrectionSpacebarLedOn = isAutoCorrection;
|
||||||
invalidateKey(mSpaceKey);
|
invalidateKey(mSpaceKey);
|
||||||
}
|
}
|
||||||
|
@ -941,10 +957,14 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) {
|
private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) {
|
||||||
paint.setTextScaleX(1.0f);
|
paint.setTextScaleX(1.0f);
|
||||||
final float textWidth = getLabelWidth(text, paint);
|
final float textWidth = getLabelWidth(text, paint);
|
||||||
if (textWidth < width) return true;
|
if (textWidth < width) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final float scaleX = width / textWidth;
|
final float scaleX = width / textWidth;
|
||||||
if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) return false;
|
if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
paint.setTextScaleX(scaleX);
|
paint.setTextScaleX(scaleX);
|
||||||
return getLabelWidth(text, paint) < width;
|
return getLabelWidth(text, paint) < width;
|
||||||
|
@ -954,19 +974,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype,
|
private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype,
|
||||||
final int width) {
|
final int width) {
|
||||||
// Choose appropriate language name to fit into the width.
|
// Choose appropriate language name to fit into the width.
|
||||||
String text = getFullDisplayName(subtype, getResources());
|
final String fullText = getFullDisplayName(subtype, getResources());
|
||||||
if (fitsTextIntoWidth(width, text, paint)) {
|
if (fitsTextIntoWidth(width, fullText, paint)) {
|
||||||
return text;
|
return fullText;
|
||||||
}
|
}
|
||||||
|
|
||||||
text = getMiddleDisplayName(subtype);
|
final String middleText = getMiddleDisplayName(subtype);
|
||||||
if (fitsTextIntoWidth(width, text, paint)) {
|
if (fitsTextIntoWidth(width, middleText, paint)) {
|
||||||
return text;
|
return middleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
text = getShortDisplayName(subtype);
|
final String shortText = getShortDisplayName(subtype);
|
||||||
if (fitsTextIntoWidth(width, text, paint)) {
|
if (fitsTextIntoWidth(width, shortText, paint)) {
|
||||||
return text;
|
return shortText;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
|
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
public static final class Color {
|
public static final class Color {
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue