Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): amend constants for showSoftKeyboard() #11309

Merged
merged 3 commits into from Nov 6, 2019

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Oct 31, 2019

  • Amend constants used in showSoftKeyboard()
TEST CASE #1
const win = Ti.UI.createWindow({
    backgroundColor: 'white',
    layout: 'vertical'
});
const textField = Ti.UI.createTextField({
    backgroundColor: '#fafafa',
    color: 'green',
    width: 250,
    top: 30,
    height: 40
});
const test = Ti.UI.createButton({
    title: 'test',
    height: 50,
    width: 100,
    top: 30
});

test.addEventListener('click', _ => {
    Ti.UI.Android.hideSoftKeyboard();
});

win.add([ textField, test ]);
win.open();
TEST CASE #2
const win = Ti.UI.createWindow({
    backgroundColor: 'gray',
    layout: 'vertical'
});

const txt_a = Ti.UI.createTextField({
    hintText: 'Text Field #1',
    width: '90%'
});
const txt_b = Ti.UI.createTextField({
    hintText: 'Text Field #2',
    width: '90%'
});
const txt_c = Ti.UI.createTextField({
    hintText: 'Text Field #3',
    width: '90%',
    softKeyboardOnFocus: Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});

txt_a.addEventListener('return', _ => {
    Ti.API.info(`'return' event fired on 'Text Field #1'`);
    txt_c.focus();
    Ti.API.info(`Set focus to 'Text Field #3'`);
});

win.add([ txt_a, txt_b, txt_c ]);
win.open();
  1. Enter text into Text Field #1
  2. Press Enter
  3. Text Field #3 should focus and allow text entry

JIRA Ticket

@build
Copy link
Contributor

build commented Oct 31, 2019

Messages
📖

✅ All tests are passing
Nice one! All 141 tests are passing.

📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.

Generated by 🚫 dangerJS against ece4dd5

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: Pass

@ssjsamir
Copy link
Contributor

ssjsamir commented Nov 1, 2019

@garymathews For the second test case should the keyboard automatically appear when Text Field #3 focuses as of right now it does not and you need to click in to Text Field #3. Test case one works as expected.

Test Environment

MacOS Catalina 10.15.1 beta
Xcode 11 
Node.js 10.16.3
Pixel XL (Android 10)
Pixel 7.1.1 Sim 
{"NPM":"4.2.15-1","CLI":"7.1.1"}

@jquick-axway
Copy link
Contributor

@ssjsamir, for test 2, does it show the virtual keyboard in Titanium 8.2.0 or older versions? I remember the TextField.focus() method automatically showing the virtual keyboard before.

@ssjsamir
Copy link
Contributor

ssjsamir commented Nov 1, 2019

@jquick-axway Using 8.2.0.GA the keyboard stays focused when it moves from Text Field 1 to Text field 3

@garymathews
Copy link
Contributor Author

garymathews commented Nov 1, 2019

I believe you need to specify softKeyboardOnFocus on the TextField for it to show.

...
const txt_c = Ti.UI.createTextField({
    hintText: 'Text Field #3',
    width: '90%',
    softKeyboardOnFocus: Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS
});
...

@lokeshchdhry
Copy link
Contributor

@garymathews , with 8.2.1.GA the keyboard stays focused when you hit enter & go to the 3rd textfield unlike this PR.

@garymathews
Copy link
Contributor Author

@lokeshchdhry Yep, but that behavior is wrong. softKeyboardOnFocus: Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS should be specified for that to happen.

@lokeshchdhry
Copy link
Contributor

FR Passed.

Studio Ver: 5.1.4.201909061933
SDK Ver: 8.3.0 local build
OS Ver: 10.14.5
Xcode Ver: Xcode 11.1
Appc NPM: 4.2.15
Appc CLI: 7.1.2-master.3
Daemon Ver: 1.1.3
Ti CLI Ver: 5.2.2
Alloy Ver: 1.14.1
Node Ver: 12.13.0
NPM Ver: 6.12.0
Java Ver: 10.0.2
Android Devices: ⇨ google Pixel (Android 9)
Emulator: Android 6.0

@ssaddique
Copy link
Contributor

I've tested this extensively and can confirm that this PR fixes the issue in relation to Test Case 1. However, I don't think this PR fixes the issue entirely for Test Case 2. It's quite buggy.

Results
Emulator API 26-29 (8.2.0.GA): Typing in TextField1 and hitting Return results in Focus on TextField3 while virtual keyboard is still shown. To actually type in TextField3, you must click on TextField3 first.

