private void applyFontSize() { int fontSize = mPageControl.getDocumentFontSize(); getSettings().setDefaultFontSize(fontSize); // 1.6 is taken from css - line-height: 1.6em; ScreenSettings.setLineHeightDips((int) (1.6 * fontSize)); }
/** apply settings set by the user using Preferences */ @Override public void applyPreferenceSettings() { applyFontSize(); changeBackgroundColour(); ScreenSettings.setContentViewHeightPx(getHeight()); }
@Override public boolean changeBackgroundColour() { if (ScreenSettings.isNightMode()) { setBackgroundColor(Color.BLACK); setTextColor(Color.WHITE); } else { setBackgroundColor(Color.WHITE); setTextColor(Color.BLACK); } // should not return false but it is used to see if text needs refreshing, which it doesn't return false; }
/** may need updating depending on environmental brightness */ @Override public boolean changeBackgroundColour() { // if night mode then set scrollbar colour int newBackgroundColour = ScreenSettings.isNightMode() ? Color.BLACK : Color.WHITE; boolean changed = mCurrentBackgroundColour != newBackgroundColour; if (changed) { setBackgroundColor(newBackgroundColour); mCurrentBackgroundColour = newBackgroundColour; } return changed; }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); // update the height in ScreenSettings ScreenSettings.setContentViewHeightPx(getMeasuredHeight()); }