1
0
Fork 0

the MainView now appears properly on Sonim XP3900

This commit is contained in:
sspanak 2024-04-25 15:46:52 +03:00 committed by Dimo Karaivanov
parent 1bd1807a0d
commit 0c32a2f113
4 changed files with 18 additions and 20 deletions

View file

@ -33,6 +33,10 @@ public class DeviceInfo {
return Build.MANUFACTURER.equals("Sonimtech");
}
public static boolean isSonimXP3900() {
return isSonim() && Build.MODEL.contains("XP3900");
}
@NonNull
@Override
public String toString() {

View file

@ -24,7 +24,7 @@ abstract public class AbstractHandler extends InputMethodService {
// UI
abstract protected void createSuggestionBar(View mainView);
abstract protected boolean forceShowWindow();
abstract protected void forceShowWindow();
abstract protected void renderMainView();
abstract protected void setStatusIcon(InputMode mode);
abstract protected void setStatusText(String status);

View file

@ -30,10 +30,6 @@ public abstract class HotkeyHandler extends TypingHandler {
@Override public boolean onOK() {
suggestionOps.cancelDelayedAccept();
if (forceShowWindow()) {
return true;
}
if (!suggestionOps.isEmpty()) {
onAcceptSuggestionManually(suggestionOps.acceptCurrent(), KeyEvent.KEYCODE_ENTER);
return true;

View file

@ -4,7 +4,6 @@ import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
@ -52,6 +51,15 @@ public class TraditionalT9 extends MainViewOps {
}
@Override
public void onComputeInsets(Insets outInsets) {
super.onComputeInsets(outInsets);
if (shouldBeVisible() && DeviceInfo.isSonimXP3900()) {
outInsets.contentTopInsets = 0; // otherwise the MainView wouldn't show up
}
}
@Override
public void onStartInput(EditorInfo inputField, boolean restarting) {
Logger.i(
@ -74,6 +82,7 @@ public class TraditionalT9 extends MainViewOps {
onFinishTyping();
}
@Override
public void onFinishInput() {
super.onFinishInput();
@ -223,27 +232,16 @@ public class TraditionalT9 extends MainViewOps {
* on how much time the restart takes, this may erase the current user input.
*/
@Override
protected boolean forceShowWindow() {
protected void forceShowWindow() {
if (isInputViewShown() || !shouldBeVisible()) {
return false;
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
requestShowSelf(InputMethodManager.SHOW_IMPLICIT);
requestShowSelf(DeviceInfo.isSonimXP3900() ? 0 : InputMethodManager.SHOW_IMPLICIT);
} else {
showWindow(true);
}
// Sonim XP3900 is quite stubborn and wouldn't show the MainView the regular way.
// Sending DPAD_CENTER seems to be the only way of doing it. But, we only want to do this
// when there is no text to avoid undesired submitting of something.
if (!isInputViewShown() && DeviceInfo.noTouchScreen(this) && textField.isEmpty()) {
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_CENTER);
} else {
return false;
}
return true;
}