public KeyboardTypeAction add(String stringToBeTyped) { Preconditions.checkNotNull(stringToBeTyped); appendDescription(stringToBeTyped); for (char c : stringToBeTyped.toCharArray()) { if (c == '\n') { keysToBeHit.add(KeyLocations.instance().findSpecial(KeyEvent.KEYCODE_ENTER)); } else { if (Character.isUpperCase(c)) { keysToBeHit.add(KeyLocations.instance().findSpecial(KeyEvent.KEYCODE_SHIFT_LEFT)); c = Character.toLowerCase(c); } try { keysToBeHit.add(KeyLocations.instance().findStandard(c)); } catch (IllegalStateException e) { if (fallbackToInjection) { Log.w(TAG, "Using fallback for " + c); keysToBeHit.add(KeyInfo.getFallbackKey("" + c)); } else { throw e; } } } } return this; }
/** * Assume visible area percentage. * * There is an bug on pre Android v11 versions where actionbar height can't be resolved when * using appcompat actionbar. This method use the appcompat actionbar height attribute when * on pre v11 versions. * * @see ViewMatchers#isDisplayingAtLeast(int) */ public static Matcher<View> isDisplayingAtLeast(final int areaPercentage) { Preconditions.checkState(areaPercentage <= 100, "Cannot have over 100 percent: %s", areaPercentage); Preconditions.checkState(areaPercentage > 0, "Must have a positive, non-zero value: %s", areaPercentage); return new IsDisplayingAtLeastMatcher(areaPercentage); }