(File file)
| 1615 | }; |
| 1616 | |
| 1617 | public Properties loadSettings(File file) { |
| 1618 | Properties props = new Properties(); |
| 1619 | |
| 1620 | if ( file.exists() && !DEBUG_RESET_OPTIONS ) { |
| 1621 | try { |
| 1622 | FileInputStream is = new FileInputStream(file); |
| 1623 | props.load(is); |
| 1624 | log.v("" + props.size() + " settings items loaded from file " + propsFile.getAbsolutePath() ); |
| 1625 | } catch ( Exception e ) { |
| 1626 | log.e("error while reading settings"); |
| 1627 | } |
| 1628 | } |
| 1629 | |
| 1630 | // default key actions |
| 1631 | for ( DefKeyAction ka : DEF_KEY_ACTIONS ) { |
| 1632 | props.applyDefault(ka.getProp(), ka.action.id); |
| 1633 | } |
| 1634 | // default tap zone actions |
| 1635 | for ( DefTapAction ka : DEF_TAP_ACTIONS ) { |
| 1636 | if ( ka.longPress ) |
| 1637 | props.applyDefault(ReaderView.PROP_APP_TAP_ZONE_ACTIONS_TAP + ".long." + ka.zone, ka.action.id); |
| 1638 | else |
| 1639 | props.applyDefault(ReaderView.PROP_APP_TAP_ZONE_ACTIONS_TAP + "." + ka.zone, ka.action.id); |
| 1640 | } |
| 1641 | |
| 1642 | if ( DeviceInfo.EINK_SCREEN ) { |
| 1643 | props.applyDefault(ReaderView.PROP_PAGE_ANIMATION, ReaderView.PAGE_ANIMATION_NONE); |
| 1644 | } else { |
| 1645 | props.applyDefault(ReaderView.PROP_PAGE_ANIMATION, ReaderView.PAGE_ANIMATION_SLIDE2); |
| 1646 | } |
| 1647 | |
| 1648 | props.applyDefault(ReaderView.PROP_APP_THEME, DeviceInfo.FORCE_LIGHT_THEME ? "WHITE" : "LIGHT"); |
| 1649 | props.applyDefault(ReaderView.PROP_APP_THEME_DAY, DeviceInfo.FORCE_LIGHT_THEME ? "WHITE" : "LIGHT"); |
| 1650 | props.applyDefault(ReaderView.PROP_APP_THEME_NIGHT, DeviceInfo.FORCE_LIGHT_THEME ? "BLACK" : "DARK"); |
| 1651 | props.applyDefault(ReaderView.PROP_APP_SELECTION_PERSIST, "0"); |
| 1652 | props.applyDefault(ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK, "3"); |
| 1653 | if ("1".equals(props.getProperty(ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK))) |
| 1654 | props.setProperty(ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK, "3"); |
| 1655 | props.applyDefault(ReaderView.PROP_APP_BOOK_PROPERTY_SCAN_ENABLED, "1"); |
| 1656 | props.applyDefault(ReaderView.PROP_APP_KEY_BACKLIGHT_OFF, DeviceInfo.SAMSUNG_BUTTONS_HIGHLIGHT_PATCH ? "0" : "1"); |
| 1657 | // autodetect best initial font size based on display resolution |
| 1658 | DisplayMetrics m = new DisplayMetrics(); |
| 1659 | getWindowManager().getDefaultDisplay().getMetrics(m); |
| 1660 | int screenWidth = m.widthPixels;//getWindowManager().getDefaultDisplay().getWidth(); |
| 1661 | int fontSize = 20; |
| 1662 | String hmargin = "4"; |
| 1663 | String vmargin = "2"; |
| 1664 | if ( screenWidth<=320 ) { |
| 1665 | fontSize = 20; |
| 1666 | hmargin = "4"; |
| 1667 | vmargin = "2"; |
| 1668 | } else if ( screenWidth<=400 ) { |
| 1669 | fontSize = 26; |
| 1670 | hmargin = "10"; |
| 1671 | vmargin = "4"; |
| 1672 | } else if ( screenWidth<=600 ) { |
| 1673 | fontSize = 32; |
| 1674 | hmargin = "20"; |
no test coverage detected