some more warnings addressed

This commit is contained in:
Helium314 2023-09-09 18:47:21 +02:00
parent 9426a2d616
commit 3ba28b7a22
18 changed files with 74 additions and 174 deletions

View file

@ -5,7 +5,7 @@ import java.util.*
object EditorInfoCompatUtils {
// Note that EditorInfo.IME_FLAG_FORCE_ASCII has been introduced
// in API level 16 (Build.VERSION_CODES.JELLY_BEAN).
// in API level 16 (Build.VERSION_CODES.JELLY_BEAN).
private val FIELD_IME_FLAG_FORCE_ASCII = CompatUtils.getField(
EditorInfo::class.java, "IME_FLAG_FORCE_ASCII")
private val OBJ_IME_FLAG_FORCE_ASCII: Int? = CompatUtils.getFieldValue(
@ -13,12 +13,12 @@ object EditorInfoCompatUtils {
private val FIELD_HINT_LOCALES = CompatUtils.getField(
EditorInfo::class.java, "hintLocales")
@kotlin.jvm.JvmStatic
@JvmStatic
fun hasFlagForceAscii(imeOptions: Int): Boolean {
return if (OBJ_IME_FLAG_FORCE_ASCII == null) false else imeOptions and OBJ_IME_FLAG_FORCE_ASCII != 0
}
@kotlin.jvm.JvmStatic
@JvmStatic
fun imeActionName(imeOptions: Int): String {
val actionId = imeOptions and EditorInfo.IME_MASK_ACTION
return when (actionId) {
@ -49,10 +49,10 @@ object EditorInfoCompatUtils {
if (hasFlagForceAscii(imeOptions)) {
flags.append("flagForceAscii|")
}
return if (action != null) flags.toString() + action else flags.toString()
return flags.toString() + action
}
@kotlin.jvm.JvmStatic
@JvmStatic
fun getPrimaryHintLocale(editorInfo: EditorInfo?): Locale? {
if (editorInfo == null) {
return null
@ -61,6 +61,6 @@ object EditorInfoCompatUtils {
?: return null
return if (LocaleListCompatUtils.isEmpty(localeList)) {
null
} else LocaleListCompatUtils.get(localeList, 0)
} else LocaleListCompatUtils[localeList, 0]
}
}

View file

@ -7,7 +7,7 @@ import org.dslul.openboard.inputmethod.compat.CompatUtils.ToBooleanMethodWrapper
object InputConnectionCompatUtils {
private var sInputConnectionType: ClassWrapper? = null
private var sRequestCursorUpdatesMethod: ToBooleanMethodWrapper? = null
val isRequestCursorUpdatesAvailable: Boolean
private val isRequestCursorUpdatesAvailable: Boolean
get() = sRequestCursorUpdatesMethod != null
/**
@ -31,7 +31,7 @@ object InputConnectionCompatUtils {
* as soon as possible to notify the current cursor/anchor position to the input method.
* @return `false` if the request is not handled. Otherwise returns `true`.
*/
@kotlin.jvm.JvmStatic
@JvmStatic
fun requestCursorUpdates(inputConnection: InputConnection,
enableMonitor: Boolean, requestImmediateCallback: Boolean): Boolean {
val cursorUpdateMode = ((if (enableMonitor) CURSOR_UPDATE_MONITOR else 0)

View file

@ -4,42 +4,19 @@ import android.content.Context
import android.text.Spannable
import android.text.SpannableString
import android.text.Spanned
import android.text.TextUtils
import android.text.style.SuggestionSpan
import org.dslul.openboard.inputmethod.annotations.UsedForTesting
import org.dslul.openboard.inputmethod.latin.SuggestedWords
import org.dslul.openboard.inputmethod.latin.SuggestedWords.SuggestedWordInfo
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
import org.dslul.openboard.inputmethod.latin.define.DebugFlags
import java.util.*
object SuggestionSpanUtils {
// Note that SuggestionSpan.FLAG_AUTO_CORRECTION has been introduced
// in API level 15 (Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1).
private val FIELD_FLAG_AUTO_CORRECTION = CompatUtils.getField(
SuggestionSpan::class.java, "FLAG_AUTO_CORRECTION")
private val OBJ_FLAG_AUTO_CORRECTION: Int? = CompatUtils.getFieldValue(
null /* receiver */, null /* defaultValue */, FIELD_FLAG_AUTO_CORRECTION) as Int
@kotlin.jvm.JvmStatic
@JvmStatic
@UsedForTesting
fun getTextWithAutoCorrectionIndicatorUnderline(
context: Context?, text: String,locale: Locale?): CharSequence {
if (TextUtils.isEmpty(text) || OBJ_FLAG_AUTO_CORRECTION == null) {
fun getTextWithAutoCorrectionIndicatorUnderline(context: Context?, text: String, locale: Locale?): CharSequence {
if (text.isEmpty())
return text
}
val spannable: Spannable = SpannableString(text)
val suggestionSpan = SuggestionSpan(context, locale, arrayOf(), OBJ_FLAG_AUTO_CORRECTION, null)
spannable.setSpan(suggestionSpan, 0, text.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE or Spanned.SPAN_COMPOSING)
val suggestionSpan = SuggestionSpan(context, locale, arrayOf(), SuggestionSpan.FLAG_AUTO_CORRECTION, null)
spannable.setSpan(suggestionSpan, 0, text.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE or Spanned.SPAN_COMPOSING)
return spannable
}
init {
if (DebugFlags.DEBUG_ENABLED) {
if (OBJ_FLAG_AUTO_CORRECTION == null) {
throw RuntimeException("Field is accidentially null.")
}
}
}
}

View file

@ -1,28 +1,24 @@
package org.dslul.openboard.inputmethod.compat
import android.os.Build
import android.view.textservice.TextInfo
import org.dslul.openboard.inputmethod.annotations.UsedForTesting
object TextInfoCompatUtils {
// Note that TextInfo.getCharSequence() is supposed to be available in API level 21 and later.
private val TEXT_INFO_GET_CHAR_SEQUENCE = CompatUtils.getMethod(TextInfo::class.java, "getCharSequence")
private val TEXT_INFO_CONSTRUCTOR_FOR_CHAR_SEQUENCE = CompatUtils.getConstructor(TextInfo::class.java, CharSequence::class.java, Int::class.javaPrimitiveType, Int::class.javaPrimitiveType,
Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
@get:UsedForTesting
val isCharSequenceSupported: Boolean
get() = TEXT_INFO_GET_CHAR_SEQUENCE != null &&
TEXT_INFO_CONSTRUCTOR_FOR_CHAR_SEQUENCE != null
get() = TEXT_INFO_GET_CHAR_SEQUENCE != null
@kotlin.jvm.JvmStatic
@JvmStatic
@UsedForTesting
fun newInstance(charSequence: CharSequence, start: Int, end: Int, cookie: Int,
sequenceNumber: Int): TextInfo? {
return if (TEXT_INFO_CONSTRUCTOR_FOR_CHAR_SEQUENCE != null) {
CompatUtils.newInstance(TEXT_INFO_CONSTRUCTOR_FOR_CHAR_SEQUENCE,
charSequence, start, end, cookie, sequenceNumber) as TextInfo
} else TextInfo(charSequence.subSequence(start, end).toString(), cookie,
sequenceNumber)
sequenceNumber: Int): TextInfo {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return TextInfo(charSequence, start, end, cookie, sequenceNumber)
return TextInfo(charSequence.subSequence(start, end).toString(), cookie, sequenceNumber)
}
/**
@ -34,11 +30,12 @@ object TextInfoCompatUtils {
* the result of [TextInfo.getText] as fall back. If `textInfo` is `null`,
* returns `null`.
*/
@kotlin.jvm.JvmStatic
@JvmStatic
@UsedForTesting
fun getCharSequenceOrString(textInfo: TextInfo?): CharSequence? {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return textInfo?.charSequence
val defaultValue: CharSequence? = textInfo?.text
return CompatUtils.invoke(textInfo, defaultValue!!,
TEXT_INFO_GET_CHAR_SEQUENCE) as CharSequence
return CompatUtils.invoke(textInfo, defaultValue!!, TEXT_INFO_GET_CHAR_SEQUENCE) as CharSequence
}
}

View file

@ -1,51 +0,0 @@
package org.dslul.openboard.inputmethod.compat
import android.content.Context
import android.os.Build
import android.os.Build.VERSION_CODES
import android.os.UserManager
import androidx.annotation.IntDef
import androidx.annotation.RequiresApi
import java.lang.reflect.Method
/**
* A temporary solution until `UserManagerCompat.isUserUnlocked()` in the support-v4 library
* becomes publicly available.
*/
object UserManagerCompatUtils {
private var METHOD_isUserUnlocked: Method? = null
const val LOCK_STATE_UNKNOWN = 0
const val LOCK_STATE_UNLOCKED = 1
const val LOCK_STATE_LOCKED = 2
/**
* Check if the calling user is running in an "unlocked" state. A user is unlocked only after
* they've entered their credentials (such as a lock pattern or PIN), and credential-encrypted
* private app data storage is available.
* @param context context from which [UserManager] should be obtained.
* @return One of [LockState].
*/
@RequiresApi(VERSION_CODES.M)
@kotlin.jvm.JvmStatic
@LockState
fun getUserLockState(context: Context): Int {
if (METHOD_isUserUnlocked == null) {
return LOCK_STATE_UNKNOWN
}
val userManager = context.getSystemService(UserManager::class.java)
?: return LOCK_STATE_UNKNOWN
val result = CompatUtils.invoke(userManager, null, METHOD_isUserUnlocked) as Boolean
return if (result) LOCK_STATE_UNLOCKED else LOCK_STATE_LOCKED
}
@kotlin.annotation.Retention(AnnotationRetention.SOURCE)
@IntDef(LOCK_STATE_UNKNOWN, LOCK_STATE_UNLOCKED, LOCK_STATE_LOCKED)
annotation class LockState
init { // We do not try to search the method in Android M and prior.
METHOD_isUserUnlocked = if (Build.VERSION.SDK_INT <= VERSION_CODES.M) {
null
} else {
CompatUtils.getMethod(UserManager::class.java, "isUserUnlocked")
}
}
}

View file

@ -10,8 +10,8 @@ object ViewOutlineProviderCompatUtils {
override fun setInsets(insets: InputMethodService.Insets) {}
}
@kotlin.jvm.JvmStatic
fun setInsetsOutlineProvider(view: View): InsetsUpdater? {
@JvmStatic
fun setInsetsOutlineProvider(view: View): InsetsUpdater {
return if (Build.VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) {
EMPTY_INSETS_UPDATER
} else ViewOutlineProviderCompatUtilsLXX.setInsetsOutlineProvider(view)

View file

@ -2,10 +2,13 @@ package org.dslul.openboard.inputmethod.compat
import android.graphics.Outline
import android.inputmethodservice.InputMethodService
import android.os.Build
import android.view.View
import android.view.ViewOutlineProvider
import androidx.annotation.RequiresApi
import org.dslul.openboard.inputmethod.compat.ViewOutlineProviderCompatUtils.InsetsUpdater
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
internal object ViewOutlineProviderCompatUtilsLXX {
fun setInsetsOutlineProvider(view: View): InsetsUpdater {
val provider = InsetsOutlineProvider(view)
@ -29,8 +32,7 @@ internal object ViewOutlineProviderCompatUtilsLXX {
return
}
// TODO: Revisit this when floating/resize keyboard is supported.
outline.setRect(
view.left, mLastVisibleTopInsets, view.right, view.bottom)
outline.setRect(view.left, mLastVisibleTopInsets, view.right, view.bottom)
}
companion object {

View file

@ -22,7 +22,6 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
import org.dslul.openboard.inputmethod.keyboard.internal.KeyDrawParams;
import org.dslul.openboard.inputmethod.keyboard.internal.KeySpecParser;
import org.dslul.openboard.inputmethod.keyboard.internal.KeyStyle;

View file

@ -28,7 +28,6 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype;
import org.dslul.openboard.inputmethod.compat.EditorInfoCompatUtils;
import org.dslul.openboard.inputmethod.compat.UserManagerCompatUtils;
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardBuilder;
import org.dslul.openboard.inputmethod.keyboard.internal.KeyboardParams;
import org.dslul.openboard.inputmethod.keyboard.internal.UniqueKeysCache;
@ -51,6 +50,7 @@ import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.N
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.os.UserManagerCompat;
/**
* This class represents a set of keyboard layouts. Each of them represents a different keyboard
@ -88,7 +88,6 @@ public final class KeyboardLayoutSet {
private final static HashMap<InputMethodSubtype, Integer> sScriptIdsForSubtypes =
new HashMap<>();
@SuppressWarnings("serial")
public static final class KeyboardLayoutSetException extends RuntimeException {
public final KeyboardId mKeyboardId;
@ -166,8 +165,6 @@ public final class KeyboardLayoutSet {
mParams = params;
}
public static final String LOCALE_GEORGIAN = "ka";
@NonNull
public Keyboard getKeyboard(final int baseKeyboardLayoutSetElementId) {
final int keyboardLayoutSetElementId;
@ -287,10 +284,7 @@ public final class KeyboardLayoutSet {
// When the device is still unlocked, features like showing the IME setting app need to
// be locked down.
// TODO: Switch to {@code UserManagerCompat.isUserUnlocked()} in the support-v4 library
// when it becomes publicly available.
@UserManagerCompatUtils.LockState final int lockState = UserManagerCompatUtils.getUserLockState(context);
if (lockState == UserManagerCompatUtils.LOCK_STATE_LOCKED) {
if (!UserManagerCompat.isUserUnlocked(context)) {
params.mNoSettingsKey = true;
}
}
@ -363,8 +357,7 @@ public final class KeyboardLayoutSet {
final String layoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX
+ SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
final int xmlId = getXmlId(resources, layoutSetName);
final XmlResourceParser parser = resources.getXml(xmlId);
try {
try (XmlResourceParser parser = resources.getXml(xmlId)) {
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
// Bovinate through the XML stupidly searching for TAG_FEATURE, and read
// the script Id from it.
@ -376,8 +369,6 @@ public final class KeyboardLayoutSet {
}
} catch (final IOException | XmlPullParserException e) {
throw new RuntimeException(e.getMessage() + " in " + layoutSetName, e);
} finally {
parser.close();
}
// If the tag is not found, then the default script is Latin.
return ScriptUtils.SCRIPT_LATIN;
@ -419,8 +410,7 @@ public final class KeyboardLayoutSet {
private void parseKeyboardLayoutSet(final Resources res, final int resId)
throws XmlPullParserException, IOException {
final XmlResourceParser parser = res.getXml(resId);
try {
try (XmlResourceParser parser = res.getXml(resId)) {
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
final int event = parser.next();
if (event == XmlPullParser.START_TAG) {
@ -432,8 +422,6 @@ public final class KeyboardLayoutSet {
}
}
}
} finally {
parser.close();
}
}

View file

@ -129,20 +129,19 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
final Resources res = mThemeContext.getResources();
final int keyboardWidth = ResourceUtils.getKeyboardWidth(res, settingsValues);
final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(mRichImm.getCurrentSubtype());
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
builder.setNumberRowEnabled(settingsValues.mShowsNumberRow);
builder.setLanguageSwitchKeyEnabled(settingsValues.isLanguageSwitchKeyEnabled());
builder.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey);
builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
&& settingsValues.mIsSplitKeyboardEnabled);
final boolean oneHandedModeEnabled = settingsValues.mOneHandedModeEnabled;
builder.setOneHandedModeEnabled(oneHandedModeEnabled);
mKeyboardLayoutSet = builder.build();
mKeyboardLayoutSet = builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
.setSubtype(mRichImm.getCurrentSubtype())
.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey)
.setNumberRowEnabled(settingsValues.mShowsNumberRow)
.setLanguageSwitchKeyEnabled(settingsValues.isLanguageSwitchKeyEnabled())
.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey)
.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
&& settingsValues.mIsSplitKeyboardEnabled)
.setOneHandedModeEnabled(oneHandedModeEnabled)
.build();
try {
mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState,
oneHandedModeEnabled);
mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState, oneHandedModeEnabled);
mKeyboardTextsSet.setLocale(mRichImm.getCurrentSubtypeLocale(), mThemeContext);
} catch (KeyboardLayoutSetException e) {
Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());

View file

@ -393,7 +393,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
* @param keyboard the keyboard to display in this view
*/
@Override
public void setKeyboard(final Keyboard keyboard) {
public void setKeyboard(@NonNull final Keyboard keyboard) {
// Remove any pending messages, except dismissing preview and key repeat.
mTimerHandler.cancelLongPressTimers();
super.setKeyboard(keyboard);
@ -804,8 +804,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
}
@Override
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
final KeyDrawParams params) {
protected void onDrawKeyTopVisuals(@NonNull final Key key, @NonNull final Canvas canvas,
@NonNull final Paint paint, @NonNull final KeyDrawParams params) {
if (key.altCodeWhileTyping() && key.isEnabled()) {
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
}

View file

@ -26,6 +26,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import org.dslul.openboard.inputmethod.accessibility.AccessibilityUtils;
import org.dslul.openboard.inputmethod.accessibility.MoreKeysKeyboardAccessibilityDelegate;
import org.dslul.openboard.inputmethod.keyboard.emoji.OnKeyEventListener;
@ -86,8 +88,8 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
}
@Override
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
final KeyDrawParams params) {
protected void onDrawKeyTopVisuals(@NonNull final Key key, @NonNull final Canvas canvas,
@NonNull final Paint paint, @NonNull final KeyDrawParams params) {
if (!key.isSpacer() || !(key instanceof MoreKeysKeyboard.MoreKeyDivider)
|| mDivider == null) {
super.onDrawKeyTopVisuals(key, canvas, paint, params);
@ -103,7 +105,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
}
@Override
public void setKeyboard(final Keyboard keyboard) {
public void setKeyboard(@NonNull final Keyboard keyboard) {
super.setKeyboard(keyboard);
mKeyDetector.setKeyboard(
keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection());

View file

@ -166,7 +166,7 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
* {@inheritDoc}
*/
@Override
public void setKeyboard(final Keyboard keyboard) {
public void setKeyboard(@NonNull final Keyboard keyboard) {
super.setKeyboard(keyboard);
mKeyDetector.setKeyboard(keyboard, 0 /* correctionX */, 0 /* correctionY */);
mMoreKeysKeyboardCache.clear();
@ -321,22 +321,12 @@ public final class EmojiPageKeyboardView extends KeyboardView implements
private void registerPress(final Key key) {
// Do not trigger key-down effect right now in case this is actually a fling action.
mPendingKeyDown = new Runnable() {
@Override
public void run() {
callListenerOnPressKey(key);
}
};
mPendingKeyDown = () -> callListenerOnPressKey(key);
mHandler.postDelayed(mPendingKeyDown, KEY_PRESS_DELAY_TIME);
}
private void registerLongPress(final Key key) {
mPendingLongPress = new Runnable() {
@Override
public void run() {
onLongPressed(key);
}
};
mPendingLongPress = () -> onLongPressed(key);
mHandler.postDelayed(mPendingLongPress, getLongPressTimeout());
}

View file

@ -167,8 +167,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
public KeyboardBuilder<KP> load(final int xmlId, final KeyboardId id) {
mParams.mId = id;
final XmlResourceParser parser = mResources.getXml(xmlId);
try {
try (XmlResourceParser parser = mResources.getXml(xmlId)) {
parseKeyboard(parser);
} catch (XmlPullParserException e) {
Log.w(BUILDER_TAG, "keyboard XML parse error", e);
@ -176,8 +175,6 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
} catch (IOException e) {
Log.w(BUILDER_TAG, "keyboard XML parse error", e);
throw new RuntimeException(e.getMessage(), e);
} finally {
parser.close();
}
return this;
}
@ -481,9 +478,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final int width = (int)keyWidth;
final int height = row.getRowHeight();
final String hintLabel = moreKeySpecs != null ? "\u25E5" : null;
final KeyboardParams params = mParams;
final Key key = new Key(label, code, outputText, hintLabel, moreKeySpecs,
labelFlags, backgroundType, x, y, width, height, params);
labelFlags, backgroundType, x, y, width, height, mParams);
endKey(key);
row.advanceXPos(keyWidth);
}
@ -555,7 +551,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final TypedArray keyboardAttr = mResources.obtainAttributes(
attr, R.styleable.Keyboard_Include);
final TypedArray keyAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
int keyboardLayout = 0;
final int keyboardLayout;
try {
XmlParseUtils.checkAttributeExists(
keyboardAttr, R.styleable.Keyboard_Include_keyboardLayout, "keyboardLayout",
@ -578,15 +574,13 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
startEndTag("<%s keyboardLayout=%s />",TAG_INCLUDE,
mResources.getResourceEntryName(keyboardLayout));
}
final XmlResourceParser parserForInclude = mResources.getXml(keyboardLayout);
try {
try (XmlResourceParser parserForInclude = mResources.getXml(keyboardLayout)) {
parseMerge(parserForInclude, row, skip);
} finally {
if (row != null) {
// Restore Row attributes.
row.popRowAttributes();
}
parserForInclude.close();
}
}

View file

@ -140,6 +140,7 @@ public final class KeyboardTextsSet {
final RunInLocale<String> getTextJob = new RunInLocale<String>() {
@Override
protected String job(final Resources res) {
// this is for identifiers in strings-action-keys.xml (100% only?)
final int resId = res.getIdentifier(name, "string", resourcePackageName);
return res.getString(resId);
}

View file

@ -222,7 +222,7 @@ public final class MoreKeySpec {
if (remain != null) {
list.add(remain);
}
return list.toArray(new String[list.size()]);
return list.toArray(new String[0]);
}
@NonNull
@ -247,7 +247,7 @@ public final class MoreKeySpec {
if (out == null) {
return array;
}
return out.toArray(new String[out.size()]);
return out.toArray(new String[0]);
}
public static String[] insertAdditionalMoreKeys(@Nullable final String[] moreKeySpecs,
@ -300,7 +300,7 @@ public final class MoreKeySpec {
if (out == null && moreKeysCount > 0) {
return moreKeys;
} else if (out != null && out.size() > 0) {
return out.toArray(new String[out.size()]);
return out.toArray(new String[0]);
} else {
return null;
}

View file

@ -242,11 +242,11 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
final EditorInfo editorInfo = new EditorInfo();
editorInfo.inputType = InputType.TYPE_CLASS_TEXT;
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo);
builder.setKeyboardGeometry(
SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT);
builder.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype));
builder.setIsSpellChecker(true /* isSpellChecker */);
builder.disableTouchPositionCorrectionData();
return builder.build();
return builder
.setKeyboardGeometry(SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT)
.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype))
.setIsSpellChecker(true /* isSpellChecker */)
.disableTouchPositionCorrectionData()
.build();
}
}

View file

@ -20,6 +20,8 @@ import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import androidx.annotation.NonNull;
import org.dslul.openboard.inputmethod.keyboard.Key;
import org.dslul.openboard.inputmethod.keyboard.Keyboard;
import org.dslul.openboard.inputmethod.keyboard.KeyboardActionListener;
@ -53,7 +55,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
// TODO: Remove redundant override method.
@Override
public void setKeyboard(final Keyboard keyboard) {
public void setKeyboard(@NonNull final Keyboard keyboard) {
super.setKeyboard(keyboard);
mIsInModalMode = false;
// With accessibility mode off, {@link #mAccessibilityDelegate} is set to null at the
@ -69,7 +71,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
@Override
protected int getDefaultCoordX() {
final MoreSuggestions pane = (MoreSuggestions)getKeyboard();
final MoreSuggestions pane = (MoreSuggestions) getKeyboard();
return pane.mOccupiedWidth / 2;
}