LayoutSpacer vSpacer = new LayoutSpacer();
vSpacer.setHeight100();
windowCanvas.addMember(vSpacer);
HLayout buttons = new HLayout();
buttons.setAlign(Alignment.CENTER);
IButton yesButton = new IButton("Yes, allow");
yesButton.setWidth(CONSENT_BUTTON_WIDTH);
yesButton.setShowRollOver(false);
yesButton.setHeight(CONSENT_BUTTON_HEIGHT);
yesButton.setIcon(Imgs.CHECKMARK.get());
yesButton.setIconOrientation("left");
yesButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GoogleAnalyticsEvent consentEvent = new GoogleAnalyticsEvent("consent", "yes");
GoogleAnalytics.trackEvent(consentEvent);
consentWindow.destroy();
view.getSettings().setTrackingConsent(true);
view.getSettings().setTrackingQueryConsent(true);
LocalStorageHelper.storeSettings(view.getSettings());
}});
yesButton.setShowDownIcon(false);
LayoutSpacer spacer1 = new LayoutSpacer();
spacer1.setWidth(10);
buttons.setAlign(Alignment.CENTER);
IButton noQueriesButton = new IButton("Yes, track site usage, but not <br>the queries/endpoints I use");
noQueriesButton.setWidth(CONSENT_BUTTON_WIDTH);
noQueriesButton.setHeight(CONSENT_BUTTON_HEIGHT);
noQueriesButton.setShowRollOver(false);
noQueriesButton.setIcon(Imgs.CHECK_CROSS.get());
noQueriesButton.setIconOrientation("left");
noQueriesButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GoogleAnalyticsEvent consentEvent = new GoogleAnalyticsEvent("consent", "yes/no");
GoogleAnalytics.trackEvent(consentEvent);
consentWindow.destroy();
view.getSettings().setTrackingConsent(true);
view.getSettings().setTrackingQueryConsent(false);
LocalStorageHelper.storeSettings(view.getSettings());
}});
noQueriesButton.setShowDownIcon(false);
LayoutSpacer spacer2 = new LayoutSpacer();
spacer2.setWidth(10);
IButton noButton = new IButton("No, disable tracking");
noButton.setShowRollOver(false);
noButton.setWidth(CONSENT_BUTTON_WIDTH);
noButton.setHeight(CONSENT_BUTTON_HEIGHT);
noButton.setIcon(Imgs.CROSS.get());
noButton.setIconOrientation("left");
noButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GoogleAnalyticsEvent consentEvent = new GoogleAnalyticsEvent("consent", "no");
GoogleAnalytics.trackEvent(consentEvent);
consentWindow.destroy();
view.getSettings().setTrackingConsent(false);
view.getSettings().setTrackingQueryConsent(false);
LocalStorageHelper.storeSettings(view.getSettings());
}});
noButton.setShowDownIcon(false);
LayoutSpacer spacer3 = new LayoutSpacer();
spacer3.setWidth(10);
IButton askLater = new IButton("Ask me later");
askLater.setShowRollOver(false);
askLater.setWidth(CONSENT_BUTTON_WIDTH - 30);
askLater.setHeight(CONSENT_BUTTON_HEIGHT);
askLater.setIconOrientation("left");
askLater.setShowDownIcon(false);
askLater.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
consentWindow.destroy();
}});
buttons.addMembers(yesButton, spacer1, noQueriesButton, spacer2, noButton, spacer3, askLater);
buttons.setMargin(5);
windowCanvas.addMember(buttons);
consentWindow.setTitle("Tracking site usage");
consentWindow.addItem(windowCanvas);
consentWindow.draw();