Skip to content

fix(android): add AndroidKey.ZOOM_IN, ZOOM_OUT and PASTE - #13

Draft
MattL1989 wants to merge 1 commit into
masterfrom
fix/android-key-zoom-paste
Draft

MattL1989 wants to merge 1 commit into
masterfrom
fix/android-key-zoom-paste

Conversation

@MattL1989

Copy link
Copy Markdown
Owner

Problem

AndroidKey names drop Android's KEYCODE_ prefix, such as ENTER, BACK, CUT and COPY. The two zoom keys were the only exceptions, named KEYCODE_ZOOM_IN and KEYCODE_ZOOM_OUT, so the expected name does not exist:

AndroidKey.ZOOM_IN
# AttributeError: type object 'AndroidKey' has no attribute 'ZOOM_IN'

PASTE (279) was also missing, although CUT (277) and COPY (278) are there.

Fix

Add ZOOM_IN = 168, ZOOM_OUT = 169 and PASTE = 279. These match KEYCODE_ZOOM_IN, KEYCODE_ZOOM_OUT and KEYCODE_PASTE in AOSP's android.view.KeyEvent. KEYCODE_ZOOM_IN and KEYCODE_ZOOM_OUT stay as aliases, so existing code keeps working. The is_*_key helpers compare values, not names, so the aliases don't affect them.

Tests

  • Added a unit test that checks the new names and values, and that the old names still give the same values. Without the fix it fails with AttributeError: type object 'AndroidKey' has no attribute 'ZOOM_IN'.
  • ruff check, ruff format --check, mypy appium and the full unit test suite pass.

🤖 Generated with Claude Code

Every AndroidKey constant drops Android's KEYCODE_ prefix (ENTER, BACK,
CUT, COPY...), except the zoom keys, which were named KEYCODE_ZOOM_IN
and KEYCODE_ZOOM_OUT. AndroidKey.ZOOM_IN therefore raised
AttributeError. PASTE (279) was also missing, although CUT (277) and
COPY (278) were there.

Add ZOOM_IN = 168, ZOOM_OUT = 169 and PASTE = 279, matching
KEYCODE_ZOOM_IN, KEYCODE_ZOOM_OUT and KEYCODE_PASTE in AOSP's
android.view.KeyEvent. KEYCODE_ZOOM_IN and KEYCODE_ZOOM_OUT stay as
aliases so existing code keeps working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant