mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-22 17:10:53 +00:00
fix some warnings
This commit is contained in:
parent
cd33575446
commit
3f30d5ce1f
4 changed files with 12 additions and 30 deletions
|
@ -38,10 +38,10 @@ object TextInfoCompatUtils {
|
|||
*/
|
||||
@JvmStatic
|
||||
@UsedForTesting
|
||||
fun getCharSequenceOrString(textInfo: TextInfo?): CharSequence? {
|
||||
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 textInfo.charSequence
|
||||
val defaultValue = textInfo.text
|
||||
return CompatUtils.invoke(textInfo, defaultValue, TEXT_INFO_GET_CHAR_SEQUENCE) as CharSequence
|
||||
}
|
||||
}
|
|
@ -6,10 +6,8 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.spellcheck;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.textservice.SentenceSuggestionsInfo;
|
||||
|
@ -34,7 +32,6 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
|
|||
mResources = service.getResources();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
private SentenceSuggestionsInfo fixWronglyInvalidatedWordWithSingleQuote(TextInfo ti,
|
||||
SentenceSuggestionsInfo ssi) {
|
||||
final CharSequence typedText = TextInfoCompatUtils.getCharSequenceOrString(ti);
|
||||
|
@ -45,7 +42,6 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
|
|||
final ArrayList<Integer> additionalOffsets = new ArrayList<>();
|
||||
final ArrayList<Integer> additionalLengths = new ArrayList<>();
|
||||
final ArrayList<SuggestionsInfo> additionalSuggestionsInfos = new ArrayList<>();
|
||||
CharSequence currentWord = null;
|
||||
for (int i = 0; i < N; ++i) {
|
||||
final SuggestionsInfo si = ssi.getSuggestionsInfoAt(i);
|
||||
final int flags = si.getSuggestionsAttributes();
|
||||
|
@ -55,9 +51,6 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
|
|||
final int offset = ssi.getOffsetAt(i);
|
||||
final int length = ssi.getLengthAt(i);
|
||||
final CharSequence subText = typedText.subSequence(offset, offset + length);
|
||||
final NgramContext ngramContext =
|
||||
new NgramContext(new NgramContext.WordInfo(currentWord));
|
||||
currentWord = subText;
|
||||
if (!subText.toString().contains(AndroidSpellCheckerService.SINGLE_QUOTE)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -68,9 +61,7 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
|
|||
if (splitTexts == null || splitTexts.length <= 1) {
|
||||
continue;
|
||||
}
|
||||
final int splitNum = splitTexts.length;
|
||||
for (int j = 0; j < splitNum; ++j) {
|
||||
final CharSequence splitText = splitTexts[j];
|
||||
for (final CharSequence splitText : splitTexts) {
|
||||
if (TextUtils.isEmpty(splitText)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -92,7 +83,7 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
|
|||
}
|
||||
}
|
||||
final int additionalSize = additionalOffsets.size();
|
||||
if (additionalSize <= 0) {
|
||||
if (additionalSize == 0) {
|
||||
return null;
|
||||
}
|
||||
final int suggestionsSize = N + additionalSize;
|
||||
|
|
|
@ -6,10 +6,7 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.spellcheck;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.view.textservice.SentenceSuggestionsInfo;
|
||||
import android.view.textservice.SuggestionsInfo;
|
||||
import android.view.textservice.TextInfo;
|
||||
|
@ -17,7 +14,6 @@ import android.view.textservice.TextInfo;
|
|||
import org.dslul.openboard.inputmethod.compat.TextInfoCompatUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||
import org.dslul.openboard.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.RunInLocale;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -70,8 +66,7 @@ public class SentenceLevelAdapter {
|
|||
private static class WordIterator {
|
||||
private final SpacingAndPunctuations mSpacingAndPunctuations;
|
||||
public WordIterator(final Resources res, final Locale locale) {
|
||||
final RunInLocale<SpacingAndPunctuations> job =
|
||||
new RunInLocale<SpacingAndPunctuations>() {
|
||||
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<>() {
|
||||
@Override
|
||||
protected SpacingAndPunctuations job(final Resources r) {
|
||||
return new SpacingAndPunctuations(r, false);
|
||||
|
@ -152,7 +147,6 @@ public class SentenceLevelAdapter {
|
|||
return new SentenceTextInfoParams(originalTextInfo, wordItems);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
public static SentenceSuggestionsInfo reconstructSuggestions(
|
||||
SentenceTextInfoParams originalTextInfoParams, SuggestionsInfo[] results) {
|
||||
if (results == null || results.length == 0) {
|
||||
|
@ -172,8 +166,7 @@ public class SentenceLevelAdapter {
|
|||
for (int i = 0; i < querySize; ++i) {
|
||||
final SentenceWordItem item = originalTextInfoParams.mItems.get(i);
|
||||
SuggestionsInfo result = null;
|
||||
for (int j = 0; j < results.length; ++j) {
|
||||
final SuggestionsInfo cur = results[j];
|
||||
for (final SuggestionsInfo cur : results) {
|
||||
if (cur != null && cur.getSequence() == item.mTextInfo.getSequence()) {
|
||||
result = cur;
|
||||
result.setCookieAndSequence(originalCookie, originalSequence);
|
||||
|
|
|
@ -32,8 +32,8 @@ public final class SpellCheckerSettingsFragment extends SubScreenFragment
|
|||
private SwitchPreferenceCompat mLookupContactsPreference;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.spell_checker_settings);
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId(getActivity(), SpellCheckerSettingsActivity.class));
|
||||
|
@ -54,13 +54,11 @@ public final class SpellCheckerSettingsFragment extends SubScreenFragment
|
|||
}
|
||||
|
||||
// Check for permissions.
|
||||
if (PermissionsUtil.checkAllPermissionsGranted(
|
||||
getActivity() /* context */, Manifest.permission.READ_CONTACTS)) {
|
||||
if (PermissionsUtil.checkAllPermissionsGranted(getContext(), Manifest.permission.READ_CONTACTS)) {
|
||||
return; // all permissions granted, no need to request permissions.
|
||||
}
|
||||
|
||||
get(getActivity() /* context */).requestPermissions(this /* PermissionsResultCallback */,
|
||||
getActivity() /* activity */, Manifest.permission.READ_CONTACTS);
|
||||
get(requireContext()).requestPermissions(this, getActivity(), Manifest.permission.READ_CONTACTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue