Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011 NativeDriver committers Copyright 2011 Google Inc.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
   * in compliance with the License. You may obtain a copy of the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software distributed under the License
  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
 
 package io.selendroid.android;
 
 
Contains keys that can be sent to Android Native driver implementations of org.openqa.selenium.WebElement. These keys are not easily represented as strings, so an instance of this enum can be used instead. Each instance is a CharSequence that is exactly one character long, and that character is a value in the Unicode private use space.

For keys that are also in Keys, the key code in this class is the same.

Author(s):
Matt DeVore
 
 public enum AndroidKeys implements CharSequence {
   // Keys that are shared with normal WebDriver (sorted alphabetically)
   ALT_LEFT(..), DEL(..), DPAD_DOWN(
       .), DPAD_RIGHT(..), DPAD_UP(
       ..), ENTER(..), SHIFT_LEFT(
 
   // Keys only for native Android apps (sorted by key code)
   BACK('\uE100'.), HOME('\uE101'.), MENU('\uE102',
       .), SEARCH('\uE103'.), SYM('\uE104',
       .), ALT_RIGHT('\uE105'.), SHIFT_RIGHT('\uE106',
 
   private final char keyCode;
   private final int androidKeyCode;
 
   private AndroidKeys(char keyCodeint androidKeyCode) {
     this. = keyCode;
     this. = androidKeyCode;
   }
 
   private AndroidKeys(Keys keyint androidKeyCode) {
     this. = key.charAt(0);
     this. = androidKeyCode;
   }

  
Returns a character's corresponding Android KeyEvent code.

Parameters:
keyCode character to get KeyEvent code for
Returns:
integer representing KeyEvent code
 
   public static int keyCodeFor(char keyCodethrows SelendroidException {
     // see whether char is a special key; if so, return that
     for (AndroidKeys key : AndroidKeys.values()) {
       if (key.charAt(0) == keyCode) {
         return key.getAndroidKeyCode();
       }
     }
 
     // otherwise, figure out corresponding KeyEvent integer
     char upperCaseKey = Character.toUpperCase(keyCode);
     if (Character.isDigit(upperCaseKey)) {
       return upperCaseKey - '0' + .;
     }
     if (Character.isLetter(upperCaseKey)) {
       return upperCaseKey - 'A' + .;
     }
     throw new SelendroidException("Character '" + keyCode + "' is not yet "
         + "supported by Selendroid.");
   }

  
Returns true if key character is defined within AndroidKeys.

Parameters:
keyCode character to check
Returns:
true if key is present within AndroidKeys
 
   public static boolean hasAndroidKeyEvent(char keyCode) {
     for (AndroidKeys key : AndroidKeys.values()) {
       if (key.charAt(0) == keyCode) {
         return true;
       }
     }
     return false;
   }

  
Returns key's corresponding Android KeyEvent code.

Returns:
Android KeyEvent code
  public int getAndroidKeyCode() {
    return ;
  }
  public char charAt(int index) {
    if (index != 0) {
      throw new IndexOutOfBoundsException();
    }
    return ;
  }
  public int length() {
    return 1;
  }
  public CharSequence subSequence(int startint end) {
    if (end == start) {
      return "";
    } else if (start == 0 && end == 1) {
      return this;
    } else {
      throw new IndexOutOfBoundsException();
    }
  }
  public String toString() {
    return String.valueOf();
  }
New to GrepCode? Check out our FAQ X