Skip to content
Snippets Groups Projects
Commit 817ae60a authored by Drahomír Karchňák's avatar Drahomír Karchňák
Browse files

#557 Add instance of QRCodeScanner to Tablexia class

parent cb1b5ddd
Branches
Tags
No related merge requests found
......@@ -54,6 +54,7 @@ public class AndroidLauncher extends AndroidApplication {
getResources().getConfiguration().locale,
SQL_CONNECTION_TYPE,
new AndroidConnectionManager(getContext()),
null,
getResources().getString(R.string.sentry_dsn),
HAS_SOFT_BACK_BUTTON,
savedInstanceState == null,
......
......@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.google.zxing.qrcode.encoder.QRCode;
import net.engio.mbassy.bus.error.IPublicationErrorHandler;
import net.engio.mbassy.bus.error.PublicationError;
......@@ -32,6 +33,7 @@ import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Utility;
import cz.nic.tablexia.util.camera.DeviceCameraControl;
import cz.nic.tablexia.util.ui.QRCodeScanner;
import cz.nic.tablexia.util.ui.button.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialogFactory;
......@@ -68,6 +70,7 @@ public class Tablexia extends TablexiaApplication {
private static final boolean LOADER_ERROR_DIALOG_HIDE_ANIMATION = false;
private static IConnectionManager connectionManager;
private static QRCodeScanner qrCodeScanner;
private final SQLConnectionType sqlConnectionType;
private MenuController menuController;
......@@ -100,14 +103,15 @@ public class Tablexia extends TablexiaApplication {
}
}
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, String sentryDSN, boolean hasSoftBackButton, boolean reset, String hwSerial, DeviceCameraControl deviceCameraControl) {
this(buildType, systemLocale, sqlConnectionType, connManager, sentryDSN, hasSoftBackButton, reset, hwSerial);
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, QRCodeScanner qrCodeScanner, String sentryDSN, boolean hasSoftBackButton, boolean reset, String hwSerial, DeviceCameraControl deviceCameraControl) {
this(buildType, systemLocale, sqlConnectionType, connManager, qrCodeScanner, sentryDSN, hasSoftBackButton, reset, hwSerial);
this.deviceCameraControl = deviceCameraControl;
}
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, String sentryDSN, boolean hasSoftBackButton, boolean reset, String hwSerial) {
public Tablexia(String buildType, Locale systemLocale, SQLConnectionType sqlConnectionType, IConnectionManager connManager, QRCodeScanner qrCodeScanner, String sentryDSN, boolean hasSoftBackButton, boolean reset, String hwSerial) {
this.reset = reset;
connectionManager = validateConnectionManager(connManager);
this.connectionManager = validateConnectionManager(connManager);
this.qrCodeScanner = qrCodeScanner;
this.sqlConnectionType = sqlConnectionType;
TablexiaSettings.init(buildType, systemLocale, hasSoftBackButton, hwSerial);
......@@ -424,6 +428,8 @@ public class Tablexia extends TablexiaApplication {
clearLoadedData();
}
//////////////////////////// Connection Manager
private static IConnectionManager validateConnectionManager(IConnectionManager connectionManager) {
if(connectionManager == null)
throw new RuntimeException(Tablexia.class.getName() + ": Connection Manager equals to " + connectionManager);
......@@ -435,6 +441,15 @@ public class Tablexia extends TablexiaApplication {
return connectionManager;
}
//////////////////////////// QR CODE READER
public static boolean hasQRCodeScanner() {
return qrCodeScanner != null;
}
public static QRCodeScanner getQRCodeScanner() {
return qrCodeScanner;
}
//////////////////////////// APPLICATION LOADERS
......
......@@ -11,6 +11,7 @@ import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaBuildConfig;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.screen.loader.IConnectionManager;
import cz.nic.tablexia.util.ui.QRCodeScanner;
public class DesktopLauncher {
......@@ -57,7 +58,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, null), config);
new LwjglApplication(new Tablexia(buildType, Locale.getDefault(), SQL_CONNECTION_TYPE, new DesktopConnectionManager(), null, sentryDSN, HAS_SOFT_BACK_BUTTON, true, null), config);
}
private static String loadAttributeFromManifest(String attributeName, String defaultValue) {
......
......@@ -54,6 +54,7 @@ public class IOSLauncher extends IOSApplication.Delegate {
Locale.getDefault(),
SQL_CONNECTION_TYPE,
new IOSConnectionManager(),
new IOSQRCodeScanner(),
sentryDSN,
HAS_SOFT_BACK_BUTTON,
false,
......
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