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

separate classes for options

This commit is contained in:
Nikolay Pultsin 2013-05-28 04:13:16 +01:00
parent 7fb943f59f
commit ce0f77c19f
9 changed files with 125 additions and 70 deletions

View file

@ -526,11 +526,11 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
}
public String getZoneMap() {
return getReader().PageTurningOptions.TapZoneMapOption.getValue();
return getReader().PageTurningOptions.TapZoneMap.getValue();
}
public void setZoneMap(String name) {
getReader().PageTurningOptions.TapZoneMapOption.setValue(name);
getReader().PageTurningOptions.TapZoneMap.setValue(name);
}
public int getZoneMapHeight(String name) {

View file

@ -35,7 +35,7 @@ import org.geometerplus.zlibrary.ui.android.view.ZLAndroidPaintContext;
import org.geometerplus.fbreader.Paths;
import org.geometerplus.fbreader.bookmodel.FBTextKind;
import org.geometerplus.fbreader.fbreader.*;
import org.geometerplus.fbreader.fbreader.options.PageTurningOptions;
import org.geometerplus.fbreader.fbreader.options.*;
import org.geometerplus.fbreader.tips.TipsManager;
import org.geometerplus.android.fbreader.DictionaryUtil;
@ -374,14 +374,14 @@ public class PreferenceActivity extends ZLPreferenceActivity {
fbReader.FooterHeightOption
)));
footerPreferences.add(statusLineScreen.addOption(profile.FooterFillOption, "footerColor"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowTOCMarksOption, "tocMarks"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterOptions.ShowTOCMarks, "tocMarks"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowClockOption, "showClock"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowBatteryOption, "showBattery"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowProgressOption, "showProgress"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterOptions.ShowClock, "showClock"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterOptions.ShowBattery, "showBattery"));
footerPreferences.add(statusLineScreen.addOption(fbReader.FooterOptions.ShowProgress, "showProgress"));
footerPreferences.add(statusLineScreen.addPreference(new FontOption(
this, statusLineScreen.Resource, "font",
fbReader.FooterFontOption, false
fbReader.FooterOptions.Font, false
)));
footerPreferences.setEnabled(
fbReader.ScrollbarTypeOption.getValue() == FBView.SCROLLBAR_SHOW_AS_FOOTER
@ -403,7 +403,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final ZLKeyBindings keyBindings = fbReader.keyBindings();
final Screen scrollingScreen = createPreferenceScreen("scrolling");
scrollingScreen.addOption(pageTurningOptions.FingerScrollingOption, "fingerScrolling");
scrollingScreen.addOption(pageTurningOptions.FingerScrolling, "fingerScrolling");
scrollingScreen.addOption(fbReader.EnableDoubleTapOption, "enableDoubleTapDetection");
final ZLPreferenceSet volumeKeysPreferences = new ZLPreferenceSet();
@ -450,14 +450,14 @@ public class PreferenceActivity extends ZLPreferenceActivity {
}));
volumeKeysPreferences.setEnabled(fbReader.hasActionForKey(KeyEvent.KEYCODE_VOLUME_UP, false));
scrollingScreen.addOption(pageTurningOptions.AnimationOption, "animation");
scrollingScreen.addOption(pageTurningOptions.Animation, "animation");
scrollingScreen.addPreference(new AnimationSpeedPreference(
this,
scrollingScreen.Resource,
"animationSpeed",
pageTurningOptions.AnimationSpeedOption
pageTurningOptions.AnimationSpeed
));
scrollingScreen.addOption(pageTurningOptions.HorizontalOption, "horizontal");
scrollingScreen.addOption(pageTurningOptions.Horizontal, "horizontal");
final Screen dictionaryScreen = createPreferenceScreen("dictionary");
try {
@ -491,11 +491,12 @@ public class PreferenceActivity extends ZLPreferenceActivity {
imagesScreen.addOption(fbReader.FitImagesToScreenOption, "fitImagesToScreen");
imagesScreen.addOption(fbReader.ImageViewBackgroundOption, "backgroundColor");
final CancelMenuOptions cancelMenuOptions = fbReader.CancelMenuOptions;
final Screen cancelMenuScreen = createPreferenceScreen("cancelMenu");
cancelMenuScreen.addOption(fbReader.ShowLibraryInCancelMenuOption, "library");
cancelMenuScreen.addOption(fbReader.ShowNetworkLibraryInCancelMenuOption, "networkLibrary");
cancelMenuScreen.addOption(fbReader.ShowPreviousBookInCancelMenuOption, "previousBook");
cancelMenuScreen.addOption(fbReader.ShowPositionsInCancelMenuOption, "positions");
cancelMenuScreen.addOption(cancelMenuOptions.ShowLibraryItem, "library");
cancelMenuScreen.addOption(cancelMenuOptions.ShowNetworkLibraryItem, "networkLibrary");
cancelMenuScreen.addOption(cancelMenuOptions.ShowPreviousBookItem, "previousBook");
cancelMenuScreen.addOption(cancelMenuOptions.ShowPositionItems, "positions");
final String[] backKeyActions =
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU };
cancelMenuScreen.addPreference(new ZLStringChoicePreference(

View file

@ -91,30 +91,13 @@ public final class FBReaderApp extends ZLApplication {
public final ZLIntegerRangeOption ScrollbarTypeOption =
new ZLIntegerRangeOption("Options", "ScrollbarType", 0, 3, FBView.SCROLLBAR_SHOW_AS_FOOTER);
public final ZLBooleanOption FooterShowTOCMarksOption =
new ZLBooleanOption("Options", "FooterShowTOCMarks", true);
public final ZLBooleanOption FooterShowClockOption =
new ZLBooleanOption("Options", "ShowClockInFooter", true);
public final ZLBooleanOption FooterShowBatteryOption =
new ZLBooleanOption("Options", "ShowBatteryInFooter", true);
public final ZLBooleanOption FooterShowProgressOption =
new ZLBooleanOption("Options", "ShowProgressInFooter", true);
public final ZLStringOption FooterFontOption =
new ZLStringOption("Options", "FooterFont", "Droid Sans");
final ZLStringOption ColorProfileOption =
new ZLStringOption("Options", "ColorProfile", ColorProfile.DAY);
public final ZLBooleanOption ShowLibraryInCancelMenuOption =
new ZLBooleanOption("CancelMenu", "library", true);
public final ZLBooleanOption ShowNetworkLibraryInCancelMenuOption =
new ZLBooleanOption("CancelMenu", "networkLibrary", true);
public final ZLBooleanOption ShowPreviousBookInCancelMenuOption =
new ZLBooleanOption("CancelMenu", "previousBook", false);
public final ZLBooleanOption ShowPositionsInCancelMenuOption =
new ZLBooleanOption("CancelMenu", "positions", true);
public final PageTurningOptions PageTurningOptions = new PageTurningOptions();
public final FooterOptions FooterOptions = new FooterOptions();
public final CancelMenuOptions CancelMenuOptions = new CancelMenuOptions();
private final ZLKeyBindings myBindings = new ZLKeyBindings("Keys");
@ -478,17 +461,17 @@ public final class FBReaderApp extends ZLApplication {
public List<CancelActionDescription> getCancelActionsList() {
myCancelActionsList.clear();
if (ShowLibraryInCancelMenuOption.getValue()) {
if (CancelMenuOptions.ShowLibraryItem.getValue()) {
myCancelActionsList.add(new CancelActionDescription(
CancelActionType.library, null
));
}
if (ShowNetworkLibraryInCancelMenuOption.getValue()) {
if (CancelMenuOptions.ShowNetworkLibraryItem.getValue()) {
myCancelActionsList.add(new CancelActionDescription(
CancelActionType.networkLibrary, null
));
}
if (ShowPreviousBookInCancelMenuOption.getValue()) {
if (CancelMenuOptions.ShowPreviousBookItem.getValue()) {
final Book previousBook = Collection.getRecentBook(1);
if (previousBook != null) {
myCancelActionsList.add(new CancelActionDescription(
@ -496,7 +479,7 @@ public final class FBReaderApp extends ZLApplication {
));
}
}
if (ShowPositionsInCancelMenuOption.getValue()) {
if (CancelMenuOptions.ShowPositionItems.getValue()) {
if (Model != null && Model.Book != null) {
for (Bookmark bookmark : invisibleBookmarks()) {
myCancelActionsList.add(new BookmarkDescription(bookmark));

View file

@ -58,9 +58,9 @@ public final class FBView extends ZLTextView {
private TapZoneMap getZoneMap() {
final PageTurningOptions prefs = myReader.PageTurningOptions;
String id = prefs.TapZoneMapOption.getValue();
String id = prefs.TapZoneMap.getValue();
if ("".equals(id)) {
id = prefs.HorizontalOption.getValue() ? "right_to_left" : "up";
id = prefs.Horizontal.getValue() ? "right_to_left" : "up";
}
if (myZoneMap == null || !id.equals(myZoneMap.Name)) {
myZoneMap = TapZoneMap.zoneMap(id);
@ -139,11 +139,11 @@ public final class FBView extends ZLTextView {
}
private boolean isFlickScrollingEnabled() {
final PageTurningOptions.FingerScrolling fingerScrolling =
myReader.PageTurningOptions.FingerScrollingOption.getValue();
final PageTurningOptions.FingerScrollingType fingerScrolling =
myReader.PageTurningOptions.FingerScrolling.getValue();
return
fingerScrolling == PageTurningOptions.FingerScrolling.byFlick ||
fingerScrolling == PageTurningOptions.FingerScrolling.byTapAndFlick;
fingerScrolling == PageTurningOptions.FingerScrollingType.byFlick ||
fingerScrolling == PageTurningOptions.FingerScrollingType.byTapAndFlick;
}
private void startManualScrolling(int x, int y) {
@ -151,7 +151,7 @@ public final class FBView extends ZLTextView {
return;
}
final boolean horizontal = myReader.PageTurningOptions.HorizontalOption.getValue();
final boolean horizontal = myReader.PageTurningOptions.Horizontal.getValue();
final Direction direction = horizontal ? Direction.rightToLeft : Direction.up;
myReader.getViewWidget().startManualScrolling(x, y, direction);
}
@ -204,7 +204,7 @@ public final class FBView extends ZLTextView {
if (isFlickScrollingEnabled()) {
myReader.getViewWidget().startAnimatedScrolling(
x, y, myReader.PageTurningOptions.AnimationSpeedOption.getValue()
x, y, myReader.PageTurningOptions.AnimationSpeed.getValue()
);
return true;
}
@ -503,7 +503,7 @@ public final class FBView extends ZLTextView {
final int lineWidth = height <= 10 ? 1 : 2;
final int delta = height <= 10 ? 0 : 1;
context.setFont(
reader.FooterFontOption.getValue(),
reader.FooterOptions.Font.getValue(),
height <= 10 ? height + 3 : height + 1,
height > 10, false, false, false
);
@ -511,19 +511,19 @@ public final class FBView extends ZLTextView {
final PagePosition pagePosition = FBView.this.pagePosition();
final StringBuilder info = new StringBuilder();
if (reader.FooterShowProgressOption.getValue()) {
if (reader.FooterOptions.ShowProgress.getValue()) {
info.append(pagePosition.Current);
info.append("/");
info.append(pagePosition.Total);
}
if (reader.FooterShowBatteryOption.getValue()) {
if (reader.FooterOptions.ShowBattery.getValue()) {
if (info.length() > 0) {
info.append(" ");
}
info.append(reader.getBatteryLevel());
info.append("%");
}
if (reader.FooterShowClockOption.getValue()) {
if (reader.FooterOptions.ShowClock.getValue()) {
if (info.length() > 0) {
info.append(" ");
}
@ -554,7 +554,7 @@ public final class FBView extends ZLTextView {
context.setFillColor(fillColor);
context.fillRectangle(left + 1, height - 2 * lineWidth, gaugeInternalRight, lineWidth + 1);
if (reader.FooterShowTOCMarksOption.getValue()) {
if (reader.FooterOptions.ShowTOCMarks.getValue()) {
if (myTOCMarks == null) {
updateTOCMarks(model);
}
@ -643,6 +643,6 @@ public final class FBView extends ZLTextView {
@Override
public Animation getAnimationType() {
return myReader.PageTurningOptions.AnimationOption.getValue();
return myReader.PageTurningOptions.Animation.getValue();
}
}

View file

@ -31,11 +31,11 @@ class TurnPageAction extends FBAction {
@Override
public boolean isEnabled() {
final PageTurningOptions.FingerScrolling fingerScrolling =
Reader.PageTurningOptions.FingerScrollingOption.getValue();
final PageTurningOptions.FingerScrollingType fingerScrolling =
Reader.PageTurningOptions.FingerScrolling.getValue();
return
fingerScrolling == PageTurningOptions.FingerScrolling.byTap ||
fingerScrolling == PageTurningOptions.FingerScrolling.byTapAndFlick;
fingerScrolling == PageTurningOptions.FingerScrollingType.byTap ||
fingerScrolling == PageTurningOptions.FingerScrollingType.byTapAndFlick;
}
@Override
@ -47,16 +47,16 @@ class TurnPageAction extends FBAction {
Reader.getViewWidget().startAnimatedScrolling(
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
x, y,
preferences.HorizontalOption.getValue()
preferences.Horizontal.getValue()
? FBView.Direction.rightToLeft : FBView.Direction.up,
preferences.AnimationSpeedOption.getValue()
preferences.AnimationSpeed.getValue()
);
} else {
Reader.getViewWidget().startAnimatedScrolling(
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
preferences.HorizontalOption.getValue()
preferences.Horizontal.getValue()
? FBView.Direction.rightToLeft : FBView.Direction.up,
preferences.AnimationSpeedOption.getValue()
preferences.AnimationSpeed.getValue()
);
}
}

View file

@ -34,9 +34,9 @@ class VolumeKeyTurnPageAction extends FBAction {
final PageTurningOptions preferences = Reader.PageTurningOptions;
Reader.getViewWidget().startAnimatedScrolling(
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
preferences.HorizontalOption.getValue()
preferences.Horizontal.getValue()
? FBView.Direction.rightToLeft : FBView.Direction.up,
preferences.AnimationSpeedOption.getValue()
preferences.AnimationSpeed.getValue()
);
}
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 2007-2013 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.fbreader.fbreader.options;
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
public class CancelMenuOptions {
public final ZLBooleanOption ShowLibraryItem =
new ZLBooleanOption("CancelMenu", "library", true);
public final ZLBooleanOption ShowNetworkLibraryItem =
new ZLBooleanOption("CancelMenu", "networkLibrary", true);
public final ZLBooleanOption ShowPreviousBookItem =
new ZLBooleanOption("CancelMenu", "previousBook", false);
public final ZLBooleanOption ShowPositionItems =
new ZLBooleanOption("CancelMenu", "positions", true);
}

View file

@ -0,0 +1,38 @@
/*
* Copyright (C) 2007-2013 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.fbreader.fbreader.options;
import org.geometerplus.zlibrary.core.options.*;
public class FooterOptions {
public final ZLBooleanOption ShowTOCMarks;
public final ZLBooleanOption ShowClock;
public final ZLBooleanOption ShowBattery;
public final ZLBooleanOption ShowProgress;
public final ZLStringOption Font;
public FooterOptions() {
ShowTOCMarks = new ZLBooleanOption("Options", "FooterShowTOCMarks", true);
ShowClock = new ZLBooleanOption("Options", "ShowClockInFooter", true);
ShowBattery = new ZLBooleanOption("Options", "ShowBatteryInFooter", true);
ShowProgress = new ZLBooleanOption("Options", "ShowProgressInFooter", true);
Font = new ZLStringOption("Options", "FooterFont", "Droid Sans");
}
}

View file

@ -23,19 +23,19 @@ import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.zlibrary.core.view.ZLView;
public class PageTurningOptions {
public static enum FingerScrolling {
public static enum FingerScrollingType {
byTap, byFlick, byTapAndFlick
}
public final ZLEnumOption<FingerScrolling> FingerScrollingOption =
new ZLEnumOption<FingerScrolling>("Scrolling", "Finger", FingerScrolling.byTapAndFlick);
public final ZLEnumOption<FingerScrollingType> FingerScrolling =
new ZLEnumOption<FingerScrollingType>("Scrolling", "Finger", FingerScrollingType.byTapAndFlick);
public final ZLEnumOption<ZLView.Animation> AnimationOption =
public final ZLEnumOption<ZLView.Animation> Animation =
new ZLEnumOption<ZLView.Animation>("Scrolling", "Animation", ZLView.Animation.slide);
public final ZLIntegerRangeOption AnimationSpeedOption =
public final ZLIntegerRangeOption AnimationSpeed =
new ZLIntegerRangeOption("Scrolling", "AnimationSpeed", 1, 10, 4);
public final ZLBooleanOption HorizontalOption =
public final ZLBooleanOption Horizontal =
new ZLBooleanOption("Scrolling", "Horizontal", true);
public final ZLStringOption TapZoneMapOption =
public final ZLStringOption TapZoneMap =
new ZLStringOption("Scrolling", "TapZoneMap", "");
}