Add a contact/pin to BBM from BB 10 Native App - qml

In my BB 10 cascades App , I need to add a Button click listener for Adding a contact information like pin:210000A to Blackberry Messenger (BBM). for that I am doing the following...
main.qml is like
import bb.cascades 1.0
Page {
Container {
layout: DockLayout {
}
TextArea {
id: pinEditor
hintText: "Enter PIN to invite"
onTextChanged: {
inviter.pin = text
}
input.submitKey: SubmitKey.Send
}
Inviter {
id: inviter
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
}
}
}
and Inviter.qml is like
import bb.cascades 1.0
Container {
property string pin
Button {
text: "Invite to BBM"
onClicked: {
query.uri = "pin:" + pin
invoke.trigger("bb.action.INVITEBBM")
}
}
attachedObjects: [
Invocation {
id: invoke
query: InvokeQuery {
id: query
invokeTargetId: "sys.bbm.sharehandler"
onQueryChanged: {
invoke.query.updateQuery()
}
}
}
but I am getting "Read only property cannot be set"error in Qml.I have also added
LIBS += -lbbplatformbbm
LIBS += -lbbsystem and BBM Permission in "bar-descriptor.xml"
Do I need to Register with BBM for Adding contact in BBM from my App? and how to fix the above error?
Please help,
Thanks

I'm guessing here, but try this way:
Container {
property string pin
Button {
text: "Invite to BBM"
onClicked: {
invoke.query.setUri("pin:" + pin)
invoke.trigger("bb.action.INVITEBBM")
}
}
attachedObjects: [
Invocation {
id: invoke
query {
invokeTargetId: "sys.bbm.sharehandler"
onQueryChanged: {
invoke.query.updateQuery()
}
}
}
]
}

Related

Sencha touch 2 custom list item button tap not fired

I am developing a Hybrid Mobile App over sencha touch 2.
Now I was in a need of a custom component to be specific a custom list item consisting of a button along with.
My view has rendered as i wanted to but the button that is added to the list item is not firing the TAP event as expected. Instead on every tap, the ITEMTAP event is fired which is creating a bit of mess.
Can someone suggest me where to look to make this work ?
Below is the code for the custom component that i created:
var listView = {
xtype : "list",
id : "desk-list-search-results",
cls : "desk-list-search-results-cls",
selectedCls : "",
defaultType:"desksearchlistitem",
store : "deskstore",
flex : 2
};
This is the code for the custom component
Ext.define("MyApp.view.DeskSearchListItem",{
extend:"Ext.dataview.component.ListItem",
requires:["Ext.Button"],
alias:"widget.desksearchlistitem",
initialize:function()
{
this.callParent(arguments);
},
config:{
layout:{
type:"hbox",
align:"left"
},
cls:'x-list-item desk-search-list-item',
title:{
cls:"desk-list-item",
flex:0,
styleHtmlContent:true,
style:"align:left;"
},
image:{
cls:"circle_image",
width:"28px",
height:"28px"
},
button:{
cls:'x-button custom-button custom-font bookdesk-button',
flex:0,
text:"Book",
width:"113px",
height:"46px",
hidden:true
},
dataMap:{
getTitle:{
setHtml:'title'
}
}
},
applyButton:function(config)
{
return Ext.factory(config,Ext.Button,this.getButton());
},
updateButton:function(newButton,oldButton)
{
if(newButton)
{
this.add(newButton);
}
if(oldButton)
{
this.remove(oldButton);
}
},
applyTitle:function(config)
{
return Ext.factory(config,Ext.Component,this.getTitle());
},
updateTitle:function(newTitle,oldTitle)
{
if(newTitle)
{
this.add(newTitle);
}
if(oldTitle)
{
this.remove(oldTitle);
}
},
applyImage:function(config)
{
return Ext.factory(config,Ext.Component,this.getImage());
},
updateImage:function(newImage,oldImage)
{
if(newImage)
{
this.add(newImage);
}
if(oldImage)
{
this.remove(oldImage);
}
}
})
Finally got a solution to this,
It can be done into the view using the listeners object.
Here is the code sample for it.
listeners:{
initialize:function()
{
var dataview = this;
dataview.on("itemtap",function(list,index,target,record,event){
event.preventDefault();
});
dataview.on("itemswipe",function(list,index,target,record,event){
if(event.direction === "right")
{
var buttonId = target.element.down(".bookdesk-button").id;
var buttonEl = Ext.ComponentQuery.query("#"+buttonId)[0];
if(Ext.isObject(buttonEl))
{
buttonEl.setZIndex(9999);
buttonEl.show({
showAnimation:{
type:"slideIn",
duration:500
}
});
var listeners = {
tap:function(btn,e,opt)
{
console.log("Button Tapped");
}
};
buttonEl.setListeners(listeners);
}
else
{
console.log("This is not a valid element");
}
}
});
}
}
Thanks Anyways.

access context property from listview checkboxitem when onchechchanged

my qml:
if i create a button and call " _model.writeapp(appname);" from its click event it works fine, but not from the listview checkbox oncheckedchanged event
context is defined
Container {
ListView {
id: listid
dataModel: _model
function getAppName() {
return (_model.readApp());
}
function writeappName(appname) {
_model.writeapp(appname);
}
//! [1]
listItemComponents: [
ListItemComponent {
id: listcomp
type: "item"
Container {
id: conchk
CheckBox {
id: chkbx
text: ListItemData.appname
onCheckedChanged: {
console.log("checked")
if (checked) {
//have to call _model.writeapp(appname);
chkbx.ListItem.view.writeappName("hi")
}
}
}
}
}
]
}
}
Try changing this:
chkbx.ListItem.view.writeappName("hi")
To this:
conchk.ListItem.view.writeappName("hi")

Dictaphone BB10 in QML

I need make small app on BB10 using QML, which record and play some voice. I have all needed permision (microphone and store file) and this code:
import bb.cascades 1.0
import bb.multimedia 1.0
Page {
property string dataUrl;
Container {
background: Color.create("#001100")
layout: StackLayout {
}
attachedObjects: [
MediaPlayer {
id: audioPlayer
sourceUrl: dataUrl + "/recording.mp4"
},
AudioRecorder {
id: recorder
outputUrl: dataUrl + "/recording.mp4"
}
]
Button {
id: btnRecord
text: "Record"
onClicked: {
recorder.record();
}
}
Button {
id: btnStop
text: "Stop Record"
onClicked: {
recorder.reset();
}
}
Button {
text: "Play Audio"
onClicked: {
audioPlayer.play()
}
}
Button {
text: "Stop Audio"
onClicked: {audioPlayer.stop()
}
}
}
}
After running I can see all buttons, but recording and/or playing is not work. I dont know what is wrong. I cant see any errors.
You're almost there. The problem is your sourceUrl is wrong. The best place to store your recording is in your app's data directory but your QML has no idea where that is.
To solve this you need to expose your app's data path to your QML using C++. You can do this using a property (more info here).
Add the following C++ code under where you create your AbstractPane object (in my case called root). This is normally done in applicationui.cpp.
root->setProperty("dataUrl", "file://" + QDir::currentPath() + "/data");
Now add the dataUrl property to your QML and use it for your sourceUrl:
Page {
property string dataUrl;
Container {
background: Color.create("#001100")
layout: StackLayout {
}
attachedObjects: [
MediaPlayer {
id: audioPlayer
sourceUrl: dataUrl + "/recording.m4a"
},
AudioRecorder {
id: recorder
outputUrl: dataUrl + "/recording.m4a"
}
]
....
}
Edit: Make sure you call audioPlayer.reset() after you've finished recording, this forces the player to reload the recorded audio. If you don't do this your audio playback may be truncated.

Invocation from function in Blackberrry 10 qml?

I have invoked invite to BBM while clicking a button in qml,but i need to send the invitation for the contacts how to do this?my code
Button {
text: "Invite"
onClicked: {
invokeQuery.uri = "pin:210000A"
invokeQuery.updateQuery();
}
attachedObjects: [
Invocation {
id: invokeShare
query: InvokeQuery {
id: invokeQuery
}
onArmed: {
trigger("bb.action.INVITEBBM");
}
}
]
}
Can anyone send me some solutions to solve this.?
Thanks
Invocation query is immutable object which means that values in the query are not dynamic. If you want to update query in dynamic you need to do it via control signals or variables.
For example, you have a component called Inviter with the pin property exposed:
import bb.cascades 1.0
Container {
property string pin
Button {
text: "Invite to BBM"
onClicked: {
query.uri = "pin:" + pin
invoke.trigger("bb.action.INVITEBBM")
}
}
attachedObjects: [
Invocation {
id: invoke
query: InvokeQuery {
id: query
invokeTargetId: "sys.bbm.sharehandler"
onQueryChanged: {
invoke.query.updateQuery()
}
}
}
]
}
Then you can use it this way:
import bb.cascades 1.0
Page {
Container {
layout: DockLayout {
}
TextArea {
id: pinEditor
hintText: "Enter PIN to invite"
onTextChanged: {
inviter.pin = text
}
input.submitKey: SubmitKey.Send
}
Inviter {
id: inviter
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
}
}
}
Also, don't forget to enable "Blackberry Messenger" permission in your bar-descriptor.xml and add following libraries to your .pro file:
LIBS += -lbbplatformbbm
LIBS += -lbbsystem

How to play SystemSounds in the Blackberry 10 Dev Alpha Simulator?

I am just trying to run the provided sample code which, as far as I know, should work just fine. Is there anything I am missing or is this a limitation of the simulator.
If so, are there any workarounds?
import bb.cascades 1.0
// To use the MediaPlayer, we must include
// the multimedia library.
import bb.multimedia 1.0
Page {
Container {
id: mainContainer
layout: StackLayout {
orientation: LayoutOrientation.TopToBottom
}
topPadding: 50.0
Label {
id: titleLbl
text: qsTr("SystemSound and MediaPlayer\n Sample App")
multiline: true
textStyle.fontSizeValue: 9.0
textStyle.fontWeight: FontWeight.Bold
textStyle.fontFamily: "Verdana"
textStyle.color: Color.DarkBlue
textStyle.textAlign: TextAlign.Center
horizontalAlignment: HorizontalAlignment.Center
}
// Part 1 of the sample: Playing system sounds.
Container {
id: systemSoundsContainer
layout: StackLayout {
orientation: LayoutOrientation.TopToBottom
}
topMargin: 100.0
horizontalAlignment: HorizontalAlignment.Center
DropDown {
id: soundSelectorDropdown
title: "Sound: "
maxWidth: 600.0
Option {
text: qsTr("Battery Alarm")
value: SystemSound.BatteryAlarm
selected: true
}
Option {
text: qsTr("Browser Start")
value: SystemSound.BrowserStartEvent
}
Option {
text: qsTr("Camera Shutter")
value: SystemSound.CameraShutterEvent
}
Option {
text: qsTr("Device Tether")
value: SystemSound.DeviceTetherEvent
}
Option {
text: qsTr("General Notification")
value: SystemSound.GeneralNotification
}
} // soundSelectorDropdown
Button {
id: systemSoundPlayButton
text: qsTr("Play Selected System Sound")
minWidth: 600.0
onClicked: {
systemSound.play();
}
} // systemSoundPlayButton
} // systemSoundsContainer
// Part 2 of the sample: Playing custom sound files.
Container {
id: customSoundsContainer
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
topMargin: 100.0
Button {
id: customSoundPlayButton1
text: qsTr("Play Sound 1")
layoutProperties: StackLayoutProperties {
spaceQuota: 1.0
}
onClicked: {
// Here we could have created a second MediaPlayer object to
// use to play our sound, but instead we programmatically
// changed the sourceUrl property of the current myPlayer
// MediaPlayer object, and re-used it to play our sounds.
myPlayer.setSourceUrl("asset:///sounds/Doorbell_001.wav")
myPlayer.play()
}
} // customSoundPlayButton1
Button {
id: customSoundPlayButton2
text: qsTr("Play Sound 2")
layoutProperties: StackLayoutProperties {
spaceQuota: 1.0
}
onClicked: {
// Same as above, here we also could have created a second
// MediaPlayer object to use to play our sound, but instead
// we programmatically changed the sourceUrl property of the
// current myPlayer MediaPlayer object, and re-used it to
// play our sounds.
myPlayer.setSourceUrl("asset:///sounds/Doorbell_002.wav")
myPlayer.play()
}
} // customSoundPlayButton2
} // customSoundsContainer
} // mainContainer
// The SystemSound and MediaPlayer objects are attached so
// they can be used in our QML code to play sounds.
attachedObjects: [
SystemSound {
id: systemSound
sound: soundSelectorDropdown.selectedValue
},
MediaPlayer {
id: myPlayer
// sourceUrl: < Set in the Button control's onClicked event handler. >
}
] // Attached objects.
}
Source: https://developer.blackberry.com/cascades/documentation/design/audio_video/playing_sounds_code_sample.html
I suspect that that System Sounds are actually .mp3 or .ogg files internally, where the "Cowbell sample" and "Pull My Beard" are using .wav files. It's a known issue, and has been discussed on the Blackberry Developer forums here and here, and also here, that the simulator does not have the correct codecs to play any sounds except .wav files. The sounds should play correctly on actual hardware.