Skip to content
Snippets Groups Projects
Commit 50e048e8 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Merge branch 'feature-sentry' into 'V3.2.1'

Feature sentry



See merge request !387
parents 100bb0aa dd8e5325
No related branches found
No related tags found
No related merge requests found
Showing
with 504 additions and 33 deletions
No preview for this file type
......@@ -29,18 +29,21 @@ android {
applicationIdSuffix rootProject.applicationIdBranch + rootProject.applicationIdDebugSuffix
buildConfigField ASSETS_CHECKSUM_FIELD_TYPE, ASSETS_CHECKSUM_FIELD_NAME, rootProject.ext.assetsChecksumPattern
resValue "string", "app_name", "${tablexiaAppName}"
resValue "string", "sentry_dsn", project.hasProperty('TABLEXIA_SENTRY_DSN_DEBUG') ? "$TABLEXIA_SENTRY_DSN_DEBUG" : "$project.sentryDSNFallbackValue";
}
release {
debuggable false
applicationIdSuffix rootProject.applicationIdBranch
buildConfigField ASSETS_CHECKSUM_FIELD_TYPE, ASSETS_CHECKSUM_FIELD_NAME, rootProject.ext.assetsChecksumPattern
resValue "string", "app_name", "${tablexiaAppName}"
resValue "string", "sentry_dsn", project.hasProperty('TABLEXIA_SENTRY_DSN_RELEASE') ? "$TABLEXIA_SENTRY_DSN_RELEASE" : "$project.sentryDSNFallbackValue";
}
devel.initWith(buildTypes.debug)
devel {
applicationIdSuffix rootProject.applicationIdDevelSuffix
buildConfigField ASSETS_CHECKSUM_FIELD_TYPE, ASSETS_CHECKSUM_FIELD_NAME, rootProject.ext.assetsChecksumPattern
resValue "string", "app_name", "${tablexiaAppName}"
resValue "string", "sentry_dsn", "$project.sentryDSNFallbackValue";
}
}
......
......@@ -18,6 +18,7 @@ import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaBuildConfig;
import cz.nic.tablexia.TablexiaSettings;
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;
......@@ -41,6 +42,7 @@ public class AndroidLauncher extends AndroidApplication {
getResources().getConfiguration().locale,
SQL_CONNECTION_TYPE,
new AndroidConnectionManager(getContext()),
getResources().getString(R.string.sentry_dsn),
HAS_SOFT_BACK_BUTTON,
savedInstanceState == null), config);
......@@ -95,23 +97,34 @@ public class AndroidLauncher extends AndroidApplication {
@Override
public boolean isUsingMobileData() {
return getConnectionType() == ConnectionType.Mobile;
}
@Override
public ConnectionType getConnectionType() {
ConnectivityManager conMan = (ConnectivityManager) androidContext.getSystemService(Context.CONNECTIVITY_SERVICE);
//We are not connected to the internet at all...
//We are not connected to the internet at all...
if(conMan == null || conMan.getActiveNetworkInfo() == null)
return false;
return ConnectionType.Unknown;
//Is user using any of mobile internet types ? Hope I didn't miss any...
//Is user using any of mobile internet types ? Hope I didn't miss any...
switch (conMan.getActiveNetworkInfo().getType()) {
case ConnectivityManager.TYPE_MOBILE:
case ConnectivityManager.TYPE_MOBILE_DUN:
case ConnectivityManager.TYPE_MOBILE_HIPRI:
case ConnectivityManager.TYPE_MOBILE_MMS:
case ConnectivityManager.TYPE_MOBILE_SUPL:
return true;
return ConnectionType.Mobile;
case ConnectivityManager.TYPE_ETHERNET:
return ConnectionType.Ethernet;
case ConnectivityManager.TYPE_WIFI:
return ConnectionType.Wifi;
default:
return false;
return ConnectionType.Unknown;
}
}
}
......
......@@ -54,6 +54,9 @@ allprojects {
applicationIdDevelSuffix = '.devel'
applicationIdDevel = applicationBaseId + applicationIdDevelSuffix
//Fallback value if sentry DSN is not defined (gradle parameter SENTRY_DSN_DEBUG or SENTRY_DSN_RELEASE)
sentryDSNFallbackValue = "None"
gdxVersion = '1.9.2'
gdxUtilsVersion = '0.13.2'
mbassadorVersion = '1.2.0'
......@@ -64,6 +67,9 @@ allprojects {
roboPodsVersion = '1.13.0'
androidSupportV4Version = '22.0.0'
googlePlayServicesVersion = '8.3.+'
servletApiVersion = '5.5.23'
ravenVersion = '7.5.0'
}
version = getVersionNameFromGit()
......@@ -398,6 +404,8 @@ project(":core") {
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.google.guava:guava:$guavaVersion"
compile "tomcat:servlet-api:$servletApiVersion"
compile "com.getsentry.raven:raven:$ravenVersion"
testCompile "junit:junit:4.11"
testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
......
......@@ -43,6 +43,7 @@ task writeTablexiaBuildConfig {
" 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)
}
......
......@@ -97,7 +97,7 @@ public class Tablexia extends TablexiaApplication {
}
}
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, boolean hasSoftBackButton, boolean reset) {
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, String sentryDSN, boolean hasSoftBackButton, boolean reset) {
this.reset = reset;
connectionManager = validateConnectionManager(connManager);
this.sqlConnectionType = sqlConnectionType;
......@@ -111,6 +111,12 @@ public class Tablexia extends TablexiaApplication {
Log.err(ApplicationBus.class, error.getMessage(), error.getCause());
}
});
if(TablexiaSettings.getInstance().getBuildType().isBugReport()) {
@SuppressWarnings("ConstantConditions")
String DSN = (TablexiaBuildConfig.SENTRY_DSN_FALLBACK == null || sentryDSN == null || TablexiaBuildConfig.SENTRY_DSN_FALLBACK.equals(sentryDSN)) ? null : sentryDSN;
TablexiaRaven.start(DSN);
}
}
private void loadingComplete() {
......@@ -302,6 +308,8 @@ public class Tablexia extends TablexiaApplication {
public void create() {
super.create();
TablexiaRaven.sendSavedReports();
// init data storage
TablexiaStorage.init(sqlConnectionType, reset);
......
package cz.nic.tablexia;
import com.badlogic.gdx.Gdx;
import com.getsentry.raven.DefaultRavenFactory;
import com.getsentry.raven.Raven;
import com.getsentry.raven.connection.Connection;
import com.getsentry.raven.connection.EventSendFailureCallback;
import com.getsentry.raven.dsn.Dsn;
import com.getsentry.raven.event.Event;
import com.getsentry.raven.event.EventBuilder;
import com.getsentry.raven.event.helper.EventBuilderHelper;
import com.getsentry.raven.event.interfaces.ExceptionInterface;
import net.engio.mbassy.listener.Handler;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.loader.TablexiaAbstractFileManager;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
/**
* Created by drahomir on 7/28/16.
*/
public class TablexiaRaven {
/**
* Custom raven factory which allows to set EventSendFailureCallback
*/
private class TablexiaRavenFactory extends DefaultRavenFactory {
private EventSendFailureCallback eventSendFailureCallback;
public Raven ravenInstance(String DSN, EventSendFailureCallback callback) {
eventSendFailureCallback = callback;
return createRavenInstance(new Dsn(DSN));
}
@Override
protected Connection createConnection(Dsn dsn) {
Connection connection = super.createConnection(dsn);
if(eventSendFailureCallback != null) connection.addEventSendFailureCallback(eventSendFailureCallback);
return connection;
}
}
/**
* Type of information to send via raven
*/
private enum InfoType {
TAG {
@Override
protected void insertInfo(TablexiaEventBuilderHelper tablexiaEventBuilderHelper, String name, String value) {
tablexiaEventBuilderHelper.addTag(name, value);
}
},
EXTRA {
@Override
protected void insertInfo(TablexiaEventBuilderHelper tablexiaEventBuilderHelper, String name, String value) {
tablexiaEventBuilderHelper.addExtra(name, value);
}
};
protected void insertInfo(TablexiaEventBuilderHelper tablexiaEventBuilderHelper, String name, String value) {}
}
/**
* Actual info values to send via raven
*/
private enum Info {
Platform(InfoType.TAG, "Platform", new StringRunnable() {
@Override
public String run() {
return Gdx.app.getType().toString();
}
}),
Version(InfoType.TAG, "Version", new StringRunnable() {
@Override
public String run() {
return TablexiaBuildConfig.VERSION_NAME;
}
}),
BuildType(InfoType.TAG, "BuildType", new StringRunnable() {
@Override
public String run() {
return TablexiaSettings.getInstance().getBuildType().toString();
}
}),
ConnectionType(InfoType.TAG, "ConnectionType", new StringRunnable() {
@Override
public String run() {
return Tablexia.getConnectionManager().getConnectionType().toString();
}
}),
Language(InfoType.EXTRA, "Language", new StringRunnable() {
@Override
public String run() {
return TablexiaSettings.getInstance().getLocale().toString();
}
}),
UserInfo(InfoType.EXTRA, "UserInfo", new StringRunnable() {
@Override
public String run() {
return TablexiaSettings.getInstance().getSelectedUser().toString();
}
}),
UserUUID(InfoType.EXTRA, "UserUUID", new StringRunnable() {
@Override
public String run() {
return TablexiaSettings.getInstance().getSelectedUser().getUuid();
}
});
private static final String DEFAULT_FALLBACK_VALUE = "UNDEFINED";
private final InfoType type;
private final String name;
private final String fallBackValue;
private final StringRunnable stringRunnable;
Info(InfoType type, String name, StringRunnable stringRunnable) {
this(type, name, DEFAULT_FALLBACK_VALUE, stringRunnable);
}
Info(InfoType type, String name, String fallbackValue, StringRunnable stringRunnable) {
this.type = type;
this.name = name;
this.fallBackValue = fallbackValue;
this.stringRunnable = stringRunnable;
}
public void insert(TablexiaEventBuilderHelper eventBuilderHelper) {
type.insertInfo(eventBuilderHelper, name, getSafeValue(stringRunnable, fallBackValue));
}
private String getSafeValue(StringRunnable runnable, String defaultValue) {
try {
return runnable.run();
}
catch (Exception e) {
return defaultValue;
}
}
}
private interface StringRunnable {
//Method which obtains the actual value of Info
String run();
}
/**
* Reports Manager - Saves and Resends reports later
*/
private static class ReportsManager extends TablexiaAbstractFileManager {
private static final String REPORT_FILE_EXTENSION = ".TablexiaReport";
private static final boolean HIDE_REPORT_FILES = true;
public ReportsManager() {
super(ReportStorageType.EXTERNAL);
}
public void storeRavenEvent(Event event) {
try {
String fileName = (HIDE_REPORT_FILES ? "." : "") + event.getId().toString() + REPORT_FILE_EXTENSION;
File dir = TablexiaAbstractFileManager.getFileStoragePathFileHandle(ReportStorageType.EXTERNAL).file();
if(!dir.exists()) dir.mkdir();
File file = new File(dir, fileName);
if(file.exists()) {
file.delete();
file.createNewFile();
}
FileOutputStream fileOut = new FileOutputStream(file);
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOut);
objectOutputStream.writeObject(event);
objectOutputStream.close();
fileOut.close();
} catch (Exception e) {
e.printStackTrace();
return;
}
}
private void sendSavedEvents(TablexiaRaven tablexiaRaven) {
try {
File dir = TablexiaAbstractFileManager.getFileStoragePathFileHandle(ReportStorageType.EXTERNAL).file();
if(!dir.exists()) return;
File[] files = dir.listFiles();
for(File file : files) {
Event e = deserializeEvent(file);
if(e != null) {
file.delete();
tablexiaRaven.sentEvent(e);
}
}
}
catch (Exception e) {
e.printStackTrace();
return;
}
}
private Event deserializeEvent(File file) {
Event event = null;
try {
FileInputStream fis = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fis);
event = (Event) ois.readObject();
ois.close();
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
return event;
}
}
public class TablexiaEventBuilderHelper implements EventBuilderHelper {
private HashMap<String, String> tablexiaTags;
private HashMap<String, String> tablexiaExtras;
public TablexiaEventBuilderHelper() {
tablexiaTags = new HashMap<String, String>();
tablexiaExtras = new HashMap<String, String>();
}
public void addTag(String key, String value) {
tablexiaTags.put(key, value);
}
public void addExtra(String key, String value) {
tablexiaExtras.put(key, value);
}
public void removeTag(String key) {
if(tablexiaTags.containsKey(key))
tablexiaTags.remove(key);
}
public void removeExtra(String key) {
if(tablexiaExtras.containsKey(key))
tablexiaExtras.remove(key);
}
@Override
public void helpBuildingEvent(EventBuilder eventBuilder) {
for(Map.Entry<String, String> tag : tablexiaTags.entrySet()) {
eventBuilder.withTag(tag.getKey(), tag.getValue());
}
for(Map.Entry<String, String> extra : tablexiaExtras.entrySet()) {
eventBuilder.withExtra(extra.getKey(), extra.getValue());
}
}
}
/**
* Actual Raven client
*/
private static final String[] SCREEN_INFO_EVENT_KEYS = new String [] {
AbstractTablexiaGame.RANDOM_SEED_SCREEN_INFO_LABEL,
AbstractTablexiaGame.GAME_DIFFICULTY_SCREEN_INFO_LABEL
};
private static TablexiaRaven instance;
private final EventSendFailureCallback DEFAULT_SEND_EVENT_FAILURE_CALLBACK = new EventSendFailureCallback() {
@Override
public void onFailure(Event event, Exception exception) {
//Calls all registered callbacks
for(EventSendFailureCallback eventSendFailureCallback : sendFailureCallbacks) eventSendFailureCallback.onFailure(event, exception);
}
};
private Set<EventSendFailureCallback> sendFailureCallbacks;
private Raven raven;
private ReportsManager reportsManager;
private TablexiaEventBuilderHelper tablexiaEventBuilderHelper;
private TablexiaRaven(String DSN) {
this.raven = new TablexiaRavenFactory().ravenInstance(DSN, DEFAULT_SEND_EVENT_FAILURE_CALLBACK);
this.sendFailureCallbacks = new HashSet<EventSendFailureCallback>();
this.reportsManager = new ReportsManager();
this.tablexiaEventBuilderHelper = new TablexiaEventBuilderHelper();
raven.addBuilderHelper(tablexiaEventBuilderHelper);
ApplicationBus.getInstance().subscribe(this);
}
private static boolean isStarted() {
return instance != null;
}
public static void start(String DSN) {
if(DSN == null || instance != null) return;
instance = new TablexiaRaven(DSN);
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
instance.sendExceptionEvent(t, e);
}
});
instance.addEventSendFailureCallback(new EventSendFailureCallback() {
@Override
public void onFailure(Event event, Exception exception) {
instance.reportsManager.storeRavenEvent(event);
}
});
}
public static void sendSavedReports() {
if(isStarted()) instance.reportsManager.sendSavedEvents(instance);
}
private void addEventSendFailureCallback(EventSendFailureCallback eventSendFailureCallback) {
if(isStarted()) {
if (eventSendFailureCallback != null) {
if (!sendFailureCallbacks.contains(eventSendFailureCallback))
sendFailureCallbacks.add(eventSendFailureCallback);
}
}
}
private void sendExceptionEvent(Thread t, Throwable e) {
EventBuilder eventBuilder = new EventBuilder()
.withMessage(e.getMessage())
.withSentryInterface(new ExceptionInterface(e))
.withLevel(Event.Level.ERROR);
for(Info info : Info.values()) {
info.insert(tablexiaEventBuilderHelper);
}
raven.runBuilderHelpers(eventBuilder);
raven.sendEvent(eventBuilder.build());
Gdx.app.exit();
}
private void sentEvent(Event e) {
if(isStarted() && e != null) instance.raven.sendEvent(e);
}
@Handler
public void handleScreenChangedEvent(TablexiaApplication.ScreenChangedEvent screenChangedEvent) {
for(String infoEventKey : SCREEN_INFO_EVENT_KEYS) {
tablexiaEventBuilderHelper.removeExtra(infoEventKey);
}
}
@Handler
public void handleScreenInfoEvent(AbstractTablexiaScreen.ScreenInfoEvent screenInfoEvent) {
for(String infoEventKey : SCREEN_INFO_EVENT_KEYS) {
if(infoEventKey.equals(screenInfoEvent.getInfoKey())) {
tablexiaEventBuilderHelper.addExtra(screenInfoEvent.getInfoKey(), screenInfoEvent.getInfoValue());
}
}
}
}
\ No newline at end of file
......@@ -163,6 +163,30 @@ public abstract class TablexiaAbstractFileManager extends AssetManager {
}
}
public enum ReportStorageType implements StorageType {
INTERNAL(RootStorageType.INTERNAL, ReportStorageType.REPORTS_DIRECTORY),
EXTERNAL(RootStorageType.LOCAL, ReportStorageType.REPORTS_DIRECTORY);
public static final String REPORTS_DIRECTORY = "reports/";
private String storagePath;
private FileHandleResolver resolver;
ReportStorageType(RootStorageType rootStorageType, String assetsPath) {
this.storagePath = rootStorageType.getStoragePath() + assetsPath;
this.resolver = rootStorageType.getResolver();
}
public String getStoragePath() {
return storagePath;
}
public FileHandleResolver getResolver() {
return resolver;
}
}
public static FileHandle getFileStoragePathFileHandle(StorageType storageType, String additionalPath) {
return storageType.getResolver().resolve(storageType.getStoragePath() + additionalPath);
}
......
......@@ -4,5 +4,12 @@ package cz.nic.tablexia.screen.loader;
* Created by Drahomir Karchnak on 11/12/15.
*/
public interface IConnectionManager {
enum ConnectionType {
Wifi,
Mobile,
Ethernet,
Unknown;
}
boolean isUsingMobileData();
ConnectionType getConnectionType();
}
......@@ -27,6 +27,7 @@ task debugJar(type: Jar) {
attributes 'Build-Type': 'debug'
attributes 'Version-Name': tablexiaVersionName
attributes 'Assets-Cheksums': getMapConvertedToString(rootProject.ext.assetsChecksum)
attributes 'Sentry-DSN': project.hasProperty('TABLEXIA_SENTRY_DSN_DEBUG') ? "$TABLEXIA_SENTRY_DSN_DEBUG" : "$project.sentryDSNFallbackValue";
}
}
}
......@@ -44,6 +45,7 @@ task releaseJar(type: Jar) {
attributes 'Build-Type': 'release'
attributes 'Version-Name': tablexiaVersionName
attributes 'Assets-Cheksums': getMapConvertedToString(rootProject.ext.assetsChecksum)
attributes 'Sentry-DSN': project.hasProperty('TABLEXIA_SENTRY_DSN_RELEASE') ? "$TABLEXIA_SENTRY_DSN_RELEASE" : "$project.sentryDSNFallbackValue";
}
}
}
......
......@@ -14,8 +14,9 @@ import cz.nic.tablexia.screen.loader.IConnectionManager;
public class DesktopLauncher {
private static final String BUILD_VARIANT_MANIFEST_ATTRIBUTE = "Build-Type";
private static final boolean HAS_SOFT_BACK_BUTTON = true;
private static final String BUILD_VARIANT_MANIFEST_ATTRIBUTE = "Build-Type";
private static final String SENTRY_DSN_KEY_MANIFEST_ATTRIBUTE = "Sentry-DSN";
private static final boolean HAS_SOFT_BACK_BUTTON = true;
private static final String DESKTOP_ICON_PATH = "icon/";
private static final String DESKTOP_ICON_16 = DESKTOP_ICON_PATH + "desktop_icon_16.png";
......@@ -32,8 +33,8 @@ public class DesktopLauncher {
public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("org.sqlite.JDBC", "jdbc:sqlite:");
public static void main(String[] arg) {
String buildType = loadAttributeFromManifest(BUILD_VARIANT_MANIFEST_ATTRIBUTE, TablexiaSettings.BuildType.DEVEL.getKey());
String buildType = loadAttributeFromManifest(BUILD_VARIANT_MANIFEST_ATTRIBUTE, TablexiaSettings.BuildType.DEVEL.getKey());
String sentryDSN = loadAttributeFromManifest(SENTRY_DSN_KEY_MANIFEST_ATTRIBUTE, null);
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = buildType == null || buildType.equals(TablexiaSettings.BuildType.DEVEL.getKey());
......@@ -56,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(), HAS_SOFT_BACK_BUTTON, true), config);
new LwjglApplication(new Tablexia(buildType, Locale.getDefault(), SQL_CONNECTION_TYPE, new DesktopConnectionManager(), sentryDSN, HAS_SOFT_BACK_BUTTON, true), config);
}
private static String loadAttributeFromManifest(String attributeName, String defaultValue) {
......@@ -69,8 +70,13 @@ public class DesktopLauncher {
private static class DesktopConnectionManager implements IConnectionManager {
@Override
public boolean isUsingMobileData() {
//TODO - return false.. its desktop ;)
return false;//TablexiaSettings.getInstance().getBuildType() == TablexiaSettings.BuildType.DEVEL;
return false; //Just desktop things...
}
@Override
public ConnectionType getConnectionType() {
//TODO - Wifi || Ethernet in Java?
return ConnectionType.Ethernet;
}
}
}
......@@ -24,6 +24,8 @@
<string>${app.build}</string>
<key>cz.nic.tablexia.BuildType</key>
<string>${app.buildtype}</string>
<key>cz.nic.tablexia.SentryDSN</key>
<string>${app.sentryDSN}</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
......
......@@ -13,7 +13,7 @@ ext {
}
// Updates or create a robovm.properties file.
def updateRoboVMProperties(String buildType, String applicationId, String iconName) {
def updateRoboVMProperties(String buildType, String applicationId, String iconName, String DSN) {
Properties props = new Properties()
def propsFile = file('robovm.properties')
......@@ -30,6 +30,7 @@ def updateRoboVMProperties(String buildType, String applicationId, String iconNa
props.setProperty('app.buildtype', buildType)
props.setProperty('app.build', '' + tablexiaVersionCode)
props.setProperty('app.executable', tablexiaAppName + '-' + buildType + '-' + tablexiaVersionName)
props.setProperty('app.sentryDSN', DSN)
props.store(propsFile.newDataOutputStream(), '')
}
......@@ -78,24 +79,25 @@ task updateRoboVMXML << {
tasks.launchIPadSimulator.doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel')
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel', sentryDSNFallbackValue)
}
tasks.launchIPhoneSimulator.doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel')
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel', sentryDSNFallbackValue)
}
tasks.launchIOSDevice.doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel')
updateRoboVMProperties("devel", applicationIdDevel, 'Icon_devel', sentryDSNFallbackValue)
}
tasks.create(name: "createDebugIPA", type: org.robovm.gradle.tasks.ArchiveTask) {
doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_DEBUG_PROVISIONING
updateRoboVMProperties("debug", applicationIdDebug, 'Icon_debug')
String DSN = project.hasProperty('TABLEXIA_SENTRY_DSN_DEBUG') ? "$TABLEXIA_SENTRY_DSN_DEBUG" : sentryDSNFallbackValue;
updateRoboVMProperties("debug", applicationIdDebug, 'Icon_debug', DSN)
}
}
......@@ -103,7 +105,8 @@ tasks.create(name: "createReleaseIPA", type: org.robovm.gradle.tasks.ArchiveTask
doFirst {
robovm.iosSignIdentity = TABLEXIA_IOS_SIGNING_IDENTITY
robovm.iosProvisioningProfile = TABLEXIA_IOS_RELEASE_PROVISIONING
updateRoboVMProperties("release", applicationIdRelease, 'Icon_release')
String DSN = project.hasProperty('TABLEXIA_SENTRY_DSN_RELEASE') ? "$TABLEXIA_SENTRY_DSN_RELEASE" : sentryDSNFallbackValue;
updateRoboVMProperties("release", applicationIdRelease, 'Icon_release', DSN)
}
}
......
......@@ -19,7 +19,6 @@
</resources>
<forceLinkClasses>
<pattern>com.badlogic.gdx.scenes.scene2d.ui.*</pattern>
<pattern>com.badlogic.gdx.physics.bullet.**</pattern>
<pattern>com.android.okhttp.HttpHandler</pattern>
<pattern>com.android.okhttp.HttpsHandler</pattern>
<pattern>com.android.org.conscrypt.**</pattern>
......@@ -31,9 +30,11 @@
<pattern>com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL</pattern>
<pattern>org.apache.harmony.security.provider.cert.DRLCertFactory</pattern>
<pattern>org.apache.harmony.security.provider.crypto.CryptoProvider</pattern>
<pattern>java.util.logging.ConsoleHandler</pattern>
<pattern>java.util.logging.SimpleFormatter</pattern>
<pattern>SQLite.**</pattern>
</forceLinkClasses>
<libs/>
<libs></libs>
<frameworks>
<framework>UIKit</framework>
<framework>OpenGLES</framework>
......
......@@ -22,16 +22,19 @@ import cz.nic.tablexia.screen.loader.IConnectionManager;
public class IOSLauncher extends IOSApplication.Delegate {
public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("SQLite.JDBCDriver", "jdbc:sqlite:");
private static final boolean HAS_SOFT_BACK_BUTTON = true;
private static final String TABLEXIA_BUILD_TYPE_KEY = "cz.nic.tablexia.BuildType";
private static final String TABLEXIA_SENTRY_DSN_KEY = "cz.nic.tablexia.SentryDSN";
private static final String FALLBACK_CONNECTION_CHECK_HOST = "nic.cz";
private static final Integer FALLBACK_CONNECTION_CHECK_PORT = 80;
public static final Tablexia.SQLConnectionType SQL_CONNECTION_TYPE = new Tablexia.SQLConnectionType("SQLite.JDBCDriver", "jdbc:sqlite:");
private static final boolean HAS_SOFT_BACK_BUTTON = true;
private static final String CONNECTION_CHECK_HOST = TablexiaBuildConfig.TABLEXIA_SERVER_HOST != null ? TablexiaBuildConfig.TABLEXIA_SERVER_HOST : FALLBACK_CONNECTION_CHECK_HOST;
private static final Integer CONNECTION_CHECK_PORT = TablexiaBuildConfig.TABLEXIA_SERVER_PORT != null ? TablexiaBuildConfig.TABLEXIA_SERVER_PORT : FALLBACK_CONNECTION_CHECK_PORT;
private static final String FALLBACK_CONNECTION_CHECK_HOST = "nic.cz";
private static final Integer FALLBACK_CONNECTION_CHECK_PORT = 80;
private TablexiaIOSFiles tablexiaIOSFiles;
private static final String CONNECTION_CHECK_HOST = TablexiaBuildConfig.TABLEXIA_SERVER_HOST != null ? TablexiaBuildConfig.TABLEXIA_SERVER_HOST : FALLBACK_CONNECTION_CHECK_HOST;
private static final Integer CONNECTION_CHECK_PORT = TablexiaBuildConfig.TABLEXIA_SERVER_PORT != null ? TablexiaBuildConfig.TABLEXIA_SERVER_PORT : FALLBACK_CONNECTION_CHECK_PORT;
private TablexiaIOSFiles tablexiaIOSFiles;
@Override
protected IOSApplication createApplication() {
......@@ -39,13 +42,15 @@ public class IOSLauncher extends IOSApplication.Delegate {
config.multisample = GLKViewDrawableMultisample._4X;
NSDictionary infoDictionary = NSBundle.getMainBundle().getInfoDictionary();
String buildType = infoDictionary.get(new NSString("cz.nic.tablexia.BuildType")).toString();
String buildType = infoDictionary.get(new NSString(TABLEXIA_BUILD_TYPE_KEY)).toString();
String sentryDSN = infoDictionary.get(new NSString(TABLEXIA_SENTRY_DSN_KEY)).toString();
tablexiaIOSFiles = new TablexiaIOSFiles();
IOSApplication iosApplication = new IOSApplication(new Tablexia(buildType,
Locale.getDefault(),
SQL_CONNECTION_TYPE,
new IOSConnectionManager(),
sentryDSN,
HAS_SOFT_BACK_BUTTON,
false), config) {
......@@ -74,14 +79,21 @@ public class IOSLauncher extends IOSApplication.Delegate {
private static class IOSConnectionManager implements IConnectionManager {
@Override
public boolean isUsingMobileData() {
return getConnectionType() == ConnectionType.Mobile;
}
@Override
public ConnectionType getConnectionType() {
InetSocketAddress socketAddress = new InetSocketAddress(CONNECTION_CHECK_HOST, CONNECTION_CHECK_PORT);
// RoboVM tries to retrive IP address using network connection. If we don't have it InetSocketAddress.getAddress() returns null
// in that case SCNetworkReachability.create(socketAddress) throws IllegalArgumentException
if (socketAddress.getAddress() == null) {
return false;
return ConnectionType.Unknown;
}
SCNetworkReachabilityFlags flags = SCNetworkReachability.create(socketAddress).getFlags();
return flags.compareTo(SCNetworkReachabilityFlags.IsWWAN) == 1;
if(flags.compareTo(SCNetworkReachabilityFlags.IsWWAN) == 1) return ConnectionType.Mobile;
else return ConnectionType.Wifi;
}
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment