@Override protected final void loadAllResources() { mNextWordDictionary = new NextWordDictionary(mContext, mLocale); mNextWordDictionary.load(); BTreeDictionary androidBuiltIn = null; try { // The only reason I see someone uses this, is for development or debugging. if (AnyApplication.getConfig().alwaysUseFallBackUserDictionary()) throw new RuntimeException("User requested to always use fall-back user-dictionary."); androidBuiltIn = createAndroidUserDictionary(mContext, mLocale); androidBuiltIn.loadDictionary(); mActualDictionary = androidBuiltIn; } catch (Exception e) { Logger.w( TAG, "Can not load Android's built-in user dictionary (since '%s'). FallbackUserDictionary to the rescue!", e.getMessage()); if (androidBuiltIn != null) { try { androidBuiltIn.close(); } catch (Exception buildInCloseException) { // it's an half-baked object, no need to worry about it buildInCloseException.printStackTrace(); Logger.w( TAG, "Failed to close the build-in user dictionary properly, but it should be fine."); } } BTreeDictionary fallback = createFallbackUserDictionary(mContext, mLocale); fallback.loadDictionary(); mActualDictionary = fallback; } }
public static int getKeyHeightFromHeightCode( KeyboardDimens keyboardDimens, int heightCode, int orientation) { int height; switch (heightCode) { case 0: height = 0; break; case -2: height = keyboardDimens.getSmallKeyHeight(); break; case -3: height = keyboardDimens.getLargeKeyHeight(); break; default: // -1 height = keyboardDimens.getNormalKeyHeight(); break; } if (orientation == Configuration.ORIENTATION_LANDSCAPE) height = (int) (height * AnyApplication.getConfig().getKeysHeightFactorInLandscape()); else height = (int) (height * AnyApplication.getConfig().getKeysHeightFactorInPortrait()); return height; }
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main_ui); mTitle = mDrawerTitle = getTitle(); mDrawerRootLayout = (DrawerLayout) findViewById(R.id.main_root_layout); mDrawerRootLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT); mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerRootLayout, /* DrawerLayout object */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); ActivityCompat.invalidateOptionsMenu( MainSettingsActivity.this); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(mDrawerTitle); ActivityCompat.invalidateOptionsMenu( MainSettingsActivity.this); // creates call to onPrepareOptionsMenu() } }; // Set the drawer toggle as the DrawerListener mDrawerRootLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); AnyApplication.getConfig().addChangedListener(menuExtraUpdaterOnConfigChange); }
@Override protected void onDestroy() { super.onDestroy(); AnyApplication.getConfig().removeChangedListener(menuExtraUpdaterOnConfigChange); }