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

Merge branch 'feature-hwidentification' into V3.2.1

parents 474c5b24 2e62d427
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.net.ConnectivityManager;
import android.os.Build;
import android.os.Bundle;
import com.badlogic.gdx.Gdx;
......@@ -44,7 +45,8 @@ public class AndroidLauncher extends AndroidApplication {
new AndroidConnectionManager(getContext()),
getResources().getString(R.string.sentry_dsn),
HAS_SOFT_BACK_BUTTON,
savedInstanceState == null), config);
savedInstanceState == null,
Build.SERIAL), config);
if (TablexiaSettings.getInstance().getBuildType().isBugReport() && TablexiaBuildConfig.FLURRY_KEY != null) {
FlurryAgent.setLogEnabled(false);
......
......@@ -35,7 +35,8 @@ task writeTablexiaBuildConfig {
"public class TablexiaBuildConfig {\n" +
"\n" +
" public final static String APP_NAME = \"${tablexiaAppName}\";\n" +
" public final static String VERSION_NAME = \"${tablexiaVersionName}\";\n" +
" public final static String APPLICATION_VERSION_NAME = \"${tablexiaVersionName}\";\n" +
" public final static Integer APPLICATION_VERSION_CODE = ${tablexiaVersionCode};\n" +
" public final static String ASSETS_CHECKSUM = \"${getMapConvertedToString(rootProject.ext.assetsChecksum)}\";\n" +
" public final static String TABLEXIA_ASSETS_URL = ${project.hasProperty('TABLEXIA_ASSETS_DOWNLOAD_URL') ? "\"$TABLEXIA_ASSETS_DOWNLOAD_URL\"" : "null"};\n" +
" public final static String TABLEXIA_SERVER_PROTOCOL = ${project.hasProperty('TABLEXIA_SERVER_PROTOCOL') ? "\"$TABLEXIA_SERVER_PROTOCOL\"" : "null"};\n" +
......
external @ 5c5f8f81
Subproject commit c9a43b48540cca60fea31b7a678265de3484a889
Subproject commit 5c5f8f81122f02f87510a505ecbd74fde4289f2b
......@@ -98,12 +98,12 @@ public class Tablexia extends TablexiaApplication {
}
}
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, String sentryDSN, boolean hasSoftBackButton, boolean reset) {
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, String sentryDSN, boolean hasSoftBackButton, boolean reset, String hwSerial) {
this.reset = reset;
connectionManager = validateConnectionManager(connManager);
this.sqlConnectionType = sqlConnectionType;
TablexiaSettings.init(buildType, systemLocale, hasSoftBackButton);
TablexiaSettings.init(buildType, systemLocale, hasSoftBackButton, hwSerial);
// register error handler for exceptions in event bus handler methods
ApplicationBus.getInstance().addErrorHandler(new IPublicationErrorHandler() {
......
......@@ -95,7 +95,7 @@ public class TablexiaRaven {
Version(InfoType.TAG, "Version", new StringRunnable() {
@Override
public String run() {
return TablexiaBuildConfig.VERSION_NAME;
return TablexiaBuildConfig.APPLICATION_VERSION_NAME;
}
}),
BuildType(InfoType.TAG, "BuildType", new StringRunnable() {
......
......@@ -53,10 +53,12 @@ public class TablexiaSettings {
private static final int WINTER_MODE_END_MONTH = 2;
private static boolean winterMode = false;
private static final String APP_NAME = TablexiaBuildConfig.APP_NAME;
private final String VERSION_NAME = TablexiaBuildConfig.VERSION_NAME;
private static final String APP_NAME = TablexiaBuildConfig.APP_NAME;
private final String APPLICATION_VERSION_NAME = TablexiaBuildConfig.APPLICATION_VERSION_NAME;
private final int APPLICATION_VERSION_CODE = TablexiaBuildConfig.APPLICATION_VERSION_CODE;
private final BuildType BUILD_TYPE;
private final boolean HAS_SOFT_BACK_BUTTON;
private static String hwSerial;
private Preferences preferences;
private LocaleDefinition systemLocale;
......@@ -164,11 +166,11 @@ public class TablexiaSettings {
return instance;
}
static void init(String buildTypeKey, Locale systemLocale, boolean hasSoftBackButton) {
TablexiaSettings.init(BuildType.getBuildTypeForKey(buildTypeKey), systemLocale, hasSoftBackButton);
static void init(String buildTypeKey, Locale systemLocale, boolean hasSoftBackButton, String hwSerial) {
TablexiaSettings.init(BuildType.getBuildTypeForKey(buildTypeKey), systemLocale, hasSoftBackButton, hwSerial);
}
static void init(BuildType buildType, Locale systemLocale, boolean hasSoftBackButton) {
static void init(BuildType buildType, Locale systemLocale, boolean hasSoftBackButton, String hwSerial) {
if (instance != null) {
String exceptionMessage = "Tablexia settings already initialized!";
Log.err(TablexiaSettings.class, exceptionMessage);
......@@ -176,6 +178,7 @@ public class TablexiaSettings {
}
instance = new TablexiaSettings(buildType, systemLocale, hasSoftBackButton);
TablexiaSettings.hwSerial = hwSerial;
}
void dispose() {
......@@ -207,13 +210,21 @@ public class TablexiaSettings {
}
public String getVersionName() {
return VERSION_NAME;
return APPLICATION_VERSION_NAME;
}
public int getVersionCode() {
return APPLICATION_VERSION_CODE;
}
public boolean hasSoftBackButton() {
return HAS_SOFT_BACK_BUTTON;
}
public String getHwSerial() {
return hwSerial;
}
public boolean isWinterMode() { return winterMode; }
public boolean isShowBoundingBoxes() {
......
......@@ -430,7 +430,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
random = TablexiaSettings.GAMES_RANDOM_SEED == null ? new TablexiaRandom() : new TablexiaRandom(TablexiaSettings.GAMES_RANDOM_SEED);
GameDefinition gameDefinition = GameDefinition.getGameDefinitionForClass(AbstractTablexiaGame.this.getClass());
GameDifficulty gameDifficulty = gameDefinition.hasTutorial() && UserDAO.isTutorialForGameDefinition(gameDefinition, getSelectedUser()) ? GameDifficulty.TUTORIAL : getGameDifficulty();
game = GameDAO.createGame(getSelectedUser(), gameDifficulty, gameDefinition, random);
game = GameDAO.createGame(getSelectedUser(), gameDifficulty, gameDefinition, random, TablexiaSettings.getInstance().getHwSerial(), TablexiaSettings.getInstance().getVersionName(), TablexiaSettings.getInstance().getVersionCode());
Log.info(getClass(), "[DB] Created new GAME object: " + game);
} else {
Log.info(getClass(), "[DB] Restored last GAME object: " + game);
......
......@@ -32,7 +32,9 @@ public class DatabaseManager {
private enum VersionScript {
VERSION_01( 1, "ALTER TABLE game ADD locale INTEGER NOT NULL DEFAULT " + Game.DEFAULT_GAME_LOCALE),
VERSION_02( 2, "ALTER TABLE game ADD version TEXT NOT NULL DEFAULT '" + Game.DEFAULT_GAME_VERSION + "'");
VERSION_02( 2, "ALTER TABLE game ADD version_name TEXT NOT NULL DEFAULT '" + Game.DEFAULT_GAME_VERSION_NAME + "'"),
VERSION_03( 3, "ALTER TABLE game ADD version_code INTEGER NOT NULL DEFAULT " + Game.DEFAULT_GAME_VERSION_CODE),
VERSION_04( 4, "ALTER TABLE game ADD hw_serial_number TEXT");
private int version;
private String sqlStatement;
......
......@@ -150,16 +150,16 @@ public class GameDAO {
// prepared statements
public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS game (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, start_time INTEGER, end_time INTEGER, difficulty_number INTEGER NOT NULL, game_number INTEGER NOT NULL, random_seed INTEGER NOT NULL, sync_at INTEGER, FOREIGN KEY(user_id) REFERENCES user(id))";
public static final String NEW_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, locale, version, random_seed) VALUES (?, ?, ?, ?, ?, ?)";
public static final String NEW_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, random_seed, locale, version_name, version_code, hw_serial_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
public static final String GAME_UPDATE_START = "UPDATE game SET start_time = ? WHERE id = ?";
public static final String GAME_UPDATE_END = "UPDATE game SET end_time = ? WHERE id = ?";
public static final String GAME_UPDATE_SYNC_AT = "UPDATE game SET sync_at = ? WHERE id = ?";
public static final String GAME_SELECT_FOR_ID = "SELECT id, user_id, difficulty_number, game_number, locale, version, random_seed, start_time, end_time FROM game WHERE id = ?";
public static final String GAME_SELECT_FOR_ID = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time, locale, version_name, version_code, hw_serial_number FROM game WHERE id = ?";
public static final String GAME_SELECT_LAST_ID = "SELECT max(id) FROM game";
public static final String GAME_SELECT_COUNT_FOR_GAME_AND_DIFFICULTY = "SELECT count(id) FROM game WHERE game_number = ? AND difficulty_number = ? AND user_id = ? AND end_time IS NOT NULL";
public static final String GAME_SELECT_FOR_USER_AND_DEFINITION = "SELECT id, user_id, difficulty_number, game_number, locale, random_seed, start_time, end_time FROM game WHERE user_id = ? AND game_number = ? AND end_time IS NOT NULL AND end_time != 0 ORDER BY start_time ASC";
public static final String GAME_SELECT_FOR_USER_AND_DEFINITION = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time, locale, version_name, version_code, hw_serial_number FROM game WHERE user_id = ? AND game_number = ? AND end_time IS NOT NULL AND end_time != 0 ORDER BY start_time ASC";
public static final String GAME_SELECT_COUNT_FOR_GAME = "SELECT count(id) FROM game WHERE game_number = ? AND user_id = ?";
public static final String GAME_SELECT_ALL_FOR_USER_SYNC = "SELECT id, user_id, difficulty_number, game_number, locale, version, random_seed, start_time, end_time FROM game where user_id = ? AND sync_at is null";
public static final String GAME_SELECT_ALL_FOR_USER_SYNC = "SELECT id, user_id, difficulty_number, game_number, version, random_seed, start_time, end_time, locale, version_name, version_code, hw_serial_number FROM game where user_id = ? AND sync_at is null";
public static final String GAME_SELECT_BY_START_AND_END = "SELECT id FROM game WHERE user_id = ? AND start_time = ? AND end_time = ?";
public static final String GAME_SELECT_BY_START_AND_NULL_END = "SELECT id FROM game WHERE user_id = ? AND start_time = ? AND end_time IS NULL";
......@@ -168,7 +168,7 @@ public class GameDAO {
public static final String GAME_SELECT_FOR_RANK_MANAGER = "SELECT id, difficulty_number, game_number, version, start_time, end_time FROM game WHERE user_id = ? AND start_time IS NOT NULL AND start_time != 0 AND end_time IS NOT NULL AND end_time != 0 ORDER BY end_time ASC";
// classic statements
public static final String IMPORT_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, locale, version, random_seed, start_time, end_time, sync_at) VALUES (%d, %d, %d, %d, %s, %d, %d, %d, %d)";
public static final String IMPORT_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, random_seed, start_time, end_time, locale, version_name, version_code, hw_serial_number, sync_at) VALUES (%d, %d, %d, %d, %d, %d, %d, %s, %d, %s, %d)";
private static Long insertNewGame(User user, GameDifficulty difficulty, GameDefinition gameDefinition, TablexiaSettings.LocaleDefinition localeDefinition, String versionName, TablexiaRandom random) {
......@@ -273,7 +273,10 @@ public class GameDAO {
resultSet.getString(6),
resultSet.getLong(7),
startTimeStr != null ? Long.valueOf(startTimeStr) : null,
endTimeStr != null ? Long.valueOf(endTimeStr) : null);
endTimeStr != null ? Long.valueOf(endTimeStr) : null,
resultSet.getString(8),
resultSet.getString(9),
resultSet.getInt(10));
selectedGame.setGamePauses(GamePauseDAO.selectGamePausesForGame(selectedGame));
selectedGame.getGameScoreMap().addAll(GameScoreDAO.selectGameScores(selectedGame.getId()));
......@@ -307,7 +310,10 @@ public class GameDAO {
resultSet.getString(6),
resultSet.getLong(7),
startTimeStr != null ? Long.valueOf(startTimeStr) : null,
endTimeStr != null ? Long.valueOf(endTimeStr) : null);
endTimeStr != null ? Long.valueOf(endTimeStr) : null,
resultSet.getString(8),
resultSet.getString(9),
resultSet.getInt(10));
game.setGamePauses(GamePauseDAO.selectGamePausesForGame(game));
game.getGameScoreMap().addAll(GameScoreDAO.selectGameScores(game.getId()));
......@@ -355,7 +361,10 @@ public class GameDAO {
version,
0L, //Don't need seed
startTimeLong,
endTimeLong
endTimeLong,
hwSerial,
applicationVersionName,
applicationVersionCode
);
game.setGamePauses(GamePauseDAO.selectGamePausesForGame(game));
......@@ -399,7 +408,10 @@ public class GameDAO {
resultSet.getInt(5),
resultSet.getLong(6),
startTimeStr != null ? Long.valueOf(startTimeStr) : null,
endTimeStr != null ? Long.valueOf(endTimeStr) : null);
endTimeStr != null ? Long.valueOf(endTimeStr) : null,
resultSet.getString(8),
resultSet.getString(9),
resultSet.getInt(10));
game.setGamePauses(GamePauseDAO.selectGamePausesForGame(game));
game.getGameScoreMap().addAll(GameScoreDAO.selectGameScores(game.getId()));
......
......@@ -55,7 +55,7 @@ public class GameTrophy {
public static class ThreeStarsReceived implements GameTrophyResolver {
public static final String GAME_SELECT_FOR_GAME_AND_DIFFICULTY = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time FROM game WHERE game_number = ? AND difficulty_number = ? AND user_id = ? AND end_time IS NOT NULL";
public static final String GAME_SELECT_FOR_GAME_AND_DIFFICULTY = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time, hw_serial_number, application_version_name, application_version_code FROM game WHERE game_number = ? AND difficulty_number = ? AND user_id = ? AND end_time IS NOT NULL";
private static List<Game> getGamesForGameAndDifficulty(User user, GameTrophyDefinition trophyDef) {
List<Game> games = new ArrayList<Game>();
......@@ -75,7 +75,10 @@ public class GameTrophy {
resultSet.getInt(4),
resultSet.getLong(5),
startTimeStr != null ? Long.valueOf(startTimeStr) : null,
endTimeStr != null ? Long.valueOf(endTimeStr) : null);
endTimeStr != null ? Long.valueOf(endTimeStr) : null,
resultSet.getString(8),
resultSet.getString(9),
resultSet.getInt(10));
game.setGamePauses(GamePauseDAO.selectGamePausesForGame(game));
game.getGameScoreMap().addAll(GameScoreDAO.selectGameScores(game.getId()));
games.add(game);
......
......@@ -155,8 +155,8 @@ public class UserTrophy {
public static class AllStarsGame implements UserTrophyResolver {
public static final String GAME_SELECT_FOR_USER_AND_DIFFICULTY = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time FROM game WHERE difficulty_number = ? AND user_id = ? AND end_time IS NOT NULL";
public static final String GAME_SELECT_FOR_USER = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time FROM game WHERE user_id = ? AND difficulty_number != ? AND start_time IS NOT NULL AND start_time != 0 AND end_time IS NOT NULL AND end_time != 0";
public static final String GAME_SELECT_FOR_USER_AND_DIFFICULTY = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time, hw_serial_number, application_version_name, application_version_code FROM game WHERE difficulty_number = ? AND user_id = ? AND end_time IS NOT NULL";
public static final String GAME_SELECT_FOR_USER = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time, hw_serial_number, application_version_name, application_version_code FROM game WHERE user_id = ? AND difficulty_number != ? AND start_time IS NOT NULL AND start_time != 0 AND end_time IS NOT NULL AND end_time != 0";
private static List<Game> getGamesForUserAndDifficulty(User user, UserTrophyDefinition trophyDef) throws SQLException {
PreparedStatement statement = TablexiaStorage.getInstance().prepareStatement(GAME_SELECT_FOR_USER_AND_DIFFICULTY);
......@@ -188,7 +188,10 @@ public class UserTrophy {
resultSet.getInt(4),
resultSet.getLong(5),
startTimeStr != null ? Long.valueOf(startTimeStr) : null,
endTimeStr != null ? Long.valueOf(endTimeStr) : null);
endTimeStr != null ? Long.valueOf(endTimeStr) : null,
resultSet.getString(8),
resultSet.getString(9),
resultSet.getInt(10));
game.setGamePauses(GamePauseDAO.selectGamePausesForGame(game));
game.getGameScoreMap().addAll(GameScoreDAO.selectGameScores(game.getId()));
......
......@@ -57,7 +57,7 @@ public class DesktopLauncher {
config.addIcon(DESKTOP_ICON_128, Files.FileType.Internal);
}
new LwjglApplication(new Tablexia(buildType, Locale.getDefault(), SQL_CONNECTION_TYPE, new DesktopConnectionManager(), sentryDSN, HAS_SOFT_BACK_BUTTON, true), config);
new LwjglApplication(new Tablexia(buildType, Locale.getDefault(), SQL_CONNECTION_TYPE, new DesktopConnectionManager(), sentryDSN, HAS_SOFT_BACK_BUTTON, true, null), config);
}
private static String loadAttributeFromManifest(String attributeName, String defaultValue) {
......
......@@ -54,7 +54,8 @@ public class IOSLauncher extends IOSApplication.Delegate {
new IOSConnectionManager(),
sentryDSN,
HAS_SOFT_BACK_BUTTON,
false), config) {
false,
null), config) {
@Override
public Files getFiles() {
......
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