1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.recents.events.ui.focus; 18 19 import android.view.KeyEvent; 20 import com.android.systemui.recents.events.EventBus; 21 22 /** 23 * Navigates the task view by arrow keys. 24 */ 25 public class NavigateTaskViewEvent extends EventBus.Event { 26 public enum Direction { 27 UNDEFINED, UP, DOWN, LEFT, RIGHT; 28 } 29 30 public Direction direction; NavigateTaskViewEvent(Direction direction)31 public NavigateTaskViewEvent(Direction direction) { 32 this.direction = direction; 33 } 34 getDirectionFromKeyCode(int keyCode)35 public static Direction getDirectionFromKeyCode(int keyCode) { 36 switch (keyCode) { 37 case KeyEvent.KEYCODE_DPAD_UP: 38 return Direction.UP; 39 case KeyEvent.KEYCODE_DPAD_DOWN: 40 return Direction.DOWN; 41 case KeyEvent.KEYCODE_DPAD_LEFT: 42 return Direction.LEFT; 43 case KeyEvent.KEYCODE_DPAD_RIGHT: 44 return Direction.RIGHT; 45 default: 46 return Direction.UNDEFINED; 47 } 48 } 49 } 50