Skip to content

Commit

Permalink
feat(wechat): add swipe event for finder in wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
XiangchenShen committed Jan 12, 2025
1 parent 201bc88 commit 54251b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion kea/device_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .device import Device

from .utils import md5, deprecated
from .input_event import SearchEvent, SetTextAndSearchEvent, TouchEvent, LongTouchEvent, ScrollEvent, SetTextEvent, KeyEvent, UIEvent
from .input_event import SearchEvent, SetTextAndSearchEvent, TouchEvent, LongTouchEvent, ScrollEvent, SetTextEvent, KeyEvent, UIEvent, SwipeEvent


class DeviceState(object):
Expand Down Expand Up @@ -600,6 +600,20 @@ def get_possible_input(self):
# For old Android navigation bars
# possible_events.append(KeyEvent(name="MENU"))

for view_id in enabled_view_ids:
if self.__safe_dict_get(self.views[view_id], 'package') == 'com.tencent.mm' and self.__safe_dict_get(self.views[view_id], 'resource_id') == "com.tencent.mm:id/media_container":
bounds = self.__safe_dict_get(self.views[view_id], 'bounds')
x0 = bounds[0][0]
y0 = bounds[0][1]
x1 = bounds[1][0]
y1 = bounds[1][1]
swipe_x = (x0 + x1) / 2.0
swipe_y0 = y0 + 3.0 * (y1 - y0) / 4.0
swipe_y1 = y0 + (y1- y0) / 4.0
possible_events.append(SwipeEvent(start_x=swipe_x, start_y=swipe_y0, end_x=swipe_x, end_y=swipe_y1, duration = 500))
possible_events.append(SwipeEvent(start_x=swipe_x, start_y=swipe_y1, end_x=swipe_x, end_y=swipe_y0, duration = 500))


self.possible_events = possible_events
return [] + possible_events

Expand Down
2 changes: 1 addition & 1 deletion kea/input_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def get_views(self):
return views

def get_event_name(self):
return self.get_event_str()
return "Swipe"

class ScrollEvent(UIEvent):
"""
Expand Down

0 comments on commit 54251b1

Please sign in to comment.