1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

ColorProfile moved into ViewOptions

This commit is contained in:
Nikolay Pultsin 2014-02-01 09:51:44 +00:00
parent 4659a33f0e
commit 19206273d6
7 changed files with 23 additions and 32 deletions

View file

@ -63,7 +63,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final FooterOptions footerOptions = fbReader.FooterOptions;
final PageTurningOptions pageTurningOptions = new PageTurningOptions();
final ImageOptions imageOptions = new ImageOptions();
final ColorProfile profile = fbReader.getColorProfile();
final ColorProfile profile = viewOptions.getColorProfile();
final ZLTextStyleCollection collection = fbReader.TextStyleCollection;
final ZLKeyBindings keyBindings = new ZLKeyBindings();

View file

@ -27,8 +27,8 @@ import org.geometerplus.zlibrary.core.options.ZLStringOption;
import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.fbreader.fbreader.ColorProfile;
import org.geometerplus.fbreader.fbreader.WallpapersUtil;
import org.geometerplus.fbreader.fbreader.options.ColorProfile;
class WallpaperPreference extends ZLStringListPreference {
private final ZLStringOption myOption;

View file

@ -152,24 +152,6 @@ public final class FBReaderApp extends ZLApplication {
}
}
private ColorProfile myColorProfile;
public ColorProfile getColorProfile() {
final String name = getColorProfileName();
if (myColorProfile == null || !name.equals(myColorProfile.Name)) {
myColorProfile = ColorProfile.get(name);
}
return myColorProfile;
}
public String getColorProfileName() {
return ViewOptions.ColorProfileName.getValue();
}
public void setColorProfileName(String name) {
ViewOptions.ColorProfileName.setValue(name);
}
public ZLKeyBindings keyBindings() {
return myBindings;
}

View file

@ -380,7 +380,7 @@ public final class FBView extends ZLTextView {
@Override
public ZLFile getWallpaperFile() {
final String filePath = myReader.getColorProfile().WallpaperOption.getValue();
final String filePath = myReader.ViewOptions.getColorProfile().WallpaperOption.getValue();
if ("".equals(filePath)) {
return null;
}
@ -401,22 +401,22 @@ public final class FBView extends ZLTextView {
@Override
public ZLColor getBackgroundColor() {
return myReader.getColorProfile().BackgroundOption.getValue();
return myReader.ViewOptions.getColorProfile().BackgroundOption.getValue();
}
@Override
public ZLColor getSelectionBackgroundColor() {
return myReader.getColorProfile().SelectionBackgroundOption.getValue();
return myReader.ViewOptions.getColorProfile().SelectionBackgroundOption.getValue();
}
@Override
public ZLColor getSelectionForegroundColor() {
return myReader.getColorProfile().SelectionForegroundOption.getValue();
return myReader.ViewOptions.getColorProfile().SelectionForegroundOption.getValue();
}
@Override
public ZLColor getTextColor(ZLTextHyperlink hyperlink) {
final ColorProfile profile = myReader.getColorProfile();
final ColorProfile profile = myReader.ViewOptions.getColorProfile();
switch (hyperlink.Type) {
default:
case FBHyperlinkType.NONE:
@ -432,7 +432,7 @@ public final class FBView extends ZLTextView {
@Override
public ZLColor getHighlightingBackgroundColor() {
return myReader.getColorProfile().HighlightingOption.getValue();
return myReader.ViewOptions.getColorProfile().HighlightingOption.getValue();
}
private class Footer implements FooterArea {
@ -498,7 +498,7 @@ public final class FBView extends ZLTextView {
//final ZLColor bgColor = getBackgroundColor();
// TODO: separate color option for footer color
final ZLColor fgColor = getTextColor(ZLTextHyperlink.NO_LINK);
final ZLColor fillColor = myReader.getColorProfile().FooterFillOption.getValue();
final ZLColor fillColor = myReader.ViewOptions.getColorProfile().FooterFillOption.getValue();
final int left = getLeftMargin();
final int right = context.getWidth() - getRightMargin();
@ -652,7 +652,7 @@ public final class FBView extends ZLTextView {
@Override
protected ZLPaintContext.ColorAdjustingMode getAdjustingModeForImages() {
if (myReader.ImageOptions.MatchBackground.getValue()) {
if (ColorProfile.DAY.equals(myReader.getColorProfile().Name)) {
if (ColorProfile.DAY.equals(myReader.ViewOptions.getColorProfile().Name)) {
return ZLPaintContext.ColorAdjustingMode.DARKEN_TO_BACKGROUND;
} else {
return ZLPaintContext.ColorAdjustingMode.LIGHTEN_TO_BACKGROUND;

View file

@ -29,12 +29,12 @@ class SwitchProfileAction extends FBAction {
@Override
public boolean isVisible() {
return !myProfileName.equals(Reader.getColorProfileName());
return !myProfileName.equals(Reader.ViewOptions.ColorProfileName.getValue());
}
@Override
protected void run(Object ... params) {
Reader.setColorProfileName(myProfileName);
Reader.ViewOptions.ColorProfileName.setValue(myProfileName);
Reader.getViewWidget().reset();
Reader.getViewWidget().repaint();
}

View file

@ -17,7 +17,7 @@
* 02110-1301, USA.
*/
package org.geometerplus.fbreader.fbreader;
package org.geometerplus.fbreader.fbreader.options;
import java.util.*;

View file

@ -23,7 +23,6 @@ import org.geometerplus.zlibrary.core.library.ZLibrary;
import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.fbreader.fbreader.FBView;
import org.geometerplus.fbreader.fbreader.ColorProfile;
public class ViewOptions {
public final ZLBooleanOption TwoColumnView;
@ -36,6 +35,8 @@ public class ViewOptions {
public final ZLIntegerRangeOption FooterHeight;
public final ZLStringOption ColorProfileName;
private ColorProfile myColorProfile;
public ViewOptions() {
final ZLibrary zlibrary = ZLibrary.Instance();
@ -63,4 +64,12 @@ public class ViewOptions {
ColorProfileName =
new ZLStringOption("Options", "ColorProfile", ColorProfile.DAY);
}
public ColorProfile getColorProfile() {
final String name = ColorProfileName.getValue();
if (myColorProfile == null || !name.equals(myColorProfile.Name)) {
myColorProfile = ColorProfile.get(name);
}
return myColorProfile;
}
}