mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Fix issue where wrong IME inputType would be set if termux was returned to from another app with text input view mode selected
This commit is contained in:
@@ -452,7 +452,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
|
|
||||||
|
|
||||||
private void setTerminalToolbarView(Bundle savedInstanceState) {
|
private void setTerminalToolbarView(Bundle savedInstanceState) {
|
||||||
final ViewPager terminalToolbarViewPager = findViewById(R.id.terminal_toolbar_view_pager);
|
final ViewPager terminalToolbarViewPager = getTerminalToolbarViewPager();
|
||||||
if (mPreferences.shouldShowTerminalToolbar()) terminalToolbarViewPager.setVisibility(View.VISIBLE);
|
if (mPreferences.shouldShowTerminalToolbar()) terminalToolbarViewPager.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
||||||
@@ -469,8 +469,9 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setTerminalToolbarHeight() {
|
private void setTerminalToolbarHeight() {
|
||||||
final ViewPager terminalToolbarViewPager = findViewById(R.id.terminal_toolbar_view_pager);
|
final ViewPager terminalToolbarViewPager = getTerminalToolbarViewPager();
|
||||||
if (terminalToolbarViewPager == null) return;
|
if (terminalToolbarViewPager == null) return;
|
||||||
|
|
||||||
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
ViewGroup.LayoutParams layoutParams = terminalToolbarViewPager.getLayoutParams();
|
||||||
layoutParams.height = (int) Math.round(mTerminalToolbarDefaultHeight *
|
layoutParams.height = (int) Math.round(mTerminalToolbarDefaultHeight *
|
||||||
(mProperties.getExtraKeysInfo() == null ? 0 : mProperties.getExtraKeysInfo().getMatrix().length) *
|
(mProperties.getExtraKeysInfo() == null ? 0 : mProperties.getExtraKeysInfo().getMatrix().length) *
|
||||||
@@ -479,13 +480,13 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void toggleTerminalToolbar() {
|
public void toggleTerminalToolbar() {
|
||||||
final ViewPager terminalToolbarViewPager = findViewById(R.id.terminal_toolbar_view_pager);
|
final ViewPager terminalToolbarViewPager = getTerminalToolbarViewPager();
|
||||||
if (terminalToolbarViewPager == null) return;
|
if (terminalToolbarViewPager == null) return;
|
||||||
|
|
||||||
final boolean showNow = mPreferences.toogleShowTerminalToolbar();
|
final boolean showNow = mPreferences.toogleShowTerminalToolbar();
|
||||||
Logger.showToast(this, (showNow ? getString(R.string.msg_enabling_terminal_toolbar) : getString(R.string.msg_disabling_terminal_toolbar)), true);
|
Logger.showToast(this, (showNow ? getString(R.string.msg_enabling_terminal_toolbar) : getString(R.string.msg_disabling_terminal_toolbar)), true);
|
||||||
terminalToolbarViewPager.setVisibility(showNow ? View.VISIBLE : View.GONE);
|
terminalToolbarViewPager.setVisibility(showNow ? View.VISIBLE : View.GONE);
|
||||||
if (showNow && terminalToolbarViewPager.getCurrentItem() == 1) {
|
if (showNow && isTerminalToolbarTextInputViewSelected()) {
|
||||||
// Focus the text input view if just revealed.
|
// Focus the text input view if just revealed.
|
||||||
findViewById(R.id.terminal_toolbar_text_input).requestFocus();
|
findViewById(R.id.terminal_toolbar_text_input).requestFocus();
|
||||||
}
|
}
|
||||||
@@ -744,6 +745,20 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||||||
return (DrawerLayout) findViewById(R.id.drawer_layout);
|
return (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ViewPager getTerminalToolbarViewPager() {
|
||||||
|
return (ViewPager) findViewById(R.id.terminal_toolbar_view_pager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTerminalViewSelected() {
|
||||||
|
return getTerminalToolbarViewPager().getCurrentItem() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTerminalToolbarTextInputViewSelected() {
|
||||||
|
return getTerminalToolbarViewPager().getCurrentItem() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void termuxSessionListNotifyUpdated() {
|
public void termuxSessionListNotifyUpdated() {
|
||||||
mTermuxSessionListViewController.notifyDataSetChanged();
|
mTermuxSessionListViewController.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@@ -186,6 +186,11 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
return mActivity.getProperties().isUsingCtrlSpaceWorkaround();
|
return mActivity.getProperties().isUsingCtrlSpaceWorkaround();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTerminalViewSelected() {
|
||||||
|
return mActivity.getTerminalToolbarViewPager() == null || mActivity.isTerminalViewSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -262,20 +262,29 @@ public final class TerminalView extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||||
if (mClient.shouldEnforceCharBasedInput()) {
|
// Ensure that inputType is only set if TerminalView is selected view with the keyboard and
|
||||||
// Some keyboards seems do not reset the internal state on TYPE_NULL.
|
// an alternate view is not selected, like an EditText. This is necessary if an activity is
|
||||||
// Affects mostly Samsung stock keyboards.
|
// initially started with the alternate view or if activity is returned to from another app
|
||||||
// https://github.com/termux/termux-app/issues/686
|
// and the alternate view was the one selected the last time.
|
||||||
outAttrs.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
if (mClient.isTerminalViewSelected()) {
|
||||||
|
if (mClient.shouldEnforceCharBasedInput()) {
|
||||||
|
// Some keyboards seems do not reset the internal state on TYPE_NULL.
|
||||||
|
// Affects mostly Samsung stock keyboards.
|
||||||
|
// https://github.com/termux/termux-app/issues/686
|
||||||
|
outAttrs.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||||
|
} else {
|
||||||
|
// Using InputType.NULL is the most correct input type and avoids issues with other hacks.
|
||||||
|
//
|
||||||
|
// Previous keyboard issues:
|
||||||
|
// https://github.com/termux/termux-packages/issues/25
|
||||||
|
// https://github.com/termux/termux-app/issues/87.
|
||||||
|
// https://github.com/termux/termux-app/issues/126.
|
||||||
|
// https://github.com/termux/termux-app/issues/137 (japanese chars and TYPE_NULL).
|
||||||
|
outAttrs.inputType = InputType.TYPE_NULL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Using InputType.NULL is the most correct input type and avoids issues with other hacks.
|
// Corresponds to android:inputType="text"
|
||||||
//
|
outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
|
||||||
// Previous keyboard issues:
|
|
||||||
// https://github.com/termux/termux-packages/issues/25
|
|
||||||
// https://github.com/termux/termux-app/issues/87.
|
|
||||||
// https://github.com/termux/termux-app/issues/126.
|
|
||||||
// https://github.com/termux/termux-app/issues/137 (japanese chars and TYPE_NULL).
|
|
||||||
outAttrs.inputType = InputType.TYPE_NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that IME_ACTION_NONE cannot be used as that makes it impossible to input newlines using the on-screen
|
// Note that IME_ACTION_NONE cannot be used as that makes it impossible to input newlines using the on-screen
|
||||||
|
@@ -34,6 +34,8 @@ public interface TerminalViewClient {
|
|||||||
|
|
||||||
boolean shouldUseCtrlSpaceWorkaround();
|
boolean shouldUseCtrlSpaceWorkaround();
|
||||||
|
|
||||||
|
boolean isTerminalViewSelected();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void copyModeChanged(boolean copyMode);
|
void copyModeChanged(boolean copyMode);
|
||||||
|
@@ -33,6 +33,11 @@ public class TermuxTerminalViewClientBase implements TerminalViewClient {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTerminalViewSelected() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyModeChanged(boolean copyMode) {
|
public void copyModeChanged(boolean copyMode) {
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user