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 ...@@ -243,6 +243,7 @@ user_rank_10=Rozumbrada
user_rank_11=Vrchní rada user_rank_11=Vrchní rada
sync_request_dialog_text=Zadej číslo průkazu: 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_button=Synchronizovat uživatele
sync_request_wrong_id=Špatně zadaný kód. sync_request_wrong_id=Špatně zadaný kód.
sync_request_error=Synchronizace se nezdařila, zkuste to prosím později. sync_request_error=Synchronizace se nezdařila, zkuste to prosím později.
......
...@@ -243,6 +243,7 @@ user_rank_10=Besserwisser ...@@ -243,6 +243,7 @@ user_rank_10=Besserwisser
user_rank_11=Oberrat user_rank_11=Oberrat
sync_request_dialog_text=Trage deine Ausweisnummer ein: 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_button=Account synchronisieren
sync_request_wrong_id=Falsch geschriebener Code. sync_request_wrong_id=Falsch geschriebener Code.
sync_request_error=Die synchronisierung ist fehlgeschlagen, bitte versuche es später noch einmal. sync_request_error=Die synchronisierung ist fehlgeschlagen, bitte versuche es später noch einmal.
......
...@@ -246,6 +246,7 @@ user_rank_10=Rozumbrada ...@@ -246,6 +246,7 @@ user_rank_10=Rozumbrada
user_rank_11=Šefmajster user_rank_11=Šefmajster
sync_request_dialog_text=Zadaj číslo preukazu: 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_button=Synchronizovať užívateľa
sync_request_wrong_id=Zle zadaný kód. sync_request_wrong_id=Zle zadaný kód.
sync_request_error=Synchronizácia sa nepodarila, skúste to prosím neskôr. 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/" ...@@ -21,7 +21,7 @@ final BUILD_CONFIG_DIR = "${buildDir}/generated/source/buildConfig/"
final BUILD_CONFIG_ENCODING = 'UTF-8' final BUILD_CONFIG_ENCODING = 'UTF-8'
android { android {
buildToolsVersion "20.0.0" buildToolsVersion "24.0.3"
compileSdkVersion 21 compileSdkVersion 21
packagingOptions { packagingOptions {
...@@ -34,11 +34,14 @@ android { ...@@ -34,11 +34,14 @@ android {
} }
defaultConfig { defaultConfig {
targetSdkVersion 17 targetSdkVersion 21
versionName tablexiaVersionName versionName tablexiaVersionName
versionCode tablexiaVersionCode versionCode tablexiaVersionCode
applicationId rootProject.applicationBaseId applicationId rootProject.applicationBaseId
testApplicationId rootProject.applicationBaseId + ".test" testApplicationId rootProject.applicationBaseId + ".test"
jackOptions {
enabled true
}
} }
buildTypes { buildTypes {
...@@ -78,9 +81,6 @@ android { ...@@ -78,9 +81,6 @@ android {
java.srcDirs = ['src/main/java'] java.srcDirs = ['src/main/java']
jniLibs.srcDirs = ['libs'] jniLibs.srcDirs = ['libs']
} }
androidTest {
java.srcDir file('src/androidTest/java')
}
test { test {
java.srcDir file('src/test/java') java.srcDir file('src/test/java')
} }
...@@ -130,8 +130,8 @@ android { ...@@ -130,8 +130,8 @@ android {
} }
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_8
} }
command { command {
...@@ -261,11 +261,3 @@ idea { ...@@ -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; ...@@ -19,33 +19,27 @@ package cz.nic.tablexia.android;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; 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.Tablexia;
import cz.nic.tablexia.TablexiaBuildConfig; import cz.nic.tablexia.android.camera.AndroidCamera2QRCodeScanner;
import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.android.camera.AndroidQRCodeScanner;
import cz.nic.tablexia.debug.BuildConfig; import cz.nic.tablexia.debug.BuildConfig;
import cz.nic.tablexia.debug.R; import cz.nic.tablexia.debug.R;
import cz.nic.tablexia.screen.loader.IConnectionManager; 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 class AndroidLauncher extends AndroidApplication {
public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("org.sqldroid.SQLDroidDriver", "jdbc:sqldroid:"); public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("org.sqldroid.SQLDroidDriver", "jdbc:sqldroid:");
protected static final int MULTI_SAMPLING_2X = 2; private static final int MULTI_SAMPLING_2X = 2;
public static final boolean HAS_SOFT_BACK_BUTTON = false; private static final boolean HAS_SOFT_BACK_BUTTON = false;
protected Tablexia tablexia; protected Tablexia tablexia;
...@@ -68,6 +62,8 @@ public class AndroidLauncher extends AndroidApplication { ...@@ -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(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useWakelock = true; config.useWakelock = true;
config.numSamples = MULTI_SAMPLING_2X; config.numSamples = MULTI_SAMPLING_2X;
...@@ -76,51 +72,12 @@ public class AndroidLauncher extends AndroidApplication { ...@@ -76,51 +72,12 @@ public class AndroidLauncher extends AndroidApplication {
getResources().getConfiguration().locale, getResources().getConfiguration().locale,
SQL_CONNECTION_TYPE, SQL_CONNECTION_TYPE,
new AndroidConnectionManager(getContext()), new AndroidConnectionManager(getContext()),
new AndroidQRCodeScanner(this), qrCodeScanner,
getResources().getString(R.string.sentry_dsn), getResources().getString(R.string.sentry_dsn),
HAS_SOFT_BACK_BUTTON, HAS_SOFT_BACK_BUTTON,
savedInstanceState == null, savedInstanceState == null,
Build.SERIAL), config); Build.SERIAL), config);
runTest(); 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) { 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 { ...@@ -25,9 +25,8 @@ buildscript {
jcenter { url "http://jcenter.bintray.com/" } jcenter { url "http://jcenter.bintray.com/" }
} }
dependencies { 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 '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.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
classpath 'com.novoda:gradle-android-command-plugin:1.3.0' classpath 'com.novoda:gradle-android-command-plugin:1.3.0'
classpath 'com.badlogicgames.gdx:gdx-tools:1.6.1' classpath 'com.badlogicgames.gdx:gdx-tools:1.6.1'
...@@ -363,7 +362,6 @@ project(":desktop") { ...@@ -363,7 +362,6 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "net.engio:mbassador:$mbassadorVersion" compile "net.engio:mbassador:$mbassadorVersion"
compile "com.jcabi:jcabi-manifests:1.1" compile "com.jcabi:jcabi-manifests:1.1"
compile "org.xerial:sqlite-jdbc:$sqlLiteJdbcVersion" compile "org.xerial:sqlite-jdbc:$sqlLiteJdbcVersion"
...@@ -372,8 +370,7 @@ project(":desktop") { ...@@ -372,8 +370,7 @@ project(":desktop") {
project(":android") { project(":android") {
apply plugin: 'android-sdk-manager' apply plugin: 'android-sdk-manager'
apply plugin: "android" apply plugin: 'com.android.application'
apply plugin: "spoon"
apply plugin: 'android-command' apply plugin: 'android-command'
configurations { natives } configurations { natives }
...@@ -382,21 +379,13 @@ project(":android") { ...@@ -382,21 +379,13 @@ project(":android") {
compile project(":core") compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion" compile "net.engio:mbassador:$mbassadorVersion"
compile "org.sqldroid:sqldroid:$sqlDroidVersion" 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"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
testCompile 'org.robolectric:robolectric:2.3' 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' androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
} }
} }
...@@ -413,8 +402,6 @@ project(":ios") { ...@@ -413,8 +402,6 @@ project(":ios") {
compile "org.robovm:robovm-cocoatouch:${roboVMVersion}" compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
compile "net.engio:mbassador:$mbassadorVersion" compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" 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" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
} }
} }
...@@ -430,7 +417,6 @@ project(":core") { ...@@ -430,7 +417,6 @@ project(":core") {
compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion" compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion"
compile "net.engio:mbassador:$mbassadorVersion" compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.google.guava:guava:$guavaVersion" compile "com.google.guava:guava:$guavaVersion"
compile "com.google.zxing:core:$zxingVersion" compile "com.google.zxing:core:$zxingVersion"
......
...@@ -63,7 +63,6 @@ task writeTablexiaBuildConfig { ...@@ -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 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 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 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" + " public final static String SENTRY_DSN_FALLBACK = \"${project.sentryDSNFallbackValue}\";\n" +
"\n" + "\n" +
"}", BUILD_CONFIG_FILE_ENCODING) "}", BUILD_CONFIG_FILE_ENCODING)
......
Subproject commit fc4a4521a08566e4981de7ba2c0c74466597762c Subproject commit 50028e47d6b5900c8aa42e04ae8b34b624c58385
...@@ -48,6 +48,7 @@ import cz.nic.tablexia.screen.AbstractTablexiaScreen; ...@@ -48,6 +48,7 @@ import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.loader.IConnectionManager; import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.util.Log; import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Utility; 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.QRCodeScanner;
import cz.nic.tablexia.util.ui.button.TablexiaButton; import cz.nic.tablexia.util.ui.button.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog; import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog;
...@@ -59,6 +60,7 @@ import cz.nic.tablexia.util.ui.dialog.components.DimmerDialogComponent; ...@@ -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.FixedSpaceContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.PositiveNegativeButtonContentDialogComponent; 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.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.TablexiaDialogComponentAdapter;
import cz.nic.tablexia.util.ui.dialog.components.TextContentDialogComponent; import cz.nic.tablexia.util.ui.dialog.components.TextContentDialogComponent;
...@@ -72,6 +74,8 @@ public class Tablexia extends TablexiaApplication { ...@@ -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 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_WIDTH = 460;
public static final int ERROR_DIALOG_HEIGHT = 300; 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 float ERROR_DIALOG_DIMMER = 0.7f;
public static final int BACK_BUTTON_SIZE = 50; public static final int BACK_BUTTON_SIZE = 50;
...@@ -96,7 +100,9 @@ public class Tablexia extends TablexiaApplication { ...@@ -96,7 +100,9 @@ public class Tablexia extends TablexiaApplication {
private boolean reset; private boolean reset;
private boolean loadingComplete = false; private boolean loadingComplete = false;
private boolean errorDialogShown = false; private boolean errorDialogShown = false;
private TablexiaComponentDialog dialog; private boolean languageDialogShown = false;
private TablexiaComponentDialog errorDialog;
private TablexiaComponentDialog languageDialog;
public static class SQLConnectionType { public static class SQLConnectionType {
...@@ -379,9 +385,10 @@ public class Tablexia extends TablexiaApplication { ...@@ -379,9 +385,10 @@ public class Tablexia extends TablexiaApplication {
if (!loadingComplete) { if (!loadingComplete) {
// load internal assets // load internal assets
if (!ApplicationFontManager.getInstance().update()) return; if (!ApplicationFontManager.getInstance().update()) return;
if (!ApplicationTextManager.getInstance().update()) return; if (!ApplicationInternalSoundManager.getInstance().update()) return;
if (!ApplicationInternalSoundManager.getInstance().update()) return;
if (!ApplicationInternalTextureManager.getInstance().update()) return; if (!ApplicationInternalTextureManager.getInstance().update()) return;
if (!processLanguageChoose()) return;
if (!ApplicationTextManager.getInstance().update()) return;
// load external assets // load external assets
if (!zipAssetLoader.update()) return; if (!zipAssetLoader.update()) return;
...@@ -504,8 +511,35 @@ public class Tablexia extends TablexiaApplication { ...@@ -504,8 +511,35 @@ public class Tablexia extends TablexiaApplication {
} }
}); });
components.add(new FixedSpaceContentDialogComponent()); components.add(new FixedSpaceContentDialogComponent());
dialog = TablexiaComponentDialogFactory.getInstance().createDialog(components.toArray(new TablexiaDialogComponentAdapter[]{})); errorDialog = TablexiaComponentDialogFactory.getInstance().createDialog(components.toArray(new TablexiaDialogComponentAdapter[]{}));
dialog.show(dialogWidth, dialogHeight); 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() { private void returnToLastLocale() {
...@@ -522,12 +556,19 @@ public class Tablexia extends TablexiaApplication { ...@@ -522,12 +556,19 @@ public class Tablexia extends TablexiaApplication {
if (loaderError != null && !errorDialogShown) { if (loaderError != null && !errorDialogShown) {
showLoaderErrorDialog(ERROR_DIALOG_WIDTH, ERROR_DIALOG_HEIGHT, loaderError); showLoaderErrorDialog(ERROR_DIALOG_WIDTH, ERROR_DIALOG_HEIGHT, loaderError);
errorDialogShown = true; errorDialogShown = true;
} else if (loaderError == null && dialog != null) { } else if (loaderError == null && errorDialog != null) {
dialog.hide(); errorDialog.hide();
} }
return errorDialogShown; return errorDialogShown;
} }
private boolean processLanguageChoose() {
if(!languageDialogShown && !TablexiaSettings.languageChosen) {
showLanguageChooseDialog();
}
return TablexiaSettings.languageChosen;
}
public static class ApplicationLoadingCompleteEvent implements ApplicationEvent { public static class ApplicationLoadingCompleteEvent implements ApplicationEvent {
private ApplicationLoadingCompleteEvent(){} private ApplicationLoadingCompleteEvent(){}
} }
......
...@@ -85,6 +85,7 @@ public class TablexiaSettings { ...@@ -85,6 +85,7 @@ public class TablexiaSettings {
private User selectedUser; private User selectedUser;