public void addCustomViewOptions() { viewOptions.clearCustomOptions(); final Collection<String> names = files.getUpdateSiteNames(); if (names.size() > 1) for (final String name : names) viewOptions.addCustomOption( "View files of the '" + name + "' site", files.forUpdateSite(name)); }
@Override protected ZLPaintContext.ColorAdjustingMode getAdjustingModeForImages() { if (myReader.ImageOptions.MatchBackground.getValue()) { if (ColorProfile.DAY.equals(myViewOptions.getColorProfile().Name)) { return ZLPaintContext.ColorAdjustingMode.DARKEN_TO_BACKGROUND; } else { return ZLPaintContext.ColorAdjustingMode.LIGHTEN_TO_BACKGROUND; } } else { return ZLPaintContext.ColorAdjustingMode.NONE; } }
@Override public ZLFile getWallpaperFile() { final String filePath = myViewOptions.getColorProfile().WallpaperOption.getValue(); if ("".equals(filePath)) { return null; } final ZLFile file = ZLFile.createFileByPath(filePath); if (file == null || !file.exists()) { return null; } return file; }
public void updateFilesTable() { Iterable<FileObject> view = viewOptions.getView(table); final Set<FileObject> selected = new HashSet<FileObject>(); for (final FileObject file : table.getSelectedFiles()) selected.add(file); table.clearSelection(); final String search = searchTerm.getText().trim(); if (!search.equals("")) view = FilesCollection.filter(search, view); // Directly update the table for display table.setFiles(view); for (int i = 0; i < table.getRowCount(); i++) if (selected.contains(table.getFile(i))) table.addRowSelectionInterval(i, i); }
@Override public ZLColor getTextColor(ZLTextHyperlink hyperlink) { final ColorProfile profile = myViewOptions.getColorProfile(); switch (hyperlink.Type) { default: case FBHyperlinkType.NONE: return profile.RegularTextOption.getValue(); case FBHyperlinkType.INTERNAL: case FBHyperlinkType.FOOTNOTE: return myReader.Collection.isHyperlinkVisited(myReader.getCurrentBook(), hyperlink.Id) ? profile.VisitedHyperlinkTextOption.getValue() : profile.HyperlinkTextOption.getValue(); case FBHyperlinkType.EXTERNAL: return profile.HyperlinkTextOption.getValue(); } }
@Override public ZLColor getHighlightingForegroundColor() { return myViewOptions.getColorProfile().HighlightingForegroundOption.getValue(); }
@Override public ZLColor getSelectionForegroundColor() { return myViewOptions.getColorProfile().SelectionForegroundOption.getValue(); }
@Override public ZLColor getBackgroundColor() { return myViewOptions.getColorProfile().BackgroundOption.getValue(); }
@Override public ZLPaintContext.FillMode getFillMode() { return getWallpaperFile() instanceof ZLResourceFile ? ZLPaintContext.FillMode.tileMirror : myViewOptions.getColorProfile().FillModeOption.getValue(); }
@Override public ZLTextStyleCollection getTextStyleCollection() { return myViewOptions.getTextStyleCollection(); }
public void setViewOption(final ViewOptions.Option option) { viewOptions.setSelectedItem(option); updateFilesTable(); }
public UpdaterFrame(final FilesCollection files) { super("ImageJ Updater"); setPreferredSize(new Dimension(780, 560)); this.files = files; setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { quit(); } }); // ======== Start: LEFT PANEL ======== final JPanel leftPanel = new JPanel(); final GridBagLayout gb = new GridBagLayout(); leftPanel.setLayout(gb); final GridBagConstraints c = new GridBagConstraints( 0, 0, // x, y 9, 1, // rows, cols 0, 0, // weightx, weighty GridBagConstraints.NORTHWEST, // anchor GridBagConstraints.HORIZONTAL, // fill new Insets(0, 0, 0, 0), 0, 0); // ipadx, ipady searchTerm = new JTextField(); searchTerm .getDocument() .addDocumentListener( new DocumentListener() { @Override public void changedUpdate(final DocumentEvent e) { updateFilesTable(); } @Override public void removeUpdate(final DocumentEvent e) { updateFilesTable(); } @Override public void insertUpdate(final DocumentEvent e) { updateFilesTable(); } }); searchPanel = SwingTools.labelComponentRigid("Search:", searchTerm); gb.setConstraints(searchPanel, c); leftPanel.add(searchPanel); Component box = Box.createRigidArea(new Dimension(0, 10)); c.gridy = 1; gb.setConstraints(box, c); leftPanel.add(box); viewOptions = new ViewOptions(); viewOptions.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { updateFilesTable(); } }); viewOptionsPanel = SwingTools.labelComponentRigid("View Options:", viewOptions); c.gridy = 2; gb.setConstraints(viewOptionsPanel, c); leftPanel.add(viewOptionsPanel); box = Box.createRigidArea(new Dimension(0, 10)); c.gridy = 3; gb.setConstraints(box, c); leftPanel.add(box); // Create labels to annotate table chooseLabel = SwingTools.label("Please choose what you want to install/uninstall:", null); c.gridy = 4; gb.setConstraints(chooseLabel, c); leftPanel.add(chooseLabel); box = Box.createRigidArea(new Dimension(0, 5)); c.gridy = 5; gb.setConstraints(box, c); leftPanel.add(box); // Label text for file summaries fileSummary = new JLabel(); summaryPanel = SwingTools.horizontalPanel(); summaryPanel.add(fileSummary); summaryPanel.add(Box.createHorizontalGlue()); // Create the file table and set up its scrollpane table = new FileTable(this); table.getSelectionModel().addListSelectionListener(this); final JScrollPane fileListScrollpane = new JScrollPane(table); fileListScrollpane.getViewport().setBackground(table.getBackground()); c.gridy = 6; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; gb.setConstraints(fileListScrollpane, c); leftPanel.add(fileListScrollpane); box = Box.createRigidArea(new Dimension(0, 5)); c.gridy = 7; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; gb.setConstraints(box, c); leftPanel.add(box); // ======== End: LEFT PANEL ======== // ======== Start: RIGHT PANEL ======== rightPanel = SwingTools.verticalPanel(); rightPanel.add(Box.createVerticalGlue()); fileDetails = new FileDetails(this); SwingTools.tab(fileDetails, "Details", "Individual file information", 350, 315, rightPanel); // TODO: put this into SwingTools, too rightPanel.add(Box.createRigidArea(new Dimension(0, 25))); // ======== End: RIGHT PANEL ======== // ======== Start: TOP PANEL (LEFT + RIGHT) ======== final JPanel topPanel = SwingTools.horizontalPanel(); topPanel.add(leftPanel); topPanel.add(Box.createRigidArea(new Dimension(15, 0))); topPanel.add(rightPanel); topPanel.setBorder(BorderFactory.createEmptyBorder(20, 15, 5, 15)); // ======== End: TOP PANEL (LEFT + RIGHT) ======== // ======== Start: BOTTOM PANEL ======== final JPanel bottomPanel2 = SwingTools.horizontalPanel(); final JPanel bottomPanel = SwingTools.horizontalPanel(); bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 15, 15)); bottomPanel.add(new FileAction("Keep as-is", null)); bottomPanel.add(Box.createRigidArea(new Dimension(15, 0))); bottomPanel.add(new FileAction("Install", Action.INSTALL, "Update", Action.UPDATE)); bottomPanel.add(Box.createRigidArea(new Dimension(15, 0))); bottomPanel.add(new FileAction("Uninstall", Action.UNINSTALL)); bottomPanel.add(Box.createHorizontalGlue()); // Button to start actions apply = SwingTools.button( "Apply changes", "Start installing/uninstalling files", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { applyChanges(); } }, bottomPanel); apply.setEnabled(files.hasChanges()); // Manage update sites updateSites = SwingTools.button( "Manage update sites", "Manage multiple update sites for updating and uploading", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { new SitesDialog( UpdaterFrame.this, UpdaterFrame.this.files, UpdaterFrame.this.files.hasUploadableSites()) .setVisible(true); } }, bottomPanel2); // TODO: unify upload & apply changes (probably apply changes first, then // upload) // includes button to upload to server if is a Developer using bottomPanel2.add(Box.createRigidArea(new Dimension(15, 0))); upload = SwingTools.button( "Upload to server", "Upload selected files to server", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { new Thread() { @Override public void run() { try { upload(); } catch (final InstantiationException e) { Log.error(e); error("Could not upload (possibly unknown protocol)"); } } }.start(); } }, bottomPanel2); upload.setVisible(files.hasUploadableSites()); enableUploadOrNot(); final IJ1Plugin fileChanges = IJ1Plugin.discover("fiji.scripting.ShowPluginChanges"); if (fileChanges != null && files.prefix(".git").isDirectory()) { bottomPanel2.add(Box.createRigidArea(new Dimension(15, 0))); showChanges = SwingTools.button( "Show changes", "Show the changes in Git since the last upload", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { new Thread() { @Override public void run() { for (final FileObject file : table.getSelectedFiles()) fileChanges.run(file.filename); } }.start(); } }, bottomPanel2); } final IJ1Plugin rebuild = IJ1Plugin.discover("fiji.scripting.RunFijiBuild"); if (rebuild != null && files.prefix(".git").isDirectory()) { bottomPanel2.add(Box.createRigidArea(new Dimension(15, 0))); rebuildButton = SwingTools.button( "Rebuild", "Rebuild using Fiji Build", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { new Thread() { @Override public void run() { String list = ""; final List<String> names = new ArrayList<String>(); for (final FileObject file : table.getSelectedFiles()) { list += ("".equals(list) ? "" : " ") + file.filename + "-rebuild"; names.add(file.filename); } if (!"".equals(list)) rebuild.run(list); final Checksummer checksummer = new Checksummer(files, getProgress("Checksumming rebuilt files")); checksummer.updateFromLocal(names); filesChanged(); updateFilesTable(); } }.start(); } }, bottomPanel2); } bottomPanel2.add(Box.createHorizontalGlue()); bottomPanel.add(Box.createRigidArea(new Dimension(15, 0))); easy = SwingTools.button( "Toggle easy mode", "Toggle between easy and verbose mode", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { toggleEasyMode(); } }, bottomPanel); bottomPanel.add(Box.createRigidArea(new Dimension(15, 0))); cancel = SwingTools.button( "Close", "Exit Update Manager", new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { quit(); } }, bottomPanel); // ======== End: BOTTOM PANEL ======== getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); getContentPane().add(topPanel); getContentPane().add(summaryPanel); getContentPane().add(bottomPanel); getContentPane().add(bottomPanel2); getRootPane().setDefaultButton(apply); table.getModel().addTableModelListener(this); pack(); SwingTools.addAccelerator( cancel, (JComponent) getContentPane(), cancel.getActionListeners()[0], KeyEvent.VK_ESCAPE, 0); addCustomViewOptions(); }
@Override protected void init(Intent intent) { final Config config = Config.Instance(); config.requestAllValuesForGroup("Style"); config.requestAllValuesForGroup("Options"); config.requestAllValuesForGroup("LookNFeel"); config.requestAllValuesForGroup("Fonts"); config.requestAllValuesForGroup("Files"); config.requestAllValuesForGroup("Scrolling"); config.requestAllValuesForGroup("Colors"); setResult(FBReader.RESULT_REPAINT); final ViewOptions viewOptions = new ViewOptions(); final MiscOptions miscOptions = new MiscOptions(); final FooterOptions footerOptions = viewOptions.getFooterOptions(); final PageTurningOptions pageTurningOptions = new PageTurningOptions(); final ImageOptions imageOptions = new ImageOptions(); final ColorProfile profile = viewOptions.getColorProfile(); final ZLTextStyleCollection collection = viewOptions.getTextStyleCollection(); final ZLKeyBindings keyBindings = new ZLKeyBindings(); final ZLAndroidLibrary androidLibrary = (ZLAndroidLibrary) ZLAndroidLibrary.Instance(); // TODO: use user-defined locale, not the default one, // or set user-defined locale as default final String decimalSeparator = String.valueOf(new DecimalFormatSymbols(Locale.getDefault()).getDecimalSeparator()); final Screen directoriesScreen = createPreferenceScreen("directories"); final Runnable libraryUpdater = new Runnable() { public void run() { final BookCollectionShadow bookCollection = new BookCollectionShadow(); bookCollection.bindToService( PreferenceActivity.this, new Runnable() { public void run() { bookCollection.reset(false); bookCollection.unbind(); } }); } }; directoriesScreen.addPreference( myChooserCollection.createPreference( directoriesScreen.Resource, "bookPath", Paths.BookPathOption, libraryUpdater)); directoriesScreen.addPreference( myChooserCollection.createPreference( directoriesScreen.Resource, "downloadDir", Paths.DownloadsDirectoryOption, libraryUpdater)); final PreferenceSet fontReloader = new PreferenceSet.Reloader(); directoriesScreen.addPreference( myChooserCollection.createPreference( directoriesScreen.Resource, "fontPath", Paths.FontPathOption, fontReloader)); final PreferenceSet wallpaperReloader = new PreferenceSet.Reloader(); directoriesScreen.addPreference( myChooserCollection.createPreference( directoriesScreen.Resource, "wallpaperPath", Paths.WallpaperPathOption, wallpaperReloader)); directoriesScreen.addPreference( myChooserCollection.createPreference( directoriesScreen.Resource, "tempDir", Paths.TempDirectoryOption, null)); final Screen appearanceScreen = createPreferenceScreen("appearance"); appearanceScreen.addPreference( new LanguagePreference( this, appearanceScreen.Resource, "language", ZLResource.interfaceLanguages()) { @Override protected void init() { setInitialValue(ZLResource.getLanguageOption().getValue()); } @Override protected void setLanguage(String code) { final ZLStringOption languageOption = ZLResource.getLanguageOption(); if (!code.equals(languageOption.getValue())) { languageOption.setValue(code); finish(); startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("fbreader-action:preferences#appearance"))); } } }); appearanceScreen.addPreference( new ZLStringChoicePreference( this, appearanceScreen.Resource, "screenOrientation", androidLibrary.getOrientationOption(), androidLibrary.allOrientations())); appearanceScreen.addPreference( new ZLBooleanPreference( this, viewOptions.TwoColumnView, appearanceScreen.Resource, "twoColumnView")); appearanceScreen.addPreference( new ZLBooleanPreference( this, miscOptions.AllowScreenBrightnessAdjustment, appearanceScreen.Resource, "allowScreenBrightnessAdjustment") { private final int myLevel = androidLibrary.ScreenBrightnessLevelOption.getValue(); @Override protected void onClick() { super.onClick(); androidLibrary.ScreenBrightnessLevelOption.setValue(isChecked() ? myLevel : 0); } }); appearanceScreen.addPreference( new BatteryLevelToTurnScreenOffPreference( this, androidLibrary.BatteryLevelToTurnScreenOffOption, appearanceScreen.Resource, "dontTurnScreenOff")); /* appearanceScreen.addPreference(new ZLBooleanPreference( this, androidLibrary.DontTurnScreenOffDuringChargingOption, appearanceScreen.Resource, "dontTurnScreenOffDuringCharging" )); */ appearanceScreen.addOption(androidLibrary.ShowStatusBarOption, "showStatusBar"); appearanceScreen.addOption(androidLibrary.DisableButtonLightsOption, "disableButtonLights"); if (DeviceType.Instance().isEInk()) { final EInkOptions einkOptions = new EInkOptions(); final Screen einkScreen = createPreferenceScreen("eink"); final PreferenceSet einkPreferences = new PreferenceSet.Enabler() { @Override protected Boolean detectState() { return einkOptions.EnableFastRefresh.getValue(); } }; einkScreen.addPreference( new ZLBooleanPreference( this, einkOptions.EnableFastRefresh, einkScreen.Resource, "enableFastRefresh") { @Override protected void onClick() { super.onClick(); einkPreferences.run(); } }); final ZLIntegerRangePreference updateIntervalPreference = new ZLIntegerRangePreference( this, einkScreen.Resource.getResource("interval"), einkOptions.UpdateInterval); einkScreen.addPreference(updateIntervalPreference); einkPreferences.add(updateIntervalPreference); einkPreferences.run(); } final Screen textScreen = createPreferenceScreen("text"); final Screen fontPropertiesScreen = textScreen.createPreferenceScreen("fontProperties"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.AntiAliasOption, "antiAlias"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.DeviceKerningOption, "deviceKerning"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.DitheringOption, "dithering"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.SubpixelOption, "subpixel"); final ZLTextBaseStyle baseStyle = collection.getBaseStyle(); final FontPreference fontPreference = new FontPreference(this, textScreen.Resource, "font", baseStyle.FontFamilyOption, false); textScreen.addPreference(fontPreference); fontReloader.add(fontPreference); textScreen.addPreference( new ZLIntegerRangePreference( this, textScreen.Resource.getResource("fontSize"), baseStyle.FontSizeOption)); textScreen.addPreference( new FontStylePreference( this, textScreen.Resource, "fontStyle", baseStyle.BoldOption, baseStyle.ItalicOption)); final ZLIntegerRangeOption spaceOption = baseStyle.LineSpaceOption; final String[] spacings = new String[spaceOption.MaxValue - spaceOption.MinValue + 1]; for (int i = 0; i < spacings.length; ++i) { final int val = spaceOption.MinValue + i; spacings[i] = (char) (val / 10 + '0') + decimalSeparator + (char) (val % 10 + '0'); } textScreen.addPreference( new ZLChoicePreference(this, textScreen.Resource, "lineSpacing", spaceOption, spacings)); final String[] alignments = {"left", "right", "center", "justify"}; textScreen.addPreference( new ZLChoicePreference( this, textScreen.Resource, "alignment", baseStyle.AlignmentOption, alignments)); textScreen.addOption(baseStyle.AutoHyphenationOption, "autoHyphenations"); final Screen moreStylesScreen = textScreen.createPreferenceScreen("more"); for (ZLTextNGStyleDescription description : collection.getDescriptionList()) { final Screen ngScreen = moreStylesScreen.createPreferenceScreen(description.Name); ngScreen.addPreference( new FontPreference( this, textScreen.Resource, "font", description.FontFamilyOption, true)); ngScreen.addPreference( new StringPreference( this, description.FontSizeOption, StringPreference.Constraint.POSITIVE_LENGTH, textScreen.Resource, "fontSize")); ngScreen.addPreference( new ZLStringChoicePreference( this, textScreen.Resource, "bold", description.FontWeightOption, new String[] {"inherit", "normal", "bold"})); ngScreen.addPreference( new ZLStringChoicePreference( this, textScreen.Resource, "italic", description.FontStyleOption, new String[] {"inherit", "normal", "italic"})); ngScreen.addPreference( new ZLStringChoicePreference( this, textScreen.Resource, "textDecoration", description.TextDecorationOption, new String[] {"inherit", "none", "underline", "line-through"})); ngScreen.addPreference( new ZLStringChoicePreference( this, textScreen.Resource, "allowHyphenations", description.HyphenationOption, new String[] {"inherit", "none", "auto"})); ngScreen.addPreference( new ZLStringChoicePreference( this, textScreen.Resource, "alignment", description.AlignmentOption, new String[] {"inherit", "left", "right", "center", "justify"})); ngScreen.addPreference( new StringPreference( this, description.LineHeightOption, StringPreference.Constraint.PERCENT, textScreen.Resource, "lineSpacing")); ngScreen.addPreference( new StringPreference( this, description.MarginTopOption, StringPreference.Constraint.LENGTH, textScreen.Resource, "spaceBefore")); ngScreen.addPreference( new StringPreference( this, description.MarginBottomOption, StringPreference.Constraint.LENGTH, textScreen.Resource, "spaceAfter")); ngScreen.addPreference( new StringPreference( this, description.MarginLeftOption, StringPreference.Constraint.LENGTH, textScreen.Resource, "leftIndent")); ngScreen.addPreference( new StringPreference( this, description.MarginRightOption, StringPreference.Constraint.LENGTH, textScreen.Resource, "rightIndent")); ngScreen.addPreference( new StringPreference( this, description.TextIndentOption, StringPreference.Constraint.LENGTH, textScreen.Resource, "firstLineIndent")); ngScreen.addPreference( new StringPreference( this, description.VerticalAlignOption, StringPreference.Constraint.LENGTH, textScreen.Resource, "verticalAlignment")); } final PreferenceSet footerPreferences = new PreferenceSet.Enabler() { @Override protected Boolean detectState() { return viewOptions.ScrollbarType.getValue() == FBView.SCROLLBAR_SHOW_AS_FOOTER; } }; final PreferenceSet bgPreferences = new PreferenceSet.Enabler() { @Override protected Boolean detectState() { return "".equals(profile.WallpaperOption.getValue()); } }; final Screen cssScreen = createPreferenceScreen("css"); cssScreen.addOption(baseStyle.UseCSSFontFamilyOption, "fontFamily"); cssScreen.addOption(baseStyle.UseCSSFontSizeOption, "fontSize"); cssScreen.addOption(baseStyle.UseCSSTextAlignmentOption, "textAlignment"); cssScreen.addOption(baseStyle.UseCSSMarginsOption, "margins"); final Screen colorsScreen = createPreferenceScreen("colors"); final WallpaperPreference wallpaperPreference = new WallpaperPreference(this, profile, colorsScreen.Resource, "background") { @Override protected void onDialogClosed(boolean result) { super.onDialogClosed(result); bgPreferences.run(); } }; colorsScreen.addPreference(wallpaperPreference); wallpaperReloader.add(wallpaperPreference); bgPreferences.add(colorsScreen.addOption(profile.BackgroundOption, "backgroundColor")); bgPreferences.run(); colorsScreen.addOption(profile.HighlightingOption, "highlighting"); colorsScreen.addOption(profile.RegularTextOption, "text"); colorsScreen.addOption(profile.HyperlinkTextOption, "hyperlink"); colorsScreen.addOption(profile.VisitedHyperlinkTextOption, "hyperlinkVisited"); colorsScreen.addOption(profile.FooterFillOption, "footer"); colorsScreen.addOption(profile.SelectionBackgroundOption, "selectionBackground"); colorsScreen.addOption(profile.SelectionForegroundOption, "selectionForeground"); final Screen marginsScreen = createPreferenceScreen("margins"); marginsScreen.addPreference( new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("left"), viewOptions.LeftMargin)); marginsScreen.addPreference( new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("right"), viewOptions.RightMargin)); marginsScreen.addPreference( new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("top"), viewOptions.TopMargin)); marginsScreen.addPreference( new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("bottom"), viewOptions.BottomMargin)); marginsScreen.addPreference( new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("spaceBetweenColumns"), viewOptions.SpaceBetweenColumns)); final Screen statusLineScreen = createPreferenceScreen("scrollBar"); final String[] scrollBarTypes = {"hide", "show", "showAsProgress", "showAsFooter"}; statusLineScreen.addPreference( new ZLChoicePreference( this, statusLineScreen.Resource, "scrollbarType", viewOptions.ScrollbarType, scrollBarTypes) { @Override protected void onDialogClosed(boolean result) { super.onDialogClosed(result); footerPreferences.run(); } }); footerPreferences.add( statusLineScreen.addPreference( new ZLIntegerRangePreference( this, statusLineScreen.Resource.getResource("footerHeight"), viewOptions.FooterHeight))); footerPreferences.add(statusLineScreen.addOption(profile.FooterFillOption, "footerColor")); footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowTOCMarks, "tocMarks")); footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowProgress, "showProgress")); footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowClock, "showClock")); footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowBattery, "showBattery")); footerPreferences.add( statusLineScreen.addPreference( new FontPreference( this, statusLineScreen.Resource, "font", footerOptions.Font, false))); footerPreferences.run(); /* final Screen colorProfileScreen = createPreferenceScreen("colorProfile"); final ZLResource resource = colorProfileScreen.Resource; colorProfileScreen.setSummary(ColorProfilePreference.createTitle(resource, fbreader.getColorProfileName())); for (String key : ColorProfile.names()) { colorProfileScreen.addPreference(new ColorProfilePreference( this, fbreader, colorProfileScreen, key, ColorProfilePreference.createTitle(resource, key) )); } */ final Screen scrollingScreen = createPreferenceScreen("scrolling"); scrollingScreen.addOption(pageTurningOptions.FingerScrolling, "fingerScrolling"); scrollingScreen.addOption(miscOptions.EnableDoubleTap, "enableDoubleTapDetection"); final PreferenceSet volumeKeysPreferences = new PreferenceSet.Enabler() { @Override protected Boolean detectState() { return keyBindings.hasBinding(KeyEvent.KEYCODE_VOLUME_UP, false); } }; scrollingScreen.addPreference( new ZLCheckBoxPreference(this, scrollingScreen.Resource, "volumeKeys") { { setChecked(keyBindings.hasBinding(KeyEvent.KEYCODE_VOLUME_UP, false)); } @Override protected void onClick() { super.onClick(); if (isChecked()) { keyBindings.bindKey( KeyEvent.KEYCODE_VOLUME_DOWN, false, ActionCode.VOLUME_KEY_SCROLL_FORWARD); keyBindings.bindKey( KeyEvent.KEYCODE_VOLUME_UP, false, ActionCode.VOLUME_KEY_SCROLL_BACK); } else { keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, FBReaderApp.NoAction); keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, FBReaderApp.NoAction); } volumeKeysPreferences.run(); } }); volumeKeysPreferences.add( scrollingScreen.addPreference( new ZLCheckBoxPreference(this, scrollingScreen.Resource, "invertVolumeKeys") { { setChecked( ActionCode.VOLUME_KEY_SCROLL_FORWARD.equals( keyBindings.getBinding(KeyEvent.KEYCODE_VOLUME_UP, false))); } @Override protected void onClick() { super.onClick(); if (isChecked()) { keyBindings.bindKey( KeyEvent.KEYCODE_VOLUME_DOWN, false, ActionCode.VOLUME_KEY_SCROLL_BACK); keyBindings.bindKey( KeyEvent.KEYCODE_VOLUME_UP, false, ActionCode.VOLUME_KEY_SCROLL_FORWARD); } else { keyBindings.bindKey( KeyEvent.KEYCODE_VOLUME_DOWN, false, ActionCode.VOLUME_KEY_SCROLL_FORWARD); keyBindings.bindKey( KeyEvent.KEYCODE_VOLUME_UP, false, ActionCode.VOLUME_KEY_SCROLL_BACK); } } })); volumeKeysPreferences.run(); scrollingScreen.addOption(pageTurningOptions.Animation, "animation"); scrollingScreen.addPreference( new AnimationSpeedPreference( this, scrollingScreen.Resource, "animationSpeed", pageTurningOptions.AnimationSpeed)); scrollingScreen.addOption(pageTurningOptions.Horizontal, "horizontal"); final Screen dictionaryScreen = createPreferenceScreen("dictionary"); final List<String> langCodes = ZLResource.languageCodes(); final ArrayList<Language> languages = new ArrayList<Language>(langCodes.size() + 1); for (String code : langCodes) { languages.add(new Language(code)); } Collections.sort(languages); languages.add( 0, new Language(Language.ANY_CODE, dictionaryScreen.Resource.getResource("targetLanguage"))); final LanguagePreference targetLanguagePreference = new LanguagePreference(this, dictionaryScreen.Resource, "targetLanguage", languages) { @Override protected void init() { setInitialValue(DictionaryUtil.TargetLanguageOption.getValue()); } @Override protected void setLanguage(String code) { DictionaryUtil.TargetLanguageOption.setValue(code); } }; DictionaryUtil.init( this, new Runnable() { public void run() { dictionaryScreen.addPreference( new DictionaryPreference( PreferenceActivity.this, dictionaryScreen.Resource, "dictionary", DictionaryUtil.singleWordTranslatorOption(), DictionaryUtil.dictionaryInfos(PreferenceActivity.this, true)) { @Override protected void onDialogClosed(boolean result) { super.onDialogClosed(result); targetLanguagePreference.setEnabled( DictionaryUtil.getCurrentDictionaryInfo(true) .SupportsTargetLanguageSetting); } }); dictionaryScreen.addPreference( new DictionaryPreference( PreferenceActivity.this, dictionaryScreen.Resource, "translator", DictionaryUtil.multiWordTranslatorOption(), DictionaryUtil.dictionaryInfos(PreferenceActivity.this, false))); dictionaryScreen.addPreference( new ZLBooleanPreference( PreferenceActivity.this, miscOptions.NavigateAllWords, dictionaryScreen.Resource, "navigateOverAllWords")); dictionaryScreen.addOption(miscOptions.WordTappingAction, "tappingAction"); dictionaryScreen.addPreference(targetLanguagePreference); targetLanguagePreference.setEnabled( DictionaryUtil.getCurrentDictionaryInfo(true).SupportsTargetLanguageSetting); } }); final Screen imagesScreen = createPreferenceScreen("images"); imagesScreen.addOption(imageOptions.TapAction, "tappingAction"); imagesScreen.addOption(imageOptions.FitToScreen, "fitImagesToScreen"); imagesScreen.addOption(imageOptions.ImageViewBackground, "backgroundColor"); imagesScreen.addOption(imageOptions.MatchBackground, "matchBackground"); final CancelMenuHelper cancelMenuHelper = new CancelMenuHelper(); final Screen cancelMenuScreen = createPreferenceScreen("cancelMenu"); cancelMenuScreen.addOption(cancelMenuHelper.ShowLibraryItemOption, "library"); cancelMenuScreen.addOption(cancelMenuHelper.ShowNetworkLibraryItemOption, "networkLibrary"); cancelMenuScreen.addOption(cancelMenuHelper.ShowPreviousBookItemOption, "previousBook"); cancelMenuScreen.addOption(cancelMenuHelper.ShowPositionItemsOption, "positions"); final String[] backKeyActions = {ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU}; cancelMenuScreen.addPreference( new ZLStringChoicePreference( this, cancelMenuScreen.Resource, "backKeyAction", keyBindings.getOption(KeyEvent.KEYCODE_BACK, false), backKeyActions)); final String[] backKeyLongPressActions = { ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction }; cancelMenuScreen.addPreference( new ZLStringChoicePreference( this, cancelMenuScreen.Resource, "backKeyLongPressAction", keyBindings.getOption(KeyEvent.KEYCODE_BACK, true), backKeyLongPressActions)); final Screen tipsScreen = createPreferenceScreen("tips"); tipsScreen.addOption(TipsManager.Instance().ShowTipsOption, "showTips"); final Screen aboutScreen = createPreferenceScreen("about"); aboutScreen.addPreference( new InfoPreference( this, aboutScreen.Resource.getResource("version").getValue(), androidLibrary.getFullVersionName())); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "site")); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "email")); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "twitter")); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "facebook")); aboutScreen.addPreference( new ThirdPartyLibrariesPreference(this, aboutScreen.Resource, "thirdParty")); }