Add private constructor to utility classes

Bug: 6129704
Change-Id: I52925ae7bd80683f63efc48649448865a5654f41
main
Tadashi G. Takaoka 2012-04-03 18:01:04 +09:00
parent d2c5533fd9
commit fde7efd877
4 changed files with 14 additions and 1 deletions

View File

@ -21,12 +21,16 @@ import android.view.inputmethod.EditorInfo;
import java.lang.reflect.Field;
public class EditorInfoCompatUtils {
// EditorInfo.IME_FLAG_FORCE_ASCII has been introduced since API#16 (JellyBean).
private static final Field FIELD_IME_FLAG_FORCE_ASCII = CompatUtils.getField(
EditorInfo.class, "IME_FLAG_FORCE_ASCII");
private static final Integer OBJ_IME_FLAG_FORCE_ASCII = (Integer) CompatUtils
.getFieldValue(null, null, FIELD_IME_FLAG_FORCE_ASCII);
// EditorInfo.IME_FLAG_FORCE_ASCII has been introduced since API#16 (JellyBean).
private EditorInfoCompatUtils() {
// This utility class is not publicly instantiable.
}
public static boolean hasFlagForceAscii(int imeOptions) {
if (OBJ_IME_FLAG_FORCE_ASCII == null)
return false;

View File

@ -40,6 +40,10 @@ public class InputMethodManagerCompatWrapper {
private InputMethodManager mImm;
private InputMethodManagerCompatWrapper() {
// This wrapper class is not publicly instantiable.
}
public static InputMethodManagerCompatWrapper getInstance() {
if (sInstance.mImm == null)
Log.w(TAG, "getInstance() is called before initialization");

View File

@ -77,6 +77,10 @@ public class SuggestionSpanUtils {
}
}
private SuggestionSpanUtils() {
// This utility class is not publicly instantiable.
}
public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(
Context context, CharSequence text) {
if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null

View File

@ -30,6 +30,7 @@ public class SuggestionsInfoCompatUtils {
? OBJ_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS : 0;
private SuggestionsInfoCompatUtils() {
// This utility class is not publicly instantiable.
}
/**