004 bada basics fundamentals&ui
Post on 10-Apr-2018
227 Views
Preview:
TRANSCRIPT
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 1/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Basics:
Fundamentals & UI
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 2/39
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 3/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
bada API overview
1. bada namespaces2. Privilege levels and groups
3
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 4/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
bada namespaces
4
User interactive features Service oriented featuresBasic bada features
Osp::App
Osp::Base
Osp::Io
Osp::Locales
Osp::Net
Osp::Security
Osp::System
Osp::Telephony
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Text
Kernel
Device
Service
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 5/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Namespaces – basic bada
5
User interactive features Service oriented featuresBasic bada features
Osp::App
Osp::Base
Osp::Io
Osp::Locales
Osp::Net
Osp::Security
Osp::System
Osp::Telephony
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Text
Kernel
Device
Service
Osp::Base
Fundamental bada
classes:
String, ArrayList,Thread,Math …
Basic bada features
Osp::App
Osp::Base
Osp::Io
Osp::LocalesOsp::Net
Osp::Security
Osp::SystemOsp::Telephony
Osp::Text
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 6/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Namespaces – User Interactive
6
User interactive features Service oriented featuresBasic bada features
Osp::App
Osp::Base
Osp::Io
Osp::Locales
Osp::Net
Osp::Security
Osp::System
Osp::Telephony
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Text
Kernel
Device
Service
User interactive features
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Uix
Extended user
interaction functions:Touch, snap,Sensors …
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 7/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Namespaces – User Interactive
7
User interactive features Service oriented featuresBasic bada features
Osp::App
Osp::Base
Osp::Io
Osp::Locales
Osp::Net
Osp::Security
Osp::System
Osp::Telephony
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Text
Kernel
Device
Service
User interactive features
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Web
Browser control API
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 8/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Namespaces – Service Oriented
8
User interactive features Service oriented featuresBasic bada features
Osp::App
Osp::Base
Osp::Io
Osp::Locales
Osp::Net
Osp::Security
Osp::System
Osp::Telephony
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Text
Kernel
Device
Service
Service oriented features
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Content
Local and remotecontentmanagement
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 9/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Namespaces – Service Oriented
9
User interactive features Service oriented featuresBasic bada features
Osp::App
Osp::Base
Osp::Io
Osp::Locales
Osp::Net
Osp::Security
Osp::System
Osp::Telephony
Osp::Graphics
Osp::Media
Osp::Ui
Osp::Uix
Osp::Web
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Text
Kernel
Device
Service
Service oriented features
Osp::Commerce
Osp::Content
Osp::Locations
Osp::Messaging
Osp::Social
Osp::Locations
Interaction,visualisation oflocations and
maps
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 10/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Privilege levels
Privilege levels are related to your developermembership
Regulate access to the platform and user-sensitive data
Every privilege level allows access to differentprivilege groups (= functionalities)
10
Level DescriptionNone-privileged Does not require any privileges.
Normal Usable by all bada developer.
System Usable only by Samsung developer partners.
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 11/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Coding idioms
1. Exception handling
2. Two phase construction
3. Memory handling4. Virtual path
11
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 12/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Exception handling (1/3)
bada does not use standard C++ exceptionhandling
All exceptions are caught by using the bada
specific result typeExamples for result error types:
12
Error Type Description
E_SUCCESS The method was successful
E_OUT_OF_MEMORY Insufficient memory
E_SYSTEM A system error occurred
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 13/39
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 14/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Exception handling (3/3)
Check the last result using GetLastResult() – If an operation returns null:
DirEnumerator * pEnum = dir. ReadN ();
if (pEnum == null){
AppLog( "Directory::ReadN() failed with error: %s" ,GetErrorMessage ( GetLastResult ()));
return false ;
}
14
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 15/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Two phase construction (1/2)
bada uses a two phase constructionWhy? – bada does not use standard C++ exception
mechanism to increase runtime efficiency – And to prevent resource leaks in C++How? – The resource allocation logic is performed in
an extra Construct() method – The destructor follows traditional C++
conventions
15
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 16/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Two phase construction (2/2)
Example:result r = E_SUCCESS;
// 1. Phase: create objectCallManager *pCallManager = new CallManager();
// 2. Phase: initialize object (+allocations)r = pCallManager-> Construct();
if(IsFailed(r)){delete pCallManager;
}
16
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 17/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Memory handling (1/3)
Ownership policy: – The “owner” of an object is responsible for
deleting dynamically allocated memory
Image * pImage = new Image ();
// Some code ...
delete pImage;
Must be deleted to avoid a memory leak!
17
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 18/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Memory handling (2/3)
Rules for ' N' postfix methods: – The caller must delete the returned instance
after an ‘N’ postfix method is called
– Change of “ownership”
Examples for ‘N’ postfix methods: – GetContentInfoN() – DecodeN() – GetValueListN() – SearchN() – OnLandMarkReceivedN()
18
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 19/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Memory handling (3/3)
GetContentInfoN():
OnLandmarksReceivedN():
ContentInfo * pInfo = null;pInfo = mgr. GetContentInfoN (contentId);delete pInfo;
voidLandmarkManager:: OnLandmarksReceivedN (,
Osp::Base::Collection:: IList * pResults,,,){
if (r == E_SUCCESS && pResults) {pMainForm->DrawLandmarks(pResults);pResults->RemoveAll(true);delete pResults;
}}
19
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 20/39Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Virtual path
Directory Usage Permission
/HomeUsed to store application specific dataE.g.:String fileName(" /Home/test.txt ");
Read/Write
/Res Used to read resource files, such as for UI ormusic and video files Read-only
/Home/Share Used to share data with other bada applications Read/Write
/Share/[appid] Used to read data from other bada apps via their[appid] Read-only
20
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 21/39
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 22/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Controls in bada
22
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 23/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
UI screen structure
Indicator
Title
Softkey
FrameThe top level windowThere is one per application
Form(s)
High level containerThere can be multiple forms
Control(s)Controls are added to
forms
23
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 24/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Create and show a Form
Step 1: Create a Form:
Step 2: Add Form to Frame:
Step 3: Show the Form:
Form1 *pForm = new Form1();pForm-> Construct (FORM_STYLE_TITLE|
FORM_STYLE_SOFTKEY_0|FORM_STYLE_INDICATOR);
Frame *pFrame = GetAppFrame ()-> GetFrame ();pFrame-> AddControl (* pForm );
pFrame-> SetCurrentForm (* pForm );pFrame-> RequestRedraw (true); // true for Draw() & Show()
Other FORM_STYLEs:NORMAL/ TITLE/ INDICATOR/ SOFTKEY_0/ SOFTKEY_1/ OPTIONKEY/ TEXT_TAB/ ICON_TAB
24
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 25/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Event handling
Events: – Controls: focus, drag and drop, touch, and key – Add EventListener to Control to handle events
TouchPressed
TouchMoved
TouchReleased
ITouchEventListener{
OnTouchPressed() {…}OnTouchMoved() {…}
OnTouchReleased() {…}OnTouchDoublePressed() {…}// …
}
25
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 26/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Handling of Touch events
Step 1: Inherit from listener interface
Step 2: Implement event handler method
Step 3: Add event listener to control
class TouchListener : public ITouchEventListener{…}
void TouchListener ::OnTouchPressed( …, const Point & currentPosition, …)
{…}
AddTouchEventListener( ITouchEventListener &);
26
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 27/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
UI Builder tool basics
27
ResourceExplorer
Design Area
Properties
Controls
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 28/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Application life cycle
28
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 29/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Overall application life cycle
OnAppInitializing()
Terminated
SuccessRunning
Failure OnForeground()
OnAppTerminating()
OnBackground()
Launch
29
Launch
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 30/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
OnAppInitializing()
Invoked as soon as application is launchedInitialize application resources
30
bool MyPlaces::OnAppInitializing( AppRegistry & appRegistry)
{// Initialize...…return true ;
}
OnForeground()OnAppInitializing()
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 31/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
OnBackground()
OnBackground() is called whena base application is launched(e.g.: incoming calls or SMS messages)
Recommendation: – Release unnecessary
resources
– Stop heavy operations• Multimedia/graphics/etc.
31
OnForeground() OnBackground()
OnAppInitializing()
void MyPlaces::OnBackground( void ) {}
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 32/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
OnForeground()
OnForeground() is called whenthe base application is terminated
Recommendation:
– Resume normal applicationprocesses and resourceconsumption
32
void MyPlaces::OnForeground( void ) {}
OnForeground() OnBackground()
OnAppInitializing()
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 33/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
OnAppTerminating()
OnAppTerminating() is called when: – Another bada app is launched – End key is pressed – Low battery or memory
Recommendation: – Save state to the registry – Destroy unnecessary, allocated
resources
33
bool MyPlaces::OnAppTerminating( AppRegistry & appRegistry, bool forcedTermination)
{// save app state into appRegistry …
}
OnAppTerminating()
OnBackground()OnForeground()
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 34/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Summary
34
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 35/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
What we have learned
bada API overview – Namepaces – Privilegesbada coding idioms
– Exception handling through result type – Two phase construction for runtime efficiency – Memory management and ‘ N’ postfix – Virtual path (/Home, /Res, etc.)UI basics – UI screen structure, controls, UI BuilderApp life cycle – 4 states
35
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 36/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
Find out more
Tutorials: – bada Tutorial.Fundamentals.pdf – bada Tutorial.Application.pdf
– bada Tutorial.UI and Graphics.pdfSamples
– BasicApp
– UiControls
36
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 37/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
3D augmented reality first person shooter
Makes use of bada to its full potential
- 360 ° OpenGL 3D graphics- Camera- Accelerometer, compass, tilt sensors- Audio feedback- Powerful hardware- To be published in SamsungApps store
Follow us on Twitter at #ROTU
by Samsung Mobile Innovator
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 38/39
Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.
8/8/2019 004 Bada Basics Fundamentals&UI
http://slidepdf.com/reader/full/004-bada-basics-fundamentalsui 39/39
top related