add pref for hiding language key

This commit is contained in:
dslul 2020-01-26 23:19:47 +01:00
parent 067a8bf190
commit 6c6c24ca84
56 changed files with 196 additions and 312 deletions

View file

@ -48,7 +48,7 @@
android:allowBackup="true"
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true"
android:extractNativeLibs="false">
android:extractNativeLibs="false">
<!-- Services -->
<service android:name="LatinIME"

View file

@ -178,7 +178,7 @@ class AccessibilityUtils private constructor() {
private val TAG = AccessibilityUtils::class.java.simpleName
private val CLASS = AccessibilityUtils::class.java.name
private val PACKAGE = AccessibilityUtils::class.java.getPackage()!!.name
public val instance = AccessibilityUtils()
val instance = AccessibilityUtils()
/*
* Setting this constant to {@code false} will disable all keyboard
* accessibility code, regardless of whether Accessibility is turned on in

View file

@ -145,7 +145,7 @@ open class KeyboardAccessibilityDelegate<KV : KeyboardView?>(protected val mKeyb
if (DEBUG_HOVER) {
Log.d(TAG, "onHoverEnter: key=$key")
}
key?.let { onHoverEnterTo(it) }
key.let { onHoverEnterTo(it) }
mLastHoverKey = key
}
@ -159,9 +159,9 @@ open class KeyboardAccessibilityDelegate<KV : KeyboardView?>(protected val mKeyb
val key = getHoverKeyOf(event)
if (key !== lastKey) {
lastKey?.let { onHoverExitFrom(it) }
key?.let { onHoverEnterTo(it) }
key.let { onHoverEnterTo(it) }
}
key?.let { onHoverMoveWithin(it) }
key.let { onHoverMoveWithin(it) }
mLastHoverKey = key
}

View file

@ -244,7 +244,7 @@ class MainKeyboardAccessibilityDelegate(mainKeyboardView: MainKeyboardView,
val codePointOfNoPanelAutoMoreKey = key.moreKeys!![0].mCode
val text: String = KeyCodeDescriptionMapper.instance.getDescriptionForCodePoint(
mKeyboardView!!.context, codePointOfNoPanelAutoMoreKey)!!
text?.let { sendWindowStateChanged(it) }
text.let { sendWindowStateChanged(it) }
}
}

View file

@ -12,33 +12,13 @@ import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
import java.util.*
object InputMethodSubtypeCompatUtils {
private val TAG = InputMethodSubtypeCompatUtils::class.java.simpleName
// Note that InputMethodSubtype(int nameId, int iconId, String locale, String mode,
// String extraValue, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype, int id)
// has been introduced in API level 17 (Build.VERSION_CODE.JELLY_BEAN_MR1).
private val CONSTRUCTOR_INPUT_METHOD_SUBTYPE = CompatUtils.getConstructor(InputMethodSubtype::class.java,
Int::class.javaPrimitiveType, Int::class.javaPrimitiveType, String::class.java, String::class.java, String::class.java, Boolean::class.javaPrimitiveType,
Boolean::class.javaPrimitiveType, Int::class.javaPrimitiveType)
@kotlin.jvm.JvmStatic
fun newInputMethodSubtype(nameId: Int, iconId: Int, locale: String?,
mode: String?, extraValue: String?, isAuxiliary: Boolean,
overridesImplicitlyEnabledSubtype: Boolean, id: Int): InputMethodSubtype? {
return if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null) {
InputMethodSubtype(nameId, iconId, locale, mode, extraValue, isAuxiliary,
overridesImplicitlyEnabledSubtype)
} else CompatUtils.newInstance(CONSTRUCTOR_INPUT_METHOD_SUBTYPE,
nameId, iconId, locale, mode, extraValue, isAuxiliary,
overridesImplicitlyEnabledSubtype, id) as InputMethodSubtype
}
// Note that InputMethodSubtype.getLanguageTag() is expected to be available in Android N+.
private val GET_LANGUAGE_TAG = CompatUtils.getMethod(InputMethodSubtype::class.java, "getLanguageTag")
@kotlin.jvm.JvmStatic
fun getLocaleObject(subtype: InputMethodSubtype): Locale { // Locale.forLanguageTag() is available only in Android L and later.
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
val languageTag = CompatUtils.invoke(subtype, null, GET_LANGUAGE_TAG) as String
val languageTag = CompatUtils.invoke(subtype, null, GET_LANGUAGE_TAG) as String?
if (!TextUtils.isEmpty(languageTag)) {
return Locale.forLanguageTag(languageTag)
}
@ -46,9 +26,4 @@ object InputMethodSubtypeCompatUtils {
return LocaleUtils.constructLocaleFromString(subtype.locale)
}
init {
if (CONSTRUCTOR_INPUT_METHOD_SUBTYPE == null) {
Log.w(TAG, "Warning!!! Constructor is not defined.")
}
}
}

View file

@ -35,53 +35,6 @@ object SuggestionSpanUtils {
return spannable
}
@UsedForTesting
fun getTextWithSuggestionSpan(context: Context?,
pickedWord: String, suggestedWords: SuggestedWords, locale: Locale?): CharSequence {
if (TextUtils.isEmpty(pickedWord) || suggestedWords.isEmpty
|| suggestedWords.isPrediction || suggestedWords.isPunctuationSuggestions) {
return pickedWord
}
val suggestionsList = ArrayList<String>()
for (i in 0 until suggestedWords.size()) {
if (suggestionsList.size >= SuggestionSpan.SUGGESTIONS_MAX_SIZE) {
break
}
val info = suggestedWords.getInfo(i)
if (info.isKindOf(SuggestedWordInfo.KIND_PREDICTION)) {
continue
}
val word = suggestedWords.getWord(i)
if (!TextUtils.equals(pickedWord, word)) {
suggestionsList.add(word.toString())
}
}
val suggestionSpan = SuggestionSpan(context, locale,
suggestionsList.toTypedArray(), 0 /* flags */, null)
val spannable: Spannable = SpannableString(pickedWord)
spannable.setSpan(suggestionSpan, 0, pickedWord.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
return spannable
}
/**
* Returns first [Locale] found in the given array of [SuggestionSpan].
* @param suggestionSpans the array of [SuggestionSpan] to be examined.
* @return the first [Locale] found in `suggestionSpans`. `null` when not
* found.
*/
@UsedForTesting
fun findFirstLocaleFromSuggestionSpans(
suggestionSpans: Array<SuggestionSpan>): Locale? {
for (suggestionSpan in suggestionSpans) {
val localeString = suggestionSpan.locale
if (TextUtils.isEmpty(localeString)) {
continue
}
return LocaleUtils.constructLocaleFromString(localeString)
}
return null
}
init {
if (DebugFlags.DEBUG_ENABLED) {
if (OBJ_FLAG_AUTO_CORRECTION == null) {

View file

@ -34,7 +34,6 @@ object UserManagerCompatUtils {
val userManager = context.getSystemService(UserManager::class.java)
?: return LOCK_STATE_UNKNOWN
val result = CompatUtils.invoke(userManager, null, METHOD_isUserUnlocked) as Boolean
?: return LOCK_STATE_UNKNOWN
return if (result) LOCK_STATE_UNLOCKED else LOCK_STATE_LOCKED
}

View file

@ -29,7 +29,7 @@ public interface KeyboardActionListener {
* @param repeatCount how many times the key was repeated. Zero if it is the first press.
* @param isSinglePointer true if pressing has occurred while no other key is being pressed.
*/
public void onPressKey(int primaryCode, int repeatCount, boolean isSinglePointer);
void onPressKey(int primaryCode, int repeatCount, boolean isSinglePointer);
/**
* Called when the user releases a key. This is sent after the {@link #onCodeInput} is called.
@ -39,7 +39,7 @@ public interface KeyboardActionListener {
* @param withSliding true if releasing has occurred because the user slid finger from the key
* to other key without releasing the finger.
*/
public void onReleaseKey(int primaryCode, boolean withSliding);
void onReleaseKey(int primaryCode, boolean withSliding);
/**
* Send a key code to the listener.
@ -56,57 +56,57 @@ public interface KeyboardActionListener {
* @param isKeyRepeat true if this is a key repeat, false otherwise
*/
// TODO: change this to send an Event object instead
public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
/**
* Sends a string of characters to the listener.
*
* @param text the string of characters to be registered.
*/
public void onTextInput(String text);
void onTextInput(String text);
/**
* Called when user started batch input.
*/
public void onStartBatchInput();
void onStartBatchInput();
/**
* Sends the ongoing batch input points data.
* @param batchPointers the batch input points representing the user input
*/
public void onUpdateBatchInput(InputPointers batchPointers);
void onUpdateBatchInput(InputPointers batchPointers);
/**
* Sends the final batch input points data.
*
* @param batchPointers the batch input points representing the user input
*/
public void onEndBatchInput(InputPointers batchPointers);
void onEndBatchInput(InputPointers batchPointers);
public void onCancelBatchInput();
void onCancelBatchInput();
/**
* Called when user released a finger outside any key.
*/
public void onCancelInput();
void onCancelInput();
/**
* Called when user finished sliding key input.
*/
public void onFinishSlidingInput();
void onFinishSlidingInput();
/**
* Send a non-"code input" custom request to the listener.
* @return true if the request has been consumed, false otherwise.
*/
public boolean onCustomRequest(int requestCode);
public void onMovePointer(int steps);
public void onMoveDeletePointer(int steps);
public void onUpWithDeletePointerActive();
boolean onCustomRequest(int requestCode);
void onMovePointer(int steps);
void onMoveDeletePointer(int steps);
void onUpWithDeletePointerActive();
public static final KeyboardActionListener EMPTY_LISTENER = new Adapter();
KeyboardActionListener EMPTY_LISTENER = new Adapter();
public static class Adapter implements KeyboardActionListener {
class Adapter implements KeyboardActionListener {
@Override
public void onPressKey(int primaryCode, int repeatCount, boolean isSinglePointer) {}
@Override

View file

@ -462,10 +462,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(
R.layout.input_view, null);
mMainKeyboardFrame = mCurrentInputView.findViewById(R.id.main_keyboard_frame);
mEmojiPalettesView = (EmojiPalettesView)mCurrentInputView.findViewById(
mEmojiPalettesView = mCurrentInputView.findViewById(
R.id.emoji_palettes_view);
mKeyboardView = (MainKeyboardView) mCurrentInputView.findViewById(R.id.keyboard_view);
mKeyboardView = mCurrentInputView.findViewById(R.id.keyboard_view);
mKeyboardView.setHardwareAcceleratedDrawingEnabled(isHardwareAcceleratedDrawingEnabled);
mKeyboardView.setKeyboardActionListener(mLatinIME);
mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled(

View file

@ -450,7 +450,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
Log.w(TAG, "Cannot find root view");
return;
}
final ViewGroup windowContentView = (ViewGroup)rootView.findViewById(android.R.id.content);
final ViewGroup windowContentView = rootView.findViewById(android.R.id.content);
// Note: It'd be very weird if we get null by android.R.id.content.
if (windowContentView == null) {
Log.w(TAG, "Cannot find android.R.id.content view to add DrawingPreviewPlacerView");
@ -618,7 +618,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
final View container = key.isActionKey() ? mMoreKeysKeyboardForActionContainer
: mMoreKeysKeyboardContainer;
final MoreKeysKeyboardView moreKeysKeyboardView =
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
container.findViewById(R.id.more_keys_keyboard_view);
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

View file

@ -20,25 +20,25 @@ import android.view.View;
import android.view.ViewGroup;
public interface MoreKeysPanel {
public interface Controller {
interface Controller {
/**
* Add the {@link MoreKeysPanel} to the target view.
* @param panel the panel to be shown.
*/
public void onShowMoreKeysPanel(final MoreKeysPanel panel);
void onShowMoreKeysPanel(final MoreKeysPanel panel);
/**
* Remove the current {@link MoreKeysPanel} from the target view.
*/
public void onDismissMoreKeysPanel();
void onDismissMoreKeysPanel();
/**
* Instructs the parent to cancel the panel (e.g., when entering a different input mode).
*/
public void onCancelMoreKeysPanel();
void onCancelMoreKeysPanel();
}
public static final Controller EMPTY_CONTROLLER = new Controller() {
Controller EMPTY_CONTROLLER = new Controller() {
@Override
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {}
@Override
@ -60,14 +60,14 @@ public interface MoreKeysPanel {
*/
// TODO: Currently the MoreKeysPanel is inside a container view that is added to the parent.
// Consider the simpler approach of placing the MoreKeysPanel itself into the parent view.
public void showMoreKeysPanel(View parentView, Controller controller, int pointX,
int pointY, KeyboardActionListener listener);
void showMoreKeysPanel(View parentView, Controller controller, int pointX,
int pointY, KeyboardActionListener listener);
/**
* Dismisses the more keys panel and calls the controller's onDismissMoreKeysPanel to remove
* the panel's container view.
*/
public void dismissMoreKeysPanel();
void dismissMoreKeysPanel();
/**
* Process a move event on the more keys panel.
@ -77,7 +77,7 @@ public interface MoreKeysPanel {
* @param pointerId pointer id touch point
* @param eventTime timestamp of touch point
*/
public void onMoveEvent(final int x, final int y, final int pointerId, final long eventTime);
void onMoveEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Process a down event on the more keys panel.
@ -87,7 +87,7 @@ public interface MoreKeysPanel {
* @param pointerId pointer id touch point
* @param eventTime timestamp of touch point
*/
public void onDownEvent(final int x, final int y, final int pointerId, final long eventTime);
void onDownEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Process an up event on the more keys panel.
@ -97,7 +97,7 @@ public interface MoreKeysPanel {
* @param pointerId pointer id touch point
* @param eventTime timestamp of touch point
*/
public void onUpEvent(final int x, final int y, final int pointerId, final long eventTime);
void onUpEvent(final int x, final int y, final int pointerId, final long eventTime);
/**
* Translate X-coordinate of touch event to the local X-coordinate of this
@ -106,7 +106,7 @@ public interface MoreKeysPanel {
* @param x the global X-coordinate
* @return the local X-coordinate to this {@link MoreKeysPanel}
*/
public int translateX(int x);
int translateX(int x);
/**
* Translate Y-coordinate of touch event to the local Y-coordinate of this
@ -115,22 +115,22 @@ public interface MoreKeysPanel {
* @param y the global Y-coordinate
* @return the local Y-coordinate to this {@link MoreKeysPanel}
*/
public int translateY(int y);
int translateY(int y);
/**
* Show this {@link MoreKeysPanel} in the parent view.
*
* @param parentView the {@link ViewGroup} that hosts this {@link MoreKeysPanel}.
*/
public void showInParent(ViewGroup parentView);
void showInParent(ViewGroup parentView);
/**
* Remove this {@link MoreKeysPanel} from the parent view.
*/
public void removeFromParent();
void removeFromParent();
/**
* Return whether the panel is currently being shown.
*/
public boolean isShowingInParent();
boolean isShowingInParent();
}

View file

@ -42,8 +42,8 @@ final class EmojiPageKeyboardView extends KeyboardView implements
private static final long KEY_RELEASE_DELAY_TIME = 30; // msec
public interface OnKeyEventListener {
public void onPressKey(Key key);
public void onReleaseKey(Key key);
void onPressKey(Key key);
void onReleaseKey(Key key);
}
private static final OnKeyEventListener EMPTY_LISTENER = new OnKeyEventListener() {

View file

@ -163,7 +163,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
@Override
protected void onFinishInflate() {
mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost);
mTabHost = findViewById(R.id.emoji_category_tabhost);
mTabHost.setup();
for (final EmojiCategory.CategoryProperties properties
: mEmojiCategory.getShownCategories()) {
@ -182,7 +182,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this);
mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager);
mEmojiPager = findViewById(R.id.emoji_keyboard_pager);
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
mEmojiPager.setOnPageChangeListener(this);
mEmojiPager.setOffscreenPageLimit(0);
@ -190,18 +190,18 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
mEmojiLayoutParams.setPagerProperties(mEmojiPager);
mEmojiCategoryPageIndicatorView =
(EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view);
findViewById(R.id.emoji_category_page_id_view);
mEmojiCategoryPageIndicatorView.setColors(
mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground);
mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);
final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar);
final LinearLayout actionBar = findViewById(R.id.emoji_action_bar);
mEmojiLayoutParams.setActionBarProperties(actionBar);
// deleteKey depends only on OnTouchListener.
mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete);
mDeleteKey = findViewById(R.id.emoji_keyboard_delete);
mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
mDeleteKey.setTag(Constants.CODE_DELETE);
mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
@ -213,12 +213,12 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
// if the event is canceled by moving off the finger from the view.
// The text on alphabet keys are set at
// {@link #startEmojiPalettes(String,int,float,Typeface)}.
mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left);
mAlphabetKeyLeft = findViewById(R.id.emoji_keyboard_alphabet_left);
mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyLeft.setOnTouchListener(this);
mAlphabetKeyLeft.setOnClickListener(this);
mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right);
mAlphabetKeyRight = findViewById(R.id.emoji_keyboard_alphabet_right);
mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyRight.setOnTouchListener(this);

View file

@ -27,11 +27,11 @@ import org.dslul.openboard.inputmethod.latin.common.InputPointers;
*/
public class BatchInputArbiter {
public interface BatchInputArbiterListener {
public void onStartBatchInput();
public void onUpdateBatchInput(
void onStartBatchInput();
void onUpdateBatchInput(
final InputPointers aggregatedPointers, final long moveEventTime);
public void onStartUpdateBatchInputTimer();
public void onEndBatchInput(final InputPointers aggregatedPointers, final long upEventTime);
void onStartUpdateBatchInputTimer();
void onEndBatchInput(final InputPointers aggregatedPointers, final long upEventTime);
}
// The starting time of the first stroke of a gesture input.

View file

@ -29,14 +29,14 @@ public interface DrawingProxy {
* @param key the {@link Key} that is being pressed.
* @param withPreview true if key popup preview should be displayed.
*/
public void onKeyPressed(@Nonnull Key key, boolean withPreview);
void onKeyPressed(@Nonnull Key key, boolean withPreview);
/**
* Called when a key is being released.
* @param key the {@link Key} that is being released.
* @param withAnimation when true, key popup preview should be dismissed with animation.
*/
public void onKeyReleased(@Nonnull Key key, boolean withAnimation);
void onKeyReleased(@Nonnull Key key, boolean withAnimation);
/**
* Start showing more keys keyboard of a key that is being long pressed.
@ -46,23 +46,23 @@ public interface DrawingProxy {
* keyboard.
*/
@Nullable
public MoreKeysPanel showMoreKeysKeyboard(@Nonnull Key key, @Nonnull PointerTracker tracker);
MoreKeysPanel showMoreKeysKeyboard(@Nonnull Key key, @Nonnull PointerTracker tracker);
/**
* Start a while-typing-animation.
* @param fadeInOrOut {@link #FADE_IN} starts while-typing-fade-in animation.
* {@link #FADE_OUT} starts while-typing-fade-out animation.
*/
public void startWhileTypingAnimation(int fadeInOrOut);
public static final int FADE_IN = 0;
public static final int FADE_OUT = 1;
void startWhileTypingAnimation(int fadeInOrOut);
int FADE_IN = 0;
int FADE_OUT = 1;
/**
* Show sliding-key input preview.
* @param tracker the {@link PointerTracker} that is currently doing the sliding-key input.
* null to dismiss the sliding-key input preview.
*/
public void showSlidingKeyInputPreview(@Nullable PointerTracker tracker);
void showSlidingKeyInputPreview(@Nullable PointerTracker tracker);
/**
* Show gesture trails.
@ -70,10 +70,10 @@ public interface DrawingProxy {
* @param showsFloatingPreviewText when true, a gesture floating preview text will be shown
* with this <code>tracker</code>'s trail.
*/
public void showGestureTrail(@Nonnull PointerTracker tracker, boolean showsFloatingPreviewText);
void showGestureTrail(@Nonnull PointerTracker tracker, boolean showsFloatingPreviewText);
/**
* Dismiss a gesture floating preview text without delay.
*/
public void dismissGestureFloatingPreviewTextWithoutDelay();
void dismissGestureFloatingPreviewTextWithoutDelay();
}

View file

@ -69,10 +69,7 @@ public final class KeySpecParser {
}
// This is a workaround to have a key that has a supplementary code point. We can't put a
// string in resource as a XML entity of a supplementary code point or a surrogate pair.
if (keySpec.startsWith(PREFIX_HEX, labelEnd + 1)) {
return true;
}
return false;
return keySpec.startsWith(PREFIX_HEX, labelEnd + 1);
}
@Nonnull

View file

@ -603,9 +603,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_CASE.equals(tag)) {
selected |= parseCase(parser, row, selected ? true : skip);
selected |= parseCase(parser, row, selected || skip);
} else if (TAG_DEFAULT.equals(tag)) {
selected |= parseDefault(parser, row, selected ? true : skip);
selected |= parseDefault(parser, row, selected || skip);
} else {
throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_SWITCH);
}
@ -625,10 +625,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean selected = parseCaseCondition(parser);
if (row == null) {
// Processing Rows.
parseKeyboardContent(parser, selected ? skip : true);
parseKeyboardContent(parser, !selected || skip);
} else {
// Processing Keys.
parseRowContent(parser, row, selected ? skip : true);
parseRowContent(parser, row, !selected || skip);
}
return selected;
}

View file

@ -42,27 +42,27 @@ public final class KeyboardState {
private static final boolean DEBUG_INTERNAL_ACTION = false;
public interface SwitchActions {
public static final boolean DEBUG_ACTION = false;
boolean DEBUG_ACTION = false;
public void setAlphabetKeyboard();
public void setAlphabetManualShiftedKeyboard();
public void setAlphabetAutomaticShiftedKeyboard();
public void setAlphabetShiftLockedKeyboard();
public void setAlphabetShiftLockShiftedKeyboard();
public void setEmojiKeyboard();
public void setSymbolsKeyboard();
public void setSymbolsShiftedKeyboard();
void setAlphabetKeyboard();
void setAlphabetManualShiftedKeyboard();
void setAlphabetAutomaticShiftedKeyboard();
void setAlphabetShiftLockedKeyboard();
void setAlphabetShiftLockShiftedKeyboard();
void setEmojiKeyboard();
void setSymbolsKeyboard();
void setSymbolsShiftedKeyboard();
/**
* Request to call back {@link KeyboardState#onUpdateShiftState(int, int)}.
*/
public void requestUpdatingShiftState(final int autoCapsFlags, final int recapitalizeMode);
void requestUpdatingShiftState(final int autoCapsFlags, final int recapitalizeMode);
public static final boolean DEBUG_TIMER_ACTION = false;
boolean DEBUG_TIMER_ACTION = false;
public void startDoubleTapShiftKeyTimer();
public boolean isInDoubleTapShiftKeyTimeout();
public void cancelDoubleTapShiftKeyTimer();
void startDoubleTapShiftKeyTimer();
boolean isInDoubleTapShiftKeyTimeout();
void cancelDoubleTapShiftKeyTimer();
}
private final SwitchActions mSwitchActions;

View file

@ -139,10 +139,7 @@ public final class MoreKeySpec {
final int code = moreKey.mCode;
if (Character.isAlphabetic(code) && mCodes.indexOfKey(code) >= 0) {
return true;
} else if (code == Constants.CODE_OUTPUT_TEXT && mTexts.contains(moreKey.mOutputText)) {
return true;
}
return false;
} else return code == Constants.CODE_OUTPUT_TEXT && mTexts.contains(moreKey.mOutputText);
}
}

View file

@ -25,10 +25,10 @@ public final class PointerTrackerQueue {
private static final boolean DEBUG = false;
public interface Element {
public boolean isModifier();
public boolean isInDraggingFinger();
public void onPhantomUpEvent(long eventTime);
public void cancelTrackingForAction();
boolean isModifier();
boolean isInDraggingFinger();
void onPhantomUpEvent(long eventTime);
void cancelTrackingForAction();
}
private static final int INITIAL_CAPACITY = 10;

View file

@ -26,13 +26,13 @@ public interface TimerProxy {
* Start a timer to detect if a user is typing keys.
* @param typedKey the key that is typed.
*/
public void startTypingStateTimer(@Nonnull Key typedKey);
void startTypingStateTimer(@Nonnull Key typedKey);
/**
* Check if a user is key typing.
* @return true if a user is in typing.
*/
public boolean isTypingState();
boolean isTypingState();
/**
* Start a timer to simulate repeated key presses while a user keep pressing a key.
@ -40,7 +40,7 @@ public interface TimerProxy {
* @param repeatCount the number of times that the key is repeating. Starting from 1.
* @param delay the interval delay to the next key repeat, in millisecond.
*/
public void startKeyRepeatTimerOf(@Nonnull PointerTracker tracker, int repeatCount, int delay);
void startKeyRepeatTimerOf(@Nonnull PointerTracker tracker, int repeatCount, int delay);
/**
* Start a timer to detect a long pressed key.
@ -49,59 +49,59 @@ public interface TimerProxy {
* @param tracker the {@link PointerTracker} that starts long pressing.
* @param delay the delay to fire the long press timer, in millisecond.
*/
public void startLongPressTimerOf(@Nonnull PointerTracker tracker, int delay);
void startLongPressTimerOf(@Nonnull PointerTracker tracker, int delay);
/**
* Cancel timers for detecting a long pressed key and a long press shift key.
* @param tracker cancel long press timers of this {@link PointerTracker}.
*/
public void cancelLongPressTimersOf(@Nonnull PointerTracker tracker);
void cancelLongPressTimersOf(@Nonnull PointerTracker tracker);
/**
* Cancel a timer for detecting a long pressed shift key.
*/
public void cancelLongPressShiftKeyTimer();
void cancelLongPressShiftKeyTimer();
/**
* Cancel timers for detecting repeated key press, long pressed key, and long pressed shift key.
* @param tracker the {@link PointerTracker} that starts timers to be canceled.
*/
public void cancelKeyTimersOf(@Nonnull PointerTracker tracker);
void cancelKeyTimersOf(@Nonnull PointerTracker tracker);
/**
* Start a timer to detect double tapped shift key.
*/
public void startDoubleTapShiftKeyTimer();
void startDoubleTapShiftKeyTimer();
/**
* Cancel a timer of detecting double tapped shift key.
*/
public void cancelDoubleTapShiftKeyTimer();
void cancelDoubleTapShiftKeyTimer();
/**
* Check if a timer of detecting double tapped shift key is running.
* @return true if detecting double tapped shift key is on going.
*/
public boolean isInDoubleTapShiftKeyTimeout();
boolean isInDoubleTapShiftKeyTimeout();
/**
* Start a timer to fire updating batch input while <code>tracker</code> is on hold.
* @param tracker the {@link PointerTracker} that stops moving.
*/
public void startUpdateBatchInputTimer(@Nonnull PointerTracker tracker);
void startUpdateBatchInputTimer(@Nonnull PointerTracker tracker);
/**
* Cancel a timer of firing updating batch input.
* @param tracker the {@link PointerTracker} that resumes moving or ends gesture input.
*/
public void cancelUpdateBatchInputTimer(@Nonnull PointerTracker tracker);
void cancelUpdateBatchInputTimer(@Nonnull PointerTracker tracker);
/**
* Cancel all timers of firing updating batch input.
*/
public void cancelAllUpdateBatchInputTimers();
void cancelAllUpdateBatchInputTimers();
public static class Adapter implements TimerProxy {
class Adapter implements TimerProxy {
@Override
public void startTypingStateTimer(@Nonnull Key typedKey) {}
@Override

View file

@ -68,7 +68,7 @@ public final class BinaryDictionaryFileDumper {
private static final boolean SHOULD_VERIFY_CHECKSUM =
DecoderSpecificConstants.SHOULD_VERIFY_CHECKSUM;
private static final String DICTIONARY_PROJECTION[] = { "id" };
private static final String[] DICTIONARY_PROJECTION = {"id"};
private static final String QUERY_PARAMETER_MAY_PROMPT_USER = "mayPrompt";
private static final String QUERY_PARAMETER_TRUE = "true";
@ -143,7 +143,7 @@ public final class BinaryDictionaryFileDumper {
final String clientId = context.getString(R.string.dictionary_pack_client_id);
final ContentProviderClient client = context.getContentResolver().
acquireContentProviderClient(getProviderUriBuilder("").build());
if (null == client) return Collections.<WordListInfo>emptyList();
if (null == client) return Collections.emptyList();
Cursor cursor = null;
try {
final Uri.Builder builder = getContentUriBuilderForType(clientId, client,
@ -161,9 +161,9 @@ public final class BinaryDictionaryFileDumper {
reinitializeClientRecordInDictionaryContentProvider(context, client, clientId);
cursor = client.query(queryUri, DICTIONARY_PROJECTION, null, null, null);
}
if (null == cursor) return Collections.<WordListInfo>emptyList();
if (null == cursor) return Collections.emptyList();
if (cursor.getCount() <= 0 || !cursor.moveToFirst()) {
return Collections.<WordListInfo>emptyList();
return Collections.emptyList();
}
final ArrayList<WordListInfo> list = new ArrayList<>();
do {
@ -179,13 +179,13 @@ public final class BinaryDictionaryFileDumper {
// happens when the content provider got suddenly killed because it crashed or because
// the user disabled it through Settings.
Log.e(TAG, "RemoteException: communication with the dictionary pack cut", e);
return Collections.<WordListInfo>emptyList();
return Collections.emptyList();
} catch (Exception e) {
// A crash here is dangerous because crashing here would brick any encrypted device -
// we need the keyboard to be up and working to enter the password, so we don't want
// to die no matter what. So let's be as safe as possible.
Log.e(TAG, "Unexpected exception communicating with the dictionary pack", e);
return Collections.<WordListInfo>emptyList();
return Collections.emptyList();
} finally {
if (null != cursor) {
cursor.close();
@ -263,7 +263,7 @@ public final class BinaryDictionaryFileDumper {
* @param output an output stream to copy the data to.
*/
public static void checkMagicAndCopyFileTo(final BufferedInputStream input,
final BufferedOutputStream output) throws FileNotFoundException, IOException {
final BufferedOutputStream output) throws IOException {
// Check the magic number
final int length = MAGIC_NUMBER_VERSION_2.length;
final byte[] magicNumberBuffer = new byte[length];

View file

@ -47,9 +47,6 @@ public class ContactsDictionaryUtils {
*/
public static boolean useFirstLastBigramsForLocale(final Locale locale) {
// TODO: Add firstname/lastname bigram rules for other languages.
if (locale != null && locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
return true;
}
return false;
return locale != null && locale.getLanguage().equals(Locale.ENGLISH.getLanguage());
}
}

View file

@ -103,8 +103,8 @@ public class ContactsManager {
* Interface to implement for classes interested in getting notified for updates
* to Contacts content provider.
*/
public static interface ContactsChangedListener {
public void onContactsChange();
public interface ContactsChangedListener {
void onContactsChange();
}
/**

View file

@ -44,13 +44,13 @@ import javax.annotation.Nullable;
*/
public interface DictionaryFacilitator {
public static final String[] ALL_DICTIONARY_TYPES = new String[] {
String[] ALL_DICTIONARY_TYPES = new String[] {
Dictionary.TYPE_MAIN,
Dictionary.TYPE_CONTACTS,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER};
public static final String[] DYNAMIC_DICTIONARY_TYPES = new String[] {
String[] DYNAMIC_DICTIONARY_TYPES = new String[] {
Dictionary.TYPE_CONTACTS,
Dictionary.TYPE_USER_HISTORY,
Dictionary.TYPE_USER};

View file

@ -260,7 +260,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
final Method factoryMethod = dictClass.getMethod(DICT_FACTORY_METHOD_NAME,
DICT_FACTORY_METHOD_ARG_TYPES);
final Object dict = factoryMethod.invoke(null /* obj */,
new Object[] { context, locale, dictFile, dictNamePrefix, account });
context, locale, dictFile, dictNamePrefix, account);
return (ExpandableBinaryDictionary) dict;
} catch (final NoSuchMethodException | SecurityException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
@ -468,18 +468,12 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
// of these methods.
public boolean hasAtLeastOneInitializedMainDictionary() {
final Dictionary mainDict = mDictionaryGroup.getDict(Dictionary.TYPE_MAIN);
if (mainDict != null && mainDict.isInitialized()) {
return true;
}
return false;
return mainDict != null && mainDict.isInitialized();
}
public boolean hasAtLeastOneUninitializedMainDictionary() {
final Dictionary mainDict = mDictionaryGroup.getDict(Dictionary.TYPE_MAIN);
if (mainDict == null || !mainDict.isInitialized()) {
return true;
}
return false;
return mainDict == null || !mainDict.isInitialized();
}
public void waitForLoadingMainDictionaries(final long timeout, final TimeUnit unit)
@ -507,7 +501,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
NgramContext ngramContextForCurrentWord = ngramContext;
for (int i = 0; i < words.length; i++) {
final String currentWord = words[i];
final boolean wasCurrentWordAutoCapitalized = (i == 0) ? wasAutoCapitalized : false;
final boolean wasCurrentWordAutoCapitalized = (i == 0) && wasAutoCapitalized;
addWordToUserHistory(mDictionaryGroup, ngramContextForCurrentWord, currentWord,
wasCurrentWordAutoCapitalized, (int) timeStampInSeconds,
blockPotentiallyOffensive);

View file

@ -39,7 +39,7 @@ final class EmojiAltPhysicalKeyDetector {
private List<EmojiHotKeys> mHotKeysList;
private static class HotKeySet extends HashSet<Pair<Integer, Integer>> { };
private static class HotKeySet extends HashSet<Pair<Integer, Integer>> { }
private abstract class EmojiHotKeys {
private final String mName;

View file

@ -394,7 +394,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
*/
@UsedForTesting
public interface UpdateEntriesForInputEventsCallback {
public void onFinished();
void onFinished();
}
/**

View file

@ -42,8 +42,8 @@ public final class InputView extends FrameLayout {
@Override
protected void onFinishInflate() {
final SuggestionStripView suggestionStripView =
(SuggestionStripView)findViewById(R.id.suggestion_strip_view);
mMainKeyboardView = (MainKeyboardView)findViewById(R.id.keyboard_view);
findViewById(R.id.suggestion_strip_view);
mMainKeyboardView = findViewById(R.id.keyboard_view);
mKeyboardTopPaddingForwarder = new KeyboardTopPaddingForwarder(
mMainKeyboardView, suggestionStripView);
mMoreSuggestionsViewCanceler = new MoreSuggestionsViewCanceler(
@ -162,9 +162,7 @@ public final class InputView extends FrameLayout {
if (me.getActionMasked() == MotionEvent.ACTION_DOWN) {
// If the down event happens in the forwarding area, successive
// {@link MotionEvent}s should be forwarded to <code>ReceiverView</code>.
if (needsToForward(x, y)) {
return true;
}
return needsToForward(x, y);
}
return false;

View file

@ -1962,12 +1962,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: Revisit here to reorganize the settings. Probably we can/should use different
// strategy once the implementation of
// {@link InputMethodManager#shouldOfferSwitchingToNextInputMethod} is defined well.
final boolean fallbackValue = mSettings.getCurrent().isLanguageSwitchKeyEnabled();
final IBinder token = getWindow().getWindow().getAttributes().token;
if (token == null) {
return fallbackValue;
}
return mRichImm.shouldOfferSwitchingToNextInputMethod(token, fallbackValue);
return mSettings.getCurrent().isLanguageSwitchKeyEnabled();
}
private void setNavigationBarVisibility(final boolean visible) {

View file

@ -100,8 +100,8 @@ public class PersonalDictionaryLookup implements Closeable {
/**
* Interface to implement for classes interested in getting notified of updates.
*/
public static interface PersonalDictionaryListener {
public void onUpdate();
public interface PersonalDictionaryListener {
void onUpdate();
}
private final Set<PersonalDictionaryListener> mListeners = new HashSet<>();

View file

@ -783,11 +783,8 @@ public final class RichInputConnection implements PrivateCommandPerformer {
return false;
}
final int codePointAfterCursor = Character.codePointAt(after, 0);
if (spacingAndPunctuations.isWordSeparator(codePointAfterCursor)
|| spacingAndPunctuations.isWordConnector(codePointAfterCursor)) {
return false;
}
return true;
return !spacingAndPunctuations.isWordSeparator(codePointAfterCursor)
&& !spacingAndPunctuations.isWordConnector(codePointAfterCursor);
}
public void removeTrailingSpace() {

View file

@ -187,7 +187,7 @@ public class RichInputMethodSubtype {
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
@Nonnull
private static final RichInputMethodSubtype DUMMY_NO_LANGUAGE_SUBTYPE =
new RichInputMethodSubtype(InputMethodSubtypeCompatUtils.newInputMethodSubtype(
new RichInputMethodSubtype(new InputMethodSubtype(
R.string.subtype_no_language_qwerty, R.drawable.ic_ime_switcher_dark,
SubtypeLocaleUtils.NO_LANGUAGE, KEYBOARD_MODE,
EXTRA_VALUE_OF_DUMMY_NO_LANGUAGE_SUBTYPE,
@ -201,7 +201,7 @@ public class RichInputMethodSubtype {
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
@Nonnull
private static final RichInputMethodSubtype DUMMY_EMOJI_SUBTYPE = new RichInputMethodSubtype(
InputMethodSubtypeCompatUtils.newInputMethodSubtype(
new InputMethodSubtype(
R.string.subtype_emoji, R.drawable.ic_ime_switcher_dark,
SubtypeLocaleUtils.NO_LANGUAGE, KEYBOARD_MODE,
EXTRA_VALUE_OF_DUMMY_EMOJI_SUBTYPE,

View file

@ -92,7 +92,7 @@ public final class Suggest {
}
public interface OnGetSuggestedWordsCallback {
public void onGetSuggestedWords(final SuggestedWords suggestedWords);
void onGetSuggestedWords(final SuggestedWords suggestedWords);
}
public void getSuggestedWords(final WordComposer wordComposer,

View file

@ -485,11 +485,8 @@ public final class StringUtils {
return true;
}
// If it has both a period and a slash, it looks like an URL.
if (hasPeriod && hasSlash) {
return true;
}
return hasPeriod && hasSlash;
// Otherwise, it doesn't look like an URL.
return false;
}
/**

View file

@ -44,11 +44,11 @@ final class CustomInputStylePreference extends DialogPreference
private static final boolean DEBUG_SUBTYPE_ID = false;
interface Listener {
public void onRemoveCustomInputStyle(CustomInputStylePreference stylePref);
public void onSaveCustomInputStyle(CustomInputStylePreference stylePref);
public void onAddCustomInputStyle(CustomInputStylePreference stylePref);
public SubtypeLocaleAdapter getSubtypeLocaleAdapter();
public KeyboardLayoutSetAdapter getKeyboardLayoutSetAdapter();
void onRemoveCustomInputStyle(CustomInputStylePreference stylePref);
void onSaveCustomInputStyle(CustomInputStylePreference stylePref);
void onAddCustomInputStyle(CustomInputStylePreference stylePref);
SubtypeLocaleAdapter getSubtypeLocaleAdapter();
KeyboardLayoutSetAdapter getKeyboardLayoutSetAdapter();
}
private static final String KEY_PREFIX = "subtype_pref_";
@ -115,9 +115,9 @@ final class CustomInputStylePreference extends DialogPreference
@Override
protected View onCreateDialogView() {
final View v = super.onCreateDialogView();
mSubtypeLocaleSpinner = (Spinner) v.findViewById(R.id.subtype_locale_spinner);
mSubtypeLocaleSpinner = v.findViewById(R.id.subtype_locale_spinner);
mSubtypeLocaleSpinner.setAdapter(mProxy.getSubtypeLocaleAdapter());
mKeyboardLayoutSetSpinner = (Spinner) v.findViewById(R.id.keyboard_layout_set_spinner);
mKeyboardLayoutSetSpinner = v.findViewById(R.id.keyboard_layout_set_spinner);
mKeyboardLayoutSetSpinner.setAdapter(mProxy.getKeyboardLayoutSetAdapter());
// All keyboard layout names are in the Latin script and thus left to right. That means
// the view would align them to the left even if the system locale is RTL, but that
@ -233,7 +233,7 @@ final class CustomInputStylePreference extends DialogPreference
public SavedState(final Parcel source) {
super(source);
mSubtype = (InputMethodSubtype)source.readParcelable(null);
mSubtype = source.readParcelable(null);
}
@SuppressWarnings("hiding")

View file

@ -34,7 +34,7 @@ public class RadioButtonPreference extends Preference {
*
* @param preference This preference.
*/
public void onRadioButtonClicked(RadioButtonPreference preference);
void onRadioButtonClicked(RadioButtonPreference preference);
}
private boolean mIsSelected;
@ -74,7 +74,7 @@ public class RadioButtonPreference extends Preference {
@Override
protected void onBindView(final View view) {
super.onBindView(view);
mRadioButton = (RadioButton)view.findViewById(R.id.radio_button);
mRadioButton = view.findViewById(R.id.radio_button);
mRadioButton.setChecked(mIsSelected);
mRadioButton.setOnClickListener(mClickListener);
view.setOnClickListener(mClickListener);

View file

@ -31,12 +31,12 @@ import org.dslul.openboard.inputmethod.latin.R;
public final class SeekBarDialogPreference extends DialogPreference
implements SeekBar.OnSeekBarChangeListener {
public interface ValueProxy {
public int readValue(final String key);
public int readDefaultValue(final String key);
public void writeValue(final int value, final String key);
public void writeDefaultValue(final String key);
public String getValueText(final int value);
public void feedbackValue(final int value);
int readValue(final String key);
int readDefaultValue(final String key);
void writeValue(final int value, final String key);
void writeDefaultValue(final String key);
String getValueText(final int value);
void feedbackValue(final int value);
}
private final int mMaxValue;
@ -68,10 +68,10 @@ public final class SeekBarDialogPreference extends DialogPreference
@Override
protected View onCreateDialogView() {
final View view = super.onCreateDialogView();
mSeekBar = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar);
mSeekBar = view.findViewById(R.id.seek_bar_dialog_bar);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
mValueView = (TextView)view.findViewById(R.id.seek_bar_dialog_value);
mValueView = view.findViewById(R.id.seek_bar_dialog_value);
return view;
}

View file

@ -266,18 +266,6 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
R.integer.config_key_preview_linger_timeout))));
}
public static boolean readShowsLanguageSwitchKey(final SharedPreferences prefs) {
if (prefs.contains(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) {
final boolean suppressLanguageSwitchKey = prefs.getBoolean(
PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
final SharedPreferences.Editor editor = prefs.edit();
editor.remove(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY);
editor.putBoolean(PREF_SHOW_LANGUAGE_SWITCH_KEY, !suppressLanguageSwitchKey);
editor.apply();
}
return prefs.getBoolean(PREF_SHOW_LANGUAGE_SWITCH_KEY, true);
}
public static String readPrefAdditionalSubtypes(final SharedPreferences prefs,
final Resources res) {
final String predefinedPrefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(

View file

@ -139,11 +139,8 @@ public class SettingsValues {
mSlidingKeyInputPreviewEnabled = prefs.getBoolean(
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW, true);
mShowsVoiceInputKey = needsToShowVoiceInputKey(prefs, res) && mInputAttributes.mShouldShowVoiceInputKey;
mIncludesOtherImesInLanguageSwitchList = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
? prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false)
: true /* forcibly */;
mShowsLanguageSwitchKey = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
? Settings.readShowsLanguageSwitchKey(prefs) : true /* forcibly */;
mIncludesOtherImesInLanguageSwitchList = !Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS || prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false) /* forcibly */;
mShowsLanguageSwitchKey = prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, false);
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mUsePersonalizedDicts = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true);
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true)

View file

@ -59,7 +59,7 @@ public abstract class SubScreenFragment extends PreferenceFragment
if (listPreference == null) {
return;
}
final CharSequence entries[] = listPreference.getEntries();
final CharSequence[] entries = listPreference.getEntries();
final int entryIndex = listPreference.findIndexOfValue(listPreference.getValue());
listPreference.setSummary(entryIndex < 0 ? null : entries[entryIndex]);
}

View file

@ -37,7 +37,7 @@ public final class SetupStartIndicatorView extends LinearLayout {
setOrientation(HORIZONTAL);
LayoutInflater.from(context).inflate(R.layout.setup_start_indicator_label, this);
final LabelView labelView = (LabelView)findViewById(R.id.setup_start_label);
final LabelView labelView = findViewById(R.id.setup_start_label);
labelView.setIndicatorView(findViewById(R.id.setup_start_indicator));
}

View file

@ -135,18 +135,18 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
final String applicationName = getResources().getString(getApplicationInfo().labelRes);
mWelcomeScreen = findViewById(R.id.setup_welcome_screen);
final TextView welcomeTitle = (TextView)findViewById(R.id.setup_welcome_title);
final TextView welcomeTitle = findViewById(R.id.setup_welcome_title);
welcomeTitle.setText(getString(R.string.setup_welcome_title, applicationName));
mSetupScreen = findViewById(R.id.setup_steps_screen);
final TextView stepsTitle = (TextView)findViewById(R.id.setup_title);
final TextView stepsTitle = findViewById(R.id.setup_title);
stepsTitle.setText(getString(R.string.setup_steps_title, applicationName));
final SetupStepIndicatorView indicatorView =
(SetupStepIndicatorView)findViewById(R.id.setup_step_indicator);
findViewById(R.id.setup_step_indicator);
mSetupStepGroup = new SetupStepGroup(indicatorView);
mStep1Bullet = (TextView)findViewById(R.id.setup_step1_bullet);
mStep1Bullet = findViewById(R.id.setup_step1_bullet);
mStep1Bullet.setOnClickListener(this);
final SetupStep step1 = new SetupStep(STEP_1, applicationName,
mStep1Bullet, findViewById(R.id.setup_step1),
@ -194,7 +194,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
.authority(getPackageName())
.path(Integer.toString(R.raw.setup_welcome_video))
.build();
final VideoView welcomeVideoView = (VideoView)findViewById(R.id.setup_welcome_video);
final VideoView welcomeVideoView = findViewById(R.id.setup_welcome_video);
welcomeVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(final MediaPlayer mp) {
@ -213,13 +213,13 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
}
});
mWelcomeVideoView = welcomeVideoView;
mWelcomeImageView = (ImageView)findViewById(R.id.setup_welcome_image);
mWelcomeImageView = findViewById(R.id.setup_welcome_image);
mActionStart = findViewById(R.id.setup_start_label);
mActionStart.setOnClickListener(this);
mActionNext = findViewById(R.id.setup_next);
mActionNext.setOnClickListener(this);
mActionFinish = (TextView)findViewById(R.id.setup_finish);
mActionFinish = findViewById(R.id.setup_finish);
mActionFinish.setCompoundDrawablesRelativeWithIntrinsicBounds(getResources().getDrawable(R.drawable.ic_setup_finish),
null, null, null);
mActionFinish.setOnClickListener(this);
@ -448,14 +448,14 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
mActivatedColor = res.getColor(R.color.setup_text_action);
mDeactivatedColor = res.getColor(R.color.setup_text_dark);
final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title);
final TextView titleView = mStepView.findViewById(R.id.setup_step_title);
titleView.setText(res.getString(title, applicationName));
mInstruction = (instruction == 0) ? null
: res.getString(instruction, applicationName);
mFinishedInstruction = (finishedInstruction == 0) ? null
: res.getString(finishedInstruction, applicationName);
mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label);
mActionLabel = mStepView.findViewById(R.id.setup_step_action_label);
mActionLabel.setText(res.getString(actionLabel));
if (actionIcon == 0) {
final int paddingEnd = mActionLabel.getPaddingEnd();
@ -469,7 +469,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
public void setEnabled(final boolean enabled, final boolean isStepActionAlreadyDone) {
mStepView.setVisibility(enabled ? View.VISIBLE : View.GONE);
mBulletView.setTextColor(enabled ? mActivatedColor : mDeactivatedColor);
final TextView instructionView = (TextView)mStepView.findViewById(
final TextView instructionView = mStepView.findViewById(
R.id.setup_step_instruction);
instructionView.setText(isStepActionAlreadyDone ? mFinishedInstruction : mInstruction);
mActionLabel.setVisibility(isStepActionAlreadyDone ? View.GONE : View.VISIBLE);

View file

@ -546,7 +546,7 @@ final class SuggestionStripLayoutHelper {
public void layoutImportantNotice(final View importantNoticeStrip,
final String importantNoticeTitle) {
final TextView titleView = (TextView)importantNoticeStrip.findViewById(
final TextView titleView = importantNoticeStrip.findViewById(
R.id.important_notice_title);
final int width = titleView.getWidth() - titleView.getPaddingLeft()
- titleView.getPaddingRight();

View file

@ -59,9 +59,9 @@ import androidx.core.view.ViewCompat;
public final class SuggestionStripView extends RelativeLayout implements OnClickListener,
OnLongClickListener {
public interface Listener {
public void showImportantNoticeContents();
public void pickSuggestionManually(SuggestedWordInfo word);
public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
void showImportantNoticeContents();
void pickSuggestionManually(SuggestedWordInfo word);
void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat);
}
static final boolean DBG = DebugFlags.DEBUG_ENABLED;
@ -139,8 +139,8 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
final LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.suggestions_strip, this);
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
mSuggestionsStrip = findViewById(R.id.suggestions_strip);
mVoiceKey = findViewById(R.id.suggestions_strip_voice_key);
mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip,
mImportantNoticeStrip);
@ -163,7 +163,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);
mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
mMoreSuggestionsView = mMoreSuggestionsContainer
.findViewById(R.id.more_suggestions_view);
mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);
@ -187,7 +187,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
*/
public void setListener(final Listener listener, final View inputView) {
mListener = listener;
mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view);
mMainKeyboardView = inputView.findViewById(R.id.keyboard_view);
}
public void updateVisibility(final boolean shouldBeVisible, final boolean isFullscreenMode) {

View file

@ -22,6 +22,6 @@ import org.dslul.openboard.inputmethod.latin.SuggestedWords;
* An object that gives basic control of a suggestion strip and some info on it.
*/
public interface SuggestionStripViewAccessor {
public void setNeutralSuggestionStrip();
public void showSuggestionStrip(final SuggestedWords suggestedWords);
void setNeutralSuggestionStrip();
void showSuggestionStrip(final SuggestedWords suggestedWords);
}

View file

@ -70,8 +70,8 @@ public class UserDictionaryAddWordContents {
private String mSavedShortcut;
/* package */ UserDictionaryAddWordContents(final View view, final Bundle args) {
mWordEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = (EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
mWordEditText = view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = view.findViewById(R.id.user_dictionary_add_shortcut);
if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
mShortcutEditText.setVisibility(View.GONE);
view.findViewById(R.id.user_dictionary_add_shortcut_label).setVisibility(View.GONE);
@ -101,8 +101,8 @@ public class UserDictionaryAddWordContents {
/* package */ UserDictionaryAddWordContents(final View view,
final UserDictionaryAddWordContents oldInstanceToBeEdited) {
mWordEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = (EditText)view.findViewById(R.id.user_dictionary_add_shortcut);
mWordEditText = view.findViewById(R.id.user_dictionary_add_word_text);
mShortcutEditText = view.findViewById(R.id.user_dictionary_add_shortcut);
mMode = MODE_EDIT;
mOldWord = oldInstanceToBeEdited.mSavedWord;
mOldShortcut = oldInstanceToBeEdited.mSavedShortcut;
@ -183,7 +183,7 @@ public class UserDictionaryAddWordContents {
// In this class we use the empty string to represent 'all locales' and mLocale cannot
// be null. However the addWord method takes null to mean 'all locales'.
UserDictionary.Words.addWord(context, newWord.toString(),
UserDictionary.Words.addWord(context, newWord,
FREQUENCY_FOR_USER_DICTIONARY_ADDS, newShortcut, TextUtils.isEmpty(mLocale) ?
null : LocaleUtils.constructLocaleFromString(mLocale));

View file

@ -133,7 +133,7 @@ public class UserDictionaryAddWordFragment extends Fragment
final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(getActivity());
final Spinner localeSpinner =
(Spinner)mRootView.findViewById(R.id.user_dictionary_add_locale);
mRootView.findViewById(R.id.user_dictionary_add_locale);
final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<>(
getActivity(), android.R.layout.simple_spinner_item, localesList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

View file

@ -99,7 +99,7 @@ public class UserDictionaryList extends PreferenceFragment {
// enabled subtypes. If we already have the locale-without-country version of the system
// locale, we don't add the system locale to avoid confusion even though it's technically
// correct to add it.
if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
if (!localeSet.contains(Locale.getDefault().getLanguage())) {
localeSet.add(Locale.getDefault().toString());
}

View file

@ -31,6 +31,6 @@ public class UserDictionaryLocalePicker extends Fragment {
}
public interface LocationChangedListener {
public void onLocaleSelected(Locale locale);
void onLocaleSelected(Locale locale);
}
}

View file

@ -132,11 +132,7 @@ public class UserDictionarySettings extends ListFragment {
final String locale;
if (null != localeFromArguments) {
locale = localeFromArguments;
} else if (null != localeFromIntent) {
locale = localeFromIntent;
} else {
locale = null;
}
} else locale = localeFromIntent;
mLocale = locale;
// WARNING: The following cursor is never closed! TODO: don't put that in a member, and
@ -145,7 +141,7 @@ public class UserDictionarySettings extends ListFragment {
// closing the cursor, so take care when resolving this TODO). We should either use a
// regular query and close the cursor, or switch to a LoaderManager and a CursorLoader.
mCursor = createCursor(locale);
TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
TextView emptyView = getView().findViewById(android.R.id.empty);
emptyView.setText(R.string.user_dict_settings_empty_text);
final ListView listView = getListView();

View file

@ -68,7 +68,7 @@ public final class AdditionalSubtypeUtils {
getPlatformVersionIndependentSubtypeId(localeString, keyboardLayoutSetName);
// NOTE: In KitKat and later, InputMethodSubtypeBuilder#setIsAsciiCapable is also available.
// TODO: Use InputMethodSubtypeBuilder#setIsAsciiCapable when appropriate.
return InputMethodSubtypeCompatUtils.newInputMethodSubtype(nameId,
return new InputMethodSubtype(nameId,
R.drawable.ic_ime_switcher_dark, localeString, KEYBOARD_MODE,
platformVersionDependentExtraValues,
false /* isAuxiliary */, false /* overrideImplicitlyEnabledSubtype */,
@ -107,7 +107,7 @@ public final class AdditionalSubtypeUtils {
final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
for (final String prefSubtype : prefSubtypeArray) {
final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
final String[] elems = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE
&& elems.length != LENGTH_WITH_EXTRA_VALUE) {
Log.w(TAG, "Unknown additional subtype specified: " + prefSubtype + " in "

View file

@ -89,7 +89,7 @@ public final class DebugLogUtils {
if (!sDBG) return;
final StringBuilder sb = new StringBuilder();
for (final Object o : args) {
sb.append(s(o).toString());
sb.append(s(o));
sb.append(" ");
}
Log.e(TAG, sb.toString());
@ -106,7 +106,7 @@ public final class DebugLogUtils {
if (!sDBG) return;
final StringBuilder sb = new StringBuilder("\u001B[31m");
for (final Object o : args) {
sb.append(s(o).toString());
sb.append(s(o));
sb.append(" ");
}
sb.append("\u001B[0m");

View file

@ -62,7 +62,7 @@ public final class JsonUtils {
} finally {
close(reader);
}
return Collections.<Object>emptyList();
return Collections.emptyList();
}
public static String listToJsonStr(final List<Object> list) {

View file

@ -20,8 +20,7 @@
<array
name="emoji_nature"
format="string"
>
<!-- <item>1f415</item> -->
>1f415
<item>1f436</item>
<item>1f429</item>
<!-- <item>1f408</item> -->

View file

@ -32,6 +32,11 @@
android:title="@string/enable_split_keyboard"
android:persistent="true"
android:defaultValue="false" />
<CheckBoxPreference
android:key="pref_show_language_switch_key"
android:title="Show language switch key"
android:defaultValue="false"
android:persistent="true" />
<CheckBoxPreference
android:key="pref_resize_keyboard"
android:title="@string/prefs_resize_keyboard"