summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2021-05-21 19:20:08 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2021-05-21 22:00:24 +0200
commit4a9eef7849a75ba91806886ea9c96d114c8d56f9 (patch)
tree29ae6ac9486c8fb3298822dce598cfa516f948e9 /android
parent817c89fa456917fd9993ae226e8e932fe90ee1d8 (diff)
tdf#106893 android: Show whole doc when closing soft keyboard
When closing the software keyboard after typing, a black area instead of the doc content was shown in Android Viewer. This looks related to the fact that a SurfaceView is involved, s.a. [1] which suggests two potential solutions to fix the issue, but none of them really works well. (Setting a transparent background didn't have any effect when I tried. Using 'android:windowSoftInputMode="adjustPan"' in AndroidManifest.xml would work in general, but trigger the problem described in tdf#96789, namely the software keyboard would be shown on top of the document and the last part of the document would not be visible with the software keyboard enabled any more.) Rather, make sure an 'LOEvent.SIZE_CHANGED' is triggered when the software keyboard is enabled or disabled, in which case 'LayerView#onLayout' is called with a 'changed=true' parameter. To avoid resetting zoom and position of the document for this case, call the 'redraw' function with param 'false' when processing this type of event in 'LOKitThread#processEvent' (s.a. Change-Id: I8ba6a7cd8d984ad99654e188e00144e1edf407ed, "android: Don't reset zoom and position on refresh event" that did a similar thing for 'LOEvent.REFRESH'). This adds a 'force' boolean parameter to 'GeckoLayerClient#sendResizeEventIfNecessary', which interestingly had been there before commit 43bbf53bbad4623355e6344094573f8efca01df2 Date: Tue Jan 27 13:01:53 2015 +0900 android: remove unneded code from GeckoLayerClient but I didn't further check whether it had been used in any way that would have been useful for this scenario back then. Stackoverflow article [2] was quite helpful. [1] https://stackoverflow.com/questions/2978290/androids-edittext-is-hidden-when-the-virtual-keyboard-is-shown-and-a-surfacevie [2] https://stackoverflow.com/questions/52223095/how-to-detect-redraw-of-screen-has-completed-after-soft-keyboard-closes Change-Id: If3fdd1335468fc50901fc6c1982c1463c7804309 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115973 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java2
-rw-r--r--android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java16
-rw-r--r--android/source/src/java/org/mozilla/gecko/gfx/LayerView.java4
3 files changed, 12 insertions, 10 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 547cb4acc6d2..a4d5ba99f1a2 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -295,7 +295,7 @@ class LOKitThread extends Thread {
closeDocument();
break;
case LOEvent.SIZE_CHANGED:
- redraw(true);
+ redraw(false);
break;
case LOEvent.CHANGE_PART:
changePart(event.mPartIndex);
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 681fb6fd6019..72a96f0bb00f 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -80,7 +80,7 @@ public class GeckoLayerClient implements PanZoomTarget {
mView.setLayerRenderer(mLayerRenderer);
- sendResizeEventIfNecessary();
+ sendResizeEventIfNecessary(false);
mView.requestRender();
}
@@ -124,21 +124,23 @@ public class GeckoLayerClient implements PanZoomTarget {
* to the layer client. That way, the layer client won't be tempted to call this, which might
* result in an infinite loop.
*/
- void setViewportSize(FloatSize size) {
+ void setViewportSize(FloatSize size, boolean forceResizeEvent) {
mViewportMetrics = mViewportMetrics.setViewportSize(size.width, size.height);
- sendResizeEventIfNecessary();
+ sendResizeEventIfNecessary(forceResizeEvent);
}
PanZoomController getPanZoomController() {
return mPanZoomController;
}
- /* Informs Gecko that the screen size has changed. */
- private void sendResizeEventIfNecessary() {
+ /* Informs Gecko that the screen size has changed.
+ * @param force: If true, a resize event will always be sent, otherwise
+ * it is only sent if size has changed. */
+ private void sendResizeEventIfNecessary(boolean force) {
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
- if (mScreenSize.equals(newScreenSize)) {
+ if (!force && mScreenSize.equals(newScreenSize)) {
return;
}
@@ -233,7 +235,7 @@ public class GeckoLayerClient implements PanZoomTarget {
}
private void geometryChanged() {
- sendResizeEventIfNecessary();
+ sendResizeEventIfNecessary(false);
if (getRedrawHint()) {
adjustViewport(null);
}
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java b/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
index 549b2a963bf5..c9c5ca003297 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -302,7 +302,7 @@ public class LayerView extends FrameLayout {
private void onSizeChanged(int width, int height) {
mGLController.surfaceChanged(width, height);
- mLayerClient.setViewportSize(new FloatSize(width, height));
+ mLayerClient.setViewportSize(new FloatSize(width, height), false);
if (mListener != null) {
mListener.surfaceChanged(width, height);
@@ -367,7 +367,7 @@ public class LayerView extends FrameLayout {
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (changed) {
- mLayerClient.setViewportSize(new FloatSize(right - left, bottom - top));
+ mLayerClient.setViewportSize(new FloatSize(right - left, bottom - top), true);
}
}