diff --git a/android/assets/text/application/application_cs.properties b/android/assets/text/application/application_cs.properties index f4aa91efd49cc359d91c171d19c1a297994ea8a8..d8dd4244809bafcb2c336f01a692538eae5024ef 100644 --- a/android/assets/text/application/application_cs.properties +++ b/android/assets/text/application/application_cs.properties @@ -10,6 +10,7 @@ system_decline=Zrušit system_exit=Konec system_retry=Znovu system_back=ZpÄ›t +system_understand=RozumĂm zipassetloader_error=Chyba: Nemohu stáhnout dodateÄŤná data! Zkontrolujte prosĂm pĹ™ipojenĂ k internetu. zipassetloader_download_request: PrávÄ› vyuĹľĂváte mobilnĂ pĹ™ipojenĂ k internetu. Tablexia potĹ™ebuje stáhnout ~150 MB hernĂch dat. PĹ™ejete si je stáhnout nynĂ ? @@ -39,7 +40,6 @@ usermenu_dialog_no = Ne user_logout_message=Opravdu chcete odhlásit stávajĂcĂho uĹľivatele? preloader_title=Jak hrát? -confirm_button=RozumĂm gamedifficulty_name=ObtĂĹľnost: gamedifficulty_tutorial=CviÄŤenĂ @@ -223,3 +223,5 @@ user_rank_11=VrchnĂ rada sync_request_dialog_text=Zadej ÄŤĂslo prĹŻkazu: sync_request_button=Synchronizovat uĹľivatele +sync_request_wrong_id=Ĺ patnÄ› zadanĂ˝ kĂłd. +sync_request_error=Synchronizace se nezdaĹ™ila, zkuste to prosĂm pozdÄ›ji. diff --git a/android/assets/text/application/application_de.properties b/android/assets/text/application/application_de.properties index 9ac93322a6fb96df41b64c577e2bc347fa61c8fc..51706868d1d6870f0adf0443f9cb23905799c66d 100644 --- a/android/assets/text/application/application_de.properties +++ b/android/assets/text/application/application_de.properties @@ -10,6 +10,7 @@ system_decline=Beenden system_exit=Verlassen system_retry=Wieder system_back=ZurĂĽck +system_understand=Ich verstehe zipassetloader_error=Fehler: Nicht, um zusätzliche Daten Download! Bitte ĂĽberprĂĽfen Sie Ihre Internetverbindung. zipassetloader_download_request=Sie verwenden im Moment das mobile Internet. Tablexia lädt ~ 150 MB an Spieldaten herunter. Möchten Sie die Daten wirklich jetzt runterladen? @@ -39,7 +40,6 @@ usermenu_dialog_yes=Ja usermenu_dialog_no=Nein user_logout_message=Möchtest du abmelden? preloader_title=Wie spielt man? -confirm_button=Ich verstehe gamedifficulty_name=Schwierigkeitsgrad: gamedifficulty_tutorial=Lernprogramm @@ -222,4 +222,6 @@ user_rank_10=Besserwisser user_rank_11=Oberrat sync_request_dialog_text=Trage deine Ausweisnummer ein: -sync_request_button=Account synchronisieren \ No newline at end of file +sync_request_button=Account synchronisieren +sync_request_wrong_id=Falsch geschriebener Code. +sync_request_error=Die synchronisierung ist fehlgeschlagen, bitte versuche es später noch einmal. \ No newline at end of file diff --git a/android/assets/text/application/application_sk.properties b/android/assets/text/application/application_sk.properties index c759c4e7cc1dda276061d1a947a0c2059434694f..ac6e0a420722de12e7069da67f0900bd55274051 100644 --- a/android/assets/text/application/application_sk.properties +++ b/android/assets/text/application/application_sk.properties @@ -10,6 +10,7 @@ system_decline=ZrušiĹĄ system_exit=Koniec system_retry=Znovu system_back=Späť +system_understand=Rozumiem zipassetloader_error=Chyba: NemĂ´Ĺľem stiahnuĹĄ dodatoÄŤná dáta! Skontrolujte prosĂm pripojenie k internetu. zipassetloader_download_request:Práve vyuĹľĂvate mobilnĂ© pripojenie k internetu. Tablexia potrebuje stiahnuĹĄ ~150 M hernĂ˝ch dat. Prajete si ich stiahnuĹĄ teraz? @@ -41,7 +42,6 @@ usermenu_dialog_no=Nie user_logout_message=Naozaj chceš odhlásiĹĄ súčasnĂ©ho uĹľĂvateÄľa? preloader_title=Ako hraĹĄ? -confirm_button=Rozumiem gamedifficulty_name=ObtiaĹľnosĹĄ: gamedifficulty_tutorial=CviÄŤenie @@ -224,4 +224,6 @@ user_rank_10=Rozumbrada user_rank_11=Ĺ efmajster sync_request_dialog_text=Zadaj ÄŤĂslo preukazu: -sync_request_button=SynchronizovaĹĄ uĹľĂvateÄľa \ No newline at end of file +sync_request_button=SynchronizovaĹĄ uĹľĂvateÄľa +sync_request_wrong_id=Zle zadanĂ˝ kĂłd. +sync_request_error=Synchronizácia sa nepodarila, skĂşste to prosĂm neskĂ´r. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1424a411d018a38906e5b6c427ffda1431f2a6a0..6f35f1a2f54fae9e056990e91a45a3be7d5a8df5 100644 --- a/build.gradle +++ b/build.gradle @@ -282,7 +282,7 @@ def getVersionNameFromGit(String relativePath) { // get last tag in current branch exec { workingDir relativePath - commandLine 'git', 'describe', '--abbrev=0', '--tags' + commandLine 'git', 'describe', '--abbrev=0', '--tags', '--always' standardOutput = stdout } String result = stdout.toString().trim(); @@ -318,7 +318,7 @@ def getVersionCodeFromGit(String relativePath) { def getBranchNameFromGit() { def stdout = new ByteArrayOutputStream() exec { - commandLine 'git', 'describe', '--contains', '--all', 'HEAD' + commandLine 'git', 'describe', '--contains', '--all', 'HEAD', '--always' standardOutput = stdout } String branchString = stdout.toString().trim() diff --git a/core/src/cz/nic/tablexia/TablexiaApplication.java b/core/src/cz/nic/tablexia/TablexiaApplication.java index 080318baf09769f0d3f23837183f81578b154ed4..4f161ee9b5146c76f27ddd6276f24b4f8be25a0a 100644 --- a/core/src/cz/nic/tablexia/TablexiaApplication.java +++ b/core/src/cz/nic/tablexia/TablexiaApplication.java @@ -462,7 +462,7 @@ public abstract class TablexiaApplication implements ApplicationListener { screen.preparePreloaderContent(PRELOADER_DIALOG_WIDTH, PRELOADER_DIALOG_HEIGHT, preloaderAssetsManager, screenComponents); // build dialog from generic and screen specific components - preloaderCloseButtonComponent = new CloseButtonContentDialogComponent(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.CONFIRM_BUTTON)) + preloaderCloseButtonComponent = new CloseButtonContentDialogComponent(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYSTEM_UNDERSTAND)) .setEnabled(false) .useOnce(true) .setInputListener(new ClickListener() { diff --git a/core/src/cz/nic/tablexia/loader/application/ApplicationTextManager.java b/core/src/cz/nic/tablexia/loader/application/ApplicationTextManager.java index abd0e5e4f86d0f204e85b15c5699e7c58d6e8c6f..cd13b5c4667782fdd7546918734dd16f979d3b37 100644 --- a/core/src/cz/nic/tablexia/loader/application/ApplicationTextManager.java +++ b/core/src/cz/nic/tablexia/loader/application/ApplicationTextManager.java @@ -30,7 +30,6 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl public static final String USER_LOGOUT_MESSAGE = "user_logout_message"; public static final String PRELOADER_TITLE = "preloader_title"; - public static final String CONFIRM_BUTTON = "confirm_button"; public static final String SYSTEM_CONFIRM = "system_confirm"; public static final String SYSTEM_DECLINE = "system_decline"; @@ -39,6 +38,7 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl public static final String SYSTEM_EXIT = "system_exit"; public static final String SYSTEM_RETRY = "system_retry"; public static final String SYSTEM_BACK = "system_back"; + public static final String SYSTEM_UNDERSTAND = "system_understand"; public static final String ZIPASSETLOADER_ERROR = "zipassetloader_error"; public static final String ZIPASSETLOADER_DOWNLOAD_REQUEST = "zipassetloader_download_request"; @@ -107,6 +107,8 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl public static final String SYNC_REQUEST_DIALOG_TEXT = "sync_request_dialog_text"; public static final String SYNC_REQUEST_BUTTON = "sync_request_button"; + public static final String SYNC_REQUEST_WRONG_ID = "sync_request_wrong_id"; + public static final String SYNC_REQUEST_ERROR = "sync_request_error"; public static final String USER_RANK_1 = "user_rank_1"; public static final String USER_RANK_2 = "user_rank_2"; diff --git a/core/src/cz/nic/tablexia/menu/user/UserMenu.java b/core/src/cz/nic/tablexia/menu/user/UserMenu.java index 7a22d759eefbbe3c1863c4b63bb19737044648f1..935745303842a556b52db46ae5cbe04b61d39d85 100644 --- a/core/src/cz/nic/tablexia/menu/user/UserMenu.java +++ b/core/src/cz/nic/tablexia/menu/user/UserMenu.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Container; +import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; @@ -21,6 +22,7 @@ import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.bus.event.DeleteUserSynchronizationEvent; import cz.nic.tablexia.bus.event.MenuControlEvent; import cz.nic.tablexia.loader.application.ApplicationInternalSoundManager; +import cz.nic.tablexia.loader.application.ApplicationInternalTextureManager; import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.menu.AbstractMenu; import cz.nic.tablexia.model.UserDAO; @@ -31,16 +33,22 @@ import cz.nic.tablexia.sync.work.DownloadUser; import cz.nic.tablexia.sync.work.PushDataToServer; import cz.nic.tablexia.sync.work.SyncWork; import cz.nic.tablexia.util.ui.ClickListenerWithSound; +import cz.nic.tablexia.util.ui.button.StandardTablexiaButton; +import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog; import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialogFactory; import cz.nic.tablexia.util.ui.dialog.components.AdaptiveSizeDialogComponent; +import cz.nic.tablexia.util.ui.dialog.components.AlertOnShowDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.BackButtonHideComponent; import cz.nic.tablexia.util.ui.dialog.components.CenterPositionDialogComponent; +import cz.nic.tablexia.util.ui.dialog.components.CloseButtonContentDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.DimmerDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.FixedSpaceContentDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.PositiveNegativeButtonContentDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.ResizableSpaceContentDialogComponent; +import cz.nic.tablexia.util.ui.dialog.components.TablexiaDialogComponentAdapter; import cz.nic.tablexia.util.ui.dialog.components.TextContentDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.TextFiledDialogComponent; +import cz.nic.tablexia.util.ui.dialog.components.TwoButtonContentDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.ViewportMaximumSizeComponent; /** @@ -61,11 +69,16 @@ public class UserMenu extends AbstractMenu { private static final int SYNC_REQUEST_DIALOG_MAXIMUM_LENGTH = 36; private static final float SYNC_DIALOG_TITLE_PAD = 0.15f; private static final float SYNC_DIALOG_TEXT_FIELD_PAD = 0.05f; + + private static final float SYNC_FAILED_DIALOG_BOTTOM_PADDING = 1/40f; public static final String CODE_REGEX = "(([0-9]|[a-f]){8})-(([0-9]|[a-f]){4})-(([0-9]|[a-f]){4})-(([0-9]|[a-f]){4})-(([0-9]|[a-f]){12})$"; private List<User> users; + //Saves the last state of uuid sync textfield... (Used to restore its state on try again button press) + private String lastSyncUUID; + public UserMenu(Float width, Float height) { super(width, height); users = new ArrayList<User>(); @@ -150,50 +163,7 @@ public class UserMenu extends AbstractMenu { final UserMenuDownloadSelectBoxItemGroup userDownload = new UserMenuDownloadSelectBoxItemGroup() { @Override public void performAction() { - final TextFiledDialogComponent textFiledDialogComponent = new TextFiledDialogComponent(SYNC_REQUEST_DIALOG_MAXIMUM_LENGTH, SYNC_REQUEST_DIALOG_PLACEHOLDER_TEXT); - textFiledDialogComponent.setTextFieldWidthPercent(DOWNLOAD_DIALOG_INPUT_WIDTH_PERCENT); - textFiledDialogComponent.setRepositionOnFocusOnMobileDevices(true); - - TablexiaComponentDialogFactory.getInstance().createDialog( - new CenterPositionDialogComponent(), - new DimmerDialogComponent(), - new ViewportMaximumSizeComponent(), - new AdaptiveSizeDialogComponent(), - new FixedSpaceContentDialogComponent(SYNC_DIALOG_TITLE_PAD), - new TextContentDialogComponent(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYNC_REQUEST_DIALOG_TEXT)), - new FixedSpaceContentDialogComponent(SYNC_DIALOG_TEXT_FIELD_PAD), - textFiledDialogComponent, - new ResizableSpaceContentDialogComponent(), - new PositiveNegativeButtonContentDialogComponent(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); - if (textFiledDialogComponent.getText().length()>0 && textFiledDialogComponent.getText().toLowerCase().matches(CODE_REGEX)) { - DownloadUser syncWork = new DownloadUser(textFiledDialogComponent.getText()); - syncWork.registerListener(new SyncWork.RestSyncListener() { - @Override - public void onSuccess(User user) { - ApplicationBus.getInstance().post(new RefreshUserMenu()).asynchronously(); - } - }); - RestSynchronizationService.doSyncWork(syncWork); - } - //Prevents keyboard getting stuck - Gdx.input.setOnscreenKeyboardVisible(false); - } - }, - new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); - //Prevents keyboard getting stuck - Gdx.input.setOnscreenKeyboardVisible(false); - } - }, - PositiveNegativeButtonContentDialogComponent.PositiveNegativeButtonType.CONFIRM_DECLINE), - new FixedSpaceContentDialogComponent(), - new BackButtonHideComponent() - ).show(SYNC_REQUEST_DIALOG_WIDTH, SYNC_REQUEST_DIALOG_HEIGHT); + showSyncDialog(null); } @Override @@ -215,6 +185,125 @@ public class UserMenu extends AbstractMenu { layoutContainer.setActor(container); } + private void showSyncDialog(String syncUUID) { + final TextFiledDialogComponent textFiledDialogComponent = new TextFiledDialogComponent(SYNC_REQUEST_DIALOG_MAXIMUM_LENGTH, SYNC_REQUEST_DIALOG_PLACEHOLDER_TEXT); + textFiledDialogComponent.setTextFieldWidthPercent(DOWNLOAD_DIALOG_INPUT_WIDTH_PERCENT); + textFiledDialogComponent.setRepositionOnFocusOnMobileDevices(true); + if(syncUUID != null && !syncUUID.isEmpty()) textFiledDialogComponent.setText(syncUUID); + + TablexiaComponentDialogFactory.getInstance().createDialog( + new CenterPositionDialogComponent(), + new DimmerDialogComponent(), + new ViewportMaximumSizeComponent(), + new AdaptiveSizeDialogComponent(), + new FixedSpaceContentDialogComponent(SYNC_DIALOG_TITLE_PAD), + new TextContentDialogComponent(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYNC_REQUEST_DIALOG_TEXT)), + new FixedSpaceContentDialogComponent(SYNC_DIALOG_TEXT_FIELD_PAD), + textFiledDialogComponent, + new ResizableSpaceContentDialogComponent(), + new PositiveNegativeButtonContentDialogComponent( + new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + UserMenu.this.lastSyncUUID = textFiledDialogComponent.getText(); + + if (textFiledDialogComponent.getText().length() > 0 && textFiledDialogComponent.getText().toLowerCase().matches(CODE_REGEX)) { + DownloadUser syncWork = new DownloadUser(textFiledDialogComponent.getText()); + syncWork.registerListener(new SyncWork.RestSyncListener() { + @Override + public void onSuccess(User user) { + ApplicationBus.getInstance().post(new RefreshUserMenu()).asynchronously(); + } + + @Override + public void onFailure(Throwable t) { + showSyncFailedDialog(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYNC_REQUEST_ERROR)); + } + + @Override + public void onWrongResponseCode(int responseCode) { + String failReason = ApplicationTextManager.ApplicationTextsAssets.SYNC_REQUEST_ERROR; + + if(responseCode == DownloadUser.USER_NOT_FOUND_STATUS_CODE) + failReason = ApplicationTextManager.ApplicationTextsAssets.SYNC_REQUEST_WRONG_ID; + + showSyncFailedDialog(ApplicationTextManager.getInstance().getText(failReason)); + } + + @Override + public void onCancelled() { + //no action + } + }); + RestSynchronizationService.doSyncWork(syncWork); + } + else { //ID was blank or didn't match the ID regex + showSyncFailedDialog(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYNC_REQUEST_WRONG_ID)); + } + + //Prevents keyboard getting stuck + Gdx.input.setOnscreenKeyboardVisible(false); + } + }, + new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + //Prevents keyboard getting stuck + Gdx.input.setOnscreenKeyboardVisible(false); + } + }, + PositiveNegativeButtonContentDialogComponent.PositiveNegativeButtonType.CONFIRM_DECLINE), + new FixedSpaceContentDialogComponent(), + new BackButtonHideComponent() + ).show(SYNC_REQUEST_DIALOG_WIDTH, SYNC_REQUEST_DIALOG_HEIGHT); + } + + private void showSyncFailedDialog(final String reason) { + Gdx.app.postRunnable(new Runnable() { + @Override + public void run() { + TablexiaComponentDialog dialog; + + List<TablexiaDialogComponentAdapter> components = new ArrayList<TablexiaDialogComponentAdapter>() { + { + add(new CenterPositionDialogComponent()); + add(new DimmerDialogComponent()); + add(new ViewportMaximumSizeComponent()); + add(new AdaptiveSizeDialogComponent()); + + add(new ResizableSpaceContentDialogComponent()); + add(new TextContentDialogComponent(reason)); + + add(new ResizableSpaceContentDialogComponent()); + add(new TwoButtonContentDialogComponent( + ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYSTEM_DECLINE), + ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SYSTEM_RETRY), + new Image(ApplicationInternalTextureManager.getInstance().getTexture(ApplicationInternalTextureManager.BUTTON_NO_ICON)), + new Image(ApplicationInternalTextureManager.getInstance().getTexture(ApplicationInternalTextureManager.BUTTON_YES_ICON)), //TODO - Use Repeat icon + StandardTablexiaButton.TablexiaButtonType.RED, + StandardTablexiaButton.TablexiaButtonType.GREEN, + null, //Cancel Button + new ClickListener() { //Try again + @Override + public void clicked(InputEvent event, float x, float y) { + showSyncDialog(lastSyncUUID); + } + } + )); + add(new FixedSpaceContentDialogComponent(SYNC_FAILED_DIALOG_BOTTOM_PADDING)); + + add(new AlertOnShowDialogComponent()); + add(new AdaptiveSizeDialogComponent()); + add(new CenterPositionDialogComponent()); + } + }; + + dialog = TablexiaComponentDialogFactory.getInstance().createDialog(components.toArray(new TablexiaDialogComponentAdapter[]{})); + dialog.show(SYNC_REQUEST_DIALOG_WIDTH, SYNC_REQUEST_DIALOG_HEIGHT, false); + } + }); + } + @Override public void dispose() { ApplicationBus.getInstance().unsubscribe(this); diff --git a/core/src/cz/nic/tablexia/sync/work/ConfirmDataReceived.java b/core/src/cz/nic/tablexia/sync/work/ConfirmDataReceived.java index 74443b90829005f025e8fadfff5facd788b9fd45..03416035786910e83730dbf521f5cd5b28319e93 100644 --- a/core/src/cz/nic/tablexia/sync/work/ConfirmDataReceived.java +++ b/core/src/cz/nic/tablexia/sync/work/ConfirmDataReceived.java @@ -31,7 +31,7 @@ public class ConfirmDataReceived extends SyncWork { } @Override - protected void onResponse(Net.HttpResponse httpResponse) { + protected void onSuccessfulResponse(Net.HttpResponse httpResponse) { GameDAO.markGamesAsSync(getUser().getGames()); ScreenDAO.markScreensAsSync(getUser().getScreens()); Log.debug(this.getClass(), String.format("Marking %d of games as synchronized", getUser().getGames() != null ? getUser().getGames().size() : 0)); diff --git a/core/src/cz/nic/tablexia/sync/work/DownloadUser.java b/core/src/cz/nic/tablexia/sync/work/DownloadUser.java index 4b2155ceacb61d973ada8371c86dd66d89142b2c..9d6a29890bd3997c42a28bdd5e06790ce90afe33 100644 --- a/core/src/cz/nic/tablexia/sync/work/DownloadUser.java +++ b/core/src/cz/nic/tablexia/sync/work/DownloadUser.java @@ -16,6 +16,7 @@ import cz.nic.tablexia.util.Log; */ public class DownloadUser extends SyncWork { + public static final int USER_NOT_FOUND_STATUS_CODE = 404; private final String uuid; public DownloadUser(String uuid) { @@ -34,7 +35,7 @@ public class DownloadUser extends SyncWork { } @Override - protected void onResponse(Net.HttpResponse httpResponse) { + protected void onSuccessfulResponse(Net.HttpResponse httpResponse) { String userJson = httpResponse.getResultAsString(); Json json = new Json(); json.setIgnoreUnknownFields(true); diff --git a/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java b/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java index 77eb89efed9b007bafb180292db69f8a43b2e0bf..3dba26421cc873848e5193e32be9e9832b1e52c0 100644 --- a/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java +++ b/core/src/cz/nic/tablexia/sync/work/PushDataToServer.java @@ -61,7 +61,7 @@ public class PushDataToServer extends SyncWork { } @Override - protected void onResponse(Net.HttpResponse httpResponse) { + protected void onSuccessfulResponse(Net.HttpResponse httpResponse) { Log.debug(this.getClass(), "received uuid: " + httpResponse.getHeader("uuid")); diff --git a/core/src/cz/nic/tablexia/sync/work/SyncWork.java b/core/src/cz/nic/tablexia/sync/work/SyncWork.java index 88f6b42bda4199cd0e2848c35728403acd47bb9d..3a8ee57174f3c89274476d9d743cf4d59adc7059 100644 --- a/core/src/cz/nic/tablexia/sync/work/SyncWork.java +++ b/core/src/cz/nic/tablexia/sync/work/SyncWork.java @@ -63,20 +63,19 @@ public abstract class SyncWork implements Net.HttpResponseListener { } if (httpResponse.getStatus().getStatusCode() != getExpectedSuccessResponseCode()) { - failed(new Exception(String.format("expected response code was %d but received %d", getExpectedSuccessResponseCode(), httpResponse.getStatus().getStatusCode()))); + Log.debug(getClass(), "Wrong Response Code received! " + httpResponse.getStatus().getStatusCode() + " (expected: " + getExpectedSuccessResponseCode() + ")"); + if(listener != null) listener.onWrongResponseCode(httpResponse.getStatus().getStatusCode()); return; } - onResponse(httpResponse); + onSuccessfulResponse(httpResponse); if (listener != null) { listener.onSuccess(getUser()); } } // override this method to handle success response from server - protected void onResponse(Net.HttpResponse httpResponse) { - - } + protected void onSuccessfulResponse(Net.HttpResponse httpResponse) {} @Override public void failed(Throwable t) { @@ -184,16 +183,10 @@ public abstract class SyncWork implements Net.HttpResponseListener { //////////// Response listener class - public abstract static class RestSyncListener { - - public void onFailure(Throwable t) { - - } - - public void onCancelled() { - - } - - public abstract void onSuccess(User user); + public interface RestSyncListener { + void onSuccess(User user); + void onFailure(Throwable t); + void onWrongResponseCode(int responseCode); + void onCancelled(); } } diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/components/TextFiledDialogComponent.java b/core/src/cz/nic/tablexia/util/ui/dialog/components/TextFiledDialogComponent.java index 39b64976f3d8591687b56e3eb921294915239248..2c9728f9a4f52892109ce1e17383a542a46ab4e9 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/components/TextFiledDialogComponent.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/components/TextFiledDialogComponent.java @@ -77,6 +77,10 @@ public class TextFiledDialogComponent extends TablexiaDialogComponentAdapter { return textField.getText(); } + public void setText(String lastSyncUUID) { + textField.setText(lastSyncUUID); + } + public float getTextFieldWidthPercent() { return textFieldWidthPercent; }