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) {
setResult(FBReader.RESULT_REPAINT);
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
final ViewOptions viewOptions = new ViewOptions();
final MiscOptions miscOptions = new MiscOptions();
final FooterOptions footerOptions = fbReader.FooterOptions;
final FooterOptions footerOptions = viewOptions.getFooterOptions();
final PageTurningOptions pageTurningOptions = new PageTurningOptions();
final ImageOptions imageOptions = new ImageOptions();
final ColorProfile profile = viewOptions.getColorProfile();

View file

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

View file

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

View file

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