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

new options collection: MiscOptions

This commit is contained in:
Nikolay Pultsin 2013-12-31 15:07:13 +02:00
parent 9b373ea150
commit 794282a979
6 changed files with 69 additions and 40 deletions

View file

@ -299,7 +299,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
public void run() {
final TextSearchPopup popup = (TextSearchPopup)myFBReaderApp.getPopupById(TextSearchPopup.ID);
popup.initPosition();
myFBReaderApp.TextSearchPatternOption.setValue(pattern);
myFBReaderApp.MiscOptions.TextSearchPattern.setValue(pattern);
if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) {
runOnUiThread(new Runnable() {
public void run() {
@ -492,7 +492,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
manager.setOnCancelListener(null);
}
});
startSearch(myFBReaderApp.TextSearchPatternOption.getValue(), true, null, false);
startSearch(myFBReaderApp.MiscOptions.TextSearchPattern.getValue(), true, null, false);
return true;
}

View file

@ -73,6 +73,8 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
final ViewOptions viewOptions = fbReader.ViewOptions;
final MiscOptions miscOptions = fbReader.MiscOptions;
final ZLAndroidLibrary androidLibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
final ColorProfile profile = fbReader.getColorProfile();
// TODO: use user-defined locale, not the default one,
@ -129,7 +131,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
));
appearanceScreen.addPreference(new ZLBooleanPreference(
this,
fbReader.AllowScreenBrightnessAdjustmentOption,
miscOptions.AllowScreenBrightnessAdjustment,
appearanceScreen.Resource,
"allowScreenBrightnessAdjustment"
) {
@ -421,7 +423,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final Screen scrollingScreen = createPreferenceScreen("scrolling");
scrollingScreen.addOption(pageTurningOptions.FingerScrolling, "fingerScrolling");
scrollingScreen.addOption(fbReader.EnableDoubleTapOption, "enableDoubleTapDetection");
scrollingScreen.addOption(miscOptions.EnableDoubleTap, "enableDoubleTapDetection");
final ZLPreferenceSet volumeKeysPreferences = new ZLPreferenceSet();
scrollingScreen.addPreference(new ZLCheckBoxPreference(
@ -527,11 +529,11 @@ public class PreferenceActivity extends ZLPreferenceActivity {
));
dictionaryScreen.addPreference(new ZLBooleanPreference(
PreferenceActivity.this,
fbReader.NavigateAllWordsOption,
miscOptions.NavigateAllWords,
dictionaryScreen.Resource,
"navigateOverAllWords"
));
dictionaryScreen.addOption(fbReader.WordTappingActionOption, "tappingAction");
dictionaryScreen.addOption(miscOptions.WordTappingAction, "tappingAction");
dictionaryScreen.addPreference(targetLanguagePreference);
targetLanguagePreference.setEnabled(
DictionaryUtil.getCurrentDictionaryInfo(true).SupportsTargetLanguageSetting

View file

@ -39,17 +39,7 @@ import org.geometerplus.fbreader.fbreader.options.*;
public final class FBReaderApp extends ZLApplication {
public final ZLTextStyleCollection TextStyleCollection;
public final ZLBooleanOption AllowScreenBrightnessAdjustmentOption;
public final ZLStringOption TextSearchPatternOption;
public final ZLBooleanOption EnableDoubleTapOption;
public final ZLBooleanOption NavigateAllWordsOption;
public static enum WordTappingAction {
doNothing, selectSingleWord, startSelecting, openDictionary
}
public final ZLEnumOption<WordTappingAction> WordTappingActionOption;
public final MiscOptions MiscOptions;
public final ImageOptions ImageOptions;
public final ViewOptions ViewOptions;
public final PageTurningOptions PageTurningOptions;
@ -60,19 +50,7 @@ public final class FBReaderApp extends ZLApplication {
{
TextStyleCollection = new ZLTextStyleCollection("Base");
AllowScreenBrightnessAdjustmentOption =
new ZLBooleanOption("LookNFeel", "AllowScreenBrightnessAdjustment", true);
TextSearchPatternOption =
new ZLStringOption("TextSearch", "Pattern", "");
EnableDoubleTapOption =
new ZLBooleanOption("Options", "EnableDoubleTap", false);
NavigateAllWordsOption =
new ZLBooleanOption("Options", "NavigateAllWords", false);
WordTappingActionOption =
new ZLEnumOption<WordTappingAction>("Options", "WordTappingAction", WordTappingAction.startSelecting);
MiscOptions = new MiscOptions();
ImageOptions = new ImageOptions();
ViewOptions = new ViewOptions();
PageTurningOptions = new PageTurningOptions();

View file

@ -34,8 +34,7 @@ import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection;
import org.geometerplus.fbreader.bookmodel.BookModel;
import org.geometerplus.fbreader.bookmodel.FBHyperlinkType;
import org.geometerplus.fbreader.bookmodel.TOCTree;
import org.geometerplus.fbreader.fbreader.options.ImageOptions;
import org.geometerplus.fbreader.fbreader.options.PageTurningOptions;
import org.geometerplus.fbreader.fbreader.options.*;
public final class FBView extends ZLTextView {
private FBReaderApp myReader;
@ -103,7 +102,7 @@ public final class FBView extends ZLTextView {
@Override
public boolean isDoubleTapSupported() {
return myReader.EnableDoubleTapOption.getValue();
return myReader.MiscOptions.EnableDoubleTap.getValue();
}
@Override
@ -129,7 +128,7 @@ public final class FBView extends ZLTextView {
return true;
}
if (myReader.AllowScreenBrightnessAdjustmentOption.getValue() && x < getContextWidth() / 10) {
if (myReader.MiscOptions.AllowScreenBrightnessAdjustment.getValue() && x < getContextWidth() / 10) {
myIsBrightnessAdjustmentInProgress = true;
myStartY = y;
myStartBrightness = ZLibrary.Instance().getScreenBrightness();
@ -224,7 +223,7 @@ public final class FBView extends ZLTextView {
final ZLTextRegion.Soul soul = region.getSoul();
boolean doSelectRegion = false;
if (soul instanceof ZLTextWordRegionSoul) {
switch (myReader.WordTappingActionOption.getValue()) {
switch (myReader.MiscOptions.WordTappingAction.getValue()) {
case startSelecting:
myReader.runAction(ActionCode.SELECTION_HIDE_PANEL);
initSelection(x, y);
@ -273,8 +272,8 @@ public final class FBView extends ZLTextView {
ZLTextRegion.Soul soul = region.getSoul();
if (soul instanceof ZLTextHyperlinkRegionSoul ||
soul instanceof ZLTextWordRegionSoul) {
if (myReader.WordTappingActionOption.getValue() !=
FBReaderApp.WordTappingAction.doNothing) {
if (myReader.MiscOptions.WordTappingAction.getValue() !=
MiscOptions.WordTappingActionEnum.doNothing) {
region = findRegion(x, y, MAX_SELECTION_DISTANCE, ZLTextRegion.AnyRegionFilter);
if (region != null) {
soul = region.getSoul();
@ -309,8 +308,8 @@ public final class FBView extends ZLTextView {
boolean doRunAction = false;
if (soul instanceof ZLTextWordRegionSoul) {
doRunAction =
myReader.WordTappingActionOption.getValue() ==
FBReaderApp.WordTappingAction.openDictionary;
myReader.MiscOptions.WordTappingAction.getValue() ==
MiscOptions.WordTappingActionEnum.openDictionary;
} else if (soul instanceof ZLTextImageRegionSoul) {
doRunAction =
myReader.ImageOptions.TapAction.getValue() ==

View file

@ -36,7 +36,7 @@ class MoveCursorAction extends FBAction {
ZLTextRegion region = fbView.getSelectedRegion();
final ZLTextRegion.Filter filter =
(region != null && region.getSoul() instanceof ZLTextWordRegionSoul)
|| Reader.NavigateAllWordsOption.getValue()
|| Reader.MiscOptions.NavigateAllWords.getValue()
? ZLTextRegion.AnyRegionFilter : ZLTextRegion.ImageOrHyperlinkFilter;
region = fbView.nextRegion(myDirection, filter);
if (region != null) {

View file

@ -0,0 +1,50 @@
/*
* 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 MiscOptions {
public final ZLBooleanOption AllowScreenBrightnessAdjustment;
public final ZLStringOption TextSearchPattern;
public final ZLBooleanOption EnableDoubleTap;
public final ZLBooleanOption NavigateAllWords;
public static enum WordTappingActionEnum {
doNothing, selectSingleWord, startSelecting, openDictionary
}
public final ZLEnumOption<WordTappingActionEnum> WordTappingAction;
public MiscOptions() {
AllowScreenBrightnessAdjustment =
new ZLBooleanOption("LookNFeel", "AllowScreenBrightnessAdjustment", true);
TextSearchPattern =
new ZLStringOption("TextSearch", "Pattern", "");
EnableDoubleTap =
new ZLBooleanOption("Options", "EnableDoubleTap", false);
NavigateAllWords =
new ZLBooleanOption("Options", "NavigateAllWords", false);
WordTappingAction =
new ZLEnumOption<WordTappingActionEnum>("Options", "WordTappingAction", WordTappingActionEnum.startSelecting);
}
}