Home | History | Annotate | Download | only in view
      1 /*
      2  * Copyright (C) 2008 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 android.view;
     18 
     19 /**
     20  * Constants to be used to play sound effects via {@link View#playSoundEffect(int)}
     21  */
     22 public class SoundEffectConstants {
     23 
     24     private SoundEffectConstants() {}
     25 
     26     public static final int CLICK = 0;
     27 
     28     public static final int NAVIGATION_LEFT = 1;
     29     public static final int NAVIGATION_UP = 2;
     30     public static final int NAVIGATION_RIGHT = 3;
     31     public static final int NAVIGATION_DOWN = 4;
     32 
     33     /**
     34      * Get the sonification constant for the focus directions.
     35      * @param direction One of {@link View#FOCUS_UP}, {@link View#FOCUS_DOWN},
     36      *     {@link View#FOCUS_LEFT}, {@link View#FOCUS_RIGHT}, {@link View#FOCUS_FORWARD}
     37      *     or {@link View#FOCUS_BACKWARD}
     38 
     39      * @return The appropriate sonification constant.
     40      */
     41     public static int getContantForFocusDirection(int direction) {
     42         switch (direction) {
     43             case View.FOCUS_RIGHT:
     44                 return SoundEffectConstants.NAVIGATION_RIGHT;
     45             case View.FOCUS_FORWARD:
     46             case View.FOCUS_DOWN:
     47                 return SoundEffectConstants.NAVIGATION_DOWN;
     48             case View.FOCUS_LEFT:
     49                 return SoundEffectConstants.NAVIGATION_LEFT;
     50             case View.FOCUS_BACKWARD:
     51             case View.FOCUS_UP:
     52                 return SoundEffectConstants.NAVIGATION_UP;
     53         }
     54         throw new IllegalArgumentException("direction must be one of "
     55                 + "{FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, FOCUS_BACKWARD}.");
     56     }
     57 }
     58