Lagrange [work/v1.10]

Android: Keyboard height; other fixes

=> 001aeda1724eea630dd141c642bbdd61e2b9b69a

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 32f8afb2..94b70ea0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,7 @@ endif ()
 
 # Defaults that depend on environment.
 set (DEFAULT_RESIZE_DRAW ON)
-if (HAIKU)
+if (HAIKU OR ANDROID)
     set (DEFAULT_RESIZE_DRAW OFF)
 endif ()
 set (DEFAULT_IDLE_SLEEP OFF)
diff --git a/src/app.c b/src/app.c
index f5f7ae2b..27c8bef7 100644
--- a/src/app.c
+++ b/src/app.c
@@ -3432,8 +3432,21 @@ void closePopups_App(void) {
 }
 
 #if defined (iPlatformAndroidMobile)
+
 float displayDensity_Android(void) {
     iApp *d = &app_;
     return toFloat_String(at_CommandLine(&d->args, 1));
 }
+
+#include 
+
+JNIEXPORT void JNICALL Java_fi_skyjake_lagrange_SDLActivity_postAppCommand(
+        JNIEnv* env, jclass jcls,
+        jstring command)
+{
+    const char *cmd = (*env)->GetStringUTFChars(env, command, NULL);
+    postCommand_Root(NULL, cmd);
+    (*env)->ReleaseStringUTFChars(env, command, cmd);
+}
+
 #endif
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 0977da4a..04257a1c 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -3100,11 +3100,6 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) {
                             NULL);
                         insertChildAfter_Widget(buttons, iClob(lineBreak), 0);
                     }
-                    else {
-#if !defined (iPlatformAppleMobile)
-                        lineBreak = new_LabelWidget("${dlg.input.linebreak}", "text.insert arg:10");
-#endif
-                    }
                     if (lineBreak) {
                         setFlags_Widget(as_Widget(lineBreak), frameless_WidgetFlag, iTrue);
                         setTextColor_LabelWidget(lineBreak, uiTextDim_ColorId);
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 24983d69..2de16e6e 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -1269,8 +1269,8 @@ void end_InputWidget(iInputWidget *d, iBool accept) {
     if (!accept) {
         /* Overwrite the edited lines. */
         splitToLines_(&d->oldText, &d->lines);
-        SDL_StopTextInput();
     }
+    SDL_StopTextInput();
     enableEditorKeysInMenus_(iTrue);
     d->inFlags &= ~isMarking_InputWidgetFlag;
     startOrStopCursorTimer_InputWidget_(d, iFalse);
@@ -2153,11 +2153,11 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
             updateAfterVisualOffsetChange_InputWidget_(d, w->root);
         }
     }
-    else if (d->sysCtrl && isCommand_UserEvent(ev, "menu.opened")) {
+#endif
+    if (deviceType_App() != desktop_AppDeviceType && isCommand_UserEvent(ev, "menu.opened")) {
         setFocus_Widget(NULL);
         return iFalse;
     }
-#endif
     if (isCommand_Widget(w, ev, "focus.gained")) {
         if (contentBounds_InputWidget_(d).size.x < minWidth_InputWidget_) {
             setFocus_Widget(NULL);
diff --git a/src/ui/lookupwidget.c b/src/ui/lookupwidget.c
index c654e3cf..f14170ad 100644
--- a/src/ui/lookupwidget.c
+++ b/src/ui/lookupwidget.c
@@ -676,17 +676,19 @@ static iBool processEvent_LookupWidget_(iLookupWidget *d, const SDL_Event *ev) {
                                                max_I2(zero_I2(),
                                                       addX_I2(bottomLeft_Rect(bounds_Widget(url)),
                                                               -extraWidth / 2))));
-#if defined(iPlatformAppleMobile)
+#if defined(iPlatformMobile)
             /* TODO: Check this again. */
             /* Adjust height based on keyboard size. */ {
                 w->rect.size.y = bottom_Rect(visibleRect_Root(root)) - top_Rect(bounds_Widget(w));
+#   if defined (iPlatformAppleMobile)
                 if (deviceType_App() == phone_AppDeviceType) {
-                    float l, r;
+                    float l = 0.0f, r = 0.0f;
                     safeAreaInsets_iOS(&l, NULL, &r, NULL);
                     w->rect.size.x = size_Root(root).x - l - r;
                     w->rect.pos.x  = l;
                     /* TODO: Need to use windowToLocal_Widget? */
                 }
+#   endif
             }
 #endif
             arrange_Widget(w);
diff --git a/src/ui/root.c b/src/ui/root.c
index 9e264993..36ac948e 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -512,7 +512,10 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
         else {
             addChild_Widget(root, iClob(sidebar));
             setWidth_SidebarWidget(sidebar, (float) width_Widget(root) / (float) gap_UI);
-            const int midHeight = height_Widget(root) / 2;// + lineHeight_Text(uiLabelLarge_FontId);
+            int midHeight = height_Widget(root) / 2;// + lineHeight_Text(uiLabelLarge_FontId);
+#if defined (iPlatformAndroidMobile)
+            midHeight += 2 * lineHeight_Text(uiLabelLarge_FontId);
+#endif
             setMidHeight_SidebarWidget(sidebar, midHeight);
             setFixedSize_Widget(as_Widget(sidebar), init_I2(-1, midHeight));
             setPos_Widget(as_Widget(sidebar), init_I2(0, height_Widget(root) - midHeight));
diff --git a/src/ui/window.c b/src/ui/window.c
index d694146a..953d5ea4 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1008,6 +1008,13 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) {
                 postCommand_App("media.player.update"); /* in case a player needs updating */
                 return iTrue;
             }
+            if (event.type == SDL_USEREVENT && isCommand_UserEvent(ev, "window.sysframe") && mw) {
+                /* This command is sent on Android to update the keyboard height. */
+                const char *cmd = command_UserEvent(ev);
+                setKeyboardHeight_MainWindow(mw, argLabel_Command(cmd, "fullheight") -
+                                                 argLabel_Command(cmd, "bottom"));
+                return iTrue;
+            }
             if (processEvent_Touch(&event)) {
                 return iTrue;
             }
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/001aeda1724eea630dd141c642bbdd61e2b9b69a
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
69.920906 milliseconds
Gemini-to-HTML Time
0.311514 milliseconds

This content has been proxied by September (ba2dc).