mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
new options collection: MiscOptions
This commit is contained in:
parent
9b373ea150
commit
794282a979
6 changed files with 69 additions and 40 deletions
|
@ -299,7 +299,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
||||||
public void run() {
|
public void run() {
|
||||||
final TextSearchPopup popup = (TextSearchPopup)myFBReaderApp.getPopupById(TextSearchPopup.ID);
|
final TextSearchPopup popup = (TextSearchPopup)myFBReaderApp.getPopupById(TextSearchPopup.ID);
|
||||||
popup.initPosition();
|
popup.initPosition();
|
||||||
myFBReaderApp.TextSearchPatternOption.setValue(pattern);
|
myFBReaderApp.MiscOptions.TextSearchPattern.setValue(pattern);
|
||||||
if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) {
|
if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -492,7 +492,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
||||||
manager.setOnCancelListener(null);
|
manager.setOnCancelListener(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
startSearch(myFBReaderApp.TextSearchPatternOption.getValue(), true, null, false);
|
startSearch(myFBReaderApp.MiscOptions.TextSearchPattern.getValue(), true, null, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
|
|
||||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||||
final ViewOptions viewOptions = fbReader.ViewOptions;
|
final ViewOptions viewOptions = fbReader.ViewOptions;
|
||||||
|
final MiscOptions miscOptions = fbReader.MiscOptions;
|
||||||
|
|
||||||
final ZLAndroidLibrary androidLibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
final ZLAndroidLibrary androidLibrary = (ZLAndroidLibrary)ZLAndroidLibrary.Instance();
|
||||||
final ColorProfile profile = fbReader.getColorProfile();
|
final ColorProfile profile = fbReader.getColorProfile();
|
||||||
// TODO: use user-defined locale, not the default one,
|
// TODO: use user-defined locale, not the default one,
|
||||||
|
@ -129,7 +131,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
));
|
));
|
||||||
appearanceScreen.addPreference(new ZLBooleanPreference(
|
appearanceScreen.addPreference(new ZLBooleanPreference(
|
||||||
this,
|
this,
|
||||||
fbReader.AllowScreenBrightnessAdjustmentOption,
|
miscOptions.AllowScreenBrightnessAdjustment,
|
||||||
appearanceScreen.Resource,
|
appearanceScreen.Resource,
|
||||||
"allowScreenBrightnessAdjustment"
|
"allowScreenBrightnessAdjustment"
|
||||||
) {
|
) {
|
||||||
|
@ -421,7 +423,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
|
|
||||||
final Screen scrollingScreen = createPreferenceScreen("scrolling");
|
final Screen scrollingScreen = createPreferenceScreen("scrolling");
|
||||||
scrollingScreen.addOption(pageTurningOptions.FingerScrolling, "fingerScrolling");
|
scrollingScreen.addOption(pageTurningOptions.FingerScrolling, "fingerScrolling");
|
||||||
scrollingScreen.addOption(fbReader.EnableDoubleTapOption, "enableDoubleTapDetection");
|
scrollingScreen.addOption(miscOptions.EnableDoubleTap, "enableDoubleTapDetection");
|
||||||
|
|
||||||
final ZLPreferenceSet volumeKeysPreferences = new ZLPreferenceSet();
|
final ZLPreferenceSet volumeKeysPreferences = new ZLPreferenceSet();
|
||||||
scrollingScreen.addPreference(new ZLCheckBoxPreference(
|
scrollingScreen.addPreference(new ZLCheckBoxPreference(
|
||||||
|
@ -527,11 +529,11 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
));
|
));
|
||||||
dictionaryScreen.addPreference(new ZLBooleanPreference(
|
dictionaryScreen.addPreference(new ZLBooleanPreference(
|
||||||
PreferenceActivity.this,
|
PreferenceActivity.this,
|
||||||
fbReader.NavigateAllWordsOption,
|
miscOptions.NavigateAllWords,
|
||||||
dictionaryScreen.Resource,
|
dictionaryScreen.Resource,
|
||||||
"navigateOverAllWords"
|
"navigateOverAllWords"
|
||||||
));
|
));
|
||||||
dictionaryScreen.addOption(fbReader.WordTappingActionOption, "tappingAction");
|
dictionaryScreen.addOption(miscOptions.WordTappingAction, "tappingAction");
|
||||||
dictionaryScreen.addPreference(targetLanguagePreference);
|
dictionaryScreen.addPreference(targetLanguagePreference);
|
||||||
targetLanguagePreference.setEnabled(
|
targetLanguagePreference.setEnabled(
|
||||||
DictionaryUtil.getCurrentDictionaryInfo(true).SupportsTargetLanguageSetting
|
DictionaryUtil.getCurrentDictionaryInfo(true).SupportsTargetLanguageSetting
|
||||||
|
|
|
@ -39,17 +39,7 @@ import org.geometerplus.fbreader.fbreader.options.*;
|
||||||
public final class FBReaderApp extends ZLApplication {
|
public final class FBReaderApp extends ZLApplication {
|
||||||
public final ZLTextStyleCollection TextStyleCollection;
|
public final ZLTextStyleCollection TextStyleCollection;
|
||||||
|
|
||||||
public final ZLBooleanOption AllowScreenBrightnessAdjustmentOption;
|
public final MiscOptions MiscOptions;
|
||||||
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 ImageOptions ImageOptions;
|
public final ImageOptions ImageOptions;
|
||||||
public final ViewOptions ViewOptions;
|
public final ViewOptions ViewOptions;
|
||||||
public final PageTurningOptions PageTurningOptions;
|
public final PageTurningOptions PageTurningOptions;
|
||||||
|
@ -60,19 +50,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
{
|
{
|
||||||
TextStyleCollection = new ZLTextStyleCollection("Base");
|
TextStyleCollection = new ZLTextStyleCollection("Base");
|
||||||
|
|
||||||
AllowScreenBrightnessAdjustmentOption =
|
MiscOptions = new MiscOptions();
|
||||||
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);
|
|
||||||
|
|
||||||
ImageOptions = new ImageOptions();
|
ImageOptions = new ImageOptions();
|
||||||
ViewOptions = new ViewOptions();
|
ViewOptions = new ViewOptions();
|
||||||
PageTurningOptions = new PageTurningOptions();
|
PageTurningOptions = new PageTurningOptions();
|
||||||
|
|
|
@ -34,8 +34,7 @@ import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.FBHyperlinkType;
|
import org.geometerplus.fbreader.bookmodel.FBHyperlinkType;
|
||||||
import org.geometerplus.fbreader.bookmodel.TOCTree;
|
import org.geometerplus.fbreader.bookmodel.TOCTree;
|
||||||
import org.geometerplus.fbreader.fbreader.options.ImageOptions;
|
import org.geometerplus.fbreader.fbreader.options.*;
|
||||||
import org.geometerplus.fbreader.fbreader.options.PageTurningOptions;
|
|
||||||
|
|
||||||
public final class FBView extends ZLTextView {
|
public final class FBView extends ZLTextView {
|
||||||
private FBReaderApp myReader;
|
private FBReaderApp myReader;
|
||||||
|
@ -103,7 +102,7 @@ public final class FBView extends ZLTextView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDoubleTapSupported() {
|
public boolean isDoubleTapSupported() {
|
||||||
return myReader.EnableDoubleTapOption.getValue();
|
return myReader.MiscOptions.EnableDoubleTap.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,7 +128,7 @@ public final class FBView extends ZLTextView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myReader.AllowScreenBrightnessAdjustmentOption.getValue() && x < getContextWidth() / 10) {
|
if (myReader.MiscOptions.AllowScreenBrightnessAdjustment.getValue() && x < getContextWidth() / 10) {
|
||||||
myIsBrightnessAdjustmentInProgress = true;
|
myIsBrightnessAdjustmentInProgress = true;
|
||||||
myStartY = y;
|
myStartY = y;
|
||||||
myStartBrightness = ZLibrary.Instance().getScreenBrightness();
|
myStartBrightness = ZLibrary.Instance().getScreenBrightness();
|
||||||
|
@ -224,7 +223,7 @@ public final class FBView extends ZLTextView {
|
||||||
final ZLTextRegion.Soul soul = region.getSoul();
|
final ZLTextRegion.Soul soul = region.getSoul();
|
||||||
boolean doSelectRegion = false;
|
boolean doSelectRegion = false;
|
||||||
if (soul instanceof ZLTextWordRegionSoul) {
|
if (soul instanceof ZLTextWordRegionSoul) {
|
||||||
switch (myReader.WordTappingActionOption.getValue()) {
|
switch (myReader.MiscOptions.WordTappingAction.getValue()) {
|
||||||
case startSelecting:
|
case startSelecting:
|
||||||
myReader.runAction(ActionCode.SELECTION_HIDE_PANEL);
|
myReader.runAction(ActionCode.SELECTION_HIDE_PANEL);
|
||||||
initSelection(x, y);
|
initSelection(x, y);
|
||||||
|
@ -273,8 +272,8 @@ public final class FBView extends ZLTextView {
|
||||||
ZLTextRegion.Soul soul = region.getSoul();
|
ZLTextRegion.Soul soul = region.getSoul();
|
||||||
if (soul instanceof ZLTextHyperlinkRegionSoul ||
|
if (soul instanceof ZLTextHyperlinkRegionSoul ||
|
||||||
soul instanceof ZLTextWordRegionSoul) {
|
soul instanceof ZLTextWordRegionSoul) {
|
||||||
if (myReader.WordTappingActionOption.getValue() !=
|
if (myReader.MiscOptions.WordTappingAction.getValue() !=
|
||||||
FBReaderApp.WordTappingAction.doNothing) {
|
MiscOptions.WordTappingActionEnum.doNothing) {
|
||||||
region = findRegion(x, y, MAX_SELECTION_DISTANCE, ZLTextRegion.AnyRegionFilter);
|
region = findRegion(x, y, MAX_SELECTION_DISTANCE, ZLTextRegion.AnyRegionFilter);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
soul = region.getSoul();
|
soul = region.getSoul();
|
||||||
|
@ -309,8 +308,8 @@ public final class FBView extends ZLTextView {
|
||||||
boolean doRunAction = false;
|
boolean doRunAction = false;
|
||||||
if (soul instanceof ZLTextWordRegionSoul) {
|
if (soul instanceof ZLTextWordRegionSoul) {
|
||||||
doRunAction =
|
doRunAction =
|
||||||
myReader.WordTappingActionOption.getValue() ==
|
myReader.MiscOptions.WordTappingAction.getValue() ==
|
||||||
FBReaderApp.WordTappingAction.openDictionary;
|
MiscOptions.WordTappingActionEnum.openDictionary;
|
||||||
} else if (soul instanceof ZLTextImageRegionSoul) {
|
} else if (soul instanceof ZLTextImageRegionSoul) {
|
||||||
doRunAction =
|
doRunAction =
|
||||||
myReader.ImageOptions.TapAction.getValue() ==
|
myReader.ImageOptions.TapAction.getValue() ==
|
||||||
|
|
|
@ -36,7 +36,7 @@ class MoveCursorAction extends FBAction {
|
||||||
ZLTextRegion region = fbView.getSelectedRegion();
|
ZLTextRegion region = fbView.getSelectedRegion();
|
||||||
final ZLTextRegion.Filter filter =
|
final ZLTextRegion.Filter filter =
|
||||||
(region != null && region.getSoul() instanceof ZLTextWordRegionSoul)
|
(region != null && region.getSoul() instanceof ZLTextWordRegionSoul)
|
||||||
|| Reader.NavigateAllWordsOption.getValue()
|
|| Reader.MiscOptions.NavigateAllWords.getValue()
|
||||||
? ZLTextRegion.AnyRegionFilter : ZLTextRegion.ImageOrHyperlinkFilter;
|
? ZLTextRegion.AnyRegionFilter : ZLTextRegion.ImageOrHyperlinkFilter;
|
||||||
region = fbView.nextRegion(myDirection, filter);
|
region = fbView.nextRegion(myDirection, filter);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue