diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-09-07 20:45:21 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-09-07 20:45:21 +0200 |
commit | 6bb9983d58538e632b5170a788fd77a957365bf7 (patch) | |
tree | ab862cef34d7a60384166472969d0c3f94f842d1 /src | |
parent | 6308dcfdd42adabbe1f4e3ec28ec8e2b4f766f8c (diff) |
added rotation detection to up/down navigation
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index e0824575..4399e7c4 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -20,6 +20,7 @@ import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; +import android.view.Surface; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -862,19 +863,37 @@ public class ConversationActivity extends XmppActivity @Override public boolean onKeyUp(int key, KeyEvent event) { + int rotation = getWindowManager().getDefaultDisplay().getRotation(); + final int upKey; + final int downKey; + switch(rotation) { + case Surface.ROTATION_90: + upKey = KeyEvent.KEYCODE_DPAD_LEFT; + downKey = KeyEvent.KEYCODE_DPAD_RIGHT; + break; + case Surface.ROTATION_180: + upKey = KeyEvent.KEYCODE_DPAD_DOWN; + downKey = KeyEvent.KEYCODE_DPAD_UP; + break; + case Surface.ROTATION_270: + upKey = KeyEvent.KEYCODE_DPAD_RIGHT; + downKey = KeyEvent.KEYCODE_DPAD_LEFT; + break; + default: + upKey = KeyEvent.KEYCODE_DPAD_UP; + downKey = KeyEvent.KEYCODE_DPAD_DOWN; + } final boolean modifier = event.isCtrlPressed(); - final boolean upKey = key == KeyEvent.KEYCODE_DPAD_UP || key == KeyEvent.KEYCODE_DPAD_LEFT; - final boolean downKey = key == KeyEvent.KEYCODE_DPAD_DOWN || key == KeyEvent.KEYCODE_DPAD_RIGHT; if (modifier && key == KeyEvent.KEYCODE_TAB && isConversationsOverviewHideable()) { toggleConversationsOverview(); return true; - } else if (modifier && downKey) { + } else if (modifier && key == downKey) { if (isConversationsOverviewHideable() && !isConversationsOverviewVisable()) { showConversationsOverview();; } selectDownConversation(); return true; - } else if (modifier && upKey) { + } else if (modifier && key == upKey) { if (isConversationsOverviewHideable() && !isConversationsOverviewVisable()) { showConversationsOverview();; } |