-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TIMOB-9546: BlackBerry: Implement Platform elements needed for KitchenSink #87
Changes from 3 commits
7c4f473
cd0e7eb
893c34c
4a59adc
9fb9d60
4b54011
c68fbe7
7eaf82d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ methods: | |
|
||
- name: createUUID | ||
summary: Creates a globally-unique identifier. | ||
platforms: [android, iphone, ipad, mobileweb] | ||
returns: | ||
type: String | ||
|
||
|
@@ -52,6 +53,7 @@ methods: | |
- name: url | ||
summary: The url to open. | ||
type: String | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: is24HourTimeFormat | ||
summary: Returns whether the system settings are configured to show times in 24-hour format. | ||
|
@@ -87,16 +89,19 @@ properties: | |
summary: The system's WIFI IP address. No other network types are supported. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: architecture | ||
summary: The system's processor architecture. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: availableMemory | ||
summary: The system's unused memory, measured in megabytes on iOS and bytes on Android. | ||
type: Number | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: batteryLevel | ||
summary: | | ||
|
@@ -109,6 +114,7 @@ properties: | |
summary: Determines whether battery monitoring is enabled. | ||
default: false | ||
type: Boolean | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: batteryState | ||
summary: Indicates the state of the battery. Accessible only when `batteryMonitoring` is enabled. | ||
|
@@ -132,6 +138,7 @@ properties: | |
from the `DisplayCaps` object that it returns. | ||
type: Titanium.Platform.DisplayCaps | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: id | ||
summary: The applications's globally-unique ID (UUID). | ||
|
@@ -145,6 +152,7 @@ properties: | |
documentation. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: locale | ||
summary: The system's default language. | ||
|
@@ -156,6 +164,7 @@ properties: | |
sections of wikipedia for reference. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: macaddress | ||
summary: The system's network interface mac address, or app UUID. | ||
|
@@ -165,6 +174,7 @@ properties: | |
unique device identification, which they have prohibited. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: model | ||
summary: The model of the device. | ||
|
@@ -199,29 +209,33 @@ properties: | |
summary: The system's WIFI network mask. No other network types are supported. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: osname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put a comment saying that for BlackBerry it will be 'blackberry' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
summary: | | ||
The short name of the system's Operating System. For example, iPhone will return `iphone`, | ||
iPad will return `ipad`, Android will return `android` and Mobile Web will return `mobileweb`. | ||
iPad will return `ipad`, Android will return `android`, Mobile Web will return `mobileweb` and | ||
BlackBerry will return `blackberry`. | ||
type: String | ||
permission: read-only | ||
|
||
- name: ostype | ||
summary: The Operating System architecture. On Android, this is `32bit`. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: processorCount | ||
summary: The number of processing cores. | ||
type: Number | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: runtime | ||
summary: The short name of the JavaScript runtime in use. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment saying that v8 is used in BlackBerry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
description: | | ||
On iOS this is "javascriptcore", on Android either "v8" or "rhino" and on Mobile Web it is | ||
determined by the browser used. | ||
On iOS this is "javascriptcore", on Android either "v8" or "rhino", on Mobile Web it is | ||
determined by the browser used and on BlackBerry it is "v8". | ||
type: String | ||
permission: read-only | ||
|
||
|
@@ -230,11 +244,13 @@ properties: | |
The system name, if set. On iOS, this can be found in Settings > General > About > Name. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
- name: version | ||
summary: The system's OS version. | ||
type: String | ||
permission: read-only | ||
platforms: [android, iphone, ipad, mobileweb] | ||
|
||
examples: | ||
- title: Battery Event Example | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/** | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2009-2012 by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
|
||
#include "NativePlatformInterface.h" | ||
#include "TiConstants.h" | ||
#include <vector> | ||
|
||
#define PROP_GETTING_FUNCTION(NAME) prop_##NAME | ||
|
||
#define PROP_GETTER(NAME) static Handle<Value> prop_##NAME(const NativePlatformInterface* instance) \ | ||
{\ | ||
return instance->NAME();\ | ||
} | ||
|
||
typedef Handle<Value> (*NATIVE_PROPGET_CALLBACK)(const NativePlatformInterface* instance); | ||
|
||
// Prototypes | ||
static vector<NATIVE_PROPGET_CALLBACK> initFunctionMap(); | ||
|
||
// Statics | ||
static const vector<NATIVE_PROPGET_CALLBACK> s_functionMap = initFunctionMap(); | ||
|
||
const NativePlatformInterface* NativePlatformInterface::instance() | ||
{ | ||
static NativePlatformInterface s_theInstance; | ||
return &s_theInstance; | ||
} | ||
|
||
NativePlatformInterface::NativePlatformInterface() | ||
{ | ||
} | ||
|
||
PROP_GETTER(getAddress) | ||
Handle<Value> NativePlatformInterface::getAddress() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getArchitecture) | ||
Handle<Value> NativePlatformInterface::getArchitecture() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getAvailableMemory) | ||
Handle<Value> NativePlatformInterface::getAvailableMemory() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getBatteryLevel) | ||
Handle<Value> NativePlatformInterface::getBatteryLevel() | ||
{ | ||
return v8::Integer::New(NativePlatformInterface::instance()->batteryInfo_.level()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
|
||
PROP_GETTER(getBatteryMonitoring) | ||
Handle<Value> NativePlatformInterface::getBatteryMonitoring() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getBatteryState) | ||
Handle<Value> NativePlatformInterface::getBatteryState() | ||
{ | ||
bb::device::BatteryInfo::ChargingState bState = NativePlatformInterface::instance()->batteryInfo_.chargingState(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
Ti::Platform::TI_BATTERY_STATE tiState = Ti::Platform::BATTERY_STATE_UNKNOWN; | ||
switch (bState) | ||
{ | ||
case bb::device::BatteryInfo::UnknownChargingState: | ||
tiState = Ti::Platform::BATTERY_STATE_UNKNOWN; | ||
break; | ||
case bb::device::BatteryInfo::NotCharging: | ||
tiState = Ti::Platform::BATTERY_STATE_UNKNOWN; | ||
break; | ||
case bb::device::BatteryInfo::Full: | ||
tiState = Ti::Platform::BATTERY_STATE_FULL; | ||
break; | ||
case bb::device::BatteryInfo::Discharging: | ||
tiState = Ti::Platform::BATTERY_STATE_UNPLUGGED; | ||
break; | ||
case bb::device::BatteryInfo::Charging: | ||
tiState = Ti::Platform::BATTERY_STATE_CHARGING; | ||
break; | ||
} | ||
return v8::Integer::New(tiState); | ||
} | ||
|
||
PROP_GETTER(getDisplayCaps) | ||
Handle<Value> NativePlatformInterface::getDisplayCaps() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getId) | ||
Handle<Value> NativePlatformInterface::getId() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getLocale) | ||
Handle<Value> NativePlatformInterface::getLocale() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getMacaddress) | ||
Handle<Value> NativePlatformInterface::getMacaddress() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getModel) | ||
Handle<Value> NativePlatformInterface::getModel() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getName) | ||
Handle<Value> NativePlatformInterface::getName() | ||
{ | ||
return String::New("blackberry"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check what the other platforms do. I'm thinking this should be BlackBerry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All platforms return lowercase information |
||
} | ||
|
||
PROP_GETTER(getNetmask) | ||
Handle<Value> NativePlatformInterface::getNetmask() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getOsname) | ||
Handle<Value> NativePlatformInterface::getOsname() | ||
{ | ||
return String::New("blackberry"); | ||
} | ||
|
||
PROP_GETTER(getOstype) | ||
Handle<Value> NativePlatformInterface::getOstype() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getProcessorCount) | ||
Handle<Value> NativePlatformInterface::getProcessorCount() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getRuntime) | ||
Handle<Value> NativePlatformInterface::getRuntime() | ||
{ | ||
return String::New("v8"); | ||
} | ||
|
||
PROP_GETTER(getUsername) | ||
Handle<Value> NativePlatformInterface::getUsername() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
PROP_GETTER(getVersion) | ||
Handle<Value> NativePlatformInterface::getVersion() | ||
{ | ||
// TODO: Finish this when will be available in SDK | ||
return Undefined(); | ||
} | ||
|
||
Handle<Value> NativePlatformInterface::getPropertyValue(int propertyNumber) | ||
{ | ||
if ((propertyNumber >= s_functionMap.size()) || (s_functionMap[propertyNumber] == NULL)) | ||
{ | ||
return Undefined(); | ||
} | ||
Handle<Value> result = (s_functionMap[propertyNumber])(NativePlatformInterface::instance()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return result; | ||
} | ||
|
||
static vector<NATIVE_PROPGET_CALLBACK> initFunctionMap() | ||
{ | ||
vector<NATIVE_PROPGET_CALLBACK> vect; | ||
vect.resize(N_PLATFORM_PROP_LAST); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass the size in the constructor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we would need that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fewer memory allocations There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use it just ones. Nothing we achieve from that rather, than have extra unusable variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we're talking about different things :) This is what I mean:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
vect[N_PLATFORM_PROP_UNDEFINED] = NULL; | ||
vect[N_PLATFORM_PROP_ADDRESS] = NULL; | ||
vect[N_PLATFORM_PROP_ARCHITECTURE] = NULL; | ||
vect[N_PLATFORM_PROP_AVAILABLEMEMORY] = NULL; | ||
vect[N_PLATFORM_PROP_BATTERYLEVEL] = PROP_GETTING_FUNCTION(getBatteryLevel); | ||
vect[N_PLATFORM_PROP_BATTERYMONITORING] = NULL; | ||
vect[N_PLATFORM_PROP_BATTERYSTATE] = PROP_GETTING_FUNCTION(getBatteryState); | ||
vect[N_PLATFORM_PROP_DISPLAYCAPS] = NULL; | ||
vect[N_PLATFORM_PROP_ID] = NULL; | ||
vect[N_PLATFORM_PROP_LOCALE] = NULL; | ||
vect[N_PLATFORM_PROP_MACADDRESS] = NULL; | ||
vect[N_PLATFORM_PROP_MODEL] = NULL; | ||
vect[N_PLATFORM_PROP_NAME] = PROP_GETTING_FUNCTION(getName); | ||
vect[N_PLATFORM_PROP_NETMASK] = NULL; | ||
vect[N_PLATFORM_PROP_OSNAME] = PROP_GETTING_FUNCTION(getOsname); | ||
vect[N_PLATFORM_PROP_OSTYPE] = NULL; | ||
vect[N_PLATFORM_PROP_PROCESSORCOUNT] = NULL; | ||
vect[N_PLATFORM_PROP_RUNTIME] = PROP_GETTING_FUNCTION(getRuntime); | ||
vect[N_PLATFORM_PROP_USERNAME] = NULL; | ||
vect[N_PLATFORM_PROP_VERSION] = NULL; | ||
return vect; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openURL is part of this Jira task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openURL already not part of app.js and doesn't prevent us from running KS. Also we don't have browser for now. That's why it leaved for near future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put a comment in the Jira
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added