boolean isInside(LatinKey key,int x,int y){
  final int code=key.codes[0];
  if (code == KEYCODE_SHIFT || code == KEYCODE_DELETE) {
    y-=key.height / 10;
    if (code == KEYCODE_SHIFT) {
      if (key.x == 0) {
        x+=key.width / 6;
      }
 else {
        x-=key.width / 6;
      }
    }
    if (code == KEYCODE_DELETE)     x-=key.width / 6;
  }
 else   if (code == LatinIME.ASCII_SPACE) {
    y+=LatinKeyboard.sSpacebarVerticalCorrection;
    if (mLanguageSwitcher.getLocaleCount() > 1) {
      if (mCurrentlyInSpace) {
        int diff=x - mSpaceDragStartX;
        if (Math.abs(diff - mSpaceDragLastDiff) > 0) {
          updateLocaleDrag(diff);
        }
        mSpaceDragLastDiff=diff;
        return true;
      }
 else {
        boolean insideSpace=key.isInsideSuper(x,y);
        if (insideSpace) {
          mCurrentlyInSpace=true;
          mSpaceDragStartX=x;
          updateLocaleDrag(0);
        }
        return insideSpace;
      }
    }
  }
 else   if (mPrefLetterFrequencies != null) {
    if (mPrefLetterX != x || mPrefLetterY != y) {
      mPrefLetter=0;
      mPrefDistance=Integer.MAX_VALUE;
    }
    final int[] pref=mPrefLetterFrequencies;
    if (mPrefLetter > 0) {
      if (DEBUG_PREFERRED_LETTER) {
        if (mPrefLetter == code && !key.isInsideSuper(x,y)) {
          Log.d(TAG,"CORRECTED !!!!!!");
        }
      }
      return mPrefLetter == code;
    }
 else {
      final boolean inside=key.isInsideSuper(x,y);
      int[] nearby=getNearestKeys(x,y);
      List<Key> nearbyKeys=getKeys();
      if (inside) {
        if (inPrefList(code,pref)) {
          mPrefLetter=code;
          mPrefLetterX=x;
          mPrefLetterY=y;
          for (int i=0; i < nearby.length; i++) {
            Key k=nearbyKeys.get(nearby[i]);
            if (k != key && inPrefList(k.codes[0],pref)) {
              final int dist=distanceFrom(k,x,y);
              if (dist < (int)(k.width * OVERLAP_PERCENTAGE_LOW_PROB) && (pref[k.codes[0]] > pref[mPrefLetter] * 3)) {
                mPrefLetter=k.codes[0];
                mPrefDistance=dist;
                if (DEBUG_PREFERRED_LETTER) {
                  Log.d(TAG,"CORRECTED ALTHOUGH PREFERRED !!!!!!");
                }
                break;
              }
            }
          }
          return mPrefLetter == code;
        }
      }
      for (int i=0; i < nearby.length; i++) {
        Key k=nearbyKeys.get(nearby[i]);
        if (inPrefList(k.codes[0],pref)) {
          final int dist=distanceFrom(k,x,y);
          if (dist < (int)(k.width * OVERLAP_PERCENTAGE_HIGH_PROB) && dist < mPrefDistance) {
            mPrefLetter=k.codes[0];
            mPrefLetterX=x;
            mPrefLetterY=y;
            mPrefDistance=dist;
          }
        }
      }
      if (mPrefLetter == 0) {
        return inside;
      }
 else {
        return mPrefLetter == code;
      }
    }
  }
  if (mCurrentlyInSpace)   return false;
  return key.isInsideSuper(x,y);
}

boolean isInside ( LatinKey key , int x , int y ) { final int code = key . codes [ 0 ] ; if ( code == KEYCODE_SHIFT || code == KEYCODE_DELETE ) { y -= key . height / 10 ; if ( code == KEYCODE_SHIFT ) { if ( key . x == 0 ) { x += key . width / 6 ; } else { x -= key . width / 6 ; } } if ( code == KEYCODE_DELETE ) x -= key . width / 6 ; } else if ( code == LatinIME . ASCII_SPACE ) { y += LatinKeyboard . sSpacebarVerticalCorrection ; if ( mLanguageSwitcher . getLocaleCount ( ) > 1 ) { if ( mCurrentlyInSpace ) { int diff = x - mSpaceDragStartX ; if ( Math . abs ( diff - mSpaceDragLastDiff ) > 0 ) { updateLocaleDrag ( diff ) ; } mSpaceDragLastDiff = diff ; return true ; } else { boolean insideSpace = key . isInsideSuper ( x , y ) ; if ( insideSpace ) { mCurrentlyInSpace = true ; mSpaceDragStartX = x ; updateLocaleDrag ( 0 ) ; } return insideSpace ; } } } else if ( mPrefLetterFrequencies != null ) { if ( mPrefLetterX != x || mPrefLetterY != y ) { mPrefLetter = 0 ; mPrefDistance = Integer . MAX_VALUE ; } final int [ ] pref = mPrefLetterFrequencies ; if ( mPrefLetter > 0 ) { if ( DEBUG_PREFERRED_LETTER ) { if ( mPrefLetter == code && ! key . isInsideSuper ( x , y ) ) { Log . d ( TAG , "CORRECTED !!!!!!" ) ; } } return mPrefLetter == code ; } else { final boolean inside = key . isInsideSuper ( x , y ) ; int [ ] nearby = getNearestKeys ( x , y ) ; List < Key > nearbyKeys = getKeys ( ) ; if ( inside ) { if ( inPrefList ( code , pref ) ) { mPrefLetter = code ; mPrefLetterX = x ; mPrefLetterY = y ; for ( int i = 0 ; i < nearby . length ; i ++ ) { Key k = nearbyKeys . get ( nearby [ i ] ) ; if ( k != key && inPrefList ( k . codes [ 0 ] , pref ) ) { final int dist = distanceFrom ( k , x , y ) ; if ( dist < ( int ) ( k . width * OVERLAP_PERCENTAGE_LOW_PROB ) && ( pref [ k . codes [ 0 ] ] > pref [ mPrefLetter ] * 3 ) ) { mPrefLetter = k . codes [ 0 ] ; mPrefDistance = dist ; if ( DEBUG_PREFERRED_LETTER ) { Log . d ( TAG , "CORRECTED ALTHOUGH PREFERRED !!!!!!" ) ; } break ; } } } return mPrefLetter == code ; } } for ( int i = 0 ; i < nearby . length ; i ++ ) { Key k = nearbyKeys . get ( nearby [ i ] ) ; if ( inPrefList ( k . codes [ 0 ] , pref ) ) { final int dist = distanceFrom ( k , x , y ) ; if ( dist < ( int ) ( k . width * OVERLAP_PERCENTAGE_HIGH_PROB ) && dist < mPrefDistance ) { mPrefLetter = k . codes [ 0 ] ; mPrefLetterX = x ; mPrefLetterY = y ; mPrefDistance = dist ; } } } if ( mPrefLetter == 0 ) { return inside ; } else { return mPrefLetter == code ; } } } if ( mCurrentlyInSpace ) return false ; return key . isInsideSuper ( x , y ) ; }
does the magic of locking the touch gesture into the spacebar when switching input languages .
