agamemnus / cordova-plugin-xapkreader

Easily access Google Play APK expansion file data.
32 stars 55 forks source link

Plugin installation is preventing the SoftKeyboard from pushing the content up #115

Open nandukalidindi opened 6 years ago

nandukalidindi commented 6 years ago

First off, that you for this wonderful plugin!

I successfully am able to get it working with the expansion files and published 2 apps thanks to this.

However, recently I found out that after the installation of the plugin the SoftKeyboard that shows up while entering into textboxes is not pushing the content, rather the content just stays as is. This could be a problem for me because I would like the users to see what they are typing on the textbox.

BEFORE INSTALLATION: screen shot 2017-11-01 at 11 17 07 pm

AFTER INSTALLATION screen shot 2017-11-01 at 11 13 18 pm

The textbox is infact behind the SoftKeyboard. The red rectangle is just some text. The white form starts right below the rectangle and that contains the textbox to be typed into.

I tried debugging it before and after the plugin installation and I am positive that this happens only after the installation.

Is there a chance that the resizing is deliberately disabled through the extension?

Thanks.

agamemnus commented 6 years ago

What if you remove the extension after installing it? Still like you didn't install it? (normal?)

nandukalidindi commented 6 years ago

Yes, cordova plugin remove com.flyingsoftgames.xapkreader removing the plugin brought it back to normal, as in the SoftKeyboard is resizing/pushing the content as expected.

agamemnus commented 6 years ago

Ok, I found something in plugin.xml.

  <config-file target="AndroidManifest.xml" parent="application">
   <activity android:name="com.flyingsoftgames.xapkreader.XAPKDownloaderActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
   </activity>

Maybe something in these config changes is doing this...

agamemnus commented 6 years ago

But then again, you want the keyboard to be hidden when the downloader bar shows so I am not sure.

nandukalidindi commented 6 years ago

Earlier today I tried adding android:windowSoftInputMode="adjustResize" to the XAPKDownloaderActivity but that did not work. Now, after modifying the activity to this <activity android:label="@string/app_name" android:name="com.flyingsoftgames.xapkreader.XAPKDownloaderActivity" /> it still does not work.

agamemnus commented 6 years ago

Can you check to see if anything is changing in the meta headers in the generated html file maybe?

agamemnus commented 6 years ago

I guess try to see exactly what changes in the two different outputs.

nandukalidindi commented 6 years ago

I don't see any HTML files being generated during the installation. Could you please tell which one is it that you meant.

agamemnus commented 6 years ago

Well, when you create a package, generated stuff goes into a separate directory, right...?

nandukalidindi commented 6 years ago

screen shot 2017-11-01 at 11 42 26 pm

These are the changed/added files. Would you be able to guess which could possibly cause this?

agamemnus commented 6 years ago

Maybe in the manifest xml? Or possibly the config.xml.

nandukalidindi commented 6 years ago

You mean when I do cordova build android? I did not yet do that step yet, it's failing right here. Please excuse me if I am not providing you exact inputs, I am a total beginner with Cordova and Android.

config.xml screen shot 2017-11-01 at 11 46 46 pm

AndroidManifest.xml screen shot 2017-11-01 at 11 47 12 pm

android/res/xml/config.xml screen shot 2017-11-01 at 11 46 15 pm

I don't feel any of these caused that.

nandukalidindi commented 6 years ago

Have you ever faced this similar problem on one of your apps where you used your plugin?

agamemnus commented 6 years ago

I don't remember. I just set the meta tag so it does not resize.

agamemnus commented 6 years ago

Oh, I get it.... you need the opposite...

agamemnus commented 6 years ago

How about this? Try and see if you can get it to work... https://stackoverflow.com/questions/31407367/on-screen-keyboard-resizes-app-when-an-input-box-is-selected-apache-cordova-visu

But this is def. an issue that should be resolved somehow without it, probably.

nandukalidindi commented 6 years ago

Yeah, I can install another plugin, not at all a problem. Let me check it and get back to you tomorrow? Keyboard.shrinkView(true); this addition hopefully resolves it temporarily.

nandukalidindi commented 6 years ago

Thank you so much for the discussion though.

agamemnus commented 6 years ago

Sure. Let me know how it goes!

nandukalidindi commented 6 years ago

So, I should add Keyboad.shrinkView after the onload in my JS file? Or is it somewhere in the Android app?

agamemnus commented 6 years ago

Unsure. Try both ways (after the onload and before you show the form) I guess...

nandukalidindi commented 6 years ago

