Skip to content

[MultiInputDialog] vertically centre multi input dialogue#12951

Merged
Frenzie merged 4 commits into
koreader:masterfrom
Commodore64user:centre-multiinput
Jan 3, 2025
Merged

[MultiInputDialog] vertically centre multi input dialogue#12951
Frenzie merged 4 commits into
koreader:masterfrom
Commodore64user:centre-multiinput

Conversation

@Commodore64user

@Commodore64user Commodore64user commented Dec 27, 2024

Copy link
Copy Markdown
Member

what's new

screenshots

before/after


This change is Reviewable

@poire-z

poire-z commented Dec 27, 2024

Copy link
Copy Markdown
Contributor

Looks alright and simple.
Let's see what @NiLuJe thinks.

Comment thread frontend/ui/widget/multiinputdialog.lua Outdated
Comment on lines +113 to +118
-- Initialize keyboard_visible
if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then
self.keyboard_visible = false
else
self.keyboard_visible = true
end

@NiLuJe NiLuJe Dec 28, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should already be handled via the call to the super class's init (i.e., InputDialog.init(self)), which handles the false branch, coupled with the fact that the (super) class default is true.

@Commodore64user Commodore64user Dec 28, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe that onCloseKeyboard and closeWidget kills the tracking because, any further attempt to call self.keyboard_visible is always nil true

@Commodore64user Commodore64user Dec 28, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

disregard the previous comment. however self.keyboard_visible is true even when it shouldn't

    logger.dbg("MultiInputDialog:", self.keyboard_visible, "1")
    -- init title and buttons in base class
    InputDialog.init(self)
    logger.dbg("MultiInputDialog:", self.keyboard_visible, "2")
    -- Kick InputDialog's own field out of the layout, we're not using it
    table.remove(self.layout, 1)
    logger.dbg("MultiInputDialog:", self.keyboard_visible, "3")
    -- Also murder said input field *and* its VK, or we get two of them and shit gets hilariously broken real fast...
    self:onCloseKeyboard()
    logger.dbg("MultiInputDialog:", self.keyboard_visible, "4")
    self._input_widget:onCloseWidget()
    logger.dbg("MultiInputDialog:", self.keyboard_visible, "5")

    -- Initialize keyboard_visible
    -- if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then
    --     self.keyboard_visible = false
    -- else
    --     self.keyboard_visible = true
    -- end
    logger.dbg("MultiInputDialog:", self.keyboard_visible, "6")
12/28/24-22:33:56 DEBUG MultiInputDialog: true 1 
12/28/24-22:33:57 DEBUG MultiInputDialog: false 2 
12/28/24-22:33:57 DEBUG MultiInputDialog: false 3 
12/28/24-22:33:57 DEBUG MultiInputDialog: true 4 
12/28/24-22:33:57 DEBUG MultiInputDialog: true 5 
12/28/24-22:33:57 DEBUG MultiInputDialog: true 6 

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

or should we do this instead?

function InputDialog:onCloseKeyboard()
    self._input_widget:onCloseKeyboard()
    if (Device:hasKeyboard() or Device:hasScreenKB()) and G_reader_settings:isFalse("virtual_keyboard_enabled") then
        return
    end
    self.keyboard_visible = self._input_widget:isKeyboardVisible()
end

@NiLuJe NiLuJe Jan 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm. Probably less mysterious with the duplication you went with, as it sort of matches the super class.

I would definitely add a comment about this being needed because InputDialog:onCloseKeyboard updates InputDialog:onCloseKeyboard though ;).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Huh. that's... interesting. Absolutely no time to check, but might be an artifact from being in init on all sides still.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had a Eureka moment on the toilet. #12994

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Had a Eureka moment on the toilet. #12994

I hope you only had one eureka moment there, and if you had more than one, please don’t share number 2. ;)

@Frenzie Frenzie Jan 3, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In binary that'd be equal volume number 10.

I'll see myself out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Defecation joke tally: No. 2

Oops. No. 3 now...

@NiLuJe NiLuJe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Untested, but looks sensible & sound.

Comment thread frontend/ui/widget/multiinputdialog.lua Outdated
self._input_widget:onCloseWidget()

-- Update self.keyboard_visible, this is needed because InputDialog:onCloseKeyboard updates it regardless of whether
-- G_reader_settings("virtual_keyboard_enabled") is disabled, which can lead to an incorrect keyboard visibility state.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you find out why so? Maybe it should be fixed somewhere?

@NiLuJe NiLuJe Jan 1, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's what I meant by #12951 (comment)

InputDialog:onCloseKeyoard does what it says on the tin: it closes the VK, which means it's no longer visible, so it forcibly always sets the visibility flag to false.

Modifying its behavior just to fix this very specific interaction seems like it could lead to more unintended consequences than just dealing with it this way here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

InputDialog:onCloseKeyoard does what it says on the tin: it closes the KB, which means it's no longer visible, so it forcibly always sets the visibility flag to false.

Well, technically, to self._input_widget:isKeyboardVisible(), which should pretty much always lead to a false after InputText:onCloseKeyboard() ;).

@Commodore64user Commodore64user requested a review from NiLuJe January 3, 2025 14:19
@Commodore64user Commodore64user changed the title [MultiInputDialog] vertically centre multi input dialog [MultiInputDialog] vertically centre multi input dialogue Jan 3, 2025

@NiLuJe NiLuJe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

(Now depends on #12994 though)

@Frenzie Frenzie added this to the 2025.01 milestone Jan 3, 2025
@Frenzie Frenzie merged commit 82eaa00 into koreader:master Jan 3, 2025
@Commodore64user Commodore64user deleted the centre-multiinput branch January 3, 2025 23:07
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
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

Successfully merging this pull request may close these issues.

multi input widgets not vertically centred

5 participants