1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

FooterOptions moved into ViewOptions; PreferenceActivity does not refer FBReaderApp

This commit is contained in:
Nikolay Pultsin 2014-02-01 21:14:12 +00:00
parent 15d0fce647
commit 537c004667
4 changed files with 30 additions and 23 deletions

View file

@ -57,10 +57,9 @@ public class PreferenceActivity extends ZLPreferenceActivity {
protected void init(Intent intent) { protected void init(Intent intent) {
setResult(FBReader.RESULT_REPAINT); setResult(FBReader.RESULT_REPAINT);
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
final ViewOptions viewOptions = new ViewOptions(); final ViewOptions viewOptions = new ViewOptions();
final MiscOptions miscOptions = new MiscOptions(); final MiscOptions miscOptions = new MiscOptions();
final FooterOptions footerOptions = fbReader.FooterOptions; final FooterOptions footerOptions = viewOptions.getFooterOptions();
final PageTurningOptions pageTurningOptions = new PageTurningOptions(); final PageTurningOptions pageTurningOptions = new PageTurningOptions();
final ImageOptions imageOptions = new ImageOptions(); final ImageOptions imageOptions = new ImageOptions();
final ColorProfile profile = viewOptions.getColorProfile(); final ColorProfile profile = viewOptions.getColorProfile();

View file

@ -40,7 +40,6 @@ public final class FBReaderApp extends ZLApplication {
public final ImageOptions ImageOptions; public final ImageOptions ImageOptions;
public final ViewOptions ViewOptions; public final ViewOptions ViewOptions;
public final PageTurningOptions PageTurningOptions; public final PageTurningOptions PageTurningOptions;
public final FooterOptions FooterOptions;
private final ZLKeyBindings myBindings; private final ZLKeyBindings myBindings;
@ -49,7 +48,6 @@ public final class FBReaderApp extends ZLApplication {
ImageOptions = new ImageOptions(); ImageOptions = new ImageOptions();
ViewOptions = new ViewOptions(); ViewOptions = new ViewOptions();
PageTurningOptions = new PageTurningOptions(); PageTurningOptions = new PageTurningOptions();
FooterOptions = new FooterOptions();
myBindings = new ZLKeyBindings(); myBindings = new ZLKeyBindings();
} }

View file

@ -38,10 +38,12 @@ import org.geometerplus.fbreader.fbreader.options.*;
public final class FBView extends ZLTextView { public final class FBView extends ZLTextView {
private final FBReaderApp myReader; private final FBReaderApp myReader;
private final ViewOptions myViewOptions;
FBView(FBReaderApp reader) { FBView(FBReaderApp reader) {
super(reader); super(reader);
myReader = reader; myReader = reader;
myViewOptions = reader.ViewOptions;
} }
public void setModel(ZLTextModel model) { public void setModel(ZLTextModel model) {
@ -340,7 +342,7 @@ public final class FBView extends ZLTextView {
@Override @Override
public ZLTextStyleCollection getTextStyleCollection() { public ZLTextStyleCollection getTextStyleCollection() {
return myReader.ViewOptions.getTextStyleCollection(); return myViewOptions.getTextStyleCollection();
} }
@Override @Override
@ -350,37 +352,37 @@ public final class FBView extends ZLTextView {
@Override @Override
public int getLeftMargin() { public int getLeftMargin() {
return myReader.ViewOptions.LeftMargin.getValue(); return myViewOptions.LeftMargin.getValue();
} }
@Override @Override
public int getRightMargin() { public int getRightMargin() {
return myReader.ViewOptions.RightMargin.getValue(); return myViewOptions.RightMargin.getValue();
} }
@Override @Override
public int getTopMargin() { public int getTopMargin() {
return myReader.ViewOptions.TopMargin.getValue(); return myViewOptions.TopMargin.getValue();
} }
@Override @Override
public int getBottomMargin() { public int getBottomMargin() {
return myReader.ViewOptions.BottomMargin.getValue(); return myViewOptions.BottomMargin.getValue();
} }
@Override @Override
public int getSpaceBetweenColumns() { public int getSpaceBetweenColumns() {
return myReader.ViewOptions.SpaceBetweenColumns.getValue(); return myViewOptions.SpaceBetweenColumns.getValue();
} }
@Override @Override
public boolean twoColumnView() { public boolean twoColumnView() {
return getContextHeight() <= getContextWidth() && myReader.ViewOptions.TwoColumnView.getValue(); return getContextHeight() <= getContextWidth() && myViewOptions.TwoColumnView.getValue();
} }
@Override @Override
public ZLFile getWallpaperFile() { public ZLFile getWallpaperFile() {
final String filePath = myReader.ViewOptions.getColorProfile().WallpaperOption.getValue(); final String filePath = myViewOptions.getColorProfile().WallpaperOption.getValue();
if ("".equals(filePath)) { if ("".equals(filePath)) {
return null; return null;
} }
@ -401,22 +403,22 @@ public final class FBView extends ZLTextView {
@Override @Override
public ZLColor getBackgroundColor() { public ZLColor getBackgroundColor() {
return myReader.ViewOptions.getColorProfile().BackgroundOption.getValue(); return myViewOptions.getColorProfile().BackgroundOption.getValue();
} }
@Override @Override
public ZLColor getSelectionBackgroundColor() { public ZLColor getSelectionBackgroundColor() {
return myReader.ViewOptions.getColorProfile().SelectionBackgroundOption.getValue(); return myViewOptions.getColorProfile().SelectionBackgroundOption.getValue();
} }
@Override @Override
public ZLColor getSelectionForegroundColor() { public ZLColor getSelectionForegroundColor() {
return myReader.ViewOptions.getColorProfile().SelectionForegroundOption.getValue(); return myViewOptions.getColorProfile().SelectionForegroundOption.getValue();
} }
@Override @Override
public ZLColor getTextColor(ZLTextHyperlink hyperlink) { public ZLColor getTextColor(ZLTextHyperlink hyperlink) {
final ColorProfile profile = myReader.ViewOptions.getColorProfile(); final ColorProfile profile = myViewOptions.getColorProfile();
switch (hyperlink.Type) { switch (hyperlink.Type) {
default: default:
case FBHyperlinkType.NONE: case FBHyperlinkType.NONE:
@ -432,7 +434,7 @@ public final class FBView extends ZLTextView {
@Override @Override
public ZLColor getHighlightingBackgroundColor() { public ZLColor getHighlightingBackgroundColor() {
return myReader.ViewOptions.getColorProfile().HighlightingOption.getValue(); return myViewOptions.getColorProfile().HighlightingOption.getValue();
} }
private class Footer implements FooterArea { private class Footer implements FooterArea {
@ -445,7 +447,7 @@ public final class FBView extends ZLTextView {
private ArrayList<TOCTree> myTOCMarks; private ArrayList<TOCTree> myTOCMarks;
public int getHeight() { public int getHeight() {
return myReader.ViewOptions.FooterHeight.getValue(); return myViewOptions.FooterHeight.getValue();
} }
public synchronized void resetTOCMarks() { public synchronized void resetTOCMarks() {
@ -494,11 +496,11 @@ public final class FBView extends ZLTextView {
return; return;
} }
final FooterOptions footerOptions = myReader.FooterOptions; final FooterOptions footerOptions = myViewOptions.getFooterOptions();
//final ZLColor bgColor = getBackgroundColor(); //final ZLColor bgColor = getBackgroundColor();
// TODO: separate color option for footer color // TODO: separate color option for footer color
final ZLColor fgColor = getTextColor(ZLTextHyperlink.NO_LINK); final ZLColor fgColor = getTextColor(ZLTextHyperlink.NO_LINK);
final ZLColor fillColor = myReader.ViewOptions.getColorProfile().FooterFillOption.getValue(); final ZLColor fillColor = myViewOptions.getColorProfile().FooterFillOption.getValue();
final int left = getLeftMargin(); final int left = getLeftMargin();
final int right = context.getWidth() - getRightMargin(); final int right = context.getWidth() - getRightMargin();
@ -599,7 +601,7 @@ public final class FBView extends ZLTextView {
@Override @Override
public Footer getFooterArea() { public Footer getFooterArea() {
if (myReader.ViewOptions.ScrollbarType.getValue() == SCROLLBAR_SHOW_AS_FOOTER) { if (myViewOptions.ScrollbarType.getValue() == SCROLLBAR_SHOW_AS_FOOTER) {
if (myFooter == null) { if (myFooter == null) {
myFooter = new Footer(); myFooter = new Footer();
myReader.addTimerTask(myFooter.UpdateTask, 15000); myReader.addTimerTask(myFooter.UpdateTask, 15000);
@ -641,7 +643,7 @@ public final class FBView extends ZLTextView {
@Override @Override
public int scrollbarType() { public int scrollbarType() {
return myReader.ViewOptions.ScrollbarType.getValue(); return myViewOptions.ScrollbarType.getValue();
} }
@Override @Override
@ -652,7 +654,7 @@ public final class FBView extends ZLTextView {
@Override @Override
protected ZLPaintContext.ColorAdjustingMode getAdjustingModeForImages() { protected ZLPaintContext.ColorAdjustingMode getAdjustingModeForImages() {
if (myReader.ImageOptions.MatchBackground.getValue()) { if (myReader.ImageOptions.MatchBackground.getValue()) {
if (ColorProfile.DAY.equals(myReader.ViewOptions.getColorProfile().Name)) { if (ColorProfile.DAY.equals(myViewOptions.getColorProfile().Name)) {
return ZLPaintContext.ColorAdjustingMode.DARKEN_TO_BACKGROUND; return ZLPaintContext.ColorAdjustingMode.DARKEN_TO_BACKGROUND;
} else { } else {
return ZLPaintContext.ColorAdjustingMode.LIGHTEN_TO_BACKGROUND; return ZLPaintContext.ColorAdjustingMode.LIGHTEN_TO_BACKGROUND;

View file

@ -38,6 +38,7 @@ public class ViewOptions {
private ColorProfile myColorProfile; private ColorProfile myColorProfile;
private ZLTextStyleCollection myTextStyleCollection; private ZLTextStyleCollection myTextStyleCollection;
private FooterOptions myFooterOptions;
public ViewOptions() { public ViewOptions() {
final ZLibrary zlibrary = ZLibrary.Instance(); final ZLibrary zlibrary = ZLibrary.Instance();
@ -81,4 +82,11 @@ public class ViewOptions {
} }
return myTextStyleCollection; return myTextStyleCollection;
} }
public FooterOptions getFooterOptions() {
if (myFooterOptions == null) {
myFooterOptions = new FooterOptions();
}
return myFooterOptions;
}
} }