Commit d5ebbe68 authored by Matyáš Latner's avatar Matyáš Latner

Merge branch 'devel' into feature-gitlab-ci

parents b29699c2 c470a10e
......@@ -58,6 +58,12 @@ android {
resValue "string", "app_name", "${tablexiaAppName}"
resValue "string", "sentry_dsn", project.sentryDSN
}
iTest.initWith(buildTypes.debug)
iTest {
applicationIdSuffix rootProject.applicationIdITestSuffix
buildConfigField ASSETS_CHECKSUM_FIELD_TYPE, ASSETS_CHECKSUM_FIELD_NAME, rootProject.ext.assetsChecksumPattern
resValue "string", "app_name", "${tablexiaAppName}"
}
devel.initWith(buildTypes.debug)
devel {
applicationIdSuffix rootProject.applicationIdDevelSuffix
......@@ -69,10 +75,10 @@ android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
manifest.srcFile 'src/main/AndroidManifest.xml'
res.srcDirs = ['res/main']
assets.srcDirs = ['assets']
java.srcDir file('src/main/java')
java.srcDirs = ['src/main/java']
jniLibs.srcDirs = ['libs']
}
test {
......@@ -85,12 +91,17 @@ android {
debug {
res.srcDirs = ['res/debug']
}
iTest {
manifest.srcFile 'src/iTest/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'src/iTest/java', '../itest/src/']
res.srcDirs = ['res/iTest']
}
devel {
res.srcDirs = ['res/devel']
}
}
assemble.dependsOn = ['assembleRelease', 'assembleDebug']
assemble.dependsOn = ['assembleRelease', 'assembleDebug', 'assembleITest']
applicationVariants.all { variant ->
if (!variant.buildType.name.equals("devel")) {
......
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity
android:name="cz.nic.tablexia.android.AndroidLauncher"
tools:node="remove"/>
<activity
android:name="cz.nic.tablexia.android.AndroidITestLauncher"
android:label="@string/app_name"
android:screenOrientation="sensorLandscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. <info@tablexia.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;
import android.os.Bundle;
import cz.nic.tablexia.testing.TestRunner;
/**
* Created by frantisek on 13.4.16.
*/
public class AndroidITestLauncher extends AndroidLauncher {
@Override
protected void onCreate(Bundle savedInstanceState) {
String testClassName = null;
Bundle extras = this.getIntent().getExtras();
if ( extras != null ) {
if (extras.containsKey("testClassName")) {
testClassName = (String) extras.get("testClassName");
}
}
super.onCreate(savedInstanceState);
runTest(testClassName);
}
private void runTest(String testClassName){
TestRunner testRunner = new TestRunner(tablexia);
testRunner.runTest(testClassName);
}
}
......@@ -28,19 +28,20 @@ import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import cz.nic.tablexia.Tablexia;
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.android.camera.AndroidQRCodeScanner;
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:");
private static final int MULTI_SAMPLING_2X = 2;
private static final boolean HAS_SOFT_BACK_BUTTON = false;
protected Tablexia tablexia;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -61,7 +62,7 @@ public class AndroidLauncher extends AndroidApplication {
config.useWakelock = true;
config.numSamples = MULTI_SAMPLING_2X;
initialize(new Tablexia(BuildConfig.BUILD_TYPE,
initialize(tablexia = new Tablexia(BuildConfig.BUILD_TYPE,
getResources().getConfiguration().locale,
SQL_CONNECTION_TYPE,
new AndroidConnectionManager(getContext()),
......
......@@ -25,7 +25,7 @@ buildscript {
jcenter { url "http://jcenter.bintray.com/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.12.0'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
classpath 'com.novoda:gradle-android-command-plugin:1.3.0'
......@@ -77,6 +77,8 @@ allprojects {
applicationIdRelease = applicationBaseId + applicationIdBranch
applicationIdDebugSuffix = '.debug'
applicationIdDebug = applicationIdRelease + applicationIdDebugSuffix
applicationIdITestSuffix = '.itest'
applicationIdITest = applicationIdRelease + applicationIdITestSuffix
applicationIdDevelSuffix = '.devel'
applicationIdDevel = applicationBaseId + applicationIdDevelSuffix
......@@ -387,6 +389,7 @@ project(":android") {
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "org.sqldroid:sqldroid:$sqlDroidVersion"
......@@ -437,6 +440,14 @@ project(":core") {
}
}
project(":itest") {
apply plugin: "java"
dependencies {
compile project(':core')
}
}
tasks.eclipse.doLast {
delete ".project"
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. <info@tablexia.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.shared.model;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/**
*
* @author Frantisek Simon <frantisek.simon@nic.cz>
*/
public class Game {
public static final int DEFAULT_GAME_LOCALE = -1;
public static final String DEFAULT_APPLICATION_VERSION_NAME = "UNKNOWN";
public static final int DEFAULT_APPLICATION_VERSION_CODE = -1;
public static final String DEFAULT_MODEL_VERSION_NAME = "UNKNOWN";
public static final int DEFAULT_MODE_VERSION_CODE = -1;
public static final int DEFAULT_BUILD_TYPE = -1;
public static final int DEFAULT_PLATFORM = -1;
public static final int BACK_COMPATIBILITY_321_RANK_SYSTEM_VERSION_CODE = 1;
private static final String DATE_AND_TIME_FORMAT = "d.M.yyyy HH:mm:ss", DATE_FORMAT = "d.M.yyyy";
private long id;
private User user;
private int gameDifficulty;
private int gameNumber;
private int gameLocale;
private Long randomSeed;
private Long startTime;
private Long endTime;
private String applicationVersionName;
private int applicationVersionCode;
private String modelVersionName;
private int modelVersionCode;
private Integer rankSystemVersionCode;
private int buildType;
private int platform;
private String hwSerialNumber;
private List<GameScore> gameScoreMap;
private List<GamePause> gamePauses;
// needed for JSON de/serialization
public Game() {
}
public Game(Long id, User user, int difficulty, int gameNumber, Long random, Long startTime, Long endTime, int gameLocale, String applicationVersionName, Integer applicationVersionCode, String modelVersionName, Integer modelVersionCode, Integer buildType, Integer platform, String hwSerialNumber, Integer rankSystemVersionCode) {
this.id = id;
this.user = user;
this.gameDifficulty = difficulty;
this.gameNumber = gameNumber;
this.gameLocale = gameLocale;
this.randomSeed = random;
this.startTime = startTime;
this.endTime = endTime;
this.applicationVersionName = applicationVersionName == null ? DEFAULT_APPLICATION_VERSION_NAME : applicationVersionName;
this.applicationVersionCode = applicationVersionCode == null ? DEFAULT_APPLICATION_VERSION_CODE : applicationVersionCode;
this.modelVersionName = modelVersionName == null ? DEFAULT_MODEL_VERSION_NAME : modelVersionName;
this.modelVersionCode = modelVersionCode == null ? DEFAULT_MODE_VERSION_CODE : modelVersionCode;
this.buildType = buildType == null ? DEFAULT_BUILD_TYPE : buildType;
this.platform = platform == null ? DEFAULT_PLATFORM : platform;
this.rankSystemVersionCode = rankSystemVersionCode;
this.hwSerialNumber = hwSerialNumber;
gameScoreMap = new ArrayList<GameScore>();
gamePauses = new ArrayList<GamePause>();
}
public long getId() {
return id;
}
public User getUser() {
return user;
}
public int getGameDifficulty() {
return gameDifficulty;
}
public int getGameNumber() {
return gameNumber;
}
public int getGameLocale() {
return gameLocale;
}
public List<GameScore> getGameScoreMap() {
return gameScoreMap;
}
public List<GamePause> getGamePauses() {
return gamePauses;
}
public String getApplicationVersionName() {
return applicationVersionName;
}
public int getApplicationVersionCode() {
return applicationVersionCode;
}
public String getModelVersionName() {
return modelVersionName;
}
public int getModelVersionCode() {
return modelVersionCode;
}
public int getBuildType() {
return buildType;
}
public int getPlatform() {
return platform;
}
public String getHwSerialNumber() {
return hwSerialNumber;
}
public long getRandomSeed() {
return randomSeed;
}
public void setGamePauses(List<GamePause> gamePauses) {
this.gamePauses = gamePauses;
}
public void setGameScoreMap(List<GameScore> gameScoreMap) {
this.gameScoreMap = gameScoreMap;
}
public Long getGameStartTime() {
return startTime != null ? startTime : 0;
}
public String getGameStartDate(boolean dateAndTime) {
if (startTime == null) return "";
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(startTime);
SimpleDateFormat sdf;
if (dateAndTime) {
sdf = new SimpleDateFormat(DATE_AND_TIME_FORMAT);
} else {
sdf = new SimpleDateFormat(DATE_FORMAT);
}
return sdf.format(cal.getTime());
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
public Long getStartTime() {
return startTime;
}
public Long getEndTime() {
return endTime;
}
public void setRankSystemVersionCode(Integer rankSystemVersionCode) {
this.rankSystemVersionCode = rankSystemVersionCode;
}
public Integer getRankSystemVersionCode() {
return rankSystemVersionCode;
}
public boolean isStarted() {
return startTime != null;
}
public boolean isFinished() {
return endTime != null;
}
public GameScore getGameScore(String key) {
for (GameScore score : getGameScoreMap()) {
if (score.getKey().equals(key)) {
return score;
}
}
return null;
}
public String getGameScoreValue(String key) {
GameScore score = getGameScore(key);
if (score == null) {
return null;
}
return score.getValue();
}
public String getGameScore(String key, String defaultValue) {
GameScore gameScore = getGameScore(key);
return (gameScore != null && gameScore.getValue() != null) ? gameScore.getValue() : defaultValue;
}
@Override
public String toString() {
String output = "GAME[id: " + id + ", user: " + (user == null ? "unknown" : user.getName()) + ", difficulty: " + gameDifficulty + ", game: " + gameNumber + ", locale: " + gameLocale + ", random: " + randomSeed + ", start: " + startTime + ", end: " + endTime + "]";
output = output + " SCORE: [";
for (GameScore gameScore : gameScoreMap) {
output = output + " " + gameScore.getKey() + " : " + gameScore.getValue();
}
output = output + "]";
return output;
}
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. <info@tablexia.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.shared.model;
/**
*
* @author Frantisek Simon <frantisek.simon@nic.cz>
*/
public class GamePause {
private long id;
private Long startTime;
private Long endTime;
// needed for JSON de/serialization
public GamePause() {
}
public GamePause(Long id, Long startTime) {
this(id, startTime, null);
}
public GamePause(Long id, Long startTime, Long endTime) {
this.id = id;
this.startTime = startTime;
this.endTime = endTime;
}
public long getId() {
return id;
}
public Long getStartTime() {
return startTime;
}
public Long getEndTime() {
return endTime;
}
public boolean hasStartTime() {
return startTime != null;
}
public boolean hasEndTime() {
return endTime != null;
}
@Override
public String toString() {
return "GAME PAUSE[id: " + id + ", start: " + startTime + ", end: " + endTime + "]";
}
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. <info@tablexia.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.shared.model;
/**
*
* @author Frantisek Simon <frantisek.simon@nic.cz>
*/
public class GameScore {
private String key;
private String value;
// needed for JSON de/serialization
public GameScore() {
}
public GameScore(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return String.format("key: %s, value: %s", key, value);
}
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. <info@tablexia.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.shared.model;
/**
* Created by danilov on 1/27/16.
*/
public class Screen {
private long id;
private long userId;
private String screenName;
private long time;
public Screen() {
}
public Screen(long id, long userId, String screenName, long time) {
this.id = id;
this.userId = userId;
this.screenName= screenName;
this.time = time;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public String getScreenName() {
return screenName;
}
public void setScreenName(String screenName) {
this.screenName = screenName;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Override
public String toString() {
return "SCREEN[User ID: " + userId + " Screen name: " + screenName+ " Time: " + time + "]";
}
}
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. <info@tablexia.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