keymanapp / keymanapp/keyman

refactor(android): merge layout JS calls into a single call

Open
#11,734 1 comment 0 reactions 1 assignee Claimed by @darcywong00 View on GitHub
android/ refactor
Dominant language
Pascal
Stars
534
Forks
143
Avg merge
2d 10h
Merged PRs (30d)
113

Description

> [...] It seems like part of the problem here is the existing spaghetti is making it very difficult to reason about the orientation state.
>
> One simple refactor I think we should try and apply is to reduce the number of `loadJavascript` calls:
>
> * Each call is costly
> * If we have a `setDimensions` function which is passed an object, then we can set as many of the dimensions as are passed in, in the specific order that they should be set, and without having to bubble that ordering detail all the up into the Java code.
> * It helps us see where we are only setting width or height or vice-versa.

_Originally posted by @mcdurdin in https://github.com/keymanapp/keyman/pull/11722#pullrequestreview-2103479072_

> This smells like it should be a single function call, `setDimensions({bannerHeight:%d,oskWidth:%d,oskHeight:%d})`.
>
> This may also be relevant:
https://github.com/keymanapp/keyman/blob/91e91bf91b56efb6cc20ebabd4a6f0a257801af0/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java#L426-L436
>
> Calls to these functions (on master branch):
> * Only 1 call to `setBannerHeight`, right here.
> * 4 calls to `setOskHeight`
> * 2 calls to `setOskWidth`

_Originally posted by @mcdurdin in https://github.com/keymanapp/keyman/pull/11722#discussion_r1630512393_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.