Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8582] BlackBerry: Implement important Gesture functionality

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-04-30T06:53:43.000+0000
Affected Version/sBacklog
Fix Version/s2013 Sprint 09 BB, 2013 Sprint 09, Release 3.2.0
ComponentsBlackBerry
Labelsnotable
ReporterFrancois Boisvert
AssigneeJosh Roesslein
Created2012-04-06T06:36:38.000+0000
Updated2017-03-03T06:41:14.000+0000

Description

Implement the Gesture module.

Acceptance Test

function orientationToString(orientation) {
  switch (orientation) {
    case Ti.UI.PORTRAIT:
      return 'portrait';
    case Ti.UI.UPSIDE_PORTRAIT:
      return 'upside portrait';
    case Ti.UI.LANDSCAPE_LEFT:
      return 'landscape left';
    case Ti.UI.LANDSCAPE_RIGHT:
      return 'landscape right';
    case Ti.UI.FACE_UP:
      return 'face up';
    case Ti.UI.FACE_DOWN:
      return 'face down';
    default:
      return 'unknown';
  }
}

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

var labelA = Ti.UI.createLabel({
  width: Ti.UI.FILL,
  text: 'e.orientation = N/A'
});
win.add(labelA);

var labelB = Ti.UI.createLabel({
  width: Ti.UI.FILL,
  text: 'Gesture.orientation = N/A'
});
win.add(labelB);

var labelC = Ti.UI.createLabel({
  width: Ti.UI.FILL,
  wrap: true,
  text: 'No shake yet.'
});
win.add(labelC);

function onShake(e) {
  Ti.API.info('Shake: {' + e.x + ', ' + e.y + ', ' + e.z + '}');
  labelC.text = 'Shake!';
  win.backgroundColor = 'yellow';
  setTimeout(function() {
    labelC.text = 'No shake yet.';
    win.backgroundColor = 'red';
  }, 500);
}

var toggleShake = Ti.UI.createButton({
  title: 'Toggle Shake'
});
var shakeEnabled = false;
toggleShake.addEventListener('click', function() {
  shakeEnabled ? Ti.Gesture.removeEventListener('shake', onShake)
               : Ti.Gesture.addEventListener('shake', onShake);
  shakeEnabled = !shakeEnabled;
});
win.add(toggleShake);

Ti.Gesture.addEventListener('orientationchange', function(e) {
  labelA.text = 'e.orientation = ' + orientationToString(e.orientation);
  labelB.text = 'Gesture.orientation = ' + orientationToString(Ti.Gesture.orientation);
});

win.open();

Rotate the device and flip it around. The first two labels should be equal and display the current orientation.

Try shaking the device, nothing should happen.

Click the "Toggle Shake" button and shake again. The background should flash yellow.

Try clicking the "Toggle Shake" button and shake again. Nothing should happen.

Comments

  1. Josh Roesslein 2013-04-24

    Created pull request [#30](https://github.com/appcelerator/titanium_mobile_blackberry/pull/30).
  2. Lee Morris 2017-03-03

    Closing ticket due to Blackberry no longer being supported.

JSON Source