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

Change default click position to close keyboard #1374

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions mapadroid/ocr/screenPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,18 @@ async def __handle_ptc_login(self) -> ScreenType:
bounds: str = ""
accept_x: Optional[int] = None
accept_y: Optional[int] = None
# On some resolutions (100, 100) position that MAD clicks by default to close keyboard
# ended on clicking Firefox SSL certifcate icon and it nuked whole flow by opening something else
# Changing it to (300, 300), but also detecting big logo image on website and taking this as new coords
exit_keyboard_x: int = 300
exit_keyboard_y: int = 300
for item in xmlroot.iter('node'):
if item.attrib["class"] == "android.widget.Image":
bounds = item.attrib['bounds']
match = re.search(r'^\[(\d+),(\d+)\]\[(\d+),(\d+)\]$', bounds)
logger.debug("Logo image Bounds {}", item.attrib['bounds'])
exit_keyboard_x = int(match.group(1)) + ((int(match.group(3)) - int(match.group(1))) / 2)
exit_keyboard_y = int(match.group(2)) + ((int(match.group(4)) - int(match.group(2))) / 2)
if item.attrib["resource-id"] == "email":
bounds = item.attrib['bounds']
logger.info("Found email/login field, clicking, filling, clicking")
Expand All @@ -466,7 +477,7 @@ async def __handle_ptc_login(self) -> ScreenType:
await self._communicator.click(int(click_x), int(click_y))
await asyncio.sleep(2)
await self._communicator.enter_text(self._worker_state.active_account.username)
await self._communicator.click(100, 100)
await self._communicator.click(exit_keyboard_x, exit_keyboard_y)
await asyncio.sleep(2)
if item.attrib["resource-id"] == "password":
bounds = item.attrib['bounds']
Expand All @@ -478,7 +489,7 @@ async def __handle_ptc_login(self) -> ScreenType:
await self._communicator.click(int(click_x), int(click_y))
await asyncio.sleep(2)
await self._communicator.enter_text(self._worker_state.active_account.password)
await self._communicator.click(100, 100)
await self._communicator.click(exit_keyboard_x, exit_keyboard_y)
await asyncio.sleep(2)
if item.attrib["resource-id"] == "accept":
bounds = item.attrib['bounds']
Expand Down
Loading