Seems like the shrinkView method is only supported in iOS https://www.npmjs.com/package/cordova-plugin-keyboard#keyboardshrinkview

agamemnus commented 6 years ago

Unclear.... I dunno, there must be a way... maybe just meta tags.....

nandukalidindi commented 6 years ago

Could you please share the snippet where you add the <meta> tag if possible? I will spend more time anyway, so will let you know if anything pans out.

agamemnus commented 6 years ago

check the options for the viewport meta tag.

nandukalidindi commented 6 years ago

@agamemnus

@Override public void onCreate (Bundle savedInstanceState) {

  if (cordovaActivity != null) {
   // <Workaround for Cordova/Crosswalk flickering status bar bug./>
   // cordovaActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
   // cordovaActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
   // <Workaround for Cordova/Crosswalk flickering status bar bug./>
  }
.
.
.
.
}

Commenting the workaround to be full screen in XAPKDownloaderActivity.java in your source code did the trick and now it is working as expected. The SoftKeyboard is pushing the content up while typing.

Once again, thank you for the discussion and the awesome plugin. Cheers!

agamemnus commented 6 years ago

Well, I need to fix this somehow.

Can you clarify something for me?

You said: "However, recently I found out that after the installation of the plugin the SoftKeyboard that shows up while entering into textboxes is not resizing/pushing the content, rather the content just stays as is. This could be a problem for me because I would like the users to see what they are typing on the textbox."

So you are saying that you want the content to be resized and bigger, but your screenshots suggest you DON'T want the content to be resized. Was it a typo?

nandukalidindi commented 6 years ago

I want the user to be able to see what she/he is typing on the textbox. In my case the softkeyboard just blocks the textbox(AFTER INSTALLATION screenshot) without bringing the textbox to focus like in the BEFORE INSTALLATION screenshot. May be I should remove the resizing word to avoid confusion.

agamemnus commented 6 years ago

But after installation, the app does seem to resize and bring something else to focus, and not the textbox that the user was typing in?

???????

The red rectangle is causing a lot of confusion for me.

What if you change the code to as follows:

  if (cordovaActivity != null) {
   // <Workaround for Cordova/Crosswalk flickering status bar bug./>
   int original_FLAG_FULLSCREEN = WindowManager.LayoutParams.FLAG_FULLSCREEN
   cordovaActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
   cordovaActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, original_FLAG_FULLSCREEN);
   // <Workaround for Cordova/Crosswalk flickering status bar bug./>
  }
nandukalidindi commented 6 years ago

Red rectangle is just to hide some private content. But as you can see the login form starts right after the red rectangle which is supposed to be pushed up like in the first screenshot.

Before commenting out the code in XAPKDownloaderActivity.java the view stays as is without moving, so I was not able to see what I was typing in the textbox. Sorry if this is too confusing. I am currently working on another laptop, let me try that and let you know in about 4 hours?

agamemnus commented 6 years ago

Great, thanks.

nandukalidindi commented 6 years ago

The snippet you provided 2 comments above did not work. I checked it a while back.

agamemnus commented 6 years ago

OK. I'll investigate further to see if I can solve this without commenting out that code. Thanks.

MajorBreakfast commented 6 years ago

This is related to https://github.com/agamemnus/cordova-plugin-xapkreader/issues/117.

The resize behavior is connected to the visibility of the status bar. I can reproduce this by calling StatusBar.hide() manually from the chrome dev tools remote device console. After the status bar is hidden, the app isn't resized anymore.

Edit: One can also see that @nandukalidindi 's screenshot after the installation of the plugin has no status bar.

erobertson42 commented 4 years ago

I know this issue is old, but I ran into this same bug today, and I'm kicking myself for not checking here before spending the majority of the day tracking it down and fixing it.

So, @nandukalidindi was on the right track.

The setting android:windowSoftInputMode="adjustResize" in the AndroidManifest.xml file is what allows the keyboard to resize the view, so that it doesn't overlap the content. However, this setting is ignored if the app is in fullscreen mode.

The code that (s)he points out forces the app into fullscreen mode, but doesn't ever change it back if applicable, so it stays that way and thus breaks the soft keyboard setting. I was able to fix it by first checking/storing the current setting, and changing it back when the activity is finished, if it changed.

Here is the pull request: https://github.com/agamemnus/cordova-plugin-xapkreader/pull/139

My knowledge of Android development using Java is limited, so this should definitely be given some scrutiny. However, my own testing seems to show that it's working.

agamemnus commented 4 years ago

Okay. I also noticed you added another check. Thank you.