configChanges was added to AndroidManifest.xml a few weeks ago, which prevents the activity from being restarted when the screen rotates. However, Toga still doesn't update its layout after the rotation.
It's safe for the template update and the Toga update to be deployed separately:
If only the template is updated, then Rubicon will log a warning about the unimplemented onConfigurationChange method, but otherwise everything is fine.
If only Toga is updated, then onConfigurationChange will exist but will never be called.
Example of the previous behavior:
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW, LEFT, CENTER, RIGHT, TOP, BOTTOM
class Hello(toga.App):
def startup(self):
labels = [
[toga.Label(text, style=Pack(flex=1)) for text in row]
for row in [
["NW", "N", "NE"],
["W", "X", "E"],
["SW", "S", "SE"],
]
]
main_box = toga.Box(
style=Pack(direction=COLUMN),
children=[
toga.Box(children=labels[0]),
toga.Box(style=Pack(flex=1)), # Spacer
toga.Box(children=labels[1]),
toga.Box(style=Pack(flex=1)), # Spacer
toga.Box(children=labels[2]),
]
)
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
# Android backend doesn't support setting alignment until after native
# widget creation.
for row in labels:
for label, text_align in zip(row, [LEFT, CENTER, RIGHT]):
label.style.update(text_align=text_align)
def main():
return Hello()
configChanges
was added to AndroidManifest.xml a few weeks ago, which prevents the activity from being restarted when the screen rotates. However, Toga still doesn't update its layout after the rotation.To fix this we'll need to implement
onConfigurationChanged
. The corresponding Toga PR is https://github.com/beeware/toga/pull/1507.It's safe for the template update and the Toga update to be deployed separately:
onConfigurationChange
method, but otherwise everything is fine.onConfigurationChange
will exist but will never be called.Example of the previous behavior:
PR Checklist: