added a workaround for showing the MainView on really stubborn phones like Sonim XP3900
This commit is contained in:
parent
31ca39bfb0
commit
16fbef0b8f
5 changed files with 22 additions and 12 deletions
|
|
@ -28,7 +28,7 @@ abstract public class AbstractHandler extends InputMethodService {
|
|||
// UI
|
||||
abstract protected View createMainView();
|
||||
abstract protected void createSuggestionBar(View mainView);
|
||||
abstract protected void forceShowWindowIfHidden();
|
||||
abstract protected void forceShowWindow(boolean forceHarder);
|
||||
abstract protected void renderMainView();
|
||||
abstract protected void setStatusIcon(InputMode mode);
|
||||
abstract protected void setStatusText(String status);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public abstract class HotkeyHandler extends TypingHandler {
|
|||
|
||||
if (!suggestionOps.isEmpty()) {
|
||||
if (shouldBeVisible() && !isInputViewShown()) {
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(true);
|
||||
} else {
|
||||
onAcceptSuggestionManually(suggestionOps.acceptCurrent(), KeyEvent.KEYCODE_ENTER);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ public abstract class HotkeyHandler extends TypingHandler {
|
|||
if (action == TextField.IME_ACTION_ENTER) {
|
||||
boolean actionPerformed = appHacks.onEnter();
|
||||
if (actionPerformed) {
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(false);
|
||||
}
|
||||
return actionPerformed;
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ public abstract class HotkeyHandler extends TypingHandler {
|
|||
DictionaryLoader.autoLoad(this, mLanguage);
|
||||
}
|
||||
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ public abstract class HotkeyHandler extends TypingHandler {
|
|||
UI.toastShortSingle(this, mInputMode.getClass().getSimpleName(), mInputMode.toString());
|
||||
}
|
||||
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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;
|
||||
|
|
@ -21,6 +22,7 @@ import io.github.sspanak.tt9.ui.UI;
|
|||
import io.github.sspanak.tt9.ui.dialogs.PopupDialog;
|
||||
import io.github.sspanak.tt9.ui.main.MainView;
|
||||
import io.github.sspanak.tt9.ui.tray.StatusBar;
|
||||
import io.github.sspanak.tt9.util.DeviceInfo;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
|
||||
public class TraditionalT9 extends HotkeyHandler {
|
||||
|
|
@ -36,7 +38,7 @@ public class TraditionalT9 extends HotkeyHandler {
|
|||
|
||||
String message = intent != null ? intent.getStringExtra(PopupDialog.INTENT_CLOSE) : null;
|
||||
if (message != null) {
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(false);
|
||||
if (!message.isEmpty()) {
|
||||
UI.toastLong(this, message);
|
||||
}
|
||||
|
|
@ -164,14 +166,14 @@ public class TraditionalT9 extends HotkeyHandler {
|
|||
|
||||
|
||||
/**
|
||||
* forceShowWindowIfHidden
|
||||
* forceShowWindow
|
||||
* Some applications may hide our window and it remains invisible until the screen is touched or OK is pressed.
|
||||
* This is fine for touchscreen keyboards, but the hardware keyboard allows typing even when the window and the suggestions
|
||||
* are invisible. This function forces the InputMethodManager to show our window.
|
||||
* WARNING! Calling this may cause a restart, which will cause InputMode to be recreated. Depending
|
||||
* on how much time the restart takes, this may erase the current user input.
|
||||
*/
|
||||
protected void forceShowWindowIfHidden() {
|
||||
protected void forceShowWindow(boolean forceHarder) {
|
||||
if (isInputViewShown() || !shouldBeVisible()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -181,6 +183,12 @@ public class TraditionalT9 extends HotkeyHandler {
|
|||
} 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.
|
||||
if (forceHarder && !isInputViewShown() && DeviceInfo.noTouchScreen(this)) {
|
||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
textField.setText(text);
|
||||
autoCorrectSpace(text, true, -1);
|
||||
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
String trimmedWord = suggestionOps.getCurrent(mInputMode.getSequenceLength());
|
||||
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
|
||||
|
||||
forceShowWindowIfHidden();
|
||||
forceShowWindow(false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue