aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java11
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java105
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java70
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java1
-rw-r--r--tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java40
6 files changed, 128 insertions, 101 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index dd2e3d392..a1b1f5dad 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -24,8 +24,6 @@ import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.latin.CollectionUtils;
import com.android.inputmethod.latin.Constants;
-
-
/**
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
* consists of rows of keys.
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 7e0ea1699..edcd888db 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -30,7 +30,6 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetExcep
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.KeyboardState;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
-import com.android.inputmethod.latin.DebugSettings;
import com.android.inputmethod.latin.ImfUtils;
import com.android.inputmethod.latin.InputView;
import com.android.inputmethod.latin.LatinIME;
@@ -69,7 +68,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private AudioAndHapticFeedbackManager mFeedbackManager;
private SubtypeSwitcher mSubtypeSwitcher;
private SharedPreferences mPrefs;
- private boolean mForceNonDistinctMultitouch;
private InputView mCurrentInputView;
private MainKeyboardView mKeyboardView;
@@ -109,8 +107,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mState = new KeyboardState(this);
setContextThemeWrapper(latinIme, getKeyboardTheme(latinIme, prefs));
- mForceNonDistinctMultitouch = prefs.getBoolean(
- DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
}
private static KeyboardTheme getKeyboardTheme(Context context, SharedPreferences prefs) {
@@ -341,10 +337,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
return mKeyboardView != null && mKeyboardView.getPointerCount() == 1;
}
- public boolean hasDistinctMultitouch() {
- return mKeyboardView != null && mKeyboardView.hasDistinctMultitouch();
- }
-
/**
* Updates state machine to figure out when to automatically switch back to the previous mode.
*/
@@ -371,9 +363,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
// TODO: Should use LAYER_TYPE_SOFTWARE when hardware acceleration is off?
}
mKeyboardView.setKeyboardActionListener(mLatinIME);
- if (mForceNonDistinctMultitouch) {
- mKeyboardView.setDistinctMultitouch(false);
- }
// This always needs to be set since the accessibility state can
// potentially change without the input view being re-created.
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 4efc526bf..de9b92f3b 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard;
import android.animation.AnimatorInflater;
import android.animation.ObjectAnimator;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -28,6 +29,7 @@ import android.graphics.Paint.Align;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Message;
+import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -47,6 +49,7 @@ import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
import com.android.inputmethod.keyboard.internal.SuddenJumpingTouchEventHandler;
import com.android.inputmethod.latin.Constants;
+import com.android.inputmethod.latin.DebugSettings;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
@@ -142,7 +145,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
protected KeyDetector mKeyDetector;
- private boolean mHasDistinctMultitouch;
+ private final boolean mHasDistinctMultitouch;
private int mOldPointerCount = 1;
private Key mOldKey;
@@ -204,7 +207,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private void startKeyRepeatTimer(final PointerTracker tracker, final long delay) {
final Key key = tracker.getKey();
- if (key == null) return;
+ if (key == null) {
+ return;
+ }
sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, key.mCode, 0, tracker), delay);
}
@@ -359,8 +364,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mTouchScreenRegulator = new SuddenJumpingTouchEventHandler(getContext(), this);
- mHasDistinctMultitouch = context.getPackageManager()
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ final boolean forceNonDistinctMultitouch = prefs.getBoolean(
+ DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
+ final boolean hasDistinctMultitouch = context.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
+ mHasDistinctMultitouch = hasDistinctMultitouch && !forceNonDistinctMultitouch;
final Resources res = getResources();
final boolean needsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
ResourceUtils.getDeviceOverrideValue(res,
@@ -409,7 +418,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
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(
getContext(), resId);
if (animator != null) {
@@ -510,18 +521,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
PointerTracker.setGestureHandlingEnabledByUser(gestureHandlingEnabledByUser);
}
- /**
- * Returns whether the device has distinct multi-touch panel.
- * @return true if the device has distinct multi-touch panel.
- */
- public boolean hasDistinctMultitouch() {
- return mHasDistinctMultitouch;
- }
-
- public void setDistinctMultitouch(final boolean hasDistinctMultitouch) {
- mHasDistinctMultitouch = hasDistinctMultitouch;
- }
-
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
@@ -557,21 +556,25 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
// Check if we are already displaying popup panel.
- if (mMoreKeysPanel != null)
+ if (mMoreKeysPanel != null) {
return false;
- if (parentKey == null)
+ }
+ if (parentKey == null) {
return false;
+ }
return onLongPress(parentKey, tracker);
}
// This default implementation returns a more keys panel.
protected MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
- if (parentKey.mMoreKeys == null)
+ if (parentKey.mMoreKeys == null) {
return null;
+ }
final View container = LayoutInflater.from(getContext()).inflate(mMoreKeysLayout, null);
- if (container == null)
+ if (container == null) {
throw new NullPointerException();
+ }
final MoreKeysKeyboardView moreKeysKeyboardView =
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
@@ -632,8 +635,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
if (moreKeysPanel == null) {
moreKeysPanel = onCreateMoreKeysPanel(parentKey);
- if (moreKeysPanel == null)
+ if (moreKeysPanel == null) {
return false;
+ }
mMoreKeysPanelCache.put(parentKey, moreKeysPanel);
}
if (mMoreKeysWindow == null) {
@@ -669,9 +673,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
public boolean isInSlidingKeyInput() {
if (mMoreKeysPanel != null) {
return true;
- } else {
- return PointerTracker.isAnyInSlidingKeyInput();
}
+ return PointerTracker.isAnyInSlidingKeyInput();
}
public int getPointerCount() {
@@ -844,14 +847,14 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override
public boolean dismissMoreKeysPanel() {
- if (mMoreKeysWindow != null && mMoreKeysWindow.isShowing()) {
- mMoreKeysWindow.dismiss();
- mMoreKeysPanel = null;
- mMoreKeysPanelPointerTrackerId = -1;
- dimEntireKeyboard(false);
- return true;
+ if (mMoreKeysWindow == null || !mMoreKeysWindow.isShowing()) {
+ return false;
}
- return false;
+ mMoreKeysWindow.dismiss();
+ mMoreKeysPanel = null;
+ mMoreKeysPanelPointerTrackerId = -1;
+ dimEntireKeyboard(false);
+ return true;
}
/**
@@ -874,16 +877,22 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
public void updateShortcutKey(final boolean available) {
final Keyboard keyboard = getKeyboard();
- if (keyboard == null) return;
+ if (keyboard == null) {
+ return;
+ }
final Key shortcutKey = keyboard.getKey(Constants.CODE_SHORTCUT);
- if (shortcutKey == null) return;
+ if (shortcutKey == null) {
+ return;
+ }
shortcutKey.setEnabled(available);
invalidateKey(shortcutKey);
}
private void updateAltCodeKeyWhileTyping() {
final Keyboard keyboard = getKeyboard();
- if (keyboard == null) return;
+ if (keyboard == null) {
+ return;
+ }
for (final Key key : keyboard.mAltCodeKeysWhileTyping) {
invalidateKey(key);
}
@@ -913,7 +922,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
public void updateAutoCorrectionState(final boolean isAutoCorrection) {
- if (!mAutoCorrectionSpacebarLedEnabled) return;
+ if (!mAutoCorrectionSpacebarLedEnabled) {
+ return;
+ }
mAutoCorrectionSpacebarLedOn = isAutoCorrection;
invalidateKey(mSpaceKey);
}
@@ -941,10 +952,14 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) {
paint.setTextScaleX(1.0f);
final float textWidth = getLabelWidth(text, paint);
- if (textWidth < width) return true;
+ if (textWidth < width) {
+ return true;
+ }
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);
return getLabelWidth(text, paint) < width;
@@ -954,19 +969,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype,
final int width) {
// Choose appropriate language name to fit into the width.
- String text = getFullDisplayName(subtype, getResources());
- if (fitsTextIntoWidth(width, text, paint)) {
- return text;
+ final String fullText = getFullDisplayName(subtype, getResources());
+ if (fitsTextIntoWidth(width, fullText, paint)) {
+ return fullText;
}
- text = getMiddleDisplayName(subtype);
- if (fitsTextIntoWidth(width, text, paint)) {
- return text;
+ final String middleText = getMiddleDisplayName(subtype);
+ if (fitsTextIntoWidth(width, middleText, paint)) {
+ return middleText;
}
- text = getShortDisplayName(subtype);
- if (fitsTextIntoWidth(width, text, paint)) {
- return text;
+ final String shortText = getShortDisplayName(subtype);
+ if (fitsTextIntoWidth(width, shortText, paint)) {
+ return shortText;
}
return "";
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 40457005b..77e781256 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -686,6 +686,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
return (sPointerTrackerQueue == null) ? 1 : sPointerTrackerQueue.size();
}
+ private static boolean isOldestTrackerInQueue(final PointerTracker tracker) {
+ return sPointerTrackerQueue == null
+ || sPointerTrackerQueue.getOldestElement() == tracker;
+ }
+
private void mayStartBatchInput(final Key key) {
if (sInGesture || !mGestureStrokeWithPreviewPoints.isStartOfAGesture()) {
return;
@@ -704,8 +709,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mListener.onStartBatchInput();
}
mTimerProxy.cancelLongPressTimer();
- final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this;
- mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker);
+ mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
}
private void mayUpdateBatchInput(final long eventTime, final Key key) {
@@ -726,8 +730,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
}
}
}
- final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this;
- mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker);
+ mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
}
private void mayEndBatchInput(final long eventTime) {
@@ -743,8 +746,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mListener.onEndBatchInput(sAggregratedPointers);
}
}
- final boolean isOldestTracker = sPointerTrackerQueue.getOldestElement() == this;
- mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker);
+ mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
}
public void processMotionEvent(final int action, final int x, final int y, final long eventTime,
@@ -1165,38 +1167,38 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
final Key curKey = mCurrentKey;
if (newKey == curKey) {
return false;
- } else if (curKey != null) {
- final int keyHysteresisDistanceSquared = mKeyDetector.getKeyHysteresisDistanceSquared(
- mIsInSlidingKeyInputFromModifier);
- final int distanceFromKeyEdgeSquared = curKey.squaredDistanceToEdge(x, y);
- if (distanceFromKeyEdgeSquared >= keyHysteresisDistanceSquared) {
- if (DEBUG_MODE) {
- final float distanceToEdgeRatio = (float)Math.sqrt(distanceFromKeyEdgeSquared)
- / mKeyboard.mMostCommonKeyWidth;
- Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
- +" %.2f key width from key edge",
- mPointerId, distanceToEdgeRatio));
- }
- return true;
+ }
+ if (curKey == null /* && newKey != null */) {
+ return true;
+ }
+ // Here curKey points to the different key from newKey.
+ final int keyHysteresisDistanceSquared = mKeyDetector.getKeyHysteresisDistanceSquared(
+ mIsInSlidingKeyInputFromModifier);
+ final int distanceFromKeyEdgeSquared = curKey.squaredDistanceToEdge(x, y);
+ if (distanceFromKeyEdgeSquared >= keyHysteresisDistanceSquared) {
+ if (DEBUG_MODE) {
+ final float distanceToEdgeRatio = (float)Math.sqrt(distanceFromKeyEdgeSquared)
+ / mKeyboard.mMostCommonKeyWidth;
+ Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
+ +" %.2f key width from key edge", mPointerId, distanceToEdgeRatio));
}
- if (sNeedsProximateBogusDownMoveUpEventHack && !mIsAllowedSlidingKeyInput
- && sTimeRecorder.isInFastTyping(eventTime)
- && mBogusMoveEventDetector.hasTraveledLongDistance(x, y)) {
- if (DEBUG_MODE) {
- final float keyDiagonal = (float)Math.hypot(
- mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
- final float lengthFromDownRatio =
- mBogusMoveEventDetector.mAccumulatedDistanceFromDownKey / keyDiagonal;
- Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
- + " %.2f key diagonal from virtual down point",
- mPointerId, lengthFromDownRatio));
- }
- return true;
+ return true;
+ }
+ if (sNeedsProximateBogusDownMoveUpEventHack && !mIsAllowedSlidingKeyInput
+ && sTimeRecorder.isInFastTyping(eventTime)
+ && mBogusMoveEventDetector.hasTraveledLongDistance(x, y)) {
+ if (DEBUG_MODE) {
+ final float keyDiagonal = (float)Math.hypot(
+ mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
+ final float lengthFromDownRatio =
+ mBogusMoveEventDetector.mAccumulatedDistanceFromDownKey / keyDiagonal;
+ Log.d(TAG, String.format("[%d] isMajorEnoughMoveToBeOnNewKey:"
+ + " %.2f key diagonal from virtual down point",
+ mPointerId, lengthFromDownRatio));
}
- return false;
- } else { // curKey == null && newKey != null
return true;
}
+ return false;
}
private void startLongPressTimer(final Key key) {
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
index 152fd569d..ba932e590 100644
--- a/java/src/com/android/inputmethod/latin/Constants.java
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -16,7 +16,6 @@
package com.android.inputmethod.latin;
-
public final class Constants {
public static final class Color {
/**
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
index 855c026b9..dcbfb39b7 100644
--- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
+++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
@@ -76,23 +76,26 @@ public class Diff extends Dicttool.Command {
private static boolean languageDiffers(final FusionDictionary dict0,
final FusionDictionary dict1) {
// If either of the dictionaries have no locale, assume it's okay
- if (null == dict0.mOptions.mAttributes.get("locale")) return true;
- if (null == dict1.mOptions.mAttributes.get("locale")) return true;
+ if (null == dict0.mOptions.mAttributes.get("locale")) return false;
+ if (null == dict1.mOptions.mAttributes.get("locale")) return false;
final String dict0Lang = dict0.mOptions.mAttributes.get("locale").split("_", 3)[0];
final String dict1Lang = dict1.mOptions.mAttributes.get("locale").split("_", 3)[0];
return !dict0Lang.equals(dict1Lang);
}
private static void diffHeaders(final FusionDictionary dict0, final FusionDictionary dict1) {
+ boolean hasDifferences = false;
if (dict0.mOptions.mFrenchLigatureProcessing != dict1.mOptions.mFrenchLigatureProcessing) {
System.out.println(" French ligature processing : "
+ dict0.mOptions.mFrenchLigatureProcessing + " <=> "
+ dict1.mOptions.mFrenchLigatureProcessing);
+ hasDifferences = true;
}
else if (dict0.mOptions.mGermanUmlautProcessing != dict1.mOptions.mGermanUmlautProcessing) {
System.out.println(" German umlaut processing : "
+ dict0.mOptions.mGermanUmlautProcessing + " <=> "
+ dict1.mOptions.mGermanUmlautProcessing);
+ hasDifferences = true;
}
final HashMap<String, String> options1 =
new HashMap<String, String>(dict1.mOptions.mAttributes);
@@ -102,53 +105,72 @@ public class Diff extends Dicttool.Command {
System.out.println(" " + optionKey + " : "
+ dict0.mOptions.mAttributes.get(optionKey) + " <=> "
+ dict1.mOptions.mAttributes.get(optionKey));
+ hasDifferences = true;
}
options1.remove(optionKey);
}
for (final String optionKey : options1.keySet()) {
System.out.println(" " + optionKey + " : null <=> " + options1.get(optionKey));
+ hasDifferences = true;
+ }
+ if (!hasDifferences) {
+ System.out.println(" No differences");
}
}
private static void diffWords(final FusionDictionary dict0, final FusionDictionary dict1) {
+ boolean hasDifferences = false;
for (final Word word0 : dict0) {
final CharGroup word1 = FusionDictionary.findWordInTree(dict1.mRoot, word0.mWord);
if (null == word1) {
// This word is not in dict1
System.out.println("Deleted: " + word0.mWord + " " + word0.mFrequency);
+ hasDifferences = true;
} else {
// We found the word. Compare frequencies, shortcuts, bigrams
if (word0.mFrequency != word1.getFrequency()) {
System.out.println("Freq changed: " + word0.mWord + " " + word0.mFrequency
+ " -> " + word1.getFrequency());
+ hasDifferences = true;
}
if (word0.mIsNotAWord != word1.getIsNotAWord()) {
System.out.println("Not a word: " + word0.mWord + " " + word0.mIsNotAWord
+ " -> " + word1.getIsNotAWord());
+ hasDifferences = true;
}
if (word0.mIsBlacklistEntry != word1.getIsBlacklistEntry()) {
System.out.println("Blacklist: " + word0.mWord + " " + word0.mIsBlacklistEntry
+ " -> " + word1.getIsBlacklistEntry());
+ hasDifferences = true;
}
- diffAttributes(word0.mWord, word0.mBigrams, word1.getBigrams());
- diffAttributes(word0.mWord, word0.mShortcutTargets, word1.getShortcutTargets());
+ hasDifferences |= hasAttributesDifferencesAndPrintThemIfAny(word0.mWord,
+ word0.mBigrams, word1.getBigrams());
+ hasDifferences |= hasAttributesDifferencesAndPrintThemIfAny(word0.mWord,
+ word0.mShortcutTargets, word1.getShortcutTargets());
}
}
+ if (!hasDifferences) {
+ System.out.println(" No differences");
+ }
}
- private static void diffAttributes(final String word, final ArrayList<WeightedString> list0,
- final ArrayList<WeightedString> list1) {
+ private static boolean hasAttributesDifferencesAndPrintThemIfAny(final String word,
+ final ArrayList<WeightedString> list0, final ArrayList<WeightedString> list1) {
if (null == list1) {
- if (null == list0) return;
+ if (null == list0) return false;
for (final WeightedString attribute0 : list0) {
System.out.println("Bigram removed: " + word + " " + attribute0.mWord + " "
+ attribute0.mFrequency);
}
- } else if (null != list0) {
+ return true;
+ }
+ boolean hasDifferences = false;
+ if (null != list0) {
for (final WeightedString attribute0 : list0) {
// The following tests with #equals(). The WeightedString#equals() method returns
// true if both the string and the frequency are the same.
if (!list1.contains(attribute0)) {
+ hasDifferences = true;
// Search for a word with the same string but a different frequency
for (final WeightedString attribute1 : list1) {
if (attribute0.mWord.equals(attribute1.mWord)) {
@@ -169,8 +191,10 @@ public class Diff extends Dicttool.Command {
// We removed any matching word that we found, so now list1 only contains words that
// are not included in list0.
for (final WeightedString attribute1 : list1) {
+ hasDifferences = true;
System.out.println("Bigram added: " + word + " " + attribute1.mWord + " "
+ attribute1.mFrequency);
}
+ return hasDifferences;
}
}