Commit bfcee823 authored by Frantisek Simon's avatar Frantisek Simon

#235 Allow user to return to previous language if downloading of new one fails

parent 2995dcc0
......@@ -9,6 +9,7 @@ system_confirm=Potvrdit
system_decline=Zrušit
system_exit=Konec
system_retry=Znovu
system_back=Zpět
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í ?
......
......@@ -9,6 +9,7 @@ system_confirm=Bestätigen
system_decline=Beenden
system_exit=Verlassen
system_retry=Wieder
system_back=Zurück
zipassetloader_error=Fehler: Nicht, um zusätzliche Daten Download! Bitte überprüfen Sie Ihre Internetverbindung.
zipassetloader_download_request: [DE - Upravit v application_de.properities] 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í ?
......
......@@ -9,6 +9,7 @@ system_confirm=Potvrdiť
system_decline=Zrušiť
system_exit=Koniec
system_retry=Znovu
system_back=Späť
zipassetloader_error=Chyba: Nemôžem stiahnuť dodatočná dáta! Skontrolujte prosím pripojenie k internetu.
zipassetloader_download_request: [SK upravit v application_sk.properties] 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í ?
......
......@@ -339,20 +339,27 @@ public class Tablexia extends TablexiaApplication {
components.add(new FixedSpaceContentDialogComponent());
components.add(new ResizableSpaceContentDialogComponent());
components.add(new PositiveNegativeButtonContentDialogComponent(
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
zipAssetLoader.reset(true);
errorDialogShown = false;
}
},
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
zipAssetLoader.reset();
errorDialogShown = false;
if (TablexiaSettings.getInstance().hasLocaleChanged()) {
TablexiaSettings.getInstance().returnToLastLocale();
zipAssetLoader.reset(false);
errorDialogShown = false;
dialog.hide();
} else {
Gdx.app.exit();
}
}
},
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
},
PositiveNegativeButtonContentDialogComponent.PositiveNegativeButtonType.AGAIN_EXIT
TablexiaSettings.getInstance().hasLocaleChanged() ? PositiveNegativeButtonContentDialogComponent.PositiveNegativeButtonType.AGAIN_BACK : PositiveNegativeButtonContentDialogComponent.PositiveNegativeButtonType.AGAIN_EXIT
));
components.add(new FixedSpaceContentDialogComponent());
dialog = TablexiaComponentDialogFactory.getInstance().createDialog(components.toArray(new TablexiaDialogComponentAdapter[]{}));
......@@ -363,7 +370,9 @@ public class Tablexia extends TablexiaApplication {
if (loaderError != null && !errorDialogShown) {
showLoaderErrorDialog(ERROR_DIALOG_WIDTH, ERROR_DIALOG_HEIGHT, loaderError);
errorDialogShown = true;
}
} else if (loaderError == null && dialog != null) {
dialog.hide();
}
return errorDialogShown;
}
......
......@@ -59,6 +59,7 @@ public class TablexiaSettings {
private Preferences preferences;
private LocaleDefinition systemLocale;
private LocaleDefinition selectedLocale;
private LocaleDefinition lastLocale;
private User selectedUser;
......@@ -387,20 +388,34 @@ public class TablexiaSettings {
}
public void setLocale(LocaleDefinition localeDefinition) {
LocaleDefinition lastLocale = selectedLocale;
lastLocale = selectedLocale;
selectedLocale = localeDefinition;
preferences.putString(LOCALE_KEY, localeDefinition.getLocaleKey());
preferences.flush();
if (!lastLocale.getLocale().getLanguage().equals(localeDefinition.getLocale().getLanguage())) {
if (hasLocaleChanged()) {
ApplicationBus.getInstance().post(new LocaleChangedEvent(localeDefinition)).asynchronously();
}
}
public boolean hasLocaleChanged() {
return lastLocale != null && !lastLocale.getLocale().getLanguage().equals(selectedLocale.getLocale().getLanguage());
}
public LocaleDefinition getLocaleDefinition() {
return selectedLocale;
}
public Locale getLocale() {
public void returnToLastLocale() {
if (hasLocaleChanged()) {
setLocale(getLastLocale());
}
}
public LocaleDefinition getLastLocale() {
return lastLocale;
}
public Locale getLocale() {
return selectedLocale.getLocale();
}
......
......@@ -40,6 +40,7 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl
public static final String SYSTEM_NO = "system_no";
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 ZIPASSETLOADER_ERROR = "zipassetloader_error";
public static final String ZIPASSETLOADER_DOWNLOAD_REQUEST = "zipassetloader_download_request";
......
......@@ -80,10 +80,10 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
public void load(Locale locale, Map<String, String> buildChecksum) {
this.locale = locale;
this.buildChecksum = buildChecksum;
reset();
reset(true);
}
public void reset() {
public void reset(boolean withSyncTask) {
error = false;
downloadResult = false;
downloadHasResult = false;
......@@ -95,7 +95,9 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
usingMobileData = Tablexia.getConnectionManager().isUsingMobileData();
setAsyncTask(new ZipAssetLoaderTask(this, locale, buildChecksum));
if (withSyncTask) {
setAsyncTask(new ZipAssetLoaderTask(this, locale, buildChecksum));
}
}
@Override
......
......@@ -15,7 +15,8 @@ public class PositiveNegativeButtonContentDialogComponent extends TwoButtonConte
public enum PositiveNegativeButtonType {
YES_NO (ApplicationTextManager.ApplicationTextsAssets.SYSTEM_YES, ApplicationTextManager.ApplicationTextsAssets.SYSTEM_NO),
CONFIRM_DECLINE (ApplicationTextManager.ApplicationTextsAssets.SYSTEM_CONFIRM, ApplicationTextManager.ApplicationTextsAssets.SYSTEM_DECLINE),
AGAIN_EXIT (ApplicationTextManager.ApplicationTextsAssets.SYSTEM_RETRY, ApplicationTextManager.ApplicationTextsAssets.SYSTEM_EXIT);
AGAIN_EXIT (ApplicationTextManager.ApplicationTextsAssets.SYSTEM_RETRY, ApplicationTextManager.ApplicationTextsAssets.SYSTEM_EXIT),
AGAIN_BACK (ApplicationTextManager.ApplicationTextsAssets.SYSTEM_RETRY, ApplicationTextManager.ApplicationTextsAssets.SYSTEM_BACK);
private final String positiveText;
private final String negativeText;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment