MOBILE COMPUTING WAHLPFLICHTFACH BLACKBERRY Sommersemester 2013 Dipl.-Ing. Andre Pura Source: https://developer.blackberry.com/cascades/documentation/ OVERVIEW • • • • • • • • • • • • • Introduction BlackBerry Enterprise Server Basics in BB10 and IDE BlackBerry 10 Concepts Cascades GUI Invocation Framework Cards Menu-Integration Data Storage Communication Location Services More ... [email protected] 2 INTRODUCTION: BB10 [email protected] 3 WHAT IS BLACKBERRY10 (BB10) • BlackBerry 10 is an operation system for mobile devices • Based on QNX • QNX was bought in 2010 by BlackBerry (vormals Research in Motion) • Micro Kernel Betriebssystem • First used by BlackBerry in the BlackBerry PlayBook (BlackBerry Tablet OS) Quelle: http://www.qnx.com [email protected] 4 DIFFERENCE TO MONOLITHIC KERNEL • Most components run in their own processes • Each process runs in its own area Monolithic Kernel Memory of Process B Process A Process B Process A Process B Micro Kernel Close process [email protected] Quelle: Embedded systems security, by Kleidermacher and Kleidermacher, Elsevier 2012 5 ADVANTAGES AND DISADVANTAGES • Advantages – If a component crashes, the system stays alive – Drivers must not be a part of the kernel • Disadvantages – Performance, a lot of context changes are necessarly – Synchronize of the processes [email protected] 6 DIFFERENCE TO OTHER PLATFORMS • Competitors: – iOS – Android – Windows Phone – Symbian [email protected] 7 DIFFERENCE TO OTHER PLATFORMS Android iOS BlackBerry OS BlackBerry 10 Windows Phone Symbian Language Java, C++ Objective C Java ME, C++ C# C++, Java ME Models 900+ 11 60+ 21 1000+ Available Apps (Feb. 2013) 845 000+ 770 000+ 100 000+ 120 000+ 115 000+ Advantages Open Source, A few devices, a lot of Good API examples and code Good support, fast growing market Small High market amount of penetration Apps, good support, few devices Disadvantag es Many apps, a lot of different devices Small API, documentation Low market penetration • Unterschied zu anderen Plattformen Many Apps, restrictive market policy [email protected] A lot of differnt devices 8 BLACKBERRY10 PLATFORM • Up to now, you had to use Java to develop for BlackBerry • Now: Android Emulator Adobe Air Cascades / QT HTML 5 Native / C++ Source: https://developer.blackberry.com/develop/platform_choice/index.html [email protected] 9 THE „OTHERS“ • HTML – Webworks, JavaScript and HTML based • Adobe Air – Actionscript / Flex based • Android Emulator – Java/Android based, Android 2.3.3 [email protected] 10 CASCADES VS NATIVE Cascades • QT/C++ • A lot of BB10 APIs • Fast development • GUI is seperated from logic Native • Fast porting of existing C++ / openGL applications • Longer development process • Pure „code“ • POSIX compliance • Simple integration of OpenSource Libraries Quelle: https://developer.blackberry.com/develop/platform_choice/ndk.html [email protected] 11 CASCADES • Supported by tat • Integrated Animations • Interface to Photoshop – Direct export from Photoshop to QML • • • • • • • Simple communication with C++ classes Native Multi-Language support Qt integragted Eclipse GUI Plugin Hard to port applications A little bit less performance than pure native More information: https://developer.blackberry.com/cascades/ [email protected] 12 Ing. Elmar Jilka, MSc BLACKBERRY ENTERPRISE SERVER [email protected] 13 BASICS: BB10 PROGRAMMING AND GUI [email protected] 14 COMPONENTS OF A BB10 CASCADES APPLICATION • A Cascades Application has 3 parts: – bar-descriptor.xml – main.cpp – .qml File [email protected] 15 DAS BAR-DESCRIPTOR.XML • Descriptes the basics of an application – – – – – – – – – Name ID Versionsnumber Author Plattform Icon Splashscreen Application Files Permissions [email protected] 16 MAIN.CPP • Startpoint of each BB10 Cascades Application • It can consist of the application itself or call an object, inherit from application [email protected] 17 .QML LAYOUT FILE • • • • A QML File describes a layout Save it in the assets folder A layout should have at least one component Define the mayor layout in the first file [email protected] 18 FLOW • User is king ! • Organize the information in a logical way • What will the user do next ? • Adapt the menu to the current screen • Invoke other applications and funcitons • Use shortcuts Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 19 BASIC ELEMENTS • BB10 has 2 typical sctructures – Tabs – Drill-Down (Navigation Pane) • It is possible to combine both Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 20 TABS • Using tabs, it is possible to access screens directly • 4 Tabs can be placed on the bottom bar • There is more space in the sidebar Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 21 DRILL-DOWN • Drill-Down (Navigation Pane) a hierachical structure of screens • Screens are pushed over each other Source: https://developer.blackberry.com/cascades/documentation/ 22 RESOLUTIONS ? Source: https://developer.blackberry.com/cascades/documentation/ 23 HANDLING DIFFERENT RESOLUTIONS (10.1) Verschiedene Auflösungen Ein Layout für alle Pro Auflösung ein Layout Anpassung per relativem Layout Ordner mit Layout für Scrollview 720x720 Dynamische Skalierung 1280x768 1280x720 [email protected] 24 KEYBOARD • There are physical (Q10) and virtual keyboards • Since 10.1 both types should be supported • Use shortcuts for physical keyboards • Think about the space for a virtual keyboard Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 25 BASICS • Everything in QML is possible in C++ • But not everytihng in C++ is possible in QML • Simple GUI Elements: – Button – Label – TextField – CheckBox – ToggleButton – Slider [email protected] 26 GENERATE THE GUI • Using QML • Using C++ [email protected] 27 CASCADES EVENT SYSTEM • Signals & Slots (Qt based) • Every GUI interaction emits a Signal, which can be connected to n slots Slot Click on Button Signal Slot N obects, Are connected to a signal Slot [email protected] 28 LAYOUTS • There are threee kinds of layouts Stack Layout Dock Layout Absolute Layout Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 29 QML AND C++ INTEGRATION • Load QML from C++ Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 30 CHANGE QML ATTRIBUTES PROGRAMMATICALLY • It is simple to change QML attributes from C++ QML Code [email protected] 31 QML ATTRIBUTES [email protected] 32 USING C++ VALUES IN QML • Connection with a QDeclarativePropertyMap Registrier the Map in QML [email protected] 33 ACCESS CUSTOM OBJECTS IN QML I • It is possible to acces C++ objects from QML [email protected] 34 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • It is possible to acces C++ objects from QML Macro for Qt Signals / Slots [email protected] 35 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • It is possible to acces C++ objects from QML Variablename in QML [email protected] 36 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • It is possible to acces C++ objects from QML Called, when the variable is read [email protected] 37 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • It is possible to acces C++ objects from QML Called, when the variable is changed in QML [email protected] 38 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • It is possible to acces C++ objects from QML Signal to emit [email protected] 39 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • Es kann auch ein eigenes Objekt in QML verwendet werden Signal to emit Variablename in QML Called, when the variable is read Called, when the variable is changed in QML [email protected] 40 ZUGRIFF AUF CUSTOM OBJECTS IN QML I • Es kann auch ein eigenes Objekt in QML verwendet werden Function used in QML [email protected] 41 ZUGRIFF AUF CUSTOM OBJECTS IN QML II • Register the C++ object to use it in QML • It is simple to access values from the object in QML [email protected] 42 INSTALLATION OF THE IDE [email protected] 43 DOWNLOAD • SDK download: – https://developer.blackberry.com/cascades/downl oad 44 CODE SIGNING KEYS • Order Code Signing Keys : – https://www.blackberry.com/SignedKeys/codesig ning.html • Important: Backup the keys ! [email protected] 45 SIMULATOR DOWNLOAD AND INSTALL • Download the simulator – https://developer.blackberry.com/develop/simula tor/index.html [email protected] 46 START IDE [email protected] 47 IDE - MENU Menü [email protected] 48 IDE – DIRECTORIES AND FILES Projects and files of the projects [email protected] 49 IDE – FUNCTIONS AND VARIABLES Functions and variables [email protected] 50 IDE - INFORMATION Information [email protected] 51 IDE - ACTIONS Actions [email protected] 52 IDE ACTIONS Choose SDK Version [email protected] 53 IDE ACTIONS SDK Version wählen SDK Version nachladen [email protected] 54 IDE ACTIONS SDK Version wählen SDK Version nachladen Neues Projekt, neue Klasse, neues Sourcefile anlegen [email protected] 55 IDE ACTIONS SDK Version wählen SDK Version nachladen Projekt kompilieren Neues Projekt, neue Klasse, neues Sourcefile anlegen [email protected] 56 IDE ACTIONS SDK Version wählen SDK Version nachladen Projekt kompilieren Neues Projekt, neue Klasse, neues Sourcefile anlegen Konfiguration ändern [email protected] 57 IDE ACTIONS SDK Version wählen SDK Version nachladen Projekt kompilieren Neues Projekt, neue Klasse, neues Sourcefile anlegen Debugging starten Konfiguration ändern [email protected] 58 IDE ACTIONS SDK Version wählen SDK Version nachladen Projekt kompilieren Neues Projekt, neue Klasse, neues Sourcefile anlegen Debugging starten Konfiguration ändern [email protected] Ausführen ohne Debugging 59 IDE ACTIONS SDK Version wählen SDK Version nachladen Sicht ändern Projekt kompilieren Neues Projekt, neue Klasse, neues Sourcefile anlegen Debugging starten Konfiguration ändern [email protected] Ausführen ohne Debugging 60 IDE - VIEWS • • • • • Application Profiler QML Editing C++ Editing Debug System Information [email protected] 61 QML EDITOR Schematic layout QML Code Cascades Components QML Eigenschaften [email protected] 62 SYSTEM INFORMATION Code Target Target Information [email protected] 63 SYSTEM INFORMATION - SUMMARY [email protected] 64 SYSTEM INFORMATION – PROCESS INFO [email protected] 65 SYSTEM INFORMATION – MEMORY INFO [email protected] 66 SYSTEM INFORMATION – MALLOC INFO [email protected] 67 SYSTEM INFORMATION – FILE EXPLORER [email protected] 68 FIRST BB10 APP [email protected] 69 FIRST APP • • • • Installation done? Keys ordered? Simulator installed? Device in Developer Mode? – (Settings / Security and Privacy / Developermode) [email protected] 70 STEPS • • • • • • Create a new project Signing Keys Backup the Signing Keys Connect Device Create Debug Token Deploy and debug the application [email protected] 71 CREATE A NEW PROJECT [email protected] 72 CREATE A NEW PROJECT [email protected] 73 CREATE A NEW PROJECT [email protected] 74 SIGNING KEYS AND CERTIFICATE Unter Windows: Extras -> Einstellungen [email protected] 75 SIGNING KEYS AND CERTIFICATE [email protected] 76 SIGNING KEYS AND CERTIFICATE Register the Signing Keys [email protected] 77 SIGNING KEYS AND CERTIFICATE Generate the developer certificate [email protected] 78 SIGNING KEYS AND CERTIFICATE - BACKUP Backup keys [email protected] 79 CONNECT THE DEVICE/SIMULATOR • Connect the device via Micro USB or start the simulator • To start the simulator use VMWare Fusion • Connect the device with the IDE [email protected] 80 START DEBUGGING [email protected] 81 START DEBUGGING [email protected] 82 START DEBUGGING Activate and click apply [email protected] 83 START DEBUGGING Start Debugging [email protected] 84 START DEBUGGING [email protected] 85 START DEBUGGING [email protected] 86 THE DEBUGGING VIEW OPENS • Open the device log messesage Project ID Process ID [email protected] 87 APPLICATION STOPS AT THE „BREAK POINT“ • The applications stops at the beginning or the first break-point • To resume the application press F8 or the Software key • Shortcuts: – F5 : Step Into – F6 : Step over – F7 : Step return [email protected] 88 EXC1 • Erzeugen Sie in der „Hello World“ Applikation ein zweites Textfeld • Dieses soll in roter Schrift oben-mittig platziert sein • Rotieren Sie das erste, schwarze Textfeld um 90° gegen den Uhrzeigersinn • Geben Sie den Textfeldern IDs: – lblSchwarz – lblRot [email protected] 89 MOBILE COMPUTING WAHLPFLICHTFACH BLACKBERRY Sommersemester 2013 Dipl.-Ing. Andre Pura BLACKBERRY 10 CONCEPTS [email protected] 91 USE C++ CLASSES IN QML • Yesterday, the object was generated in C++ and used in QML • But it is also possible to generate an object in QML Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 92 USE C++ CLASSES IN QML • The object must be registered and can be used in QML directly [email protected] 93 [email protected] 94 extends [email protected] 95 andre[email protected] 96 [email protected] 97 [email protected] 98 [email protected] 99 HOW CAN WE ACCESS C++ FROM QML ? [email protected] 100 HOW CAN WE ACCESS C++ FROM QML ? 1. Create C++ Object in QML – Register Class in QML, create the object in C++ 2. Pass a C++ Object to QML – Create object in C++, pass it to qml 3. Using the PropertyMap (Gleich 2.) – Generate a PropertyMap and push it to QML [email protected] 101 HOW CAN WE ACCESS QML FROM C++ ? [email protected] 102 HOW CAN WE ACCESS QML FROM C++ ? 1. C++ Objekt nach QML übergeben – Objekt in C++ erzeugen, Objekt nach QML übergeben 2. Property direkt im Code ändern – Das Objekt aus dem Root-Objekt extrahieren und die Property setzen [email protected] 103 APPLICATION LIFETIME [email protected] 104 APPLICATION LIFETIME Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 105 APPLICATION LIFETIME • Each application runs through the cyclus • At the moment it is not possible to generate an application without a GUI (should be possible with 10.2) • An application in the „background“ is alwaysa visible as an „Active Frame“ • If the permission „run in background“ is enabled, the „stopped“ state does not exist [email protected] 106 APPLICATION LIFETIME • Each application has 3 different states: – Fullscreen – Thumbnail – Invisible Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 107 APPLICATION LIFETIME • Each application has 3 different states: – Fullscreen – Thumbnail – Invisible Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 108 APPLICATION LIFETIME • Each application has 3 different states: – Fullscreen – Thumbnail – Invisible Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 109 CASCADES JAVASCRIPT [email protected] 110 CASCADES • • • • JAVASCRIPT JavaScript can be used in QML Inline Code Using an external library Usually JavaScript is used to react on signals Source: http://www.crackberry.com [email protected] 111 JAVASCRIPT IN CASCADES [email protected] 112 INLINE JAVASCRIPT IN CASCADES Signal JavaScript [email protected] 113 JAVASCRIPT IN CASCADES - FUNKTION JavaScript [email protected] 114 JAVASCRIPT IN CASCADES - FUNKTION [email protected] 115 CONNECT A SIGNAL TO A JAVASCRIPT FUNCTION [email protected] 116 CONNECT A SIGNAL TO A JAVASCRIPT FUNCTION Signal Function [email protected] 117 CONNECT A SIGNAL TO A JAVASCRIPT FUNCTION [email protected] 118 CONNECT A SIGNAL TO A JAVASCRIPT FUNCTION onClicked:{ root.changeTest(); } [email protected] 119 GUI ELEMENTS [email protected] 120 BASICS ON GUI ELEMENTS • QML Components are always on the same level in a container • Each component can have properties and signals • Use JavaScript to react on signals • You can design your own components [email protected] 121 BASICS ON GUI ELEMENTS Components Property Additional objects [email protected] 122 Component BASICS ON GUI ELEMENTS Property Signal [email protected] 123 GUI ELEMENTS- CONTAINER • A Container is used to goupe other GUI elements • Only a container can have childs • The alignement of the elements can be adjusted in a container (Standard: StackLayout) • Is a container deleted from a scene, all ist childs are deleted [email protected] 124 GUI ELEMENTS- CONTAINER • The size of the container is defined by ist childs • Width and height can be modified with: – preferredWidth, preferredHeight – minWidth, minHeight – maxWidth, maxHeight • Usually the background is tranparent [email protected] 125 GUI ELEMENTS- CONTAINER • Signals: – onControlAdded – onControlReplaced – onControlRemoved – onControlMoved – onLayoutChanged – onBackgroundChanged – onClipContentToBoundsChanged [email protected] 126 Components GUI ELEMENTS- CONTAINER Attached objects [email protected] 127 GUI ELEMENTS- LABEL • A label is used to show a short text • Not interactive • The visual appearance (z.B. Color) is extended by AbstractTextControl • Important properties: – text – multiline • Important signals: – onMultilineChanged Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 128 GUI ELEMENTS- BUTTON • • • • A button is an interactive GUI component It is used for „click“ actions Triggers actions 3 different appearances: – Ein Bild und einen Text – Nur ein Text – Nur ein Bild Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 129 GUI ELEMENTS- BUTTON • Important signal – onClicked (extended by AbstractButton) • Properties – imageSource – image – text [email protected] 130 GUI ELEMENTS- TEXTFIELD • A TextField is an input field to interact with the user • It can be configured for different kinds of inputs – eMail Adresse – Password – Chat – Url Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 131 GUI ELEMENTS- TEXTFIELD • Important Properties – – – – hintText inputMode validator Input (Mit TextInputProperties) • submitKey • flags (Spellcheck, PredictionOff) • Important signals – onTextChanging – onValidatorChanged [email protected] 132 GUI ELEMENTS- SLIDER • A Slider enables the user to select a value from a defined range • It is better to use a Slider instead of a TextField • Intuitive • Important properties – fromValue – toValue – value • Important signal – onValueChanged [email protected] 133 GUI ELEMENTS– SEGMENTED CONTROL • A horizontal selector for up to 4 different actions • Is used to change the view of the current page • Important property – selectedIndex • Important Signal – onSelectedIndexChanged Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 134 GUI ELEMENTS– SCROLL VIEW • A ScrollView is related to the Containers • It enables scrollig and zooming • Like all other components, a single element in a ScrollView is allowed (But you can use a Container in it) • Important properties – content – scrollViewProperties [email protected] 135 GUI ELEMENTS– IMAGEVIEW • The ImageView is used to display images • A ScrollView is used for pitch-to-zoom • Important properties – scalingMethod – imageSource [email protected] 136 GUI ELEMENTS– WEBVIEW • There are a lot of use cases, where it is necessary to show html or load external websites • It is possible to load locale content and external content • Important property – Html and/or url • Important signals – onUrlChanged – onLoadingChanged – onMessageReceived [email protected] 137 GUI ELEMENTS– WEBVIEW • html: • url: [email protected] 138 GUI ELEMENTS– WEBVIEW • Cascades can communicate with JavaScript in a WebView • JavaScript must be enabled in the WebView • Messages are used for the communication • postMessage is used to sent a message to JavaScript, which is embedded in a WebView • onMessageReceived is used to receive a message from an embedded Javascript [email protected] 139 GUI ELEMENTS– WEBVIEW • JavaScript, which is embedded in a WebView, can react with onmessage() and postMessage [email protected] 140 GUI ELEMENTS– WEBVIEW • JavaScript, which is embedded in a WebView, can react with onmessage() and postMessage [email protected] 141 WHY IS IT IMPORTANT TO COMMUNICATE WITH EMBEDDED JAVASCRIPT? [email protected] 142 WARUM MIT JAVASCRIPT KOMMUNIZIEREN? • Integrate existing content fro the Internet to the application • Use native GUI elements to trigger actions on a webpage • Using native GUI elements is more intuitve • Fast Cross-Platform-Developing – 1 Update for all operation systems [email protected] 143 GUI ELEMENTS– ACTIVITY INDICATOR • An ActivityIndicator is used to inform the user, that a background thread is working • It is used (in difference to a progress bar), when the duration of the loading is unknown • Important Properties – running • Important Signals – onStarted – onStopped • Functions – Start – Stop Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 144 GUI ELEMENTS– ACTIVITY INDICATOR Initalize the ActivityIndicator [email protected] 145 GUI ELEMENTS– ACTIVITY INDICATOR Initalize the ActivityIndicator Start the ActivityIndicator Stop the ActivityIndicator [email protected] 146 GUI ELEMENTS– ACTIONITEM • ActionItems are used to define additional actions • These Actions can be for the whole Page or a specific component (Context Menu) • Each Action can be defined with an icon and a text • An ActionSet combines actions to a set Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 147 GUI ELEMENTS– ACTIONITEM CONTEXTACTION Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 148 GUI ELEMENTS– ACTIONITEM CONTEXTACTION [email protected] 149 GUI ELEMENTS– ACTIONITEM CONTEXTACTION [email protected] 150 GUI ELEMENTS– ACTIONITEM – PAGE ACTION • ActionItems placed on a Page er used to define additional actions • Important properties – ActionItem.placement Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 151 APPLICATIONMENU • The Application menu is not directly connected to a single page • Usually settings and additional information about the application can be bound in the menu • The menu is on the top • Swipe-down at the top shows/hides the menu • Important properties of the entries – title – imageSource • Important signal – onTriggered Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 152 APPLICATIONMENU Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 153 APPLICATIONMENU [email protected] 154 ORIENTATION HANDLING • There are two different orientations: – Portrait – Landscape • Tablets usually use the landscape orientation • Smartphones usually use the portrait orientation Hint: Q10: Portrait == Landscape Mode Source: https://developer.blackberry.com/cascades/documentation/ 155 ORIENTATION HANDLING • Define the usage of both orientations in the manifest Source: https://developer.blackberry.com/cascades/documentation/ 156 ORIENTATION HANDLING • Define the support in QML to react on orientation changes (when the GUI is loaded) • Use the OrientationHandler to react on the orientation change [email protected] 157 ORIENTATION HANDLING • onOrientationAboutToChange in the handler is used to react on changes [email protected] 158 ADD GUI ELEMENTS PROGRAMMATICALLY • In some use cases it is necessary to add GUI elements programmatically • Remember: Use containers to add elements on the same level Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 159 ADD GUI ELEMENTS PROGRAMMATICALLY • Add a container in QML and define a name for the obecjt • Initialize the container in C++ and add the elements [email protected] 160 ADD GUI ELEMENTS PROGRAMMATICALLY [email protected] 161 BEISPIEL DER GUI ELEMENTE [email protected] 162 EX 1 • • • • Create a new BlackBerry Cascades Projekt Create a Button and a Label Write 0 (zero) in the Label If the button is clicked, increase the number in the label by 1 [email protected] 163 EX 1 • Write a function in JavaScript, which calculates the nth Fibonacci Number (If you do not know how to calculate the Fibonacci Numbers, search the internet) • Generate a slider from 2 - 20 • Generate an additional label • When the user changes the value with the slider, calculate the nth Fiboncci Number and show it in the label [email protected] 164 HINT [email protected] 165 EX 2 • Download Lena – http://sipi.usc.edu/database/preview/misc/4.2.04 .png • Create a new Cascades Projekt • Create an ImageView with Lena • Create an ActionItem in the context of the ImageView – Rotate the Image on each click on the action item [email protected] 166 EX 2 • Create an ActionItem for a Page-Action • If it is triggered, change the visibility of Lena – If Lena is visibile -> invisibile – If Lena is invisibile -> visibile • Change the text of the ActionItem on each click („visible“ <-> „invisible“) [email protected] 167 EX 3 • Create a new BlackBerry Projekt with a Navigation Pane • Study the sourcecode • Create a new Button and create an other Page as a new qml file • If the new button is clicked, open the new page • If there isn‘t a back button on the page, add it. [email protected] 168 EX 3 • Create on the new page a button, which opens another page • Create an application menu with an ActionItem • If it is triggered, pop all pages until the first page is reached [email protected] 169 MOBILE COMPUTING WAHLPFLICHTFACH BLACKBERRY Sommersemester 2013 Dipl.-Ing. Andre Pura RECAPITULATION • Development in BB10 – – – – – HTML Native C++ Adobe Air Cascades Android Emulator • Elements of an application – – – – – GUI in QML Code in C++ Description Files (z.B. Mainfest) Assets You can use JavaScript in QML [email protected] 171 RECAPITULATION • 2 types of applications – Drill-Down – Tabs • Important GUI Elements – Container – Label – ImageView – Button – TextField [email protected] 172 RECAPITULATION • Menus – Context Menu – Page Context Menu – Application Menu • ActionItem [email protected] 173 RECAPITULATION • Communication between QML and C++ – Generate Object in C++ and pass it to QML – PropertyMap – Import C++ Class in QML and generate objects [email protected] 174 INVOCATION FRAMEWORK [email protected] 175 INVOCATION FRAMEWORK • Use the invocation framework to call an other application • Messages can be used to pass data • Configure your own application to be invokable from other applications • It is possible to invoke an application without knowing the name of the other application. Only the task is necessary [email protected] 176 INVOCATION FRAMEWORK • An Invocation Request is the message sent to the system to inform the system that an application should be invoked • Invocation Request can be used to inform another application about changes • Attributes of a message – Target – Action – Data [email protected] 177 INVOCATION FRAMEWORK - ATTRIBUTE • Target – Each target application has an unique identifier – The „reverse DNS“ scheme is used (eg com.example.myapp) • Action – Descripts the task which should be done – To call an defined action, the „reverse DNS“ scheme is used (eg com.example.myapp.VIEW) – There are some predefined actions – These actions start with bb.action. [email protected] 178 INVOCATION FRAMEWORK - ATTRIBUTE • Data – Data is passed as MIME type or URI • URI describes where the data can be found • MIME type descripes the kind of data – A small amout of data (< 16kb) can be sent directly, if the URI is data://local – Own MIME Types start with application/vnd (eg application/vnd.mycompany.mydata) [email protected] 179 INVOCATION FRAMEWORK – BOUND VS UNBOUND INVOCATIONS • Bound Invocation – Knwon target – Start a known application directly • Unbound Invocation – Known task – If no task is defined, the Invocation Framework calls bb.action.VIEW Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 180 INVOCATION FRAMEWORK – BOUND INVOCATION Quelle: http://devblog.blackberry.com/2012/11/bbm-invocation-framework/ [email protected] 181 INVOCATION FRAMEWORK – UNBOUND INVOCATION Quelle: http://supportforums.blackberry.com/t5/Cascades-Development/Open-browser-from-app/td-p/1952547 [email protected] 182 INVOCATION FRAMEWORK – PROBLEMS SENDING DATA • A small amount of data can be sent directly • If the URI is used, be aware, that the called application can access the data • If the called application cannot access the file directly, it is copied to the called application‘s directory • It is possible to control this behaviour using the following attributes: – – – – Preserve CopyReadOnly CopyReadWrite Link [email protected] 183 INVOCATION FRAMEWORK – MULTIPLE FILES • Sent multiple files, adapt the MIME type – filelist/mixed – filelist/document – filelist/media • If all files in the same directory, the URI is the path to this directory • If the files are in different directories, a JSON with the paths is required [email protected] 184 INVOCATION FRAMEWORK – CORE APPLICATIONS • A lot of the standard applications can invoked using the invocation framework Quelle: http://supportforums.blackberry.com/t5/Cascades-Development/Open-browser-from-app/td-p/1952547 [email protected] 185 INVOCATION FRAMEWORK – RECEIVING INVOCATIONS • It is possible to receive Invocation Requests from other applications • Therefore you have to define your application as a target in the bar-descriptor.xml (Manifest) [email protected] 186 INVOCATION FRAMEWORK – RECEIVING INVOCATIONS • In addition, some lines of C++ code is required • The application have to known in which state it was started [email protected] 187 [email protected] 188 Connect to the InvocationManager [email protected] 189 React on the kind of start [email protected] 190 INVOCATION FRAMEWORK – TARGET FILTER • Applications, which can do the job, will be identified by target filters • These Filters are a part of <invoke-target> in the Manifest • Attribute – Filter: Descripts the criteria of a filter – Action: The action, which can be called – MIME Type: The kind of file/data which can be opened – Uris: A scheme for the URI – Exts: the allowed extensions [email protected] 191 INVOCATION FRAMEWORK – TARGET FILTER • There are some rules: – The URI cannot only be a Wildcard-Character (*) – If bb.action.VIEW or bb.action.OPEN is defined as an action and if the MIME type is a wildcard , the URI cannot be data:// or file:// – If URI equals to data:// or file:// and the MIME type is a wildcard, there must be at least an extension that is not a wildcard • If a rule is violated, you are not able to install the application on the device (Error: 884 Restricted Invoke Filter) [email protected] 192 EXAMPLES TARGET FILTER • Allowed – actions=bb.action.OPEN; types=*;uris=http://; – actions=bb.action.OPEN,bb.action.VIEW; types=*; uris=file://; exts=jpg,gif,tif; – actions=bb.action.VIEW; types=*; uris=data://; exts=jpg,gif,tif; • Not allowed – actions=bb.action.OPEN,bb.action.VIEW,bb.action.SET; types=*; uris=file://; – actions=bb.action.OPEN; types=*; uris=data://; – actions=bb.action.VIEW; types=*; uris=*; – actions=bb.action.VIEW; types=*; – actions=bb.action.OPEN,bb.action.VIEW; types=*; uris=file://; exts=*; [email protected] 193 EXAMPLES TARGET FILTER [email protected] 194 EXAMPLES TARGET FILTER 2 Filter [email protected] 195 EXAMPLE TARGET FILTER Filter for PNG or JPEG files which are in the data or in a message Filter for a URI with the extension of .png or .jpg [email protected] 196 INVOCATION FRAMEWORK – HOW CAN THE FRAMEWORK DETERMINE THE RIGHT TARGET? • If an unbound invoke is sent to the Invocation Framework, it tries to determine the right target (Process is called Invocation Brokering) • An application is used in the process if ... – the action matches – every application used for the process, if no action is defined [email protected] 197 INVOCATION FRAMEWORK – HOW CAN THE FRAMEWORK DETERMINE THE RIGHT TARGET? • At this point the MIME type and URI schemes are compared – URI Schema is equal? (if the extension is set, only if it matches too) – MIME Type equal? • Sorting the applications – Most matching URI scheme (from the number of matching characteristics) – If there are equal filters, the MIME type is compared – An explicit match is better than a wildcard – If there are equal filters at this point, the URI extensions are compared – If there are equal filters, the system default is used – If there is no system default, the oldest filter is used [email protected] 198 INVOCATION FRAMEWORK – CARD OR APPLICATION • There are 2 options showing a preview – External application – Card • The difference can be defined in the task: – Do you plan to make a „simple“ action with the data and come back to the application ? -> Card – Do you want to process the data with a lot of different methods and proceed working in the new application ? -> external application [email protected] 199 CARDS [email protected] 200 CARDS • Cards can be used to provide the whole functionality or a part of it to another application • Usually specialised tasks are used for cards • The card is pushed over the calling application without closing it • An application can only call a single card by the time. But a card can call another card [email protected] 201 CARDS - KINDS • There are three kinds of cards: Picker Composer Previewer Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 202 CARDS - KINDS • Picker – Pick existing content to use in the application (eg Files) • Composer – Generate or edit existing content • Previewer – Preview content • The kind of the card defined the animation of the card and how peek is handled. [email protected] 203 CARDS – TRANSITION – COMPOSER AND PICKER • The transition between the application and the card is defined by the kind Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 204 CARDS – TRANSITION - PREVIEWER Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 205 CARDS – PEEKING • The Previewer support full peeking • The Composer and Picker only support peeking on the action bar Source: https://developer.blackberry.com/cascades/documentation/ 206 CARDS - DESIGN • BlackBerry defines in the GUI Guidelines some rules • Cards must support both orientations [email protected] 207 CARDS • Cards are called using invocations • If the user closes the card, an signal is emitted and can be used by the calling application • Previewer closes without an signal • Emitting the closing signal for a Composer is optional • Usually you want to have a closing signal when a Picker is used • It is also possible to close a card from the calling application [email protected] 208 CARDS - CODE • React on peek [email protected] 209 CARDS - CODE • React on response [email protected] 210 CARDS - REGISTER • Card must be registered in the manifest [email protected] 211 CARDS - STARTMODE • If an application is started, it must be identified, if the application was called by another application as a card or not [email protected] 212 [email protected] 213 Connect to „invoked“ signal [email protected] 214 Is the application called as a card? [email protected] 215 CARDS - STARTMODE • Wait for the „invoked“ signal and react on it [email protected] 216 CARDS – SEND A RESPONSE • If the card is closed, you can/must provide dan response [email protected] 217 CARDS – RESIZE AND ORIENTATION • Each card must support both orientations • It is possible, that the card is resized (eg if a virtual keyboard is required). The card must react on these kind of changes [email protected] 218 [email protected] 219 Connect to resize signal [email protected] 220 Function, which is called on an emitted signal [email protected] 221 EXAMPLES OF INVOCATIONS [email protected] 222 MENU INTEGRATION [email protected] 223 INTEGRATION IN THE CONTEXT MENU • As we have learned, it is possible generate a context menu • But it is possible that the operation system BB10 adds more elements automatically • And what is even better: It is possible to be added in other applications as well [email protected] 224 INTEGRATION INS CONTEXT MENU • „Normal“ integration in the contextmenu • Integrate the selection of the operation system • Which applications are integrated is decided by BB10 using the filters [email protected] 225 ACTIVE FRAME [email protected] 226 ACTIVE FRAME • An Active Frame visual state of the thubnailed application • The frame can be static or dynamic • A simple static cover is better than a missing cover • The cover itself cannot be interactive: if the user clicks on it, the application is going to the fullscreen state Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 227 ACTIVE FRAME • A dynamic active frame should be updated rarely • Different resolutions require different active frames • Sometimes less information is more ... • Style: SlatePro, regular weight, 30px height Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 228 ACTIVE FRAME – STYLE GUIDELINES Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 229 ACTIVE FRAME – STYLE GUIDELINES Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 230 ACTIVE FRAME - STATIC • Register the components to use them in QML • Generate the Cover for the active frame in QML [email protected] 231 ACTIVE FRAME - STATISCH • Initialize the cover • Set the cover [email protected] 232 ACTIVE FRAME - DYNAMIC • Usually an dynamic active frame is set in C++ • Be aware of the update cycles • The dynamic content must provide additional information for the user • The first update can be triggers by calling update() or by connect to the thumb nailed signal (preferred) [email protected] 233 ACTIVE FRAME - DYNAMIC [email protected] 234 ACTIVE FRAME - DYNAMIC Load GUI from QML [email protected] 235 ACTIVE FRAME - DYNAMIC Trigger first update [email protected] 236 ACTIVE FRAME - DYNAMIC [email protected] 237 ACTIVE FRAME - DYNAMIC Trigger the update every 2 hours Call the first update, when the appication is thumbnailed [email protected] 238 ACTIVE FRAME – DYNAMIC- SET [email protected] 239 EXAMPLES OF ACTIVE FRAMES [email protected] 240 PROJECT • • • • Groups of 4 Think about a small project Development time per person: 10 -15h Kick Off Presentation on Thursday – – – – – – 5-10 min about your project 1st Slide: Name of the group, members Which steps do you need to reach your goal? Who is responsible for which part ? Which API do you want to use Is there an equal application in the market? If there is an equal application, why is your application „better“? • Send me your commented project until the 5th of July – Source – Compiled BAR File – PDF with more information about your project (Members, goal, achievements) [email protected] 241 EX 1 • Create a new BB Cascades Projekt • Create 5 Buttons • Use the invocation framework to connect the clicked signal from the buttons to: – Open a browser with orf.at – Create an eMail with: subject: „Hallo Composer“, text: „how are you doing ?“ – Open an image – Open the BlackBerry World – Generate a new „Remember“ message with: „VO nicht vergessen“ and the description: „Das darf ich einfach nicht vergessen“ [email protected] 242 EX 1 • Create another button • This button is used in Ex2 [email protected] 243 EX 2 • • • • Create a new BB Cascades Projekt Create an ImageView Set an Invoke Filter for this application If the application is Invoked, the ImageView should show the passed image. [email protected] 244 EX 2 • Add the following function to the additional button from Ex1 – Start application from Ex2 with an image using the invocation framework • Try to start application2 from the first application [email protected] 245 EX 3 • Create a new BB Cascades Projekt • Generate a QML file for an active frame • Set the active frame for the application • Additional: – Replace the static active frame with a dynamic frame – Create a timer and count a number up in the active frame [email protected] 246 MOBILE COMPUTING WAHLPFLICHTFACH BLACKBERRY Sommersemester 2013 Dipl.-Ing. Andre Pura RECAPITULATION • Development in BB10 – – – – – HTML Native C++ Adobe Air Cascades Android Emulator • Elements of an application – – – – GUI in QML Code in C++ Description Files (z.B. Mainfest) Assets (wobei GUIs auch Assets sind) • You can use JavaScript in QML [email protected] 248 RECAPITULATION • 2 types of applications – Drill-Down – Tabs • Important GUI Elements – Container – Label – ImageView – Button – TextField [email protected] 249 RECAPITULATION • Menus – Context Menu – Page Context Menu – Application Menu • ActionItem [email protected] 250 RECAPITULATION • Communication between QML and C++ – Generate Object in C++ and pass it to QML – PropertyMap – Import C++ Class in QML and generate objects [email protected] 251 RECAPITULATION • ActiveFrame can be static and dynamic • Usually, dynamic frames are generated in C++ • An ActiveFrame must support both orientations and resizing • A lot of updates drain the battery [email protected] 252 DATA STORAGE [email protected] 253 CASCADES ACCES DATA • Cascades has an advanced system access data • This system has different elements [email protected] 254 CASCADES ACCES DATA- ELEMENTE Raw Daten, eg JSON [email protected] 255 CASCADES ACCES DATA- ELEMENTE Access to the raw data Eg to generate new files [email protected] 256 CASCADES ACCES DATA- ELEMENTE Adapter to connect the GUI to acces data from QML simple and fast [email protected] 257 CASCADES ACCES DATA- ELEMENTE Sorts and organizes the data to show it in the best way [email protected] 258 CASCADES ACCES DATA- ELEMENTE The graphical representation of the data [email protected] 259 FILE SYSTEM • There are different permissions for different folders and files • Data, which is deployed within the application, must be in the assets directory • The „working directory“ (application root) is the directory where the application is executed • It is not allowed to place any data in the „working directory“ programmatically [email protected] 260 FILE SYSTEM - STRUCTUR Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 261 FILE SYSTEM - STRUCTUR Application root (r)1 1 [email protected] r = read w = write s = symbolic 262 FILE SYSTEM - STRUCTUR Installation directory (r) 1 [email protected] r = read w = write s = symbolic 263 FILE SYSTEM - STRUCTUR Binary Files and other application ressources (r) 1 [email protected] r = read w = write s = symbolic 264 FILE SYSTEM - STRUCTUR Images, media files and qml documents (r) 1 [email protected] r = read w = write s = symbolic 265 FILE SYSTEM - STRUCTUR The application has full access to this directory. It is application‘s „Home“ directory (rw) 1 [email protected] r = read w = write s = symbolic 266 FILE SYSTEM - STRUCTUR Databases (rw) 1 [email protected] r = read w = write s = symbolic 267 FILE SYSTEM - STRUCTUR Log Files (r) 1 [email protected] r = read w = write s = symbolic 268 Shared Folder: The - STRUCTUR FILE SYSTEM subfolders contain the shared files for all applications. If the permission „access_shared“ is set, the application is allowed to write. (rws) 1 [email protected] r = read w = write s = symbolic 269 FILE SYSTEM - STRUCTUR This folder contains data, which is shared with other applications using the invocation framework (rw) 1 [email protected] r = read w = write s = symbolic 270 FILE SYSTEM - STRUCTUR Temporary folder: This directory is used to save temporary files. QNX can delete this directory, if the appication is closed (rw) 1 [email protected] r = read w = write s = symbolic 271 FILESYSTEM – WORKING DIRECTORY • Different names – Application Root – Current Directory – Sandbox • Access data using relative or absolute path – ./data – /accounts/1000/appdata/namespace.application/ data [email protected] 272 FILESYSTEM – WORKING DIRECTORY • Access the directories using QDir • currentPath – Path to the Working Directory of the application • homePath – Path to the data directory of the application • tempPath – Path to the temp directory [email protected] 273 FILESYSTEM - ASSETS • The assets directory is read only • If a non source code file should be deployed with the application, it must be placed in the assets folder • If you try to change a file in the assets directory, it must be copied to an other directory with the appropriate persmissions (eg ./data) • The folder can be accessed from QML using „asset:///name“ [email protected] 274 FILESYSTEM – ASSETS - EXAMPLE • Example: An image should be packed with the application, changed when the application is called the first time and showed an the following starts of the application [email protected] 275 FILESYSTEM – ASSETS - EXAMPLE • Example: An image should be packed with the application, changed when the application is called the first time and showed an the following starts of the application – Copy the image to ./data and then manipulate it – Or change the image and save it to ./data [email protected] 276 FILESYSTEM – ASSETS - EXAMPLE • Example: An image should be packed with the application, changed when the application is called the first time and showed an the following starts of the application – Copy the image to ./data and then manipulate it – Or change the image and save it to ./data – When the application is started, check if the image exists in ./data. If it exists, load it from ./data. Otherwise it must be loaded from the assets folder [email protected] 277 FILESYSTEM – READ/WRITE • Before you can access a file, it must be checked if the parent directory exists. • QDir can be used – Use QDir::cd(QString) to check if a directory exists – Use QDir::mkpath(QString) to generate a directory and all its non-existing parent directories • Use QFile to access files [email protected] 278 FILESYSTEM – READ/WRITE • Write • Read [email protected] 279 JSON DATA • JSON is often used to save data • Name:Value Pairs are saved or a batch of objects (more information: http://www.json.org/) • It is possible to load JSON data and pass it to da datamodel • For processing JsonDataAccess is used • Arrays are read as QVariantList • Objects are read as QVariantMap • The bb::data library is required for processing JSON data (LIBS += -lbbdata) [email protected] 280 JSON - CODE [email protected] 281 JSON - CODE Generate the data model Attributes of a JSON object [email protected] 282 JSON - CODE Load JSON [email protected] 283 JSON - CODE Connect the datamodel with JSON [email protected] 284 JSON - QML [email protected] 285 XML DATA • It is also possible to store data in a structured way using the XML scheme • Is very common • Easier for humans to read • HTML is in the XML scheme • Accessing data in QML can be done using XMLDataAccess • It is necessary to link against bb::data Library (LIBS += -lbbdata) [email protected] 286 XML DATA Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 287 XML DATA- CODE [email protected] 288 READ XML IN QML [email protected] 289 SQL - DATA • It is better to store a higher amount of data in a „real“ database • Tables • External and local databases • SqlDataAcces to access the data • The bb::data library is required (LIBS += lbbdata) [email protected] 290 SQL READ [email protected] 291 SQL WRITE [email protected] 292 SQL WRITE Generate database [email protected] 293 SQL WRITE Open database [email protected] 294 SQL WRITE Connect to database [email protected] 295 SQL WRITE Generate table and instert data [email protected] 296 DATASOURCE QML • SQL, JSON or XML can be loaded using QML only • DataSource must be imported • Local and external DataSource can accessed • A DataSource can be used to organize the data in QML [email protected] 297 DATASOURCE QML – EXTERNAL XML [email protected] 298 GROUPEDATAMODEL • This model is required to sort data for a list • It is possible to sort by different attributes • A combination of attributes is also possible – z.B. Name, Date of Birth • The following data types cen be sort: Char, Date, Datetime, Double, Int, LongLong, String, Time, UInt, ULongLong, Url [email protected] 299 GROUPEDATAMODEL • It is possible to group elments Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 300 GROUPEDATAMODEL - QML [email protected] 301 GROUPEDATAMODEL - QML Sort by: firstName lastName, if the firstName is equal [email protected] 302 GROUPEDATAMODEL - QML How should the entry look like? [email protected] 303 STANDARDLISTITEM • A StandardListItem can have the following attributes – Image – ImageSource – Title – Status – Description Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 304 STANDARDLISTITEM • A StandardListItem can have the following attributes – Image – ImageSource – Title – Status – Description Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 305 EXAMPLE: HOW TO READ A RSS FEED? • • • • • • • • RSS = XML External source Linking against –lbbdata is required Register the type to use in QML Generate DataSource and Groupmodel Generate a list Load Done [email protected] 306 EXAMPLE: HOW TO READ A RSS FEED? • • • • • • • • RSS = XML External source Linking against –lbbdata is required Register the type to use in QML Generate DataSource and Groupmodel Generate a list Load Done [email protected] 307 EXAMPLE: HOW TO READ A RSS FEED? [email protected] 308 EXAMPLE: HOW TO READ A RSS FEED? [email protected] 309 EXAMPLE: HOW TO READ A RSS FEED? No grouping and sort by the date of publishing url to the RSS feed and where the single items can be found [email protected] 310 EXAMPLE: HOW TO READ A RSS FEED? [email protected] 311 EXAMPLE: HOW TO READ A RSS FEED? /rss/channel/item [email protected] 312 EXAMPLE: HOW TO READ A RSS FEED? If there is existing data, delete it and add the new data [email protected] 313 EXAMPLE: HOW TO READ A RSS FEED? [email protected] 314 EXAMPLE: HOW TO READ A RSS FEED? Connect the list with the DataModel How a ListItem looks like [email protected] 315 EXAMPLE: HOW TO READ A RSS FEED? Load RSS Feed [email protected] 316 EXAMPLE: HOW TO READ A RSS FEED? Load RSS Feed [email protected] 317 COMMUNICATION [email protected] 318 NETWORKING • In mobile computing it is in a lot of cases necessary to communicate with a server • A request is sent to a server • A reply is received • It is necessary to allow the application access the internet by setting the permission Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 319 NETWORKING Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 320 NETWORKING Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 321 NETWORKING Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 322 PUSH • Push is used to send a small amount of data to n devices • It is possible to push up to 8kb of data • A server distributes the push notification to n devices • Usually push is used to inform the user about new information • A new push message should be displayed using notifications [email protected] 323 PUSH 1. The Content Provider sends PushRequest 2. The BlackBerry server replies 3. The BlackBerry server sends data to the devices 4. The devices reply 5. The BlackBerry server passes the replies to the Content Provider 6. The Content Provider approves the receiving of the replies Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 324 PUSH • It is possible to send a message to – A single device (unicast) – All registered devices (broadcast) – A part of the registered devices (multicast) • It is better to use push, than pulling content in the background • BIS (BlackBerry Internet Service) BES (BlackBerry Enterprise Service) Push • To use BIS push, an application must be registered [email protected] 325 PUSH - MANIFEST • Permessions to receive push messages • Using the invocation framework, the application is startet with the pushed data [email protected] 326 PUSH - MANIFEST • Permissions to receive push messages Using the bb.action.push, it is possible to identify, that the application was started using push • Using the invocation framework, the application is started with the pushed data [email protected] 327 PUSH - MANIFEST • To start the application, when the notification is clicked: [email protected] 328 PUSH - MANIFEST • To start the application, when the notification is clicked: The BlackBerry Hub tries to launch BB_OPEN_INVOCATION_ACTION, which is equal to bb.action.OPEN [email protected] 329 PUSH - CODE • If BB10 receives a push notification, it passes it to the registered application • The application decides what happens with the message [email protected] 330 PUSH - CODE • If BB10 receives a push notification, it passes it to the registered application • The application decides what happens with the message If a push notification is send to the application, a notification in the hub can be initialized [email protected] 331 PUSH - CODE • If the user clicks on a notification in the BlackBerry Hub the application is invoked using BB_OPEN_INVOCATION_ACTION [email protected] 332 PUSH - CODE • If the user clicks on a notification in the BlackBerry Hub the application is invoked using BB_OPEN_INVOCATION_ACTION The application was called form the Hub using an invocation from a notification [email protected] 333 NOTIFICATIONS • Notifications are used to inform the user about an incoming event • An event can be e.g. a message, an update, ... Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 334 SET A NOTIFICATION PROGRAMMATICALLY • It is easy so set an notification programmatically [email protected] 335 SET A NOTIFICATION PROGRAMMATICALLY • It is easy so set an notification programmatically Initialize the notification Set title and text Initialize the invocation Sent the notification to the BlackBerry Hub [email protected] 336 DELETE A NOTIFICATION • You should delete the notification from the hub, if it was consumed • Single notification • All notifications [email protected] 337 NOTIFICATION - QML • Notifications can be initializied using WML • Configure it: • And deliver it to the hub [email protected] 338 EX 1 • • • • Create a new BB Cascades Projekt Create a txt file in the assets folder Generate 2 buttons If Button1 is clicked, load the content of the textfile and save it to a QString • Show the content in a textarea (editable) • If Button2 is clicked, copy the content of the textarea to a new file in the shared documents folder [email protected] 339 EX 2 • Create a new BB Cascades Projekt • Read the RSS Feed from the FH Hagenberghttp://www.fhooe.at/index.php?id=94&type=100 • Show the title and publisher date in a list • Sort the list by publishing date • Optional: group the entries by categories [email protected] 340 EX 3 • Create a new BB Cascades Projekt • Create 2 Buttons • If button1 is clicked, generate a notification and send it to the hub • If button2 is clicked, dismiss the notifications [email protected] 341 MOBILE COMPUTING WAHLPFLICHTFACH BLACKBERRY Sommersemester 2013 Dipl.-Ing. Andre Pura RECAPITULATION • Development in BB10 – – – – – HTML Native C++ Adobe Air Cascades Android Emulator • Elements of an application – – – – GUI in QML Code in C++ Description Files (z.B. Mainfest) Assets (wobei GUIs auch Assets sind) • You can use JavaScript in QML [email protected] 343 RECAPITULATION • 2 types of applications – Drill-Down – Tabs • Important GUI Elements – Container – Label – ImageView – Button – TextField [email protected] 344 RECAPITULATION • Menus – Context Menu – Page Context Menu – Application Menu • ActionItem [email protected] 345 RECAPITULATION • Communication between QML and C++ – Generate Object in C++ and pass it to QML – PropertyMap – Import C++ Class in QML and generate objects [email protected] 346 RECAPITULATION • ActiveFrame can be static and dynamic • Usually, dynamic frames are generated in C++ • An ActiveFrame must support both orientations and resizing • A lot of updates drain the battery [email protected] 347 RECAPITULATION • The file system has three different areas – Shared – Shared Invoke – Application area • The different areas have different permissions • It is possible to access XML, JSON and SQL from QML directly • DataSources are used to get content • The DataModel organizes and sorts the data • Lists are used to show content [email protected] 348 RECAPITULATION • A small amount of data can be sent to a device / devices using push • Applications can be called using a push message • In the hub push messages can be showed as a notification • Notifications are visible in the hub • On click on a notification an invoke is sent to the invocation framework [email protected] 349 COMMUNICATION [email protected] 350 NFC (NEAR FIELD COMMUNICATION) • • • • • • A lot of mobile devices have NFC It is possible to exchange data in a short range NFC can be used C++ and Cascades/Qt Not all interfaces can be found in Cascades/Qt Simpler using Cascades/Qt Best way: Invocation Framework [email protected] 351 NFC – INVOCATION FRAMEWORK • Usually NFC is used to exchange simple data • NFC Share Card using Invocation • Action for the Invocation: bb.action.SHARE • If the user chooses NFC, a preview of the content is shown Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 352 NFC – INVOCATION FRAMEWORK • If the sent data is too big using NFC, a Bluetooth handshake is initialized • The content is submitted using Bluetooth • Files are always sent using Bluetooth • Data can be sent using NFC Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 353 NFC – INVOCATION FRAMEWORK: FILE Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 354 NFC – INVOCATION FRAMEWORK: DATA [email protected] 355 NFC – INVOCATION FRAMEWORK: SQUENCEDIAGRAM [email protected] 356 Source: https://developer.blackberry.com/cascades/documentation/ NFC – INVOCATION FRAMEWORK DATA • Direct connection, if data < 1 kb • If the receiving device can handle the incoming data • Sender: – mimeType = application/vnd.rim.nfc.ndef – uri is empty – data = <byte array representation of custom NDEF message> – action = bb.action.SHARE [email protected] 357 NFC – INVOCATION FRAMEWORK DATA • Receiver: – Registered with the Invocation Framework bb.action.OPEN – mimeType = application/vnd.rim.nfc.ndef – uri = <filter>, z.B. <property var="uris" value="ndef://1/Sp"/> [email protected] 358 NFC – INVOCATION FRAMEWORK DATA • Data should be sent to a known application (z.B. Browser) – mimeType = “text/plain” or mimeType = “text/URI-list” – uri is Empty. – data = <text representation of your payload> – action = bb.action.SHARE [email protected] 359 NFC – INVOCATION FRAMEWORK DATA • NDEF schemes known by BlackBerry: [email protected] 360 NFC – INVOCATION FRAMEWORK EXAMPLE DATA [email protected] 361 NFC – INVOCATION FRAMEWORK EXAMPLE DATA [email protected] 362 NFC – INVOCATION FRAMEWORK FILE • mimeType = <your custom mime Type>. Example:application/myapp1. • uri = <URI encoded string to a local file located on sending device>. Example: file:///shared/myapp1/sound1.mp3 • data = “” • action = bb.action.SHARE [email protected] 363 NFC – INVOCATION FRAMEWORK EXAMPLE FILE [email protected] 364 NFC – CASCADES/QT • Using Data or File • NfcShareManager • You have to inform the user about the different steps • It is necessary to handle alle sharing events [email protected] 365 NFC – CASCADES/QT: DATA Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 366 NFC – CASCADES/QT: FILE Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 367 NFC – CASCADES/QT: SEND • It is possible to share data and files – NfcShareDataContent – NfcShareFilesContent [email protected] 368 NFC – CASCADES/QT: SEND • It is possible to share data and files – NfcShareDataContent – NfcShareFilesContent [email protected] 369 NFC – CASCADES/QT: SEND • Data is passed to NfcShareManager • Data is valid until – Is was used – the ShareMode is set to disabled [email protected] 370 NFC – CASCADES/QT: SEND • Data is passed to NfcShareManager • Data is valid until – Is was used share data – the ShareModeExample is settoto disabled [email protected] 371 NFC – CASCADES/QT: SEND [email protected] 372 NFC – CASCADES/QT: SEND In difference to sending data, uri is passed here. Bluetooth will be activated and the data is sent using it [email protected] 373 NFC – CASCADES/QT: RECEIVE • To receive a NFC invocation, register the application [email protected] 374 NFC – CASCADES/QT: RECEIVE • To receive a NFC invocation, register the application Types which are supported by the application [email protected] 375 NFC – CASCADES/QT: RECEIVE Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 376 NFC – CASCADES/QT: RECEIVE 377 Source: https://developer.blackberry.com/cascades/documentation/ BLACKBERRYMESSENGER (BBM) • Beside other communication channels, BlackBerry Messanger provides a unique way for communication • encrypted • BBM has a lot of features – – – – – – – Status updates Video calls Voice calls Pin-To-Pin Messeging Screen sharing Text messeges Groups [email protected] 378 BBM CONNECT • It is possible to connect applications to BBM • Event driven • It is possible to access – BBM user profile – Contact list – Messaging – Application profile box [email protected] 379 BBM – BEST PRACTISE • Sending invitations and messages – Make sure that users are the ones who initiate requests to engage other users. – If users want to invite others to join games, forums, or chats, you can allow users to enter their own text or you can provide default text – Include a contextual link in messages that recipients receive, where possible. [email protected] 380 BBM – BEST PRACTISE • Choosing contacts – Provide contacts with filter options, if possible and if meaningful to the task. – Allow users to filter contacts by contact categories that they created in BBM. [email protected] 381 BBM – BEST PRACTISE • Chats – Make sure that users have the ability to choose the people that they want to chat with. – When a chat begins, expose the chat interface – Make sure that you design your screens so that users can access key features when the chat interface is open. – Make a chat interface available on multiple screens in your application – If your application supports multiple chats, make sure that users have a way to switch between chats. [email protected] 382 BBM – BEST PRACTISE • Profile boxes – Give users the option to add information – Always ask permission before updating – If users allow your application to update their personal message, use the personal message field to describe a quality that is attributed to the user – Include only new events that users accomplish or specific activities that are meaningful milestones in a profile box. – Provide a succinct description for each event in the profile box – Include a meaningful icon for the activity or event. – Create icons that are 119 x 119 pixels. [email protected] 383 BBM CONNECT • Register application with BBM • Update BBM status [email protected] 384 BBM CONNECT • Register application with BBM • Update BBM status Call the C++ function to update the BBM status [email protected] 385 BBM CONNECT • Register application with BBM • Update BBM status Update the status [email protected] 386 LOCATION SERVICES • Location services are very important do the users [email protected] 387 LOCATION SERVICES • Location services are very important to the users – Provide location based services – Provide location based advertisment – Routing – Maps enriched applications – Combine location services with other services [email protected] 388 LOCATION SERVICES • Three different parts: – Positioning: Find the location of a device using GPS satellites, cell ID, or Wi-Fi positioning. – Geocoding: Find coordinates for a street address (geocoding), or find a street address for geospatial coordinates (reverse geocoding). – Mapping: Display a location in a MapView or integrate with the BlackBerry Maps application. [email protected] 389 LOCATION SERVICES • Difference between – GPS Positioning – Celluar Positioning – WiFi Positioning [email protected] 390 LOCATION SERVICES • Init location service • Retrieve a single position [email protected] 391 LOCATION SERVICES • Continues updates [email protected] 392 LOCATION SERVICES • Continues updates [email protected] 393 LOCATION SERVICES • If continuous updates are received, connect to the timeout signal [email protected] 394 LOCATION SERVICES • If continuous updates are received, connect to the timeout signal [email protected] 395 LOCATION SERVICES • Updates are provided every 5 seconds – Set the interval • Are updates required in „background“ [email protected] 396 GEOPOSITIONS • Information from the geo position – QGeoCoordinate – Direction – GroundSpeed – VerticalSpeed – MagneticVariation – HorizontalAccuracy – Vertical Accuracy – Timestamp [email protected] 397 (REVERSE) GEOCODING • Reverse geocoding is used to convert a GPS position into an address – Used to make a position human readable • Geocoding is used to find coordinates for a given address – Used to make an address machine readable [email protected] 398 REVERSE GEOCODING [email protected] 399 REVERSE GEOCODING [email protected] 400 REVERSE GEOCODING Get the service providers [email protected] 401 REVERSE GEOCODING Set the coordinates for the reverse process [email protected] 402 REVERSE GEOCODING Connect to the error and finished signal [email protected] 403 REVERSE GEOCODING Slots for the signals [email protected] 404 GEOCODING [email protected] 405 REVERSE GEOCODING [email protected] 406 REVERSE GEOCODING Get the service providers [email protected] 407 REVERSE GEOCODING Set the coordinates for the coding process [email protected] 408 REVERSE GEOCODING Connect to the error and finished signal [email protected] 409 REVERSE GEOCODING Slots for the signals [email protected] 410 MAPS • BlackBerry maps is installed on all BlackBerry 10 devices • It can be used in a static or dynamic way – MapView – MapGenerator [email protected] 411 Source: https://developer.blackberry.com/cascades/documentation/ STATIC MAP • Initialize the map generator • Process the reply [email protected] 412 STATIC MAP • Initialize the map generator • Process the reply [email protected] 413 MAPVIEW • Link against LIBS += -lbbcascadesmaps • A graphics user interface (GUI) control that displays a map along with user-defined geographic elements, which can be points of interest or other location-aware elements. • All data shown on the map is provided by the MapData object • It still exists, if the MapView is destroyed [email protected] 414 MAPVIEW [email protected] 415 MAPVIEW Initialize the first position [email protected] 416 MAPVIEW Connect to the signal [email protected] 417 ADVERTISMENT SERVICE • Provides ads from different platforms • Simple to integrate • A lot of statistics about the usage [email protected] 418 ADVERTISMENT SERVICE Source: https://developer.blackberry.com/cascades/documentation/ [email protected] 419 ADVERTISMENT SERVICE : STEPS • Register at http://adservices.blackberry.com/register/ • LIBS += -lbbcascadesadvertisement • Set persmissions – Device Identifying – GPS Location (optional) • Register type [email protected] 420 ADVERTISMENT SERVICE : STEPS • Import in QML • QML [email protected] 421 ADDTIONAL INFORMATION [email protected] 422 BUILD FOR BB • Criteria – – – – – – User Benefits User Experience Performance Service Integration Security Internationalization • Benefits – Additional area in the BlackBerry World – Additional advertisment at different events – A „thank you“ gift • https://developer.blackberry.com/builtforblackberry/ [email protected] 423 CASCADES ROADMAP https://developer.blackberry.com/cascades/download/roadmap/ [email protected] 424 VENDOR REGISTRATION • No registration or submission fees. None. $0.00 • Multiple monetization opportunities with in-app purchasing, subscription billing, and mobile ad services • Crystal clear, transparent submission process • Increase the discoverability of your apps with a range of "Top 25" lists that end users can search on both the mobile and desktop storefront versions of BlackBerry World • Make it easy for end users to purchase your apps and digital goods by providing popular payment methods like PayPal, credit card, and direct to carrier billing (carrier dependent see below...) • https://developer.blackberry.com/devzone/blackberryworld/apply_ for_a_blackberry_world_membership_account.html#pde13504060 51752 Source: https://developer.blackberry.com/devzone/blackberryworld/ [email protected] 425 RELEASE CHECKLIST • Review tips that can help smooth the approval process and get your app up on BlackBerry World faster. • Start with our guidelines for naming your app, then go on to create great descriptions and images to help get your app noticed. • Check that your release is ready. Make decisions about app security, digital rights, export regulations and similar details. • If you don't already have one, apply for a membership account on the vendor portal. • Review guidelines and criteria to give your app the best chance for a quick approval for sale on BlackBerry World. • Submit your app, create a release, and add any digital goods you want to sell in your app. Source: https://developer.blackberry.com/devzone/blackberryworld/ [email protected] 426 ADDITIONAL LINKS • Documentation – https://developer.blackberry.com/cascades/documentation/ • BlackBerry News – http://crackberry.com/ • Developer Forum – http://supportforums.blackberry.com/t5/Cascades-Development/bdp/Cascades • Samples – https://github.com/blackberry/ • Code Snippets – http://cascadescode.tumblr.com/ • Vendor Portal – https://appworld.blackberry.com/isvportal/login_input.do?pageId=0 [email protected] 427 COPYRIGHT [email protected] 428 EX 1 • Create a new BlackBerry Cascades Project • Read the JSON Data from – http://dienststellen.bmf.gv.at/finanzamtsliste.json • Show the data in a list, sorted by the name • Generate a second page, which shows the details of the selected name • If an entry in the list is triggered, open the second page with the details for the selected name [email protected] 429 EX 1 • Think about useful invocations and include them (at least 1). If you define the invocation as a context action, define also an icon! (search for the bb standard icons on the web) • Is grouping possible? What would be a good grouping argument • Optional: – Generate a static map of the location and add it to the details page – Load the image data included in the json asynchronously – Implement an Activity Indicator as a loading sign [email protected] 430 HINT [email protected] 431 HINT 0 1 2 3 4 5 6 7 8 9 10 [email protected] 432 HINT 0 1 2 3 4 5 6 7 8 9 10 indexPath [email protected] 433 HINT 0 1 2 [email protected] 434 PROJECT: CERTIFICATE SIGNING • Signing documents directly an the smartphone • Used for – Sign a document on the smartphone to use it in govermental transactions – Time logging systems – Banking application • Signing server structural is provided • Usage using the „share“ invocation • Supported by – – – – – BlackBerry Austria BlackBerry Germany mappau Bundeskanzleramt (BKA) Genoa [email protected] 435