Qt 5.1 Android program does not send keypresses - android

I am creating a program in Qt 5.1 and Qt Quick 2.0 for Android but my phone doesn't seem to send keypresses. The same code works when i run it on my desktop so the focus seems to be okay.
Both the Keys.onPressed and the Keys.onBackPressed don't work, the back key just closes the program. I am debugging on a Android 4.2 device via ADB.
Main.qml
Rectangle {
id: container
focus: true
Keys.onPressed: {
console.log(event.key)
if (event.key === Qt.Key_Backspace) {
if (rectangleDetails.visible === true) {
console.log("Left key pressed")
rectangleDetails.visible = false
listViewIndex.visible = true
event.accepted = true
} else {
Qt.quit()
}
}
}
Keys.onBackPressed: {
console.log("Back key pressed")
if (rectangleDetails.visible === true) {
rectangleDetails.visible = false
listViewIndex.visible = true
event.accepted = true
} else {
Qt.quit()
}
}
Thanks in advance

Try Keys.onReleased. This should solve your issue. See here for more information http://qt-project.org/forums/viewthread/29366

Related

onbeforeinstallprompt fails to fire

I'm building a PWA and have the following hooked event
let isCompat = "onbeforeinstallprompt" in window,
isSamsung = /Samsung/i.test(_ua)
if (!window.matchMedia('(display-mode: fullscreen)').matches
&& !window.matchMedia('(display-mode: standalone)').matches
&& !screenfull.isFullscreen
) {
console.log(isCompat, isSamsung, screenfull)
if(isCompat) {
window.addEventListener('beforeinstallprompt', (event) => {
...
btn.addEventListener('click', () => {
let s = invite.prompt()
if(invite.userChoice) ...
}, { once: true })
event.preventDefault()
invite = event
})
} else {
if(isIDevice) {
....
} else if(screenfull.isEnabled) {
...
}
}
The logic executes successful on latest chrome for android on a Samsung J5 1st generation. But not on the latest updated of Samsung Internet Browser 16.2.1.56 regardless of the fact that isCompat and isSamsung is true
My research so far shows that is should be firing so I am not sure why. Is there a shim that can be implemented to make it work on Samsung Internet?
an example and be viewed at https://622f59ba2b54ab2a844cf515--goofy-jackson-e12a89.netlify.app/

tipsi-stripe 3d secure at react-native

I want to integrate Stripe 3d secure in my react native app. Using this lib: https://github.com/tipsi/tipsi-stripe, and with simple payment it works well. But with 3D I have several problem on iOS and also on Android:
iOS: createCardSource: true (at line 7 crashing the app).(Solved)
iOS: Stucked before redirection on the secure page
Android: How I know if the user paid or decline the payment at the remote page?(At line 27 no any data in the secure3dSourceResponse object)
import stripe from "tipsi-stripe";
paymentRequest = async (mutation, deal) => {
let paymentRequest;
try {
paymentRequest = await stripe.paymentRequestWithCardForm({
...options,
createCardSource: true
});
//iOS and Android gets back different objects.
const threeDSecure = Platform.OS === "android"
? paymentRequest.card.three_d_secure
: paymentRequest.details.three_d_secure;
if (
threeDSecure === "recommended"
|| threeDSecure === "required"
) {
let prefix = Platform.OS === "android"
? `appName://appName/`
: `appName://`;
let secure3dSourceResponse = null;
try {
const { dealFeeUSD } = this.state;
// On iOS the process stucked here, without any error message
secure3dSourceResponse = await stripe.createSourceWithParams({
type: "threeDSecure",
amount: dealFeeUSD || 3000,
currency: "USD",
flow: "redirect",
returnURL: prefix,
card: paymentRequest.sourceId
});
// On android I have no any data in secure3dSourceResponse after Stripe returns from their page.
} catch (error) {
console.log('secure3dSourceResponse', secure3dSourceResponse)
}
} else {
if (paymentRequest && paymentRequest.tokenId) {
this.handlePayDeal(mutation, deal, paymentRequest.tokenId);
}
}
} catch (error) {
console.log("paymentRequest: " + JSON.stringify(error));
}
};

Appcelerator Android Camera always make application force close

I make an apps using Appcelerator (Titanium SDK).
and I have a problem when open camera, I already set camera permission in tiapp.xml.
And I've try use a source from kitchen Sink titanium.
Here's my code
var win;
function fireUpTheCamera() {
if (Ti.Platform.osname === 'android'|| Ti.Platform.osname == "iphone" || Ti.Platform.osname == 'ipad') {
win.removeEventListener('focus', fireUpTheCamera);
}
Titanium.Media.showCamera({
success:function(event) {
var cropRect = event.cropRect;
var image = event.media;
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
var imageView = Ti.UI.createImageView({
width:win.width,
height:win.height,
image:event.media
});
win.add(imageView);
}
else
{
alert("got the wrong type back ="+event.mediaType);
}
},
cancel:function() {
},
error:function(error) {
// create alert
var a = Titanium.UI.createAlertDialog({title:'Camera'});
// set message
if (error.code == Titanium.Media.NO_CAMERA)
{
a.setMessage('Please run this test on device');
}
else
{
a.setMessage('Unexpected error: ' + error.code);
}
// show alert
a.show();
},
saveToPhotoGallery:true,
allowEditing:true,
mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
});
}
function cam_basic(_args) {
win = Titanium.UI.createWindow({
title:_args.title
});
if (Ti.Platform.osname === 'android'|| Ti.Platform.osname == "iphone" || Ti.Platform.osname == 'ipad') {
win.addEventListener('focus', fireUpTheCamera);
} else {
fireUpTheCamera();
}
return win;
};
module.exports = cam_basic;
when I finish capture picture and press the OK button, it's always restart application without any error message, also in the log.
I'm using SDK 6.0.0GA.
Please give me some help, and what's wrong with my code.
Before firing up the camera you have to ask the end user for permissions. I'm using this snippet and it works with Ti-5.4.0.
if(Ti.Media.hasCameraPermissions())
fireUpTheCamera();
else
{
Ti.Media.requestCameraPermissions(function(permission)
{
if(permission.success)
fireUpTheCamera();
else
alert('Please Provide permission first');
});
}
Since Titanium sdk 5.1 you need to request runtime permission as well to use the camera.
See here: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-requestCameraPermissions

Keypress event not working on Android device

I have a directive which controls my input value desired formatted or not.
directive('validNumber', function(shareDataService)
{
return
{
require: 'ngModel',
link: function(scope, element, attrs, ngModelCtrl)
{
if(!ngModelCtrl)
{
return;
}
ngModelCtrl.$parsers.push(function(val) {
if (angular.isUndefined(val)) {
var val = '';
}
var clean = val.replace(/[^-0-9\.]/g, '');
var decimalCheck = clean.split('.');
if(!angular.isUndefined(decimalCheck[1]))
{
decimalCheck[1] = decimalCheck[1].slice(0,2);
clean = decimalCheck[0] + '.' + decimalCheck[1];
}
if (val !== clean)
{
ngModelCtrl.$setViewValue(clean);
ngModelCtrl.$render();
}
return scope.hesapla(clean);
});
element.bind('keypress', function(event) {
if(event.keyCode === 32) { // space
event.preventDefault();
}
});
element.bind('keypress', function(event) {
if(event.keyCode === 45) { // - key
event.preventDefault();
}
});
}
};
})
It's working on browser perfectly but keypress event not working on the device.Tried to inspect device with google chrome but not firing. I also tried keyup or keydown but still not working. How can I get this done?
Thank you
Include jQuery Mobile file
What you need to do is just include a jQuery file into your project. A file named jQuery.mobile.js or quite similar (ex. jQuery.ui.js) of any version can help you.
You can download it from : Download | jQuery Mobile

How to use setMuted() in qml file Qt Android

This is probably a very noob question... I am very new to Qt, and trying programming in Qt creator. Now I created a new Qt Quick Application from Qt creator, and I play a audio and i would like control volume and mute but idon't know how.
Button {
id: muteButton
onClicked: mediaPlayer.muted ...
text: qsTr("Mute")
}
Slider {
id: volumeSlider
Layout.fillWidth: true
maximumValue: mediaPlayer.volume = 1.0
property bool sync: false
onValueChanged: {
if (!sync)
mediaPlayer.seek(value)
}
Connections {
target: mediaPlayer
onPositionChanged: {
volumeSlider.sync = true
volumeSlider.value = mediaPlayer.volume
volumeSlider.sync = false
}
}
Try
onClicked:
{ mediaPlayer.muted = true; }
Set to false if you want to unmute.

Categories

Resources