From aa0b00f7c4e1db347f307b785d66a1200ce50a9a Mon Sep 17 00:00:00 2001 From: George Georgovassilis Date: Wed, 6 Mar 2024 06:25:21 +0200 Subject: [PATCH] Fixes #104 --- .../AppInstallPromptViewImpl.java | 9 ++++----- .../activities/settings/SettingsScreenImpl.java | 16 ++++++---------- .../screentemplates/install-app-prompt.html | 6 +++--- .../client/screentemplates/settings.html | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/main/java/superstartrek/client/activities/appinstallation/AppInstallPromptViewImpl.java b/src/main/java/superstartrek/client/activities/appinstallation/AppInstallPromptViewImpl.java index 8e8a66d8..ea0cf0be 100644 --- a/src/main/java/superstartrek/client/activities/appinstallation/AppInstallPromptViewImpl.java +++ b/src/main/java/superstartrek/client/activities/appinstallation/AppInstallPromptViewImpl.java @@ -3,6 +3,7 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import superstartrek.client.activities.PopupViewImpl; +import superstartrek.client.eventbus.Events; import superstartrek.client.screentemplates.ScreenTemplates; public class AppInstallPromptViewImpl extends PopupViewImpl implements AppInstallPromptView { @@ -20,10 +21,8 @@ protected String getContentForHtmlPanel(ScreenTemplates templates) { protected void decorateWidget(ScreenTemplates templates, Element element) { super.decorateWidget(templates, element); element.setId("app-install-prompt"); - //TODO: switch to ui handler - addDomHandler((event) -> { - Element e = event.getNativeEvent().getEventTarget().cast(); - switch (e.getId()) { + presenter.getApplication().eventBus.addHandler(Events.INTERACTION, tag -> { + switch (tag) { case "install-yes": presenter.userClickedInstallButton(); break; @@ -34,6 +33,6 @@ protected void decorateWidget(ScreenTemplates templates, Element element) { presenter.userDoesntWantToInstallAppEver(); break; } - }, ClickEvent.getType()); + }); } } diff --git a/src/main/java/superstartrek/client/activities/settings/SettingsScreenImpl.java b/src/main/java/superstartrek/client/activities/settings/SettingsScreenImpl.java index 9b42eb68..371fe750 100644 --- a/src/main/java/superstartrek/client/activities/settings/SettingsScreenImpl.java +++ b/src/main/java/superstartrek/client/activities/settings/SettingsScreenImpl.java @@ -3,12 +3,14 @@ import java.util.HashSet; import java.util.Set; +import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.DomEvent; import superstartrek.client.activities.BaseScreen; +import superstartrek.client.eventbus.Events; import superstartrek.client.screentemplates.ScreenTemplates; public class SettingsScreenImpl extends BaseScreen implements SettingsScreen { @@ -39,7 +41,6 @@ public SettingsScreenImpl(SettingsPresenter p) { eNavDefault = getElementById("nav-default"); eNavBottom = getElementById("nav-bottom"); addDomHandler((event) -> handleChange(event), ChangeEvent.getType()); - addDomHandler((event) -> handleClick(event), ClickEvent.getType()); uiScales.add(eSmall); uiScales.add(eMedium); uiScales.add(eLarge); @@ -66,18 +67,13 @@ protected void handleChange(DomEvent event) { } } - protected void handleClick(DomEvent event) { - NativeEvent ne = event.getNativeEvent(); - Element e = ne.getEventTarget().cast(); - - if (eCheckForUpdates.isOrHasChild(e)) { - presenter.onCheckForUpdatesButtonClicked(); - } - } - @Override protected void decorateScreen(ScreenTemplates templates, Element element) { element.setInnerHTML(templates.settingsScreen().getText()); + presenter.getApplication().eventBus.addHandler(Events.INTERACTION, tag->{ + if ("cmd_check_for_updates_2".equals(tag)) + presenter.onCheckForUpdatesButtonClicked(); + }); } @Override diff --git a/src/main/java/superstartrek/client/screentemplates/install-app-prompt.html b/src/main/java/superstartrek/client/screentemplates/install-app-prompt.html index 196621e8..dfbcde13 100644 --- a/src/main/java/superstartrek/client/screentemplates/install-app-prompt.html +++ b/src/main/java/superstartrek/client/screentemplates/install-app-prompt.html @@ -1,3 +1,3 @@ - - - + + + diff --git a/src/main/java/superstartrek/client/screentemplates/settings.html b/src/main/java/superstartrek/client/screentemplates/settings.html index ae973ea2..81efcb72 100644 --- a/src/main/java/superstartrek/client/screentemplates/settings.html +++ b/src/main/java/superstartrek/client/screentemplates/settings.html @@ -45,7 +45,7 @@

Settings

- +