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

Handle all events so dragging works in Android 7+ #24

Merged
merged 1 commit into from
Jan 10, 2017
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2012-2016 Sauce Labs, Inc.
Copyright 2012-2016 JS Foundation and other contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "android-apidemos",
"version": "1.1.2",
"description": "A fork of Google's Android ApiDemos application, used for testing Appium",
"license": "Apache-2.0",
"main": "bin/ApiDemos-debug.apk",
"directories": {
"test": "tests"
Expand Down
8 changes: 4 additions & 4 deletions res/layout/drag_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -26,8 +26,8 @@

<io.appium.android.apis.view.DraggableDot android:id="@+id/drag_dot_hidden" android:layout_width="wrap_content" android:layout_height="wrap_content" dot:radius="64dp" android:padding="15dp" android:layout_toRightOf="@id/drag_dot_3" android:layout_alignTop="@id/drag_dot_3" android:visibility="invisible" dot:legend="Surprise!"/>

<TextView android:id="@+id/drag_result_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/drag_explanation" android:layout_alignRight="@id/drag_explanation" android:layout_toRightOf="@id/drag_dot_2"/>
<TextView android:id="@+id/drag_result_text" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_below="@id/drag_dot_3" android:layout_alignLeft="@id/drag_dot_3"/>

<TextView android:id="@+id/drag_text" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_below="@id/drag_dot_3" android:layout_alignLeft="@id/drag_dot_3"/>
<TextView android:id="@+id/drag_text" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_below="@id/drag_result_text" android:layout_alignLeft="@id/drag_result_text"/>

</RelativeLayout>
6 changes: 4 additions & 2 deletions src/io/appium/android/apis/view/DragAndDropDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
mResultText = (TextView) findViewById(R.id.drag_result_text);
mResultText.setOnDragListener(new View.OnDragListener() {
public boolean onDrag(View v, DragEvent event) {
mResultText.setText("Dragging...");
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED: {
Expand All @@ -65,8 +66,9 @@ public boolean onDrag(View v, DragEvent event) {
mResultText.setText(dropped ? "Dropped!" : "No drop");
} break;
}
return false;
// watch all events, or on Android 7+ we don't get the ACTION_DRAG_ENDED event
return true;
}
});
}
}
}