Skip to content
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-24317] Android: Focus area for view pinch event #8757

Merged
merged 8 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 55 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,61 @@ public class TiC
*/
public static final String EVENT_PROPERTY_SCALE = "scale";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_TIME = "time";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_FOCUS_X = "focusX";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_FOCUS_Y = "focusY";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_CURRENT_SPAN = "currentSpan";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_CURRENT_SPAN_X = "currentSpanX";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_CURRENT_SPAN_Y = "currentSpanY";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_PREVIOUS_SPAN = "previousSpan";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_PREVIOUS_SPAN_X = "previousSpanX";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_PREVIOUS_SPAN_Y = "previousSpanY";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_TIME_DELTA = "timeDelta";

/**
* @module.api
*/
public static final String EVENT_PROPERTY_IN_PROGRESS = "inProgress";

/**
* @module.api
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,18 @@ public boolean onScale(ScaleGestureDetector sgd)

if (didScale) {
KrollDict data = new KrollDict();
data.put(TiC.EVENT_PROPERTY_CURRENT_SPAN, sgd.getCurrentSpan());
data.put(TiC.EVENT_PROPERTY_CURRENT_SPAN_X, sgd.getCurrentSpanX());
data.put(TiC.EVENT_PROPERTY_CURRENT_SPAN_Y, sgd.getCurrentSpanY());
data.put(TiC.EVENT_PROPERTY_TIME, sgd.getEventTime());
data.put(TiC.EVENT_PROPERTY_FOCUS_X, sgd.getFocusX());
data.put(TiC.EVENT_PROPERTY_FOCUS_Y, sgd.getFocusY());
data.put(TiC.EVENT_PROPERTY_PREVIOUS_SPAN, sgd.getPreviousSpan());
data.put(TiC.EVENT_PROPERTY_PREVIOUS_SPAN_X, sgd.getPreviousSpanX());
data.put(TiC.EVENT_PROPERTY_PREVIOUS_SPAN_Y, sgd.getPreviousSpanY());
data.put(TiC.EVENT_PROPERTY_SCALE, sgd.getCurrentSpan() / startSpan);
data.put(TiC.EVENT_PROPERTY_TIME_DELTA, sgd.getTimeDelta());
data.put(TiC.EVENT_PROPERTY_IN_PROGRESS, sgd.isInProgress());
data.put(TiC.EVENT_PROPERTY_VELOCITY, (sgd.getScaleFactor() - 1.0f) / timeDelta * 1000);
data.put(TiC.EVENT_PROPERTY_SOURCE, proxy);

Expand Down
88 changes: 85 additions & 3 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ events:
- name: pinch
summary: Fired when the device detects a pinch gesture.
description: |
A pinch is a touch and expand or contract
with two fingers. The event occurs continuously until a finger is lifted again.
platforms: [iphone,ipad]
A pinch is a touch and expand or contract
with two fingers. The event occurs continuously until a finger is lifted again.
platforms: [iphone, ipad, android]
since: "1.8.0"
properties:
- name: scale
Expand All @@ -328,6 +328,88 @@ events:
- name: velocity
summary: The velocity of the pinch in scale factor per second.
type: Number

- name: time
summary: The event time of the current event being processed.
type: Number
since: "7.4.0"
platforms: [android]

- name: timeDelta
summary: |
The time difference in milliseconds between the previous accepted scaling event and the
current scaling event.
type: Number
since: "7.4.0"
platforms: [android]

- name: currentSpan
summary: |
The average distance between each of the pointers forming the gesture in progress through
the focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: currentSpanX
summary: |
The average X distance between each of the pointers forming the gesture in progress through
the focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: currentSpanY
summary: |
The average Y distance between each of the pointers forming the gesture in progress through
the focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: previousSpan
summary: |
The previous average distance between each of the pointers forming the gesture in progress through
the focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: previousSpanX
summary: |
The previous average X distance between each of the pointers forming the gesture in progress through
the focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: previousSpanY
summary: |
The previous average Y distance between each of the pointers forming the gesture in progress through
the focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: focusX
summary: |
The X coordinate of the current gesture's focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: focusY
summary: |
The Y coordinate of the current gesture's focal point.
type: Number
since: "7.4.0"
platforms: [android]

- name: inProgress
summary: Returns `true` if a scale gesture is in progress, `false` otherwise.
type: Number
since: "7.4.0"
platforms: [android]

- name: postlayout
summary: Fired when a layout cycle is finished.
Expand Down