mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
smooth scrolling
new page dialog look'n'feel options git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@922 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
f7b8cebe42
commit
3d95db3b52
30 changed files with 743 additions and 807 deletions
|
@ -1 +1 @@
|
|||
<!ENTITY FBReaderVersion "0.3.4">
|
||||
<!ENTITY FBReaderVersion "0.4.0">
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
<node name="recent" value="Recent"/>
|
||||
</node>
|
||||
<node name="menu">
|
||||
<node name="preferences" value="Preferences">
|
||||
<node name="preferences" value="FBReader..."/>
|
||||
<node name="bookInfo" value="Current Book..."/>
|
||||
</node>
|
||||
<node name="preferences-old" value="Settings (Old)"/>
|
||||
<node name="preferences" value="Settings"/>
|
||||
<node name="showLibrary" value="Library"/>
|
||||
<node name="library" value="Library Old">
|
||||
<node name="previousBook" value="Previous Book"/>
|
||||
|
@ -46,6 +44,36 @@
|
|||
<node name="quit" value="Close"/>
|
||||
</node>
|
||||
<node name="dialog">
|
||||
<node name="Preferences">
|
||||
<node name="LookNFeel" value="Look & Feel">
|
||||
<node name="autoOrientation" value="Auto orientation">
|
||||
<node name="summaryOn" value="The display will rotate when user moves the device"/>
|
||||
<node name="summaryOff" value="The display will not rotate when user moves the device"/>
|
||||
</node>
|
||||
<node name="showStatusBar" value="Show status bar">
|
||||
<node name="summaryOn" value="The status bar will be shown in reading mode"/>
|
||||
<node name="summaryOff" value="The status bar will be hidden in reading mode"/>
|
||||
</node>
|
||||
</node>
|
||||
<node name="Scrolling" value="Scrolling">
|
||||
<node name="flick" value="Flick scrolling">
|
||||
<node name="summaryOn" value="Pages will be scrolled by finger flick"/>
|
||||
<node name="summaryOff" value="Pages will be scrolled by finger tap"/>
|
||||
</node>
|
||||
<node name="volumeKeys" value="Volume keys scrolling">
|
||||
<node name="summaryOn" value="Volume keys will be used for scrolling"/>
|
||||
<node name="summaryOff" value="Volume keys will be used as usual"/>
|
||||
</node>
|
||||
<node name="animated" value="Animated scrolling">
|
||||
<node name="summaryOn" value="Pages will be scrolled smoothly"/>
|
||||
<node name="summaryOff" value="Pages will be scrolled instantly"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Horizontal scrolling">
|
||||
<node name="summaryOn" value="Scroll pages horizontally"/>
|
||||
<node name="summaryOff" value="Scroll pages vertically"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node name="button">
|
||||
<node name="go" value="&Go!"/>
|
||||
<node name="thisOnly" value="This only"/>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<node name="recent" value="Недавние"/>
|
||||
</node>
|
||||
<node name="menu">
|
||||
<node name="preferences" value="Настройки"/>
|
||||
<node name="bookInfo" value="Информация о книге..."/>
|
||||
<node name="toc" value="Содержание"/>
|
||||
<node name="library" value="Библиотека">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.geometerplus.zlibrary.ui.android" android:versionCode="304" android:versionName="0.3.4">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.geometerplus.zlibrary.ui.android" android:versionCode="400" android:versionName="0.4.0">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application android:name="org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication" android:icon="@drawable/fbreader" android:label="FBReader">
|
||||
<activity android:name="org.geometerplus.android.fbreader.FBReader" android:icon="@drawable/fbreader" android:label="FBReader" android:screenOrientation="sensor" android:configChanges="orientation|keyboardHidden">
|
||||
<activity android:name="org.geometerplus.android.fbreader.FBReader" android:icon="@drawable/fbreader" android:label="FBReader" android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -12,7 +12,9 @@
|
|||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.TOCActivity" android:configChanges="orientation|keyboardHidden">
|
||||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookDownloader" android:theme="@android:style/Theme.Dialog" android:screenOrientation="sensor" android:configChanges="orientation|keyboardHidden">
|
||||
<activity android:name="org.geometerplus.android.fbreader.preferences.PreferenceActivity" android:configChanges="orientation|keyboardHidden">
|
||||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookDownloader" android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<binding key="<F>" action="search"/>
|
||||
<binding key="<P>" action="findPrevious"/>
|
||||
<binding key="<N>" action="findNext"/>
|
||||
<binding key="<VolumeDown>" action="touchScrollForward"/>
|
||||
<binding key="<VolumeUp>" action="touchScrollBackward"/>
|
||||
<binding key="<VolumeDown>" action="volumeKeyScrollForward"/>
|
||||
<binding key="<VolumeUp>" action="volumeKeyScrollBackward"/>
|
||||
<binding key="<Ctrl>+<Home>" action="gotoHome"/>
|
||||
<binding key="<Home>" action="gotoSectionStart"/>
|
||||
<binding key="<End>" action="gotoSectionEnd"/>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<menubar>
|
||||
<submenu id="preferences">
|
||||
<item id="preferences"/>
|
||||
<item id="bookInfo"/>
|
||||
</submenu>
|
||||
<item id="preferences"/>
|
||||
<item id="preferences-old"/>
|
||||
<submenu id="navigate">
|
||||
<item id="gotoHome"/>
|
||||
<item id="gotoSectionStart"/>
|
||||
|
|
|
@ -32,9 +32,11 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
import android.net.Uri;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
import org.geometerplus.zlibrary.core.dialogs.ZLDialogManager;
|
||||
//import org.geometerplus.zlibrary.ui.android.dialogs.ZLAndroidDialogManager;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
||||
|
@ -47,7 +49,11 @@ public class BookDownloader extends Activity {
|
|||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
//((ZLAndroidDialogManager)ZLDialogManager.getInstance()).setActivity(this);
|
||||
setRequestedOrientation(
|
||||
ZLAndroidApplication.Instance().AutoOrientationOption.getValue() ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR :
|
||||
ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
|
||||
);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.downloader);
|
||||
|
|
|
@ -19,11 +19,47 @@
|
|||
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidActivity;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
|
||||
public class FBReader extends ZLAndroidActivity {
|
||||
private int myFullScreenFlag;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
final ZLAndroidApplication application = ZLAndroidApplication.Instance();
|
||||
myFullScreenFlag =
|
||||
application.ShowStatusBarOption.getValue() ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
getWindow().setFlags(
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN, myFullScreenFlag
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final ZLAndroidApplication application = ZLAndroidApplication.Instance();
|
||||
|
||||
final int fullScreenFlag =
|
||||
application.ShowStatusBarOption.getValue() ? 0 : WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||
if (fullScreenFlag != myFullScreenFlag) {
|
||||
startActivity(new Intent(this, this.getClass()));
|
||||
finish();
|
||||
}
|
||||
setRequestedOrientation(
|
||||
application.AutoOrientationOption.getValue() ?
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR :
|
||||
ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
|
||||
);
|
||||
}
|
||||
|
||||
protected ZLApplication createApplication(String fileName) {
|
||||
String[] args = (fileName != null) ? new String[] { fileName } : new String[0];
|
||||
ZLApplication application = new org.geometerplus.fbreader.fbreader.FBReader(args);
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2009 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.android.fbreader.preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.*;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.*;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
import org.geometerplus.fbreader.fbreader.ScrollingPreferences;
|
||||
|
||||
public class PreferenceActivity extends android.preference.PreferenceActivity {
|
||||
private final ZLResource myResource = ZLResource.resource("dialog").getResource("Preferences");
|
||||
private final ArrayList<ZLPreference> myPreferences = new ArrayList<ZLPreference>();
|
||||
|
||||
private class Category {
|
||||
private final ZLResource myResource;
|
||||
private final PreferenceCategory myCategory;
|
||||
|
||||
Category(String resourceKey) {
|
||||
myResource = PreferenceActivity.this.myResource.getResource(resourceKey);
|
||||
myCategory = new PreferenceCategory(PreferenceActivity.this);
|
||||
myCategory.setTitle(myResource.getValue());
|
||||
myScreen.addPreference(myCategory);
|
||||
}
|
||||
|
||||
void addOption(ZLBooleanOption option, String resourceKey) {
|
||||
ZLBooleanPreference preference =
|
||||
new ZLBooleanPreference(PreferenceActivity.this, option, myResource, resourceKey);
|
||||
myCategory.addPreference(preference);
|
||||
myPreferences.add(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private PreferenceScreen myScreen;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
myScreen = getPreferenceManager().createPreferenceScreen(this);
|
||||
|
||||
final Category lookNFeelCategory = new Category("LookNFeel");
|
||||
lookNFeelCategory.addOption(ZLAndroidApplication.Instance().AutoOrientationOption, "autoOrientation");
|
||||
lookNFeelCategory.addOption(ZLAndroidApplication.Instance().ShowStatusBarOption, "showStatusBar");
|
||||
|
||||
final Category scrollingCategory = new Category("Scrolling");
|
||||
final ScrollingPreferences scrollingPreferences = ScrollingPreferences.Instance();
|
||||
scrollingCategory.addOption(scrollingPreferences.FlickOption, "flick");
|
||||
scrollingCategory.addOption(scrollingPreferences.VolumeKeysOption, "volumeKeys");
|
||||
scrollingCategory.addOption(scrollingPreferences.AnimateOption, "animated");
|
||||
scrollingCategory.addOption(scrollingPreferences.HorizontalOption, "horizontal");
|
||||
|
||||
setPreferenceScreen(myScreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
for (ZLPreference preference : myPreferences) {
|
||||
preference.accept();
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2009 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.android.fbreader.preferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.CheckBoxPreference;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
class ZLBooleanPreference extends CheckBoxPreference implements ZLPreference {
|
||||
private final ZLBooleanOption myOption;
|
||||
|
||||
ZLBooleanPreference(Context context, ZLBooleanOption option, ZLResource rootResource, String resourceKey) {
|
||||
super(context);
|
||||
myOption = option;
|
||||
|
||||
ZLResource resource = rootResource.getResource(resourceKey);
|
||||
setTitle(resource.getValue());
|
||||
setSummaryOn(resource.getResource("summaryOn").getValue());
|
||||
setSummaryOff(resource.getResource("summaryOff").getValue());
|
||||
setChecked(option.getValue());
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
myOption.setValue(isChecked());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2009 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.android.fbreader.preferences;
|
||||
|
||||
interface ZLPreference {
|
||||
void accept();
|
||||
}
|
|
@ -115,13 +115,7 @@ class ZLAndroidDialogContent extends ZLDialogContent {
|
|||
);
|
||||
break;
|
||||
case ZLOptionKind.KEY:
|
||||
view = new ZLAndroidKeyOptionView(
|
||||
this, name, (ZLKeyOptionEntry)option
|
||||
);
|
||||
break;
|
||||
case ZLOptionKind.ORDER:
|
||||
// TODO: implement
|
||||
break;
|
||||
case ZLOptionKind.MULTILINE:
|
||||
// TODO: implement
|
||||
break;
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 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.zlibrary.ui.android.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import android.text.*;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.dialogs.ZLKeyOptionEntry;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidKeyUtil;
|
||||
|
||||
class ZLAndroidKeyOptionView extends ZLAndroidOptionView {
|
||||
private TextView myLabel;
|
||||
private EditText myEditor;
|
||||
private Spinner mySpinner;
|
||||
|
||||
protected ZLAndroidKeyOptionView(ZLAndroidDialogContent tab, String name, ZLKeyOptionEntry option) {
|
||||
super(tab, name, option);
|
||||
}
|
||||
|
||||
private void setKeyName(String keyName) {
|
||||
myEditor.setText(keyName);
|
||||
myTab.invalidateView();
|
||||
final ZLKeyOptionEntry keyEntry = (ZLKeyOptionEntry)myOption;
|
||||
mySpinner.setSelection(keyEntry.actionIndex(keyName));
|
||||
keyEntry.onKeySelected(keyName);
|
||||
}
|
||||
|
||||
void addAndroidViews() {
|
||||
final Context context = myTab.getContext();
|
||||
|
||||
if (myLabel == null) {
|
||||
myLabel = new TextView(context);
|
||||
myLabel.setText(ZLResource.resource("keyOptionView").getResource("actionFor").getValue());
|
||||
myLabel.setPadding(0, 12, 0, 12);
|
||||
myLabel.setTextSize(18);
|
||||
}
|
||||
myTab.addAndroidView(myLabel, false);
|
||||
|
||||
final ZLKeyOptionEntry keyEntry = (ZLKeyOptionEntry)myOption;
|
||||
|
||||
if (myEditor == null) {
|
||||
myEditor = new EditText(context) {
|
||||
protected boolean getDefaultEditable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
setKeyName(ZLAndroidKeyUtil.getKeyNameByCode(keyCode));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
myTab.addAndroidView(myEditor, true);
|
||||
|
||||
if (myEditor.getText().length() > 0) {
|
||||
if (mySpinner == null) {
|
||||
mySpinner = new Spinner(context);
|
||||
final ComboAdapter adapter = new ComboAdapter(keyEntry.getActionNames());
|
||||
mySpinner.setAdapter(adapter);
|
||||
mySpinner.setOnItemSelectedListener(adapter);
|
||||
}
|
||||
myTab.addAndroidView(mySpinner, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void reset() {
|
||||
final ZLKeyOptionEntry keyEntry = (ZLKeyOptionEntry)myOption;
|
||||
keyEntry.onReset();
|
||||
if (myEditor != null) {
|
||||
setKeyName("");
|
||||
}
|
||||
}
|
||||
|
||||
protected void _onAccept() {
|
||||
((ZLKeyOptionEntry)myOption).onAccept();
|
||||
myLabel = null;
|
||||
myEditor = null;
|
||||
mySpinner = null;
|
||||
}
|
||||
|
||||
private class ComboAdapter extends BaseAdapter implements Spinner.OnItemSelectedListener {
|
||||
private final ArrayList myValues;
|
||||
|
||||
ComboAdapter(ArrayList values) {
|
||||
myValues = values;
|
||||
}
|
||||
|
||||
public void onItemSelected(AdapterView parent, View v, int position, long id) {
|
||||
final ZLKeyOptionEntry keyEntry = (ZLKeyOptionEntry)myOption;
|
||||
keyEntry.onValueChanged(myEditor.getText().toString(), position);
|
||||
}
|
||||
|
||||
public void onNothingSelected(AdapterView parent) {
|
||||
}
|
||||
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
TextView textView = new TextView(parent.getContext());
|
||||
textView.setPadding(0, 12, 0, 12);
|
||||
textView.setTextSize(20);
|
||||
textView.setText((String)getItem(position));
|
||||
convertView = textView;
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
EditText editor;
|
||||
if (convertView != null) {
|
||||
editor = (EditText)convertView;
|
||||
} else {
|
||||
editor = new EditText(parent.getContext()) {
|
||||
protected boolean getDefaultEditable() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
editor.setText((String)getItem(position));
|
||||
return editor;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return myValues.size();
|
||||
}
|
||||
|
||||
public Object getItem(int position) {
|
||||
return myValues.get(position);
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public boolean stableIds() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||
import android.app.Application;
|
||||
|
||||
import org.geometerplus.zlibrary.core.xml.own.ZLOwnXMLProcessorFactory;
|
||||
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
|
||||
import org.geometerplus.zlibrary.core.sqliteconfig.ZLSQLiteConfig;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.application.ZLAndroidApplicationWindow;
|
||||
|
@ -33,6 +34,9 @@ import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
|||
public class ZLAndroidApplication extends Application {
|
||||
private static ZLAndroidApplication ourApplication;
|
||||
|
||||
public final ZLBooleanOption AutoOrientationOption = new ZLBooleanOption("LookNFeel", "AutoOrientation", true);
|
||||
public final ZLBooleanOption ShowStatusBarOption = new ZLBooleanOption("LookNFeel", "ShowStatusBar", true);
|
||||
|
||||
public static ZLAndroidApplication Instance() {
|
||||
return ourApplication;
|
||||
}
|
||||
|
|
|
@ -33,18 +33,18 @@ public class ZLAndroidViewWidget extends ZLViewWidget {
|
|||
widget.setViewWidget(this);
|
||||
}
|
||||
|
||||
protected void scrollTo(int shift) {
|
||||
protected void scrollTo(int viewPage, int shift) {
|
||||
final ZLAndroidWidget widget =
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||
widget.setViewWidget(this);
|
||||
widget.scrollTo(shift);
|
||||
widget.scrollToPage(viewPage, shift);
|
||||
}
|
||||
|
||||
protected void startAutoScrolling(boolean forward) {
|
||||
protected void startAutoScrolling(int viewPage) {
|
||||
final ZLAndroidWidget widget =
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||
widget.setViewWidget(this);
|
||||
widget.startAutoScrolling(forward);
|
||||
widget.startAutoScrolling(viewPage);
|
||||
}
|
||||
|
||||
public void repaint() {
|
||||
|
@ -54,8 +54,4 @@ public class ZLAndroidViewWidget extends ZLViewWidget {
|
|||
// I'm not sure about threads, so postInvalidate() is used instead of invalidate()
|
||||
widget.postInvalidate();
|
||||
}
|
||||
|
||||
protected void setVerticalScrollbarParameters(int full, int from, int to) {
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget().setVerticalScrollbarParameters(full, from, to);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,10 +67,11 @@ public class ZLAndroidWidget extends View {
|
|||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
if (myScreenIsTouched) {
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
view.onStylusRelease(myTouchX, myTouchY);
|
||||
myScrollingInProgress = false;
|
||||
myScrollingShift = 0;
|
||||
myScreenIsTouched = false;
|
||||
view.onScrollingFinished(ZLView.PAGE_CENTRAL);
|
||||
setPageToScroll(ZLView.PAGE_CENTRAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,32 +120,69 @@ public class ZLAndroidWidget extends View {
|
|||
}
|
||||
myScrollingSpeed *= 1.5;
|
||||
}
|
||||
canvas.drawBitmap(myMainBitmap, 0, myScrollingShift, context.Paint);
|
||||
int shift = (myScrollingShift < 0) ? (myScrollingShift + h) : (myScrollingShift - h);
|
||||
canvas.drawBitmap(mySecondaryBitmap, 0, shift, context.Paint);
|
||||
final boolean horizontal =
|
||||
(myViewPageToScroll == ZLView.PAGE_RIGHT) ||
|
||||
(myViewPageToScroll == ZLView.PAGE_LEFT);
|
||||
canvas.drawBitmap(
|
||||
myMainBitmap,
|
||||
horizontal ? myScrollingShift : 0,
|
||||
horizontal ? 0 : myScrollingShift,
|
||||
context.Paint
|
||||
);
|
||||
final int size = horizontal ? w : h;
|
||||
int shift = (myScrollingShift < 0) ? (myScrollingShift + size) : (myScrollingShift - size);
|
||||
canvas.drawBitmap(
|
||||
mySecondaryBitmap,
|
||||
horizontal ? shift : 0,
|
||||
horizontal ? 0 : shift,
|
||||
context.Paint
|
||||
);
|
||||
if (stopScrolling) {
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
if (myScrollingBound != 0) {
|
||||
Bitmap swap = myMainBitmap;
|
||||
myMainBitmap = mySecondaryBitmap;
|
||||
mySecondaryBitmap = swap;
|
||||
mySecondaryBitmapIsUpToDate = false;
|
||||
ZLApplication.Instance().getCurrentView().onScrollingFinished(0, (myScrollingBound < 0) ? 1 : -1);
|
||||
view.onScrollingFinished(myViewPageToScroll);
|
||||
} else {
|
||||
view.onScrollingFinished(ZLView.PAGE_CENTRAL);
|
||||
}
|
||||
setPageToScroll(ZLView.PAGE_CENTRAL);
|
||||
myScrollingInProgress = false;
|
||||
myScrollingShift = 0;
|
||||
} else {
|
||||
if (shift < 0) {
|
||||
shift += h;
|
||||
shift += size;
|
||||
}
|
||||
// TODO: set color
|
||||
canvas.drawLine(0, shift, w, shift, context.Paint);
|
||||
if (horizontal) {
|
||||
canvas.drawLine(shift, 0, shift, h + 1, context.Paint);
|
||||
} else {
|
||||
canvas.drawLine(0, shift, w + 1, shift, context.Paint);
|
||||
}
|
||||
if (myScrollingInProgress) {
|
||||
postInvalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scrollTo(int shift) {
|
||||
private int myViewPageToScroll = ZLView.PAGE_CENTRAL;
|
||||
private void setPageToScroll(int viewPage) {
|
||||
if (myViewPageToScroll != viewPage) {
|
||||
myViewPageToScroll = viewPage;
|
||||
mySecondaryBitmapIsUpToDate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void scrollToPage(int viewPage, int shift) {
|
||||
switch (viewPage) {
|
||||
case ZLView.PAGE_BOTTOM:
|
||||
case ZLView.PAGE_RIGHT:
|
||||
shift = -shift;
|
||||
break;
|
||||
}
|
||||
|
||||
if (myMainBitmap == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -153,20 +191,54 @@ public class ZLAndroidWidget extends View {
|
|||
mySecondaryBitmapIsUpToDate = false;
|
||||
}
|
||||
myScrollingShift = shift;
|
||||
setPageToScroll(viewPage);
|
||||
drawOnBitmap(mySecondaryBitmap);
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
void startAutoScrolling(boolean forward) {
|
||||
void startAutoScrolling(int viewPage) {
|
||||
if (myMainBitmap == null) {
|
||||
return;
|
||||
}
|
||||
drawOnBitmap(mySecondaryBitmap);
|
||||
myScrollingInProgress = true;
|
||||
final boolean scrollUp = myScrollingShift > 0;
|
||||
myScrollingSpeed = (scrollUp == forward) ? 3 : -3;
|
||||
final int h = getHeight();
|
||||
myScrollingBound = forward ? (scrollUp ? h : -h) : 0;
|
||||
switch (viewPage) {
|
||||
case ZLView.PAGE_CENTRAL:
|
||||
switch (myViewPageToScroll) {
|
||||
case ZLView.PAGE_CENTRAL:
|
||||
myScrollingSpeed = 0;
|
||||
break;
|
||||
case ZLView.PAGE_LEFT:
|
||||
case ZLView.PAGE_TOP:
|
||||
myScrollingSpeed = -3;
|
||||
break;
|
||||
case ZLView.PAGE_RIGHT:
|
||||
case ZLView.PAGE_BOTTOM:
|
||||
myScrollingSpeed = 3;
|
||||
break;
|
||||
}
|
||||
myScrollingBound = 0;
|
||||
break;
|
||||
case ZLView.PAGE_LEFT:
|
||||
myScrollingSpeed = 3;
|
||||
myScrollingBound = getWidth();
|
||||
break;
|
||||
case ZLView.PAGE_RIGHT:
|
||||
myScrollingSpeed = -3;
|
||||
myScrollingBound = -getWidth();
|
||||
break;
|
||||
case ZLView.PAGE_TOP:
|
||||
myScrollingSpeed = 3;
|
||||
myScrollingBound = getHeight();
|
||||
break;
|
||||
case ZLView.PAGE_BOTTOM:
|
||||
myScrollingSpeed = -3;
|
||||
myScrollingBound = -getHeight();
|
||||
break;
|
||||
}
|
||||
if (viewPage != ZLView.PAGE_CENTRAL) {
|
||||
setPageToScroll(viewPage);
|
||||
}
|
||||
drawOnBitmap(mySecondaryBitmap);
|
||||
postInvalidate();
|
||||
}
|
||||
|
||||
|
@ -210,8 +282,7 @@ public class ZLAndroidWidget extends View {
|
|||
canvas.rotate(90, w / 2, w / 2);
|
||||
break;
|
||||
}
|
||||
int dy = (bitmap == myMainBitmap) ? 0 : ((myScrollingShift > 0) ? -1 : 1);
|
||||
view.paint(0, dy);
|
||||
view.paint((bitmap == myMainBitmap) ? ZLView.PAGE_CENTRAL : myViewPageToScroll);
|
||||
context.endPaint();
|
||||
}
|
||||
|
||||
|
@ -227,8 +298,6 @@ public class ZLAndroidWidget extends View {
|
|||
}
|
||||
|
||||
private boolean myScreenIsTouched;
|
||||
private int myTouchX;
|
||||
private int myTouchY;
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
int x = (int)event.getX();
|
||||
|
@ -257,8 +326,6 @@ public class ZLAndroidWidget extends View {
|
|||
break;
|
||||
}
|
||||
}
|
||||
myTouchX = x;
|
||||
myTouchY = y;
|
||||
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
switch (event.getAction()) {
|
||||
|
@ -283,8 +350,7 @@ public class ZLAndroidWidget extends View {
|
|||
if (keyName.equals("<Menu>") || keyName.equals("<Call>")) {
|
||||
return false;
|
||||
}
|
||||
ZLApplication.Instance().doActionByKey(keyName);
|
||||
return true;
|
||||
return ZLApplication.Instance().doActionByKey(keyName);
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
|
@ -295,6 +361,7 @@ public class ZLAndroidWidget extends View {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
private int myScrollBarRange;
|
||||
private int myScrollBarOffset;
|
||||
private int myScrollBarThumbSize;
|
||||
|
@ -317,16 +384,42 @@ public class ZLAndroidWidget extends View {
|
|||
myScrollBarOffset = from;
|
||||
myScrollBarThumbSize = to - from;
|
||||
}
|
||||
*/
|
||||
|
||||
protected int computeVerticalScrollExtent() {
|
||||
return myScrollBarThumbSize;
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
if (myScrollingInProgress || (myScrollingShift != 0)) {
|
||||
final int from = view.getScrollbarThumbLength(ZLView.PAGE_CENTRAL);
|
||||
final int to = view.getScrollbarThumbLength(myViewPageToScroll);
|
||||
final boolean horizontal =
|
||||
(myViewPageToScroll == ZLView.PAGE_RIGHT) ||
|
||||
(myViewPageToScroll == ZLView.PAGE_LEFT);
|
||||
final int size = horizontal ? getWidth() : getHeight();
|
||||
final int shift = Math.abs(myScrollingShift);
|
||||
return (from * (size - shift) + to * shift) / size;
|
||||
} else {
|
||||
return view.getScrollbarThumbLength(ZLView.PAGE_CENTRAL);
|
||||
}
|
||||
}
|
||||
|
||||
protected int computeVerticalScrollOffset() {
|
||||
return myScrollBarOffset;
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
if (myScrollingInProgress || (myScrollingShift != 0)) {
|
||||
final int from = view.getScrollbarThumbPosition(ZLView.PAGE_CENTRAL);
|
||||
final int to = view.getScrollbarThumbPosition(myViewPageToScroll);
|
||||
final boolean horizontal =
|
||||
(myViewPageToScroll == ZLView.PAGE_RIGHT) ||
|
||||
(myViewPageToScroll == ZLView.PAGE_LEFT);
|
||||
final int size = horizontal ? getWidth() : getHeight();
|
||||
final int shift = Math.abs(myScrollingShift);
|
||||
return (from * (size - shift) + to * shift) / size;
|
||||
} else {
|
||||
return view.getScrollbarThumbPosition(ZLView.PAGE_CENTRAL);
|
||||
}
|
||||
}
|
||||
|
||||
protected int computeVerticalScrollRange() {
|
||||
return myScrollBarRange;
|
||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||
return view.getScrollbarFullSize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,15 +21,16 @@ package org.geometerplus.fbreader.fbreader;
|
|||
|
||||
public interface ActionCode {
|
||||
String SHOW_LIBRARY = "showLibrary";
|
||||
String SHOW_OPTIONS = "preferences";
|
||||
String SHOW_OPTIONS = "preferences-old";
|
||||
String SHOW_PREFERENCES = "preferences";
|
||||
String UNDO = "undo";
|
||||
String REDO = "redo";
|
||||
String SHOW_CONTENTS = "toc";
|
||||
String SEARCH = "search";
|
||||
String FIND_PREVIOUS = "findPrevious";
|
||||
String FIND_NEXT = "findNext";
|
||||
String TOUCH_SCROLL_FORWARD = "touchScrollForward";
|
||||
String TOUCH_SCROLL_BACKWARD = "touchScrollBackward";
|
||||
String VOLUME_KEY_SCROLL_FORWARD = "volumeKeyScrollForward";
|
||||
String VOLUME_KEY_SCROLL_BACKWARD = "volumeKeyScrollBackward";
|
||||
String TRACKBALL_SCROLL_FORWARD = "trackballScrollForward";
|
||||
String TRACKBALL_SCROLL_BACKWARD = "trackballScrollBackward";
|
||||
String SCROLL_TO_HOME = "gotoHome";
|
||||
|
|
|
@ -96,15 +96,12 @@ public class BookTextView extends FBView {
|
|||
}
|
||||
}
|
||||
|
||||
protected void onPreparePaintInfo() {
|
||||
protected void onPaintInfoPrepared() {
|
||||
if (myPositionStack.isEmpty()) {
|
||||
myPositionStack.add(new Position(myCurrentModelIndex, getStartCursor()));
|
||||
} else {
|
||||
((Position)myPositionStack.get(myCurrentPointInStack)).set(getStartCursor());
|
||||
((Position)myPositionStack.get(myCurrentPointInStack)).ModelIndex = myCurrentModelIndex;
|
||||
|
||||
// Position position = (Position)myPositionStack.get(myCurrentPointInStack);
|
||||
// System.out.println("current position " + position.ModelIndex + " , " + position.ParagraphIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,11 +150,7 @@ public class BookTextView extends FBView {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean onStylusRelease(int x, int y) {
|
||||
if (super.onStylusRelease(x, y)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onStylusPress(int x, int y) {
|
||||
ZLTextElementArea area = getElementByCoordinates(x, y);
|
||||
if (area != null) {
|
||||
ZLTextElement element = area.Element;
|
||||
|
@ -199,7 +192,8 @@ public class BookTextView extends FBView {
|
|||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return super.onStylusPress(x, y);
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
|
|
|
@ -50,8 +50,6 @@ public final class FBReader extends ZLApplication {
|
|||
public final ZLBooleanOption UseSeparateBindingsOption =
|
||||
new ZLBooleanOption("KeysOptions", "UseSeparateBindings", false);
|
||||
|
||||
public final ScrollingOptions TouchScrollingOptions =
|
||||
new ScrollingOptions("TouchScrolling", ZLTextView.ScrollingMode.NO_OVERLAPPING);
|
||||
public final ScrollingOptions TrackballScrollingOptions =
|
||||
new ScrollingOptions("TrackballScrolling", ZLTextView.ScrollingMode.SCROLL_LINES);
|
||||
|
||||
|
@ -107,6 +105,7 @@ public final class FBReader extends ZLApplication {
|
|||
|
||||
addAction(ActionCode.SHOW_LIBRARY, new ShowLibrary(this));
|
||||
addAction(ActionCode.SHOW_OPTIONS, new ShowOptionsDialogAction(this));
|
||||
addAction(ActionCode.SHOW_PREFERENCES, new PreferencesAction(this));
|
||||
addAction(ActionCode.SHOW_CONTENTS, new ShowTOCAction(this));
|
||||
|
||||
addAction(ActionCode.SEARCH, new SearchAction(this));
|
||||
|
@ -116,8 +115,8 @@ public final class FBReader extends ZLApplication {
|
|||
addAction(ActionCode.SCROLL_TO_HOME, new ScrollToHomeAction(this));
|
||||
addAction(ActionCode.SCROLL_TO_START_OF_TEXT, new DummyAction(this));
|
||||
addAction(ActionCode.SCROLL_TO_END_OF_TEXT, new DummyAction(this));
|
||||
addAction(ActionCode.TOUCH_SCROLL_FORWARD, new ScrollingAction(this, TouchScrollingOptions, true));
|
||||
addAction(ActionCode.TOUCH_SCROLL_BACKWARD, new ScrollingAction(this, TouchScrollingOptions, false));
|
||||
addAction(ActionCode.VOLUME_KEY_SCROLL_FORWARD, new VolumeKeyScrollingAction(this, true));
|
||||
addAction(ActionCode.VOLUME_KEY_SCROLL_BACKWARD, new VolumeKeyScrollingAction(this, false));
|
||||
addAction(ActionCode.TRACKBALL_SCROLL_FORWARD, new ScrollingAction(this, TrackballScrollingOptions, true));
|
||||
addAction(ActionCode.TRACKBALL_SCROLL_BACKWARD, new ScrollingAction(this, TrackballScrollingOptions, false));
|
||||
addAction(ActionCode.CANCEL, new CancelAction(this));
|
||||
|
@ -174,8 +173,8 @@ public final class FBReader extends ZLApplication {
|
|||
}
|
||||
}
|
||||
|
||||
ZLTextView getTextView() {
|
||||
return (ZLTextView)getCurrentView();
|
||||
FBView getTextView() {
|
||||
return (FBView)getCurrentView();
|
||||
}
|
||||
|
||||
int getMode() {
|
||||
|
|
|
@ -45,18 +45,52 @@ public abstract class FBView extends ZLTextViewImpl {
|
|||
super(context);
|
||||
}
|
||||
|
||||
final void doScrollPage(boolean forward) {
|
||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||
if (preferences.AnimateOption.getValue()) {
|
||||
final int viewPage =
|
||||
preferences.HorizontalOption.getValue() ?
|
||||
(forward ? PAGE_RIGHT : PAGE_LEFT) :
|
||||
(forward ? PAGE_BOTTOM : PAGE_TOP);
|
||||
startAutoScrolling(viewPage);
|
||||
} else {
|
||||
scrollPage(forward, ZLTextView.ScrollingMode.NO_OVERLAPPING, 0);
|
||||
ZLApplication.Instance().refreshWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private int myStartX;
|
||||
private int myStartY;
|
||||
private boolean myScrollingIsActive;
|
||||
private boolean myIsManualScrollingActive;
|
||||
|
||||
public boolean onStylusPress(int x, int y) {
|
||||
if (super.onStylusPress(x, y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
myStartX = x;
|
||||
myStartY = y;
|
||||
myScrollingIsActive = true;
|
||||
if (!isScrollingActive()) {
|
||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||
if (preferences.FlickOption.getValue()) {
|
||||
myStartX = x;
|
||||
myStartY = y;
|
||||
setScrollingActive(true);
|
||||
myIsManualScrollingActive = true;
|
||||
} else {
|
||||
if (preferences.HorizontalOption.getValue()) {
|
||||
if (x <= Context.getWidth() / 3) {
|
||||
doScrollPage(false);
|
||||
} else if (x >= Context.getWidth() * 2 / 3) {
|
||||
doScrollPage(true);
|
||||
}
|
||||
} else {
|
||||
if (y <= Context.getHeight() / 3) {
|
||||
doScrollPage(false);
|
||||
} else if (y >= Context.getHeight() * 2 / 3) {
|
||||
doScrollPage(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//activateSelection(x, y);
|
||||
return true;
|
||||
|
@ -67,18 +101,23 @@ public abstract class FBView extends ZLTextViewImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (myScrollingIsActive) {
|
||||
final int diffY = y - myStartY;
|
||||
boolean doScroll = true;
|
||||
if (diffY > 0) {
|
||||
ZLTextWordCursor cursor = getStartCursor();
|
||||
doScroll = !cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst();
|
||||
} else if (diffY < 0) {
|
||||
ZLTextWordCursor cursor = getEndCursor();
|
||||
doScroll = !cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast();
|
||||
}
|
||||
if (doScroll) {
|
||||
scrollTo(diffY);
|
||||
synchronized (this) {
|
||||
if (isScrollingActive() && myIsManualScrollingActive) {
|
||||
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
|
||||
final int diff = horizontal ? x - myStartX : y - myStartY;
|
||||
if (diff > 0) {
|
||||
ZLTextWordCursor cursor = getStartCursor();
|
||||
if (!cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst()) {
|
||||
scrollTo(horizontal ? PAGE_LEFT : PAGE_TOP, diff);
|
||||
}
|
||||
} else if (diff < 0) {
|
||||
ZLTextWordCursor cursor = getEndCursor();
|
||||
if (!cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast()) {
|
||||
scrollTo(horizontal ? PAGE_RIGHT : PAGE_BOTTOM, -diff);
|
||||
}
|
||||
} else {
|
||||
scrollTo(PAGE_CENTRAL, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -87,33 +126,48 @@ public abstract class FBView extends ZLTextViewImpl {
|
|||
}
|
||||
|
||||
public boolean onStylusRelease(int x, int y) {
|
||||
boolean scrollingWasActive = myScrollingIsActive;
|
||||
myScrollingIsActive = false;
|
||||
|
||||
if (super.onStylusRelease(x, y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (scrollingWasActive) {
|
||||
final int diffY = y - myStartY;
|
||||
boolean doScroll = false;
|
||||
if (diffY > 0) {
|
||||
ZLTextWordCursor cursor = getStartCursor();
|
||||
doScroll = !cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst();
|
||||
} else if (diffY < 0) {
|
||||
ZLTextWordCursor cursor = getEndCursor();
|
||||
doScroll = !cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast();
|
||||
}
|
||||
if (doScroll) {
|
||||
final int h = Context.getHeight();
|
||||
final int w = Context.getWidth();
|
||||
final int minDiff = (h > w) ? h / 4 : h / 3;
|
||||
startAutoScrolling(Math.abs(diffY) >= minDiff);
|
||||
synchronized (this) {
|
||||
if (isScrollingActive() && myIsManualScrollingActive) {
|
||||
setScrollingActive(false);
|
||||
myIsManualScrollingActive = false;
|
||||
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
|
||||
final int diff = horizontal ? x - myStartX : y - myStartY;
|
||||
boolean doScroll = false;
|
||||
if (diff > 0) {
|
||||
ZLTextWordCursor cursor = getStartCursor();
|
||||
doScroll = !cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst();
|
||||
} else if (diff < 0) {
|
||||
ZLTextWordCursor cursor = getEndCursor();
|
||||
doScroll = !cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast();
|
||||
}
|
||||
if (doScroll) {
|
||||
final int h = Context.getHeight();
|
||||
final int w = Context.getWidth();
|
||||
final int minDiff = horizontal ?
|
||||
((w > h) ? w / 4 : w / 3) :
|
||||
((h > w) ? h / 4 : h / 3);
|
||||
int viewPage = PAGE_CENTRAL;
|
||||
if (Math.abs(diff) > minDiff) {
|
||||
viewPage = horizontal ?
|
||||
((diff < 0) ? PAGE_RIGHT : PAGE_LEFT) :
|
||||
((diff < 0) ? PAGE_BOTTOM : PAGE_TOP);
|
||||
}
|
||||
if (ScrollingPreferences.Instance().AnimateOption.getValue()) {
|
||||
startAutoScrolling(viewPage);
|
||||
} else {
|
||||
scrollTo(PAGE_CENTRAL, 0);
|
||||
onScrollingFinished(viewPage);
|
||||
ZLApplication.Instance().refreshWindow();
|
||||
setScrollingActive(false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//activateSelection(x, y);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 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;
|
||||
|
||||
import org.geometerplus.android.fbreader.preferences.PreferenceActivity;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.dialogs.ZLAndroidDialogManager;
|
||||
|
||||
class PreferencesAction extends FBAction {
|
||||
PreferencesAction(FBReader fbreader) {
|
||||
super(fbreader);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
final ZLAndroidDialogManager dialogManager =
|
||||
(ZLAndroidDialogManager)ZLAndroidDialogManager.getInstance();
|
||||
dialogManager.runActivity(PreferenceActivity.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package org.geometerplus.fbreader.fbreader;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
|
||||
|
||||
public class ScrollingPreferences {
|
||||
private static ScrollingPreferences ourInstance;
|
||||
|
||||
public static ScrollingPreferences Instance() {
|
||||
return (ourInstance != null) ? ourInstance : new ScrollingPreferences();
|
||||
}
|
||||
|
||||
public final ZLBooleanOption FlickOption = new ZLBooleanOption("Scrolling", "Flick", true);
|
||||
public final ZLBooleanOption VolumeKeysOption = new ZLBooleanOption("Scrolling", "VolumeKeys", true);
|
||||
public final ZLBooleanOption AnimateOption = new ZLBooleanOption("Scrolling", "ShowAnimated", true);
|
||||
public final ZLBooleanOption HorizontalOption = new ZLBooleanOption("Scrolling", "Horizontal", false);
|
||||
|
||||
private ScrollingPreferences() {
|
||||
ourInstance = this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 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;
|
||||
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextView;
|
||||
|
||||
class VolumeKeyScrollingAction extends FBAction {
|
||||
private final boolean myForward;
|
||||
|
||||
VolumeKeyScrollingAction(FBReader fbreader, boolean forward) {
|
||||
super(fbreader);
|
||||
myForward = forward;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return ScrollingPreferences.Instance().VolumeKeysOption.getValue();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
Reader.getTextView().doScrollPage(myForward);
|
||||
}
|
||||
}
|
|
@ -1,242 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 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.optionsDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.geometerplus.zlibrary.core.application.*;
|
||||
import org.geometerplus.zlibrary.core.dialogs.*;
|
||||
import org.geometerplus.zlibrary.core.options.*;
|
||||
import org.geometerplus.zlibrary.core.optionEntries.*;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.view.ZLViewWidget;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.*;
|
||||
|
||||
public class KeyBindingsPage {
|
||||
|
||||
public KeyBindingsPage(FBReader fbreader, ZLDialogContent dialogTab) {
|
||||
if (new ZLBooleanOption(ZLOption.PLATFORM_GROUP, "FullKeyboardControlSupported", false).getValue()) {
|
||||
dialogTab.addOption("grabSystemKeys", new KeyboardControlEntry(fbreader));
|
||||
}
|
||||
MultiKeyOptionEntry keyEntry = new MultiKeyOptionEntry(dialogTab.getResource("action"), fbreader);
|
||||
OrientationEntry orientationEntry = new OrientationEntry(keyEntry);
|
||||
ZLBooleanOptionEntry useSeparateBindingsEntry = new UseSeparateOptionsEntry(fbreader, keyEntry, orientationEntry);
|
||||
dialogTab.addOption("separate", useSeparateBindingsEntry);
|
||||
dialogTab.addOption("orientation", orientationEntry);
|
||||
dialogTab.addOption("action", keyEntry);//?
|
||||
useSeparateBindingsEntry.onStateChanged(useSeparateBindingsEntry.initialState());
|
||||
//dialogTab.addOption("keyDelay", new ZLSimpleSpinOptionEntry(fbreader.KeyDelayOption, 50));
|
||||
}
|
||||
|
||||
private static class KeyboardControlEntry extends ZLSimpleBooleanOptionEntry {
|
||||
private FBReader myFBReader;
|
||||
public KeyboardControlEntry(FBReader fbreader) {
|
||||
super(fbreader.KeyboardControlOption);
|
||||
myFBReader = fbreader;
|
||||
}
|
||||
|
||||
public void onStateChanged(boolean state) {
|
||||
super.onStateChanged(state);
|
||||
myFBReader.grabAllKeys(state);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SingleKeyOptionEntry extends ZLSimpleKeyOptionEntry {
|
||||
private final CodeIndexBimap myBimap;
|
||||
|
||||
public SingleKeyOptionEntry(final CodeIndexBimap bimap, ZLKeyBindings bindings) {
|
||||
super(bindings);
|
||||
myBimap = bimap;
|
||||
}
|
||||
|
||||
public CodeIndexBimap codeIndexBimap() {
|
||||
return myBimap;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MultiKeyOptionEntry extends ZLKeyOptionEntry {
|
||||
private final ZLResource myResource;
|
||||
private ZLSimpleKeyOptionEntry.CodeIndexBimap myBimap;
|
||||
private SingleKeyOptionEntry myEntry0;
|
||||
private SingleKeyOptionEntry myEntry90;
|
||||
private SingleKeyOptionEntry myEntry180;
|
||||
private SingleKeyOptionEntry myEntry270;
|
||||
private SingleKeyOptionEntry myCurrentEntry;
|
||||
private ZLOptionEntry myExitOnCancelEntry;
|
||||
|
||||
public MultiKeyOptionEntry(final ZLResource resource, FBReader fbreader) {
|
||||
super();
|
||||
myResource = resource;
|
||||
myBimap = new ZLSimpleKeyOptionEntry.CodeIndexBimap();
|
||||
myEntry0 = new SingleKeyOptionEntry(myBimap, fbreader.keyBindings(ZLViewWidget.Angle.DEGREES0));
|
||||
myEntry90 = new SingleKeyOptionEntry(myBimap, fbreader.keyBindings(ZLViewWidget.Angle.DEGREES90));
|
||||
myEntry180 = new SingleKeyOptionEntry(myBimap, fbreader.keyBindings(ZLViewWidget.Angle.DEGREES180));
|
||||
myEntry270 = new SingleKeyOptionEntry(myBimap, fbreader.keyBindings(ZLViewWidget.Angle.DEGREES270));
|
||||
myCurrentEntry = myEntry0;
|
||||
myExitOnCancelEntry = null;
|
||||
|
||||
addAction(ZLApplication.NoAction);
|
||||
|
||||
// switch view
|
||||
addAction(ActionCode.SHOW_LIBRARY);
|
||||
addAction(ActionCode.SHOW_CONTENTS);
|
||||
|
||||
// navigation
|
||||
addAction(ActionCode.SCROLL_TO_HOME);
|
||||
addAction(ActionCode.SCROLL_TO_START_OF_TEXT);
|
||||
addAction(ActionCode.SCROLL_TO_END_OF_TEXT);
|
||||
addAction(ActionCode.GOTO_NEXT_TOC_SECTION);
|
||||
addAction(ActionCode.GOTO_PREVIOUS_TOC_SECTION);
|
||||
addAction(ActionCode.UNDO);
|
||||
addAction(ActionCode.REDO);
|
||||
|
||||
// selection
|
||||
//addAction(ActionCode.COPY_SELECTED_TEXT_TO_CLIPBOARD);
|
||||
//addAction(ActionCode.OPEN_SELECTED_TEXT_IN_DICTIONARY);
|
||||
//addAction(ActionCode.CLEAR_SELECTION);
|
||||
|
||||
// search
|
||||
addAction(ActionCode.SEARCH);
|
||||
addAction(ActionCode.FIND_PREVIOUS);
|
||||
addAction(ActionCode.FIND_NEXT);
|
||||
|
||||
// look
|
||||
addAction(ActionCode.INCREASE_FONT);
|
||||
addAction(ActionCode.DECREASE_FONT);
|
||||
addAction(ActionCode.TOGGLE_FULLSCREEN);
|
||||
addAction(ActionCode.FULLSCREEN_ON);
|
||||
addAction(ActionCode.ROTATE_SCREEN);
|
||||
|
||||
// dialogs
|
||||
addAction(ActionCode.SHOW_OPTIONS);
|
||||
|
||||
// quit
|
||||
addAction(ActionCode.CANCEL);
|
||||
addAction(ActionCode.QUIT);
|
||||
}
|
||||
|
||||
public int actionIndex(String key) {
|
||||
return myCurrentEntry.actionIndex(key);
|
||||
}
|
||||
|
||||
public void onAccept() {
|
||||
myEntry0.onAccept();
|
||||
myEntry90.onAccept();
|
||||
myEntry180.onAccept();
|
||||
myEntry270.onAccept();
|
||||
}
|
||||
|
||||
public void onReset() {
|
||||
myEntry0.onReset();
|
||||
myEntry90.onReset();
|
||||
myEntry180.onReset();
|
||||
myEntry270.onReset();
|
||||
}
|
||||
|
||||
public void onKeySelected(String key) {
|
||||
if (myExitOnCancelEntry != null) {
|
||||
myExitOnCancelEntry.setVisible(ActionCode.CANCEL.equals(myBimap.codeByIndex(myCurrentEntry.actionIndex(key))));
|
||||
}
|
||||
}
|
||||
|
||||
public void onValueChanged(String key, int index) {
|
||||
myCurrentEntry.onValueChanged(key, index);
|
||||
if (myExitOnCancelEntry != null) {
|
||||
myExitOnCancelEntry.setVisible(ActionCode.CANCEL.equals(myBimap.codeByIndex(index)));
|
||||
}
|
||||
}
|
||||
|
||||
public void setOrientation(int angle) {
|
||||
switch (angle) {
|
||||
case ZLViewWidget.Angle.DEGREES0:
|
||||
myCurrentEntry = myEntry0;
|
||||
break;
|
||||
case ZLViewWidget.Angle.DEGREES90:
|
||||
myCurrentEntry = myEntry90;
|
||||
break;
|
||||
case ZLViewWidget.Angle.DEGREES180:
|
||||
myCurrentEntry = myEntry180;
|
||||
break;
|
||||
case ZLViewWidget.Angle.DEGREES270:
|
||||
myCurrentEntry = myEntry270;
|
||||
break;
|
||||
}
|
||||
resetView();
|
||||
}
|
||||
|
||||
public void setExitOnCancelEntry(ZLOptionEntry exitOnCancelEntry) {
|
||||
myExitOnCancelEntry = exitOnCancelEntry;
|
||||
}
|
||||
|
||||
private void addAction(final String actionId) {
|
||||
myBimap.insert(actionId);
|
||||
addActionName(myResource.getResource(actionId).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static class OrientationEntry extends ZLComboOptionEntry {
|
||||
private MultiKeyOptionEntry myKeyEntry;
|
||||
private static final ArrayList VALUES = new ArrayList();
|
||||
|
||||
public OrientationEntry(MultiKeyOptionEntry keyEntry) {
|
||||
myKeyEntry = keyEntry;
|
||||
}
|
||||
|
||||
public ArrayList getValues() {
|
||||
if (VALUES.size() == 0) {
|
||||
VALUES.add("0 Degrees");
|
||||
VALUES.add("90 Degrees Counterclockwise");
|
||||
VALUES.add("180 Degrees");
|
||||
VALUES.add("90 Degrees Clockwise");
|
||||
}
|
||||
return VALUES;
|
||||
}
|
||||
|
||||
public String initialValue() {
|
||||
return (String) getValues().get(0);
|
||||
}
|
||||
|
||||
public void onAccept(String value) {}
|
||||
|
||||
public void onValueSelected(int index) {
|
||||
final int angles [] = {ZLViewWidget.Angle.DEGREES0, ZLViewWidget.Angle.DEGREES90,
|
||||
ZLViewWidget.Angle.DEGREES180, ZLViewWidget.Angle.DEGREES270};
|
||||
myKeyEntry.setOrientation(angles[index]);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UseSeparateOptionsEntry extends ZLSimpleBooleanOptionEntry {
|
||||
private ZLOptionEntry myKeyEntry;
|
||||
private OrientationEntry myOrientationEntry;
|
||||
|
||||
public UseSeparateOptionsEntry(FBReader fbreader, ZLOptionEntry keyEntry, OrientationEntry orientationEntry) {
|
||||
super(fbreader.UseSeparateBindingsOption);
|
||||
myKeyEntry = keyEntry;
|
||||
myOrientationEntry = orientationEntry;
|
||||
}
|
||||
|
||||
public void onStateChanged(boolean state) {
|
||||
super.onStateChanged(state);
|
||||
myOrientationEntry.setVisible(state);
|
||||
myKeyEntry.resetView();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,8 +49,6 @@ public class OptionsDialog {
|
|||
// encodingTab.addOption("defaultEncodingSet", encodingSetEntry);
|
||||
// encodingTab.addOption("defaultEncoding", encodingEntry);
|
||||
|
||||
new ScrollingOptionsPage(myDialog.createTab("Scrolling"), fbreader);
|
||||
|
||||
final ZLDialogContent selectionTab = myDialog.createTab("Selection");
|
||||
selectionTab.addOption("enableSelection", FBView.selectionOption());
|
||||
|
||||
|
@ -85,8 +83,6 @@ public class OptionsDialog {
|
|||
builder.setInitial(BACKGROUND);
|
||||
colorsTab.addOption(colorKey, builder.comboEntry());
|
||||
colorsTab.addOption("", builder.colorEntry());
|
||||
|
||||
new KeyBindingsPage(fbreader, myDialog.createTab("Keys"));
|
||||
}
|
||||
|
||||
public ZLOptionsDialog getDialog() {
|
||||
|
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 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.optionsDialog;
|
||||
|
||||
import java.util.*;
|
||||
import org.geometerplus.zlibrary.core.util.*;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.*;
|
||||
import org.geometerplus.zlibrary.core.dialogs.*;
|
||||
import org.geometerplus.zlibrary.core.optionEntries.*;
|
||||
import org.geometerplus.zlibrary.core.options.*;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextView;
|
||||
|
||||
public class ScrollingOptionsPage {
|
||||
private ScrollingEntries myTouchScrollingEntries;
|
||||
private ScrollingEntries myTrackballScrollingEntries;
|
||||
|
||||
public ScrollingOptionsPage(ZLDialogContent dialogTab, FBReader fbreader) {
|
||||
final String optionsForKey = "optionsFor";
|
||||
ZLComboOptionEntry mainEntry = new ScrollingTypeEntry(dialogTab.getResource(optionsForKey), fbreader);
|
||||
dialogTab.addOption(optionsForKey, mainEntry);
|
||||
|
||||
final ZLResource modeResource = dialogTab.getResource("mode");
|
||||
ScrollingModeEntry.ourNoOverlappingString = modeResource.getResource("noOverlapping").getValue();
|
||||
ScrollingModeEntry.ourKeepLinesString = modeResource.getResource("keepLines").getValue();
|
||||
ScrollingModeEntry.ourScrollLinesString = modeResource.getResource("scrollLines").getValue();
|
||||
ScrollingModeEntry.ourScrollPercentageString = modeResource.getResource("scrollPercentage").getValue();
|
||||
ScrollingModeEntry.ourDisableString = modeResource.getResource("disable").getValue();
|
||||
|
||||
myTouchScrollingEntries = new ScrollingEntries(fbreader, fbreader.TouchScrollingOptions);
|
||||
myTrackballScrollingEntries = new ScrollingEntries(fbreader, fbreader.TrackballScrollingOptions);
|
||||
|
||||
mainEntry.onStringValueSelected(mainEntry.initialValue());
|
||||
|
||||
myTouchScrollingEntries.connect(dialogTab);
|
||||
myTrackballScrollingEntries.connect(dialogTab);
|
||||
}
|
||||
|
||||
|
||||
private static class ScrollingEntries {
|
||||
private final ZLComboOptionEntry myModeEntry;
|
||||
private final ZLSpinOptionEntry myLinesToKeepEntry;
|
||||
private final ZLSpinOptionEntry myLinesToScrollEntry;
|
||||
private final ZLSpinOptionEntry myPercentToScrollEntry;
|
||||
|
||||
public ScrollingEntries(FBReader fbreader, ScrollingOptions options) {
|
||||
myModeEntry = new ScrollingModeEntry(fbreader, this, options.ModeOption);
|
||||
myLinesToKeepEntry = new ZLSimpleSpinOptionEntry(options.LinesToKeepOption, 1);
|
||||
myLinesToScrollEntry = new ZLSimpleSpinOptionEntry(options.LinesToScrollOption, 1);
|
||||
myPercentToScrollEntry = new ZLSimpleSpinOptionEntry(options.PercentToScrollOption, 5);
|
||||
myModeEntry.onStringValueSelected(myModeEntry.initialValue());
|
||||
}
|
||||
|
||||
void connect(ZLDialogContent dialogTab) {
|
||||
dialogTab.addOption("mode", myModeEntry);
|
||||
dialogTab.addOption("linesToKeep", myLinesToKeepEntry);
|
||||
dialogTab.addOption("linesToScroll", myLinesToScrollEntry);
|
||||
dialogTab.addOption("percentToScroll", myPercentToScrollEntry);
|
||||
}
|
||||
|
||||
void show(boolean visible) {
|
||||
if (myModeEntry != null) {
|
||||
myModeEntry.setVisible(visible);
|
||||
if (visible) {
|
||||
((ScrollingModeEntry)myModeEntry).onMadeVisible();
|
||||
} else {
|
||||
myLinesToKeepEntry.setVisible(false);
|
||||
myLinesToScrollEntry.setVisible(false);
|
||||
myPercentToScrollEntry.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class ScrollingTypeEntry extends ZLComboOptionEntry {
|
||||
private final String myTouchScrollingString;
|
||||
private final String myTrackballScrollingString;
|
||||
|
||||
private final ZLResource myResource;
|
||||
private final FBReader myFBReader;
|
||||
private final ArrayList myValues = new ArrayList();
|
||||
|
||||
public ScrollingTypeEntry(final ZLResource resource, FBReader fbreader) {
|
||||
myResource = resource;
|
||||
myFBReader = fbreader;
|
||||
|
||||
myTouchScrollingString = resource.getResource("touch").getValue();
|
||||
myTrackballScrollingString = resource.getResource("trackball").getValue();
|
||||
|
||||
myValues.add(myTouchScrollingString);
|
||||
myValues.add(myTrackballScrollingString);
|
||||
}
|
||||
|
||||
public void onValueSelected(int index) {
|
||||
final String selectedValue = (String) getValues().get(index);
|
||||
myTouchScrollingEntries.show(myTouchScrollingString.equals(selectedValue));
|
||||
myTrackballScrollingEntries.show(myTrackballScrollingString.equals(selectedValue));
|
||||
}
|
||||
|
||||
public ArrayList getValues() {
|
||||
return myValues;
|
||||
}
|
||||
|
||||
public String initialValue() {
|
||||
return myTouchScrollingString;
|
||||
}
|
||||
|
||||
public void onAccept(String value) {}
|
||||
}
|
||||
|
||||
|
||||
private static class ScrollingModeEntry extends ZLComboOptionEntry {
|
||||
public static String ourNoOverlappingString = "";
|
||||
public static String ourKeepLinesString = "";
|
||||
public static String ourScrollLinesString = "";
|
||||
public static String ourScrollPercentageString = "";
|
||||
public static String ourDisableString = "";
|
||||
|
||||
private FBReader myFBReader;
|
||||
private ScrollingOptionsPage.ScrollingEntries myEntries;
|
||||
private ZLIntegerOption myOption;
|
||||
private final ArrayList/*<String>*/ myValues = new ArrayList();
|
||||
private int myCurrentIndex;
|
||||
|
||||
private static String nameByCode(int code) {
|
||||
switch (code) {
|
||||
case ZLTextView.ScrollingMode.KEEP_LINES:
|
||||
return ourKeepLinesString;
|
||||
case ZLTextView.ScrollingMode.SCROLL_LINES:
|
||||
return ourScrollLinesString;
|
||||
case ZLTextView.ScrollingMode.SCROLL_PERCENTAGE:
|
||||
return ourScrollPercentageString;
|
||||
default:
|
||||
return ourNoOverlappingString;
|
||||
}
|
||||
}
|
||||
|
||||
private static int codeByName(final String name) {
|
||||
if (ourKeepLinesString.equals(name)) {
|
||||
return ZLTextView.ScrollingMode.KEEP_LINES;
|
||||
}
|
||||
if (ourScrollLinesString.equals(name)) {
|
||||
return ZLTextView.ScrollingMode.SCROLL_LINES;
|
||||
}
|
||||
if (ourScrollPercentageString.equals(name)) {
|
||||
return ZLTextView.ScrollingMode.SCROLL_PERCENTAGE;
|
||||
}
|
||||
return ZLTextView.ScrollingMode.NO_OVERLAPPING;
|
||||
}
|
||||
|
||||
public ScrollingModeEntry(FBReader fbreader, ScrollingOptionsPage.ScrollingEntries entries, ZLIntegerOption option) {
|
||||
myEntries = entries;
|
||||
myFBReader = fbreader;
|
||||
myOption = option;
|
||||
myValues.add(ourNoOverlappingString);
|
||||
myValues.add(ourKeepLinesString);
|
||||
myValues.add(ourScrollLinesString);
|
||||
myValues.add(ourScrollPercentageString);
|
||||
}
|
||||
|
||||
public void onValueSelected(int index) {
|
||||
myCurrentIndex = index;
|
||||
final String selectedValue = (String) getValues().get(index);
|
||||
myEntries.myLinesToKeepEntry.setVisible(ourKeepLinesString.equals(selectedValue));
|
||||
myEntries.myLinesToScrollEntry.setVisible(ourScrollLinesString.equals(selectedValue));
|
||||
myEntries.myPercentToScrollEntry.setVisible(ourScrollPercentageString.equals(selectedValue));
|
||||
}
|
||||
|
||||
public void onMadeVisible() {
|
||||
onValueSelected(myCurrentIndex);
|
||||
}
|
||||
|
||||
public ArrayList getValues() {
|
||||
return myValues;
|
||||
}
|
||||
|
||||
public String initialValue() {
|
||||
return nameByCode(myOption.getValue());
|
||||
}
|
||||
|
||||
public void onAccept(String value) {
|
||||
myOption.setValue(codeByName(value));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -191,20 +191,17 @@ public abstract class ZLApplication {
|
|||
action.checkAndRun();
|
||||
}
|
||||
}
|
||||
|
||||
//may be protected
|
||||
abstract public ZLKeyBindings keyBindings();
|
||||
|
||||
public final void doActionByKey(String key) {
|
||||
public final boolean doActionByKey(String key) {
|
||||
String actionId = keyBindings().getBinding(key);
|
||||
if (actionId != null) {
|
||||
ZLAction a = getAction(keyBindings().getBinding(key));
|
||||
if ((a != null)){// &&
|
||||
//(!a.useKeyDelay() /*||
|
||||
//(myLastKeyActionTime.millisecondsTo(ZLTime()) >= KeyDelayOption.getValue())*/)) {
|
||||
a.checkAndRun();
|
||||
//myLastKeyActionTime = ZLTime();
|
||||
}
|
||||
return (a != null) && a.checkAndRun();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean closeWindow() {
|
||||
|
@ -248,10 +245,12 @@ public abstract class ZLApplication {
|
|||
return isVisible();
|
||||
}
|
||||
|
||||
public final void checkAndRun() {
|
||||
public final boolean checkAndRun() {
|
||||
if (isEnabled()) {
|
||||
run();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean useKeyDelay() {
|
||||
|
|
|
@ -30,8 +30,14 @@ abstract public class ZLView {
|
|||
|
||||
abstract public String getCaption();
|
||||
|
||||
abstract public void paint(int dx, int dy);
|
||||
abstract public void onScrollingFinished(int dx, int dy);
|
||||
public static final int PAGE_CENTRAL = 0;
|
||||
public static final int PAGE_LEFT = 1;
|
||||
public static final int PAGE_RIGHT = 2;
|
||||
public static final int PAGE_TOP = 3;
|
||||
public static final int PAGE_BOTTOM = 4;
|
||||
|
||||
abstract public void paint(int viewPage);
|
||||
abstract public void onScrollingFinished(int viewPage);
|
||||
|
||||
public boolean onStylusPress(int x, int y) {
|
||||
return false;
|
||||
|
@ -53,24 +59,21 @@ abstract public class ZLView {
|
|||
return false;
|
||||
}
|
||||
|
||||
final public void setVerticalScrollbarParameters(int full, int from, int to) {
|
||||
public abstract int getScrollbarFullSize();
|
||||
public abstract int getScrollbarThumbPosition(int viewPage);
|
||||
public abstract int getScrollbarThumbLength(int viewPage);
|
||||
|
||||
final public void scrollTo(int viewPage, int shift) {
|
||||
ZLViewWidget viewWidget = ZLApplication.Instance().getViewWidget();
|
||||
if (viewWidget != null) {
|
||||
viewWidget.setVerticalScrollbarParameters(full, from, to);
|
||||
viewWidget.scrollTo(viewPage, shift);
|
||||
}
|
||||
}
|
||||
|
||||
final public void scrollTo(int shift) {
|
||||
public void startAutoScrolling(int viewPage) {
|
||||
ZLViewWidget viewWidget = ZLApplication.Instance().getViewWidget();
|
||||
if (viewWidget != null) {
|
||||
viewWidget.scrollTo(shift);
|
||||
}
|
||||
}
|
||||
|
||||
final public void startAutoScrolling(boolean forward) {
|
||||
ZLViewWidget viewWidget = ZLApplication.Instance().getViewWidget();
|
||||
if (viewWidget != null) {
|
||||
viewWidget.startAutoScrolling(forward);
|
||||
viewWidget.startAutoScrolling(viewPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ abstract public class ZLViewWidget {
|
|||
|
||||
// TODO: change to protected
|
||||
abstract public void repaint();
|
||||
abstract protected void scrollTo(int shift);
|
||||
abstract protected void startAutoScrolling(boolean forward);
|
||||
|
||||
abstract protected void setVerticalScrollbarParameters(int full, int from, int to);
|
||||
abstract protected void scrollTo(int viewPage, int shift);
|
||||
abstract protected void startAutoScrolling(int viewPage);
|
||||
}
|
||||
|
|
|
@ -385,34 +385,74 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void onScrollingFinished(int dx, int dy) {
|
||||
if ((dx < 0) || (dy < 0)) {
|
||||
ZLTextPage swap = myNextPage;
|
||||
myNextPage = myCurrentPage;
|
||||
myCurrentPage = myPreviousPage;
|
||||
myPreviousPage = swap;
|
||||
myPreviousPage.reset();
|
||||
if (myCurrentPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myNextPage);
|
||||
myCurrentPage.EndCursor.setCursor(myNextPage.StartCursor);
|
||||
myCurrentPage.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
private volatile boolean myScrollingIsActive;
|
||||
protected boolean isScrollingActive() {
|
||||
return myScrollingIsActive;
|
||||
}
|
||||
protected void setScrollingActive(boolean active) {
|
||||
myScrollingIsActive = active;
|
||||
}
|
||||
|
||||
public final synchronized void startAutoScrolling(int viewPage) {
|
||||
if (isScrollingActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setScrollingActive(true);
|
||||
super.startAutoScrolling(viewPage);
|
||||
}
|
||||
|
||||
public final synchronized void onScrollingFinished(int viewPage) {
|
||||
setScrollingActive(false);
|
||||
switch (viewPage) {
|
||||
case PAGE_CENTRAL:
|
||||
break;
|
||||
case PAGE_LEFT:
|
||||
case PAGE_TOP:
|
||||
{
|
||||
ZLTextPage swap = myNextPage;
|
||||
myNextPage = myCurrentPage;
|
||||
myCurrentPage = myPreviousPage;
|
||||
myPreviousPage = swap;
|
||||
myPreviousPage.reset();
|
||||
if (myCurrentPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myNextPage);
|
||||
myCurrentPage.EndCursor.setCursor(myNextPage.StartCursor);
|
||||
myCurrentPage.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
} else if (!myCurrentPage.EndCursor.isNull() &&
|
||||
!myNextPage.StartCursor.isNull() &&
|
||||
!myCurrentPage.EndCursor.equalsToCursor(myNextPage.StartCursor)) {
|
||||
myNextPage.reset();
|
||||
myNextPage.StartCursor.setCursor(myCurrentPage.EndCursor);
|
||||
myNextPage.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
}
|
||||
if (myCurrentPage.PaintState == PaintStateEnum.READY) {
|
||||
onPaintInfoPrepared();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if ((dx > 0) || (dy > 0)) {
|
||||
ZLTextPage swap = myPreviousPage;
|
||||
myPreviousPage = myCurrentPage;
|
||||
myCurrentPage = myNextPage;
|
||||
myNextPage = swap;
|
||||
myNextPage.reset();
|
||||
if (myCurrentPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myPreviousPage);
|
||||
myCurrentPage.StartCursor.setCursor(myPreviousPage.EndCursor);
|
||||
myCurrentPage.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
case PAGE_RIGHT:
|
||||
case PAGE_BOTTOM:
|
||||
{
|
||||
ZLTextPage swap = myPreviousPage;
|
||||
myPreviousPage = myCurrentPage;
|
||||
myCurrentPage = myNextPage;
|
||||
myNextPage = swap;
|
||||
myNextPage.reset();
|
||||
if (myCurrentPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myPreviousPage);
|
||||
myCurrentPage.StartCursor.setCursor(myNextPage.EndCursor);
|
||||
myCurrentPage.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
}
|
||||
if (myCurrentPage.PaintState == PaintStateEnum.READY) {
|
||||
onPaintInfoPrepared();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void paint(int dx, int dy) {
|
||||
System.err.println("paint " + dx + ' ' + dy);
|
||||
public synchronized void paint(int viewPage) {
|
||||
myTextElementMap.clear();
|
||||
|
||||
final ZLTextBaseStyle baseStyle = ZLTextStyleCollection.getInstance().getBaseStyle();
|
||||
|
@ -424,22 +464,28 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
}
|
||||
|
||||
ZLTextPage page;
|
||||
if ((dx < 0) || (dy < 0)) {
|
||||
page = myPreviousPage;
|
||||
if (myPreviousPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myCurrentPage);
|
||||
myPreviousPage.EndCursor.setCursor(myCurrentPage.StartCursor);
|
||||
myPreviousPage.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
}
|
||||
} else if ((dx > 0) || (dy > 0)) {
|
||||
page = myNextPage;
|
||||
if (myNextPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myCurrentPage);
|
||||
myNextPage.StartCursor.setCursor(myCurrentPage.EndCursor);
|
||||
myNextPage.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
}
|
||||
} else {
|
||||
page = myCurrentPage;
|
||||
switch (viewPage) {
|
||||
default:
|
||||
case PAGE_CENTRAL:
|
||||
page = myCurrentPage;
|
||||
break;
|
||||
case PAGE_TOP:
|
||||
case PAGE_LEFT:
|
||||
page = myPreviousPage;
|
||||
if (myPreviousPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myCurrentPage);
|
||||
myPreviousPage.EndCursor.setCursor(myCurrentPage.StartCursor);
|
||||
myPreviousPage.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
}
|
||||
break;
|
||||
case PAGE_BOTTOM:
|
||||
case PAGE_RIGHT:
|
||||
page = myNextPage;
|
||||
if (myNextPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
preparePaintInfo(myCurrentPage);
|
||||
myNextPage.StartCursor.setCursor(myCurrentPage.EndCursor);
|
||||
myNextPage.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
preparePaintInfo(page);
|
||||
|
@ -448,17 +494,6 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
return;
|
||||
}
|
||||
|
||||
{
|
||||
final int fullScrollBarSize = myTextSize[myTextSize.length - 1];
|
||||
final int scrollBarStart = sizeOfTextBeforeCursor(page.StartCursor);
|
||||
final int scrollBarEnd = sizeOfTextBeforeCursor(page.EndCursor);
|
||||
setVerticalScrollbarParameters(
|
||||
fullScrollBarSize,
|
||||
scrollBarStart,
|
||||
(scrollBarEnd != -1) ? scrollBarEnd : fullScrollBarSize
|
||||
);
|
||||
}
|
||||
|
||||
final ArrayList<ZLTextLineInfo> lineInfos = page.LineInfos;
|
||||
final int[] labels = new int[lineInfos.size() + 1];
|
||||
context.moveYTo(getTopMargin());
|
||||
|
@ -480,6 +515,53 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
}
|
||||
}
|
||||
|
||||
private ZLTextPage getPage(int viewPage) {
|
||||
switch (viewPage) {
|
||||
default:
|
||||
case PAGE_CENTRAL:
|
||||
return myCurrentPage;
|
||||
case PAGE_TOP:
|
||||
case PAGE_LEFT:
|
||||
return myPreviousPage;
|
||||
case PAGE_BOTTOM:
|
||||
case PAGE_RIGHT:
|
||||
return myNextPage;
|
||||
}
|
||||
}
|
||||
|
||||
public final int getScrollbarFullSize() {
|
||||
if ((myTextSize == null) || (myTextSize.length == 0)) {
|
||||
return 1;
|
||||
}
|
||||
return myTextSize[myTextSize.length - 1];
|
||||
}
|
||||
|
||||
public final int getScrollbarThumbPosition(int viewPage) {
|
||||
if ((myTextSize == null) || (myTextSize.length == 0)) {
|
||||
return 0;
|
||||
}
|
||||
ZLTextPage page = getPage(viewPage);
|
||||
preparePaintInfo(page);
|
||||
return Math.max(0, sizeOfTextBeforeCursor(page.StartCursor));
|
||||
}
|
||||
|
||||
public final int getScrollbarThumbLength(int viewPage) {
|
||||
if ((myTextSize == null) || (myTextSize.length == 0)) {
|
||||
return 0;
|
||||
}
|
||||
ZLTextPage page = getPage(viewPage);
|
||||
preparePaintInfo(page);
|
||||
int start = sizeOfTextBeforeCursor(page.StartCursor);
|
||||
if (start == -1) {
|
||||
start = 0;
|
||||
}
|
||||
int end = sizeOfTextBeforeCursor(page.EndCursor);
|
||||
if (end == -1) {
|
||||
end = myTextSize[myTextSize.length - 1];
|
||||
}
|
||||
return Math.max(1, end - start);
|
||||
}
|
||||
|
||||
private int sizeOfTextBeforeCursor(ZLTextWordCursor wordCursor) {
|
||||
final ZLTextWordCursor cursor = new ZLTextWordCursor(wordCursor);
|
||||
if (cursor.isEndOfParagraph() && !cursor.nextParagraph()) {
|
||||
|
@ -987,7 +1069,11 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
}
|
||||
}
|
||||
|
||||
public void scrollPage(boolean forward, int scrollingMode, int value) {
|
||||
public synchronized final void scrollPage(boolean forward, int scrollingMode, int value) {
|
||||
if (isScrollingActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
preparePaintInfo(myCurrentPage);
|
||||
myPreviousPage.reset();
|
||||
myNextPage.reset();
|
||||
|
@ -1054,12 +1140,22 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
page.OldHeight = newHeight;
|
||||
if (page.PaintState != PaintStateEnum.NOTHING_TO_PAINT) {
|
||||
page.LineInfos.clear();
|
||||
if (!page.StartCursor.isNull()) {
|
||||
page.EndCursor.reset();
|
||||
page.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
} else if (!page.EndCursor.isNull()) {
|
||||
page.StartCursor.reset();
|
||||
page.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
if (page == myPreviousPage) {
|
||||
if (!page.EndCursor.isNull()) {
|
||||
page.StartCursor.reset();
|
||||
page.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
} else if (!page.StartCursor.isNull()) {
|
||||
page.EndCursor.reset();
|
||||
page.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
}
|
||||
} else {
|
||||
if (!page.StartCursor.isNull()) {
|
||||
page.EndCursor.reset();
|
||||
page.PaintState = PaintStateEnum.START_IS_KNOWN;
|
||||
} else if (!page.EndCursor.isNull()) {
|
||||
page.StartCursor.reset();
|
||||
page.PaintState = PaintStateEnum.END_IS_KNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1168,11 +1264,11 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
if (page == myCurrentPage) {
|
||||
myPreviousPage.reset();
|
||||
myNextPage.reset();
|
||||
onPreparePaintInfo();
|
||||
onPaintInfoPrepared();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPreparePaintInfo() {
|
||||
protected void onPaintInfoPrepared() {
|
||||
}
|
||||
|
||||
public void clearCaches() {
|
||||
|
@ -1303,7 +1399,6 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
|
||||
public boolean onStylusMovePressed(int x, int y) {
|
||||
if (mySelectionModel.extendTo(x, y)) {
|
||||
//copySelectedTextToClipboard(ZLDialogManager::CLIPBOARD_SELECTION);
|
||||
ZLApplication.Instance().refreshWindow();
|
||||
return true;
|
||||
}
|
||||
|
@ -1323,5 +1418,4 @@ public abstract class ZLTextViewImpl extends ZLTextView {
|
|||
ZLApplication.Instance().refreshWindow();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue