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

[Android] Softkeyboard overlap HTML text input field when you focus on input with StageWebView #128

Open
itlancer opened this issue Oct 13, 2019 · 3 comments

Comments

@itlancer
Copy link

Problem Description

Softkeyboard overlap HTML text input field when you focus on input with StageWebView.
It happens if text input on web page at the bottom of screen and soft keyboard will be displayed over it.
Tested with multiple Android devices with different web pages and different OS versions and firmwares.
It has been tested with many different AIR versions even with latests AIR 32.0.0.144 beta and AIR 33.0.2.281.
The same problem in all cases.
It works fine for iOS.

Changing android:hardwareAccelerated in application manifest doesn't help.
Changing android:windowSoftInputMode in application manifest doesn't help.
<softKeyboardBehavior>pan</softKeyboardBehavior> and other values doesn't help.
Changing renderMode in application manifest doesn't help.

Tracker and related issues:
https://tracker.adobe.com/#/view/AIR-4159718
https://forum.starling-framework.org/d/11407-soft-keyboard-goes-over-stagewebview
https://community.adobe.com/t5/Air/Android-StageWebView-HTML-text-input-does-not-pan-app-when/td-p/8355529
https://stackoverflow.com/questions/22776614/push-up-keyboard-on-screen

Steps to Reproduce

Launch code below with any Android device. It will load test web page with many text inputs. Click on any text input which displayed at the bottom of screen.
Application example with sources attached.
stagewebview_textinput_softkeyboard_bug.zip

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.StageWebView;
	import flash.geom.Rectangle;
	
	public class StageWebViewTextInputSoftKeyboardBug extends Sprite {
		private var stageWebView:StageWebView;
		
		public function StageWebViewTextInputSoftKeyboardBug() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stageWebView = new StageWebView(true);
			stageWebView.loadURL("https://codepen.io/maheshambure21/full/EozKKy");
			stageWebView.viewPort = new Rectangle(0, 0, 1080, 1920);//You can change viewport for your test device
			stageWebView.stage = stage;
		}
	}
}

Actual Result:
Softkeyboard overlap text input that user cannot see what entering.

Expected Result:
StageWebView content should pan so that the text field being targeted in always visible so users can see which text they are entering. This panning should be handled automatically by AIR.

Known Workarounds

none

@marcanw
Copy link

marcanw commented Oct 20, 2019

I faced this issue long time ago.
On android I had to monitor the keyboard size (some ane let you get the keyboard size) and adapt the viewport according it.

@itlancer
Copy link
Author

I faced this issue long time ago.
On android I had to monitor the keyboard size (some ane let you get the keyboard size) and adapt the viewport according it.

@marcanw, I can get real keyboard size via ANE but how to move web page inside StageWebView to make html text input field visible for user in such cases?

@marcanw
Copy link

marcanw commented Oct 20, 2019

You just have to resize the viewport of the StageWebView in order to have the bottom of the viewport just on top of the keyboard. So the bottom of your page will be visible maybe after a scroll of the user but it will be possible for the user to see it.
Here is my code:

var kby:int = getKeyboardY();
var vh:int = webView.viewPort.height;
if(kby < vh) webView.viewPort = new Rectangle(0, 0,w, kby);
else if(kby > vh && svaH != vh) webView.viewPort = new Rectangle(0, 0,w, h);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants