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      * @throws {@link IllegalArgumentException} when the passed direction is not one of the
     41      *     documented values.
     42      */
     43     public static int getContantForFocusDirection(int direction) {
     44         switch (direction) {
     45             case View.FOCUS_RIGHT:
     46                 return SoundEffectConstants.NAVIGATION_RIGHT;
     47             case View.FOCUS_FORWARD:
     48             case View.FOCUS_DOWN:
     49                 return SoundEffectConstants.NAVIGATION_DOWN;
     50             case View.FOCUS_LEFT:
     51                 return SoundEffectConstants.NAVIGATION_LEFT;
     52             case View.FOCUS_BACKWARD:
     53             case View.FOCUS_UP:
     54                 return SoundEffectConstants.NAVIGATION_UP;
     55         }
     56         throw new IllegalArgumentException("direction must be one of "
     57                 + "{FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, FOCUS_BACKWARD}.");
     58     }
     59 }
     60