Emulator API 26-29 (8.2.1.GA): Typing in TextField1 and hitting Return results in Focus on TextField3, while virtual keyboard is still shown. However, it is not required to click on TextField3 to type into it as in 8.2.0.GA. You can start typing right away upon return/focus of TextField3.

Emulator API 26-29 (this PR): Upon hitting return from TextField1, the keyboard disappears but the focus is now on TextField3. To bring up the keyboard, you must click on TextField3 to start typing.

Note: using softKeyboardOnFocus: Ti.UI.Android.SOFT_KEYBOARD_SHOW_ON_FOCUS results in endless warnings in the terminal, and overall reduced performance of the emulator. The errors shown are:

[WARN]  IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
[WARN]  IInputConnectionWrapper: getSelectedText on inactive InputConnection
[WARN]  IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection
[WARN]  IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
[WARN]  IInputConnectionWrapper: endBatchEdit on inactive InputConnection

Device Nexus 5X API 26: Both 8.2.0.GA and 8.2.1.GA function the same. Upon hitting return, you can start typing immediately in TextField3 without having to tap on TextField3 first.

Device Nexus 5X API 26 (this PR): With this PR build, the app fails to launch entirely. Error(s) shown below:

[WARN]  W/System.err: java.lang.ClassNotFoundException: Didn't find class "ti.modules.titanium.platform.PlatformModule" on path: DexPathList[[zip file "/data/app/com.axway.timob-QiAVF3Dz4l8PXeBh0MkQig==/base.apk"],nativeLibraryDirectories=[/data/app/com.axway.timob-QiAVF3Dz4l8PXeBh0MkQig==/lib/arm64, /data/app/com.axway.timob-QiAVF3Dz4l8PXeBh0MkQig==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
[WARN]  W/System.err:   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
[WARN]  W/System.err:   at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[WARN]  W/System.err:   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:168)
[WARN]  W/System.err:   at org.appcelerator.kroll.KrollRuntime.runModule(KrollRuntime.java:225)
[WARN]  W/System.err:   at org.appcelerator.titanium.TiLaunchActivity.loadScript(TiLaunchActivity.java:107)
[WARN]  W/System.err:   at org.appcelerator.titanium.TiRootActivity.loadScript(TiRootActivity.java:480)
[WARN]  W/System.err:   at org.appcelerator.titanium.TiLaunchActivity.onResume(TiLaunchActivity.java:192)
[WARN]  W/System.err:   at org.appcelerator.titanium.TiRootActivity.onResume(TiRootActivity.java:499)
[WARN]  W/System.err:   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1354)
[WARN]  W/System.err:   at android.app.Activity.performResume(Activity.java:7079)
[WARN]  W/System.err:   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3620)
[WARN]  W/System.err:   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3685)
[WARN]  W/System.err:   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2898)
[WARN]  W/System.err:   at android.app.ActivityThread.-wrap11(Unknown Source:0)
[WARN]  W/System.err:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
[WARN]  W/System.err:   at android.os.Handler.dispatchMessage(Handler.java:105)
[WARN]  W/System.err:   at android.os.Looper.loop(Looper.java:164)
[WARN]  W/System.err:   at android.app.ActivityThread.main(ActivityThread.java:6541)
[WARN]  W/System.err:   at java.lang.reflect.Method.invoke(Native Method)
[WARN]  W/System.err:   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
[ERROR] KrollProxy: (main) [30,30] Error creating proxy
[ERROR] KrollProxy: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.Class.newInstance()' on a null object reference

Test Environment

Studio Ver:     5.1.4.201909061933
SDK Ver:        8.3.0.v20191030085531
OS Ver:         10.14.6
Appc NPM:       4.2.15
Appc CLI:       7.1.1
Daemon Ver:     1.1.3
Ti CLI Ver:     5.2.1
Alloy Ver:      1.14.1
Node Ver:       10.16.3
NPM Ver:        6.12.0

@garymathews
Copy link
Contributor Author

No idea why you are experiencing java.lang.ClassNotFoundException but it is unrelated to this issue. I have updated the PR to resolve the IInputConnectionWrapper spam and responsiveness.

8.2.1.GA has invalid behaviour due to the constants being wrong (that this PR resolves). The keyboard should not show on focus by default unless specified, this is default Android behaviour.

@lokeshchdhry
Copy link
Contributor

Changes verified.
No IInputConnectionWrapper logs seen.

@sgtcoolguy sgtcoolguy merged commit ae3da3a into tidev:master Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants