Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12233] BlackBerry: Implement important Titanium.Accelerometer functionality

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-05-06T05:45:41.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 09 BB, 2013 Sprint 09, Release 3.2.0
ComponentsBlackBerry
Labelsn/a
ReporterRussell McMahon
AssigneeJosh Roesslein
Created2013-01-07T13:17:57.000+0000
Updated2017-03-09T07:52:22.000+0000

Description

Acceptance Test

var win = Ti.UI.createWindow({
  layout: 'vertical'
});

var enableAccelerometer = Ti.UI.createButton({
  title: 'Toggle Accelerometer'
});
win.add(enableAccelerometer);

var labels = ['x', 'y', 'z'].map(function(coord) {
  var label = Ti.UI.createLabel({text: coord + ': N/A'});
  win.add(label);
  return label;
});

function onUpdate(e) {
  labels[0].text = e.x;
  labels[1].text = e.y;
  labels[2].text = e.z;
}

var accelerometerEnabled = false;
enableAccelerometer.addEventListener('click', function() {
  accelerometerEnabled ? Ti.Accelerometer.removeEventListener('update', onUpdate)
                       : Ti.Accelerometer.addEventListener('update', onUpdate);
  accelerometerEnabled = !accelerometerEnabled;
});

win.open();

Try moving the device around. No updates should be displayed.

Click "Toggle Accelerometer". Move device and you should now see updates (x, y, z values).

Click the toggle button again and the updates should stop. Repeat and verify.

Comments

  1. Josh Roesslein 2013-05-01

    Ready for code review and testing.
  2. Lee Morris 2017-03-09

    Closing ticket as fixed.

JSON Source