fixed the system spellchecker not being detected on CAT S22 Flip
This commit is contained in:
parent
685cbc1b4f
commit
67dd940376
2 changed files with 35 additions and 1 deletions
|
|
@ -0,0 +1,10 @@
|
||||||
|
package io.github.sspanak.tt9.preferences.screens.setup;
|
||||||
|
|
||||||
|
import android.view.textservice.SentenceSuggestionsInfo;
|
||||||
|
import android.view.textservice.SpellCheckerSession;
|
||||||
|
import android.view.textservice.SuggestionsInfo;
|
||||||
|
|
||||||
|
class DummySpellCheckerListener implements SpellCheckerSession.SpellCheckerSessionListener {
|
||||||
|
public void onGetSuggestions(SuggestionsInfo[] results){}
|
||||||
|
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results){}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package io.github.sspanak.tt9.preferences.screens.setup;
|
package io.github.sspanak.tt9.preferences.screens.setup;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.service.textservice.SpellCheckerService;
|
import android.service.textservice.SpellCheckerService;
|
||||||
|
import android.view.textservice.SpellCheckerSession;
|
||||||
|
import android.view.textservice.TextServicesManager;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
|
@ -18,13 +21,14 @@ public class ItemSpellCheck extends ItemClickable {
|
||||||
if (DeviceInfo.noTouchScreen(activity)) {
|
if (DeviceInfo.noTouchScreen(activity)) {
|
||||||
disable();
|
disable();
|
||||||
item.setVisible(false);
|
item.setVisible(false);
|
||||||
} else if (isSpellCheckEnabled(activity)) {
|
} else if (isSpellCheckEnabled(activity) || isTextSpellCheckerEnabled(activity)) {
|
||||||
enable();
|
enable();
|
||||||
} else {
|
} else {
|
||||||
disable();
|
disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isSpellCheckEnabled(PreferencesActivity activity) {
|
private boolean isSpellCheckEnabled(PreferencesActivity activity) {
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -34,6 +38,23 @@ public class ItemSpellCheck extends ItemClickable {
|
||||||
return activity.getPackageManager().resolveService(spellCheckIntent, 0) != null;
|
return activity.getPackageManager().resolveService(spellCheckIntent, 0) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isTextSpellCheckerEnabled(PreferencesActivity activity) {
|
||||||
|
if (activity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextServicesManager tsm = (TextServicesManager) activity.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
|
||||||
|
SpellCheckerSession session = tsm.newSpellCheckerSession(null, null, new DummySpellCheckerListener(), true);
|
||||||
|
if (session == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
session.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
@ -43,6 +64,7 @@ public class ItemSpellCheck extends ItemClickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
|
|
@ -51,6 +73,7 @@ public class ItemSpellCheck extends ItemClickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableClickHandler() {
|
public void enableClickHandler() {
|
||||||
if (item != null && item.isEnabled()) {
|
if (item != null && item.isEnabled()) {
|
||||||
|
|
@ -58,6 +81,7 @@ public class ItemSpellCheck extends ItemClickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onClick(Preference p) {
|
protected boolean onClick(Preference p) {
|
||||||
return UI.showSystemSpellCheckerSettings(p.getContext());
|
return UI.showSystemSpellCheckerSettings(p.getContext());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue