Commit ef26761d authored by Aneta Steimarova's avatar Aneta Steimarova

Merge branch 'V3.4' into merge_java_8

parents 9e629d3d e300d981
......@@ -243,6 +243,7 @@ user_rank_10=Rozumbrada
user_rank_11=Vrchní rada
sync_request_dialog_text=Zadej číslo průkazu:
sync_request_qr_dialog_text=Zadej číslo průkazu nebo naskenuj QR kód, který nalezneš ve svém profilu.
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.
......
......@@ -243,6 +243,7 @@ user_rank_10=Besserwisser
user_rank_11=Oberrat
sync_request_dialog_text=Trage deine Ausweisnummer ein:
sync_request_qr_dialog_text=Trage deine Ausweisnummer ein oder scanne den QR-Code ein, der du in deinem Profil findest.
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.
......
......@@ -246,6 +246,7 @@ user_rank_10=Rozumbrada
user_rank_11=Šefmajster
sync_request_dialog_text=Zadaj číslo preukazu:
sync_request_qr_dialog_text=Zadaj číslo preukazu alebo naskenuj QR kód, ktorý nájdeš vo svojom profile.
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.
......
......@@ -21,7 +21,7 @@ final BUILD_CONFIG_DIR = "${buildDir}/generated/source/buildConfig/"
final BUILD_CONFIG_ENCODING = 'UTF-8'
android {
buildToolsVersion "20.0.0"
buildToolsVersion "24.0.3"
compileSdkVersion 21
packagingOptions {
......@@ -34,11 +34,14 @@ android {
}
defaultConfig {
targetSdkVersion 17
targetSdkVersion 21
versionName tablexiaVersionName
versionCode tablexiaVersionCode
applicationId rootProject.applicationBaseId
testApplicationId rootProject.applicationBaseId + ".test"
jackOptions {
enabled true
}
}
buildTypes {
......@@ -78,9 +81,6 @@ android {
java.srcDirs = ['src/main/java']
jniLibs.srcDirs = ['libs']
}
androidTest {
java.srcDir file('src/androidTest/java')
}
test {
java.srcDir file('src/test/java')
}
......@@ -130,8 +130,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
command {
......@@ -261,11 +261,3 @@ idea {
}
}
}
spoon {
debug = true
failOnFailure = false
//testSizes = ['small', 'medium']
adbTimeout = 10*60
failIfNoDeviceConnected = false
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.android.test.instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import com.squareup.spoon.Spoon;
import java.io.File;
import cz.nic.tablexia.android.AndroidLauncher;
/**
* Created by lhoracek on 5/13/15.
*/
public abstract class AbstractOpenglTest<T extends AndroidLauncher> extends ActivityInstrumentationTestCase2<T> {
public AbstractOpenglTest(Class<T> activityClass) {
super(activityClass);
}
/**
* Sleep the thread to wait for animations to complete
*
* @param seconds
*/
protected void sleep(float seconds) {
try {
Thread.sleep((int) (seconds * 1000));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* Take screenshot using custom OpenGL readPixels buffer method instead of using decorView. Lets the Spoon create the file first and then just overwrites it.
* Not the best method, but the simplest.
* @param name
*/
protected void screenshot(String name) {
File screenshot = Spoon.screenshot(getActivity(), name);
getActivity().takeScreenshot(screenshot);
sleep(3);
}
}
......@@ -19,33 +19,27 @@ package cz.nic.tablexia.android;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.net.ConnectivityManager;
import android.os.Build;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.flurry.android.FlurryAgent;
import java.io.File;
import java.io.FileOutputStream;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaBuildConfig;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.android.camera.AndroidCamera2QRCodeScanner;
import cz.nic.tablexia.android.camera.AndroidQRCodeScanner;
import cz.nic.tablexia.debug.BuildConfig;
import cz.nic.tablexia.debug.R;
import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ui.QRCodeScanner;
public class AndroidLauncher extends AndroidApplication {
public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("org.sqldroid.SQLDroidDriver", "jdbc:sqldroid:");
protected static final int MULTI_SAMPLING_2X = 2;
public static final boolean HAS_SOFT_BACK_BUTTON = false;
private static final int MULTI_SAMPLING_2X = 2;
private static final boolean HAS_SOFT_BACK_BUTTON = false;
protected Tablexia tablexia;
......@@ -68,6 +62,8 @@ public class AndroidLauncher extends AndroidApplication {
}
}
QRCodeScanner qrCodeScanner = android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? new AndroidCamera2QRCodeScanner(this) : new AndroidQRCodeScanner(this);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useWakelock = true;
config.numSamples = MULTI_SAMPLING_2X;
......@@ -76,51 +72,12 @@ public class AndroidLauncher extends AndroidApplication {
getResources().getConfiguration().locale,
SQL_CONNECTION_TYPE,
new AndroidConnectionManager(getContext()),
new AndroidQRCodeScanner(this),
qrCodeScanner,
getResources().getString(R.string.sentry_dsn),
HAS_SOFT_BACK_BUTTON,
savedInstanceState == null,
Build.SERIAL), config);
runTest();
if (TablexiaSettings.getInstance().getBuildType().isBugReport() && TablexiaBuildConfig.FLURRY_KEY != null) {
FlurryAgent.setLogEnabled(false);
FlurryAgent.setVersionName(TablexiaSettings.getInstance().getFullName());
FlurryAgent.init(this, TablexiaBuildConfig.FLURRY_KEY);
}
}
/**
* Method supporting screenshots during UI testing the application using OpenGL
*
* @param file
*/
public void takeScreenshot(final File file) {
tablexia.takeScreenShot(new Tablexia.ScreenshotListener() {
@Override
public void screenshotTaken(int width, int height, int[] screen) {
try {
for (int i = 0; i < screen.length; ++i) {
// The alpha and green channels' positions are preserved while the red and blue are swapped
screen[i] = ((screen[i] & 0xff00ff00)) | ((screen[i] & 0x000000ff) << 16) | ((screen[i] & 0x00ff0000) >> 16);
}
Bitmap sb = Bitmap.createBitmap(screen, width, height, Bitmap.Config.RGB_565);
// flip bitmap vertically
Matrix matrixMirror = new Matrix();
matrixMirror.preScale(1.0f, -1.0f);
sb = Bitmap.createBitmap(sb, 0, 0, sb.getWidth(), sb.getHeight(), matrixMirror, false);
// overwrite file
FileOutputStream fOut = new FileOutputStream(file);
sb.compress(Bitmap.CompressFormat.PNG, 100, fOut);
sb.recycle();
fOut.flush();
fOut.close();
} catch (Exception e) {
e.printStackTrace();
Log.err(this.getClass().getSimpleName(), e.getMessage());
}
}
});
}
public void post(Runnable r) {
......
package cz.nic.tablexia.android.camera;
/*
* Copyright 2012 Johnny Lish (johnnyoneeyed@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import android.content.Context;
import android.hardware.Camera;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.io.IOException;
import cz.nic.tablexia.util.Log;
public class CameraSurface extends SurfaceView implements SurfaceHolder.Callback {
private Camera camera;
private OnCameraReadyCallback cameraReadyCallback;
public CameraSurface(Context context, OnCameraReadyCallback cameraReadyCallback) {
super(context);
getHolder().addCallback(this);
this.cameraReadyCallback = cameraReadyCallback;
}
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
try {
camera.setPreviewDisplay(holder);
cameraReadyCallback.onCameraReady();
} catch (IOException e) {
Log.err(getClass(), "Cannot decode bitmap!", e);
}
}
public void orientationChanged(int i){
if (camera!=null) {
switch (i){
case Surface.ROTATION_90:
camera.setDisplayOrientation(0);
break;
case Surface.ROTATION_180:
camera.setDisplayOrientation(180);
break;
case Surface.ROTATION_270:
camera.setDisplayOrientation(180);
break;
default:
camera.setDisplayOrientation(0);
}
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
camera.setPreviewCallback(null);
camera.stopPreview();
holder.removeCallback(this);
holder.getSurface().release();
camera.release();
camera = null;
}
public Camera getCamera() {
return camera;
}
}
\ No newline at end of file
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.android.camera;
/**
* Created by Vitaliy Vashchenko on 7.10.16.
*/
public interface OnCameraReadyCallback {
void onCameraReady();
}
......@@ -25,9 +25,8 @@ buildscript {
jcenter { url "http://jcenter.bintray.com/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.12.0'
classpath 'de.felixschulze.gradle:gradle-spoon-plugin:2.1'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
classpath 'com.novoda:gradle-android-command-plugin:1.3.0'
classpath 'com.badlogicgames.gdx:gdx-tools:1.6.1'
......@@ -363,7 +362,6 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.jcabi:jcabi-manifests:1.1"
compile "org.xerial:sqlite-jdbc:$sqlLiteJdbcVersion"
......@@ -372,8 +370,7 @@ project(":desktop") {
project(":android") {
apply plugin: 'android-sdk-manager'
apply plugin: "android"
apply plugin: "spoon"
apply plugin: 'com.android.application'
apply plugin: 'android-command'
configurations { natives }
......@@ -382,21 +379,13 @@ project(":android") {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "org.sqldroid:sqldroid:$sqlDroidVersion"
compile "com.android.support:support-v4:$androidSupportV4Version"
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
compile files('libs/FlurryAnalytics-6.1.0.jar')
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
testCompile 'org.robolectric:robolectric:2.3'
androidTestCompile "com.squareup.spoon:spoon-client:1.1.7"
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
}
}
......@@ -413,8 +402,6 @@ project(":ios") {
compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
......@@ -430,7 +417,6 @@ project(":core") {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.google.guava:guava:$guavaVersion"
compile "com.google.zxing:core:$zxingVersion"
......
......@@ -63,7 +63,6 @@ task writeTablexiaBuildConfig {
" public final static String TABLEXIA_SERVER_HOST = ${project.hasProperty('TABLEXIA_SERVER_HOST') ? "\"$TABLEXIA_SERVER_HOST\"" : "null"};\n" +
" public final static Integer TABLEXIA_SERVER_PORT = ${project.hasProperty('TABLEXIA_SERVER_PORT') ? "$TABLEXIA_SERVER_PORT" : "null"};\n" +
" public final static String TABLEXIA_SERVER_SECRET = ${project.hasProperty('TABLEXIA_SERVER_SECRET') ? "\"$TABLEXIA_SERVER_SECRET\"" : "null"};\n" +
" public final static String FLURRY_KEY = ${project.hasProperty('TABLEXIA_FLURRY_KEY') ? "\"$TABLEXIA_FLURRY_KEY\"" : "null"};\n" +
" public final static String SENTRY_DSN_FALLBACK = \"${project.sentryDSNFallbackValue}\";\n" +
"\n" +
"}", BUILD_CONFIG_FILE_ENCODING)
......
Subproject commit fc4a4521a08566e4981de7ba2c0c74466597762c
Subproject commit 50028e47d6b5900c8aa42e04ae8b34b624c58385
......@@ -48,6 +48,7 @@ import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Utility;
import cz.nic.tablexia.util.ui.button.StandardTablexiaButton;
import cz.nic.tablexia.util.ui.QRCodeScanner;
import cz.nic.tablexia.util.ui.button.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog;
......@@ -59,6 +60,7 @@ 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.SingleButtonContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.TablexiaDialogComponentAdapter;
import cz.nic.tablexia.util.ui.dialog.components.TextContentDialogComponent;
......@@ -72,6 +74,8 @@ public class Tablexia extends TablexiaApplication {
public static final String ERROR_DIALOG_BACKGROUND_INTERNAL = INTERNAL_GFX_ASSETS_PATH + "dialog_square_borderlines.9.png";
public static final int ERROR_DIALOG_WIDTH = 460;
public static final int ERROR_DIALOG_HEIGHT = 300;
public static final int LOCALE_DIALOG_WIDTH = 320;
public static final int LOCALE_DIALOG_HEIGHT = 320;
public static final float ERROR_DIALOG_DIMMER = 0.7f;
public static final int BACK_BUTTON_SIZE = 50;
......@@ -96,7 +100,9 @@ public class Tablexia extends TablexiaApplication {
private boolean reset;
private boolean loadingComplete = false;
private boolean errorDialogShown = false;
private TablexiaComponentDialog dialog;
private boolean languageDialogShown = false;
private TablexiaComponentDialog errorDialog;
private TablexiaComponentDialog languageDialog;
public static class SQLConnectionType {
......@@ -379,9 +385,10 @@ public class Tablexia extends TablexiaApplication {
if (!loadingComplete) {
// load internal assets
if (!ApplicationFontManager.getInstance().update()) return;
if (!ApplicationTextManager.getInstance().update()) return;
if (!ApplicationInternalSoundManager.getInstance().update()) return;
if (!ApplicationInternalTextureManager.getInstance().update()) return;
if (!processLanguageChoose()) return;
if (!ApplicationTextManager.getInstance().update()) return;
// load external assets
if (!zipAssetLoader.update()) return;
......@@ -504,8 +511,35 @@ public class Tablexia extends TablexiaApplication {
}
});
components.add(new FixedSpaceContentDialogComponent());
dialog = TablexiaComponentDialogFactory.getInstance().createDialog(components.toArray(new TablexiaDialogComponentAdapter[]{}));
dialog.show(dialogWidth, dialogHeight);
errorDialog = TablexiaComponentDialogFactory.getInstance().createDialog(components.toArray(new TablexiaDialogComponentAdapter[]{}));
errorDialog.show(dialogWidth, dialogHeight);
}
private void showLanguageChooseDialog() {
languageDialogShown = true;
ArrayList<TablexiaDialogComponentAdapter> adapters = new ArrayList<>();
adapters.add(new CenterPositionDialogComponent());
for(final TablexiaSettings.LocaleDefinition localeDefinition : TablexiaSettings.LocaleDefinition.values()) {
if(localeDefinition.getNativeLocaleName() != null) {
adapters.add(new SingleButtonContentDialogComponent(
localeDefinition.getNativeLocaleName(),
true,
StandardTablexiaButton.TablexiaButtonType.GREEN,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TablexiaSettings.getInstance().setLocale(localeDefinition);
TablexiaSettings.languageChosen = true;
languageDialog.hide();
}
}
));
}
}
languageDialog = TablexiaComponentDialogFactory.getInstance().createDialog(adapters.toArray(new TablexiaDialogComponentAdapter[]{}));
languageDialog.show(LOCALE_DIALOG_WIDTH, LOCALE_DIALOG_HEIGHT);
}
private void returnToLastLocale() {
......@@ -522,12 +556,19 @@ 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();
} else if (loaderError == null && errorDialog != null) {
errorDialog.hide();
}
return errorDialogShown;
}
private boolean processLanguageChoose() {
if(!languageDialogShown && !TablexiaSettings.languageChosen) {
showLanguageChooseDialog();
}
return TablexiaSettings.languageChosen;
}
public static class ApplicationLoadingCompleteEvent implements ApplicationEvent {
private ApplicationLoadingCompleteEvent(){}
}
......
......@@ -85,6 +85,7 @@ public class TablexiaSettings {
private User selectedUser;
private boolean soundMuted = false;
protected static boolean languageChosen = false;
public enum Platform {
......@@ -217,6 +218,7 @@ public class TablexiaSettings {
BUILD_TYPE = buildType;
HAS_SOFT_BACK_BUTTON = hasSoftBackButton;
this.systemLocale = LocaleDefinition.getLocaleDefinitionForLocale(systemLocale);
languageChosen = selectedLocale == LocaleDefinition.FALLBACK_VARIANT || languageChosen;
}
public static TablexiaSettings getInstance() {
......@@ -254,6 +256,13 @@ public class TablexiaSettings {
lastLocale = LocaleDefinition.getLocaleDefinitionForKey(preferences.getString(LAST_LOCALE_KEY));
selectedLocale = LocaleDefinition.getLocaleDefinitionForKey(preferences.getString(LOCALE_KEY));
selectedUser = reset ? null : UserDAO.selectUser(preferences.getLong(SELECTED_USER));
languageChosen = selectedLocale != LocaleDefinition.FALLBACK_VARIANT || languageChosen;
//If system speech is supported and is not default speech (czech), set flag.
//If czech was fallback variant, correct flag is already set.
for (LocaleDefinition localeDefinition : LocaleDefinition.values()) {
if (localeDefinition == getSystemLocale() && localeDefinition != LocaleDefinition.cs_CZ) languageChosen = true;
}
Calendar calendar = GregorianCalendar.getInstance();
winterMode = (calendar.get(Calendar.MONTH) > WINTER_MODE_START_MONTH) || (calendar.get(Calendar.MONTH) < WINTER_MODE_END_MONTH);
......@@ -438,15 +447,15 @@ public class TablexiaSettings {
}
public enum LocaleDefinition {
SYSTEM (null, null, "system", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true) {
SYSTEM (null, null, "system", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SYSTEM, true, null, false) {
@Override
public int getLocaleNumber() {
return getLocaleDefinitionForLocale(instance.systemLocale.locale).modelLocaleDefinition.number();
}
},
cs_CZ (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.cs_CZ, new Locale("cs", "CZ"), "cs_CZ", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, true),
sk_SK (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.sk_SK, new Locale("sk", "SK"), "sk_SK", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, true),
de_DE (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.de_DE, new Locale("de", "DE"), "de_DE", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, true);
cs_CZ (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.cs_CZ, new Locale("cs", "CZ"), "cs_CZ", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_CZECH, true, "čeština", true),
sk_SK (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.sk_SK, new Locale("sk", "SK"), "sk_SK", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_SLOVAK, true, "slovenčina", true),
de_DE (cz.nic.tablexia.shared.model.definitions.LocaleDefinition.de_DE, new Locale("de", "DE"), "de_DE", ApplicationTextManager.ApplicationTextsAssets.LANGUAGE_GERMAN, true, "deutsch", true);
public final static LocaleDefinition DEFAULT_LOCALE = LocaleDefinition.cs_CZ;
private final static LocaleDefinition FALLBACK_VARIANT = LocaleDefinition.SYSTEM;
......@@ -456,15 +465,19 @@ public class TablexiaSettings {
private final String localeKey;
private final String descriptionKey;
private final boolean enabled;
private final String nativeLocaleName;
private final boolean selectable;
private static List<LocaleDefinition> enabledLocaleDefinitions;
LocaleDefinition(cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition, Locale locale, String localeKey, String descriptionKey, boolean enabled) {
LocaleDefinition(cz.nic.tablexia.shared.model.definitions.LocaleDefinition modelLocaleDefinition, Locale locale, String localeKey, String descriptionKey, boolean enabled, String nativeLocaleName, boolean selectable) {
this.modelLocaleDefinition = modelLocaleDefinition;
this.locale = locale;
this.localeKey = localeKey;
this.descriptionKey = descriptionKey;
this.enabled = enabled;
this.nativeLocaleName = nativeLocaleName;
this.selectable = selectable;
}
public String getLocaleKey() {
......@@ -479,6 +492,10 @@ public class TablexiaSettings {
return descriptionKey;
}
public String getNativeLocaleName() {
return nativeLocaleName;
}
public Locale getLocale() {
return locale != null ? locale : instance.systemLocale.locale;
}
......@@ -504,9 +521,11 @@ public class TablexiaSettings {
public static LocaleDefinition getLocaleDefinitionForLocale(Locale locale) {
for (LocaleDefinition localeDefinition : getEnabledLocaleDefinitions()) {
if (localeDefinition.locale != null && localeDefinition.locale.equals(locale)) {
languageChosen = true;
return localeDefinition;
}
}
languageChosen = false;
return DEFAULT_LOCALE;
}
......@@ -521,6 +540,16 @@ public class TablexiaSettings {
}
return enabledLocaleDefinitions;
}
public static List<LocaleDefinition> getSelectableLocaleDefinitions() {
List<LocaleDefinition> selectableLocaleDefinitions = new ArrayList<>();
for (LocaleDefinition localeDefinition : LocaleDefinition.values()) {
if (localeDefinition.selectable) {
selectableLocaleDefinitions.add(localeDefinition);
}
}
return selectableLocaleDefinitions;
}
}
public void setLocale(LocaleDefinition localeDefinition) {
......@@ -555,6 +584,10 @@ public class TablexiaSettings {
return selectedLocale.getLocale();
}
public LocaleDefinition getSystemLocale() {
return systemLocale;
}
//////////////////////////// SCREEN SIZE
......
......@@ -1382,7 +1382,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
}
private void forceGameEnd(GameResultDefinition gameResult) {
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getGameResultResolver().getExampleScoreForGameResult(getGameDifficulty().getDifficultyDefinition(), gameResult);
List<GameScore> gameScores = GameDefinition.getGameDefinitionForClass(getClass()).getCurrentGameScoreResolver().getExampleScoreForGameResult(getGameDifficulty().getDifficultyDefinition(), gameResult);
setGameScores(gameScores);
waitForActualGameScore();
......
......@@ -19,13 +19,10 @@ package cz.nic.tablexia.game;
import com.badlogic.gdx.scenes.scene2d.Group;
import java.util.List;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.bus.ApplicationBus.ApplicationEvent;
import cz.nic.tablexia.game.difficulty.GameDifficulty;