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

Add option to change direction on arrow keys #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
36 changes: 28 additions & 8 deletions app/src/main/java/com/totsp/crossword/PlayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,13 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
case KeyEvent.KEYCODE_DPAD_DOWN:

if ((System.currentTimeMillis() - lastKey) > 50) {
previous = getBoard().moveDown();
this.render(previous);
if (prefs.getBoolean("arrowKeysChangeDirection", false) && getBoard().isAcross()) {
previous = getBoard().toggleDirection();
this.render(previous);
} else {
previous = getBoard().moveDown();
this.render(previous);
}
}


Expand All @@ -792,8 +797,13 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
case KeyEvent.KEYCODE_DPAD_UP:

if ((System.currentTimeMillis() - lastKey) > 50) {
previous = getBoard().moveUp();
this.render(previous);
if (prefs.getBoolean("arrowKeysChangeDirection", false) && getBoard().isAcross()) {
previous = getBoard().toggleDirection();
this.render(previous);
} else {
previous = getBoard().moveUp();
this.render(previous);
}
}

lastKey = System.currentTimeMillis();
Expand All @@ -803,8 +813,13 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
case KeyEvent.KEYCODE_DPAD_LEFT:

if ((System.currentTimeMillis() - lastKey) > 50) {
previous = getBoard().moveLeft();
this.render(previous);
if (prefs.getBoolean("arrowKeysChangeDirection", false) && !getBoard().isAcross()) {
previous = getBoard().toggleDirection();
this.render(previous);
} else {
previous = getBoard().moveLeft();
this.render(previous);
}
}

lastKey = System.currentTimeMillis();
Expand All @@ -814,8 +829,13 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
case KeyEvent.KEYCODE_DPAD_RIGHT:

if ((System.currentTimeMillis() - lastKey) > 50) {
previous = getBoard().moveRight();
this.render(previous);
if (prefs.getBoolean("arrowKeysChangeDirection", false) && !getBoard().isAcross()) {
previous = getBoard().toggleDirection();
this.render(previous);
} else {
previous = getBoard().moveRight();
this.render(previous);
}
}

lastKey = System.currentTimeMillis();
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@
android:summary="Enter changes direction rather than moving to the next clue."
android:key="enterChangesDirection"
/>

<androidx.preference.CheckBoxPreference
android:title="Arrow Keys Change Direction"
android:defaultValue="false"
android:summary="Arrow keys change direction instead of moving the cursor when you try to move perpendicular to the current direction."
android:key="arrowKeysChangeDirection"
/>

<androidx.preference.CheckBoxPreference
android:title="Double Tap Zoom"
Expand Down