Commit 7b88844e authored by Drahomír Karchňák's avatar Drahomír Karchňák

#633 Fixed delay when opening qr code reader for the first time on IOS. #641 Small fixes.

parent ff7ba373
...@@ -21,9 +21,6 @@ import com.badlogic.gdx.Gdx; ...@@ -21,9 +21,6 @@ import com.badlogic.gdx.Gdx;
import cz.nic.tablexia.util.Log; import cz.nic.tablexia.util.Log;
/**
* Created by drahomir on 10/5/16.
*/
public abstract class QRCodeScanner { public abstract class QRCodeScanner {
public enum CameraPermissionStatus { public enum CameraPermissionStatus {
Allowed(true, false), Allowed(true, false),
...@@ -105,7 +102,7 @@ public abstract class QRCodeScanner { ...@@ -105,7 +102,7 @@ public abstract class QRCodeScanner {
} else { } else {
Log.info(getClass(), "Scanning is not allowed, but permission change is not requested!"); Log.info(getClass(), "Scanning is not allowed, but permission change is not requested!");
} }
return;
} }
Log.info(getClass(), "Starting Camera Preview!"); Log.info(getClass(), "Starting Camera Preview!");
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
sourceSets.main.java.srcDirs = [ "src/" ] sourceSets.main.java.srcDirs = [ "src/" ]
sourceCompatibility = '1.7' targetCompatibility = '1.8'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
robovm { robovm {
......
...@@ -129,31 +129,28 @@ public class IOSQRCodeScanner extends QRCodeScanner { ...@@ -129,31 +129,28 @@ public class IOSQRCodeScanner extends QRCodeScanner {
@Override @Override
protected void requestPermissionSettingChange() { protected void requestPermissionSettingChange() {
Log.info(getClass(), "Requesting permission change!");
//First request... //First request...
if(getCameraPermissionStatus() == CameraPermissionStatus.NotDetermined) { if(getCameraPermissionStatus() == CameraPermissionStatus.NotDetermined) {
Log.info(getClass(), "Requesting access for media type: " + AVMediaType.Video);
cameraDevice.requestAccessForMediaType(AVMediaType.Video, new VoidBooleanBlock() { cameraDevice.requestAccessForMediaType(AVMediaType.Video, new VoidBooleanBlock() {
@Override @Override
public void invoke(boolean result) { public void invoke(final boolean result) {
if (result) { if (result) {
cameraPermissionStatus = CameraPermissionStatus.Allowed; cameraPermissionStatus = CameraPermissionStatus.Allowed;
Log.info(getClass(), "Starting camera preview again!"); //Camera has to be launched from main thread!
startCameraPreview(); Gdx.app.postRunnable(() -> startCameraPreview());
} else cameraPermissionStatus = CameraPermissionStatus.Denied; }
else cameraPermissionStatus = CameraPermissionStatus.Denied;
} }
}); });
} }
else { //First permission request has been denied. Open our own dialog... else { //First permission request has been denied. Open our own dialog...
TablexiaComponentDialogFactory.getInstance().createPermissionDialog( TablexiaComponentDialogFactory.getInstance().createPermissionDialog(
ApplicationTextManager.getInstance().getText(PERMISSION_MESSAGE_TEXT_KEY), ApplicationTextManager.getInstance().getText(PERMISSION_MESSAGE_TEXT_KEY),
new Runnable() { () -> {
@Override //On success open settings url for this app
public void run() { UIApplication.getSharedApplication().openURL(new NSURL(UIApplication.getOpenSettingsURLString()));
//On success open settings url for this app
UIApplication.getSharedApplication().openURL(new NSURL(UIApplication.getOpenSettingsURLString()));
}
} }
).show(); ).show();
} }
...@@ -209,7 +206,7 @@ public class IOSQRCodeScanner extends QRCodeScanner { ...@@ -209,7 +206,7 @@ public class IOSQRCodeScanner extends QRCodeScanner {
@Override @Override
public void willAnimateRotation(UIInterfaceOrientation uiInterfaceOrientation, double v) { public void willAnimateRotation(UIInterfaceOrientation uiInterfaceOrientation, double v) {
//Unforunately this method is deprecated and there isnt binding in RoboVM for these replacements... //Unfortunately this method is deprecated and there isn't binding in RoboVM for any of these replacements...
// - willTransitionToTraitCollection:withTransitionCoordinator: // - willTransitionToTraitCollection:withTransitionCoordinator:
// - viewWillTransitionToSize:withTransitionCoordinator: // - viewWillTransitionToSize:withTransitionCoordinator:
super.willAnimateRotation(uiInterfaceOrientation, v); super.willAnimateRotation(uiInterfaceOrientation, v);
......
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