calabash/calabash-android — pull request #386 by mgrebenets (2014-04-16 04:08:43+00:00)
Title: Backdoors, scroll, tag, list view properties, activity orientation and formatting

# Summary
- Support for backdoors
- Get/set activity orientation
- Scroll in all 4 directions
- Get list view properties
- Tap property support (query by)
- "Not Equal" predicate
- Successful result with message
- Formatting: trailing spaces, blank lines

## Backdoors
This is identical to bakdoors in iOS.
Backdoor methods must all have the same signature
```
public String backdoorMethod(String arg);
```
They must be methods of the main `Application` subclass (aka main activity)
```
import android.app.Application;

public class MyApplication extends Application {
/* ... */
public String backdoorMethod(String arg) {
return "";
}
}
```

To implement backdoors added new 'backdoor' action and returning backdoor result in "bonusInformation", also implemented `backoor` ruby API to behave just like iOS version.

New file: `actions/application/Backdoor.java`.

## Activity Orientation
- Modified `set_activity_orientation` action to support "left", "right", "up" and "down" orientations in addition to "landscape" and "portrait".
- This makes it similar to iOS code and makes it easier to write cross-platform code.
- Added `get_activity_orientation` action to return current activity orientation
- Using "message" to return orientation, probably should use "bonusInformation" instead.

New file: `actions/activity/GetActivityImplementation.java`.

## Scroll
Added new `scroll` action (`actions/scrolling/Scroll.java`).
This action allows scrolling in all 4 directions, just like iOS implementation.
Additionally, when scrolling sideways, an optional "scroll position" argument is supported, ranged from 0.0 to 1.0.

Implemented `scroll` Ruby API using new action.

## List View Properties
Added new `get_list_properties` action (`actions/list/GetListProperties.java`).
This action returns such list view properties as
- Size (similar to calling `:size` on `UIScrollView` subclass in iOS)
- Content size (similar to calling `:contentSize` on `UIScrollView` subclass in iOS)
- Content offset (similar to calling `:contentOffset` on `UIScrollView` subclass in iOS)

At the moment works with vertical `ListView` or subclasses.
Uses `ListAdapter` to calculate rows sizes and other information.

## Tag Property
- Added "tag" value to the hash describing an element (`.../query/ViewMapper.java`)
- Added `getTagForView` to get the view's tag (if any).
- Added `viewsForQuery` method to return list of all the views matching given query.
- Exposed `evaluateQueryForPath` as public to implement `viewsForQuery`
- Support predicates for "tag" property in queries

Can be used as an alternative to an ID. Since anything can be a tag in Android, it can be utilized to be similar to `accessbilityIdentifier` in iOS.

## Not Equal Predicate
Added `NOTEQUAL` predicate support (`.../query/ast/ComparisonOperator.java` and `.../query/ast/UIQueryASTPredicate.java`) to enable queries with "!=" and "<>" comparisons.

## Successful Result with Message
Added `public static Result successResult(final String message)` as helper method to construct successful result with message.

## Minor Changes / Formatting
- Sublime kills off all trailing spaces and obsolete spaces in empty lines for each file that I save (it's the way it should be after all)
- README.md
- Result.java
- Swipe.java
- GetListData.java
- InvocationOperation.java
- Query.java
- UIQueryUtils.java
- Ignore `ruby-gem/test-server/out`