From 99e998286d71cf698d0a809a29b15d1a231ebbb1 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 22 Apr 2013 19:48:23 +0900 Subject: [ZF1] Check profanity in Java rather than in native Bug: 7226877 Change-Id: Ib6c32bfee9977c27dbf7e1e590b2b00d9ceb7301 --- .../com/android/inputmethod/latin/BinaryDictionary.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java') diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index dbc2b9082..03f7d1c10 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -147,10 +147,20 @@ public final class BinaryDictionary extends Dictionary { ++len; } if (len > 0) { - final int score = SuggestedWordInfo.KIND_WHITELIST == mOutputTypes[j] + final int flags = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_FLAGS; + if (0 != (flags & SuggestedWordInfo.KIND_FLAG_POSSIBLY_OFFENSIVE) + && 0 == (flags & SuggestedWordInfo.KIND_FLAG_EXACT_MATCH)) { + // If the word is possibly offensive, we don't output it unless it's also + // an exact match. + continue; + } + final int kind = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_KIND; + final int score = SuggestedWordInfo.KIND_WHITELIST == kind ? SuggestedWordInfo.MAX_SCORE : mOutputScores[j]; + // TODO: check that all users of the `kind' parameter are ready to accept + // flags too and pass mOutputTypes[j] instead of kind suggestions.add(new SuggestedWordInfo(new String(mOutputCodePoints, start, len), - score, mOutputTypes[j], mDictType)); + score, kind, mDictType)); } } return suggestions; -- cgit v1.2.3-83-g751a