static { // API Level 11 is Build.VERSION_CODES.HONEYCOMB. // When right/left adjustment mode, outInsets uses touchableRegion to cut out IME rectangle. // Because only after API.11(HONEYCOMB) supports touchableRegion, filter it. InsetsCalculator tmpCalculator = null; if (Build.VERSION.SDK_INT >= 11) { // Try to create RegsionInsetsCalculator if the API level is high enough. try { Class<?> clazz = Class.forName( new StringBuilder(MozcView.class.getCanonicalName()) .append('$') .append("RegionInsetsCalculator") .toString()); tmpCalculator = InsetsCalculator.class.cast(clazz.newInstance()); } catch (ClassNotFoundException e) { MozcLog.e(e.getMessage(), e); } catch (IllegalArgumentException e) { MozcLog.e(e.getMessage(), e); } catch (IllegalAccessException e) { MozcLog.e(e.getMessage(), e); } catch (InstantiationException e) { MozcLog.e(e.getMessage(), e); } } if (tmpCalculator == null) { tmpCalculator = new DefaultInsetsCalculator(); } insetsCalculator = tmpCalculator; }
/** * Detects hardware keyboard type and sets it to the given {@code sharedPreferences}. If the * {@code sharedPreferences} is {@code null}, or already has valid hardware keyboard type, just * does nothing. * * <p>Note: if the new detected hardware keyboard type is set to the {@code sharedPreferences} and * if it has registered callbacks, of course, they will be invoked as usual. */ public static void maybeSetDetectedHardwareKeyMap( SharedPreferences sharedPreferences, Configuration configuration, boolean forceToSet) { if (sharedPreferences == null) { return; } // First, check if the hardware keyboard type has already set to the preference. if (getHardwareKeyMap(sharedPreferences) != null) { // Found the valid value. return; } // Here, the HardwareKeyMap hasn't set yet, so detect hardware keyboard type. HardwareKeyMap detectedKeyMap = null; switch (configuration.keyboard) { case Configuration.KEYBOARD_12KEY: detectedKeyMap = HardwareKeyMap.TWELVEKEY; break; case Configuration.KEYBOARD_QWERTY: detectedKeyMap = HardwareKeyMap.JAPANESE109A; break; case Configuration.KEYBOARD_NOKEYS: case Configuration.KEYBOARD_UNDEFINED: default: break; } if (detectedKeyMap != null) { setHardwareKeyMap(sharedPreferences, detectedKeyMap); } else if (forceToSet) { setHardwareKeyMap(sharedPreferences, HardwareKeyMap.DEFAULT); } MozcLog.i("RUN HARDWARE KEYBOARD DETECTION: " + detectedKeyMap); }