mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
fixed first scrolling direction; animation speed setting
This commit is contained in:
parent
9d7932a015
commit
5f5e8a398a
29 changed files with 275 additions and 39 deletions
|
@ -1,5 +1,5 @@
|
|||
<?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="10000" android:versionName="1.0" android:installLocation="auto">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.geometerplus.zlibrary.ui.android" android:versionCode="10001" android:versionName="1.0.1" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="4" />
|
||||
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.0
|
||||
1.0.1
|
||||
|
|
|
@ -515,6 +515,10 @@
|
|||
<node name="slide" value="Animace vysunutí"/>
|
||||
<node name="shift" value="Animace posunutí"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Vodorovné posouvání">
|
||||
<node name="summaryOn" value="Posouvat stránky vodorovně"/>
|
||||
<node name="summaryOff" value="Posouvat stránky svisle"/>
|
||||
|
|
|
@ -512,6 +512,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Horizontales umblättern">
|
||||
<node name="summaryOn" value="Seiten horizontal umblättern"/>
|
||||
<node name="summaryOff" value="Seiten vertikal umblättern"/>
|
||||
|
|
|
@ -514,6 +514,10 @@
|
|||
<node name="slide" value="Slide animation"/>
|
||||
<node name="shift" value="Shift animation"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed">
|
||||
<node name="fast" value="fast"/>
|
||||
<node name="slow" value="slow"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Horizontal scrolling">
|
||||
<node name="summaryOn" value="Scroll pages horizontally"/>
|
||||
<node name="summaryOff" value="Scroll pages vertically"/>
|
||||
|
|
|
@ -514,6 +514,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Défilement horizontal">
|
||||
<node name="summaryOn" value="Défilement des pages horizontalement"/>
|
||||
<node name="summaryOff" value="Défilement des pages verticalement"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Deslizar"/>
|
||||
<node name="shift" value="Pasar"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Desprazamento horizontal">
|
||||
<node name="summaryOn" value="Desprazar as páxinas en horizontal"/>
|
||||
<node name="summaryOff" value="Desprazar as páxinas en vertical"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Vízszintes lapozás">
|
||||
<node name="summaryOn" value="Oldalak görgetése vízszintesen"/>
|
||||
<node name="summaryOff" value="Oldalak görgetése függőlegesen"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Scorrimento orizzontale">
|
||||
<node name="summaryOn" value="Scorri le pagine orizzontalmente"/>
|
||||
<node name="summaryOff" value="Scorri le pagine in verticale"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Slide-animatie"/>
|
||||
<node name="shift" value="Shift-animatie"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Horizontaal omslaan">
|
||||
<node name="summaryOn" value="Pagina's horizontaal omslaan"/>
|
||||
<node name="summaryOff" value="Pagina's verticaal omslaan"/>
|
||||
|
|
|
@ -176,8 +176,8 @@
|
|||
<node name="cancelMenu">
|
||||
<node name="previousBook" value="Открыть предыдущую книгу"/>
|
||||
<node name="returnTo" value="Вернуться к ..."/>
|
||||
<node name="back" value="Back" toBeTranslated="true"/>
|
||||
<node name="forward" value="Forward" toBeTranslated="true"/>
|
||||
<node name="back" value="Назад"/>
|
||||
<node name="forward" value="Вперед"/>
|
||||
<node name="close" value="Закрыть FBReader"/>
|
||||
</node>
|
||||
<node name="menu">
|
||||
|
@ -425,7 +425,7 @@
|
|||
<node name="selectionBackground" value="Фон пометки"/>
|
||||
<node name="text" value="Обычный текст"/>
|
||||
<node name="hyperlink" value="Гиперссылка"/>
|
||||
<node name="hyperlinkVisited" value="Visited hyperlink text" toBeTranslated="true"/>
|
||||
<node name="hyperlinkVisited" value="Посещенная ссылка"/>
|
||||
<node name="highlighting" value="Фон результатов поиска"/>
|
||||
<node name="footer" value="Подвал"/>
|
||||
</node>
|
||||
|
@ -506,10 +506,14 @@
|
|||
</node>
|
||||
<node name="animation" value="Анимация">
|
||||
<node name="none" value="Выключить анимацию"/>
|
||||
<node name="curl" value="Curl animation" toBeTranslated="true"/>
|
||||
<node name="curl" value="Трехмерная анимация"/>
|
||||
<node name="slide" value="Сдвиг с перекрытием"/>
|
||||
<node name="shift" value="Сдвиг"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Скорость анимации">
|
||||
<node name="fast" value="быстро"/>
|
||||
<node name="slow" value="медленно"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Горизонтальное перелистывание">
|
||||
<node name="summaryOn" value="При листании страница движется по горизонтали"/>
|
||||
<node name="summaryOff" value="При листании страница движется по вертикали"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="เลื่อนหน้าแบบสไลด์"/>
|
||||
<node name="shift" value="เลื่อนหน้าแบบสลับ"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="เลื่อนหน้าในแนวนอน">
|
||||
<node name="summaryOn" value="เลื่อนหน้าตามแนวนอน"/>
|
||||
<node name="summaryOff" value="เลื่อนหน้าตามแนวตั้ง"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Горизонтальне перегортання">
|
||||
<node name="summaryOn" value="При гортанні сторінка рухається по горизонталі"/>
|
||||
<node name="summaryOff" value="При гортанні сторінка рухається по вертикалі"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="Cuộn ngang">
|
||||
<node name="summaryOn" value="Cuộn trang theo chiều ngang"/>
|
||||
<node name="summaryOff" value="Cuộn trang theo chiều dọc"/>
|
||||
|
|
|
@ -511,6 +511,10 @@
|
|||
<node name="slide" value="Slide animation" toBeTranslated="true"/>
|
||||
<node name="shift" value="Shift animation" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="animationSpeed" value="Animation speed" toBeTranslated="true">
|
||||
<node name="fast" value="fast" toBeTranslated="true"/>
|
||||
<node name="slow" value="slow" toBeTranslated="true"/>
|
||||
</node>
|
||||
<node name="horizontal" value="横向翻阅">
|
||||
<node name="summaryOn" value="横向翻阅" />
|
||||
<node name="summaryOff" value="纵向翻阅" />
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (C) 2010-2011 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.content.DialogInterface;
|
||||
import android.graphics.*;
|
||||
import android.graphics.drawable.*;
|
||||
import android.preference.DialogPreference;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
||||
class AnimationSpeedPreference extends DialogPreference implements ZLPreference {
|
||||
private final ZLIntegerRangeOption myOption;
|
||||
private final ZLResource myResource;
|
||||
|
||||
private SeekBar mySlider;
|
||||
|
||||
AnimationSpeedPreference(Context context, ZLResource resource, String resourceKey, ZLIntegerRangeOption option) {
|
||||
super(context, null);
|
||||
myOption = option;
|
||||
myResource = resource.getResource(resourceKey);
|
||||
final String title = myResource.getValue();
|
||||
setTitle(title);
|
||||
setDialogTitle(title);
|
||||
setDialogLayoutResource(R.layout.animation_speed_dialog);
|
||||
|
||||
final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
|
||||
setPositiveButtonText(buttonResource.getResource("ok").getValue());
|
||||
setNegativeButtonText(buttonResource.getResource("cancel").getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindDialogView(View view) {
|
||||
mySlider = (SeekBar)view.findViewById(R.id.animation_speed_slider);
|
||||
mySlider.setMax(myOption.MaxValue - myOption.MinValue);
|
||||
mySlider.setProgress(myOption.getValue() - myOption.MinValue);
|
||||
mySlider.setProgressDrawable(new SeekBarDrawable());
|
||||
|
||||
super.onBindDialogView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
myOption.setValue(myOption.MinValue + mySlider.getProgress());
|
||||
}
|
||||
}
|
||||
|
||||
public void onAccept() {
|
||||
}
|
||||
|
||||
private class SeekBarDrawable extends Drawable {
|
||||
private final Drawable myBase;
|
||||
private final Paint myPaint;
|
||||
private final Paint myOutlinePaint;
|
||||
|
||||
public SeekBarDrawable() {
|
||||
myBase = mySlider.getProgressDrawable();
|
||||
|
||||
myPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
myPaint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
myPaint.setColor(Color.BLACK);
|
||||
myPaint.setAlpha(255);
|
||||
|
||||
myOutlinePaint = new Paint(myPaint);
|
||||
myOutlinePaint.setStyle(Paint.Style.STROKE);
|
||||
myOutlinePaint.setStrokeWidth(3);
|
||||
myOutlinePaint.setColor(0xFFAAAAAA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
myBase.setBounds(bounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onStateChange(int[] state) {
|
||||
invalidateSelf();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStateful() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onLevelChange(int level) {
|
||||
return myBase.setLevel(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
myBase.draw(canvas);
|
||||
|
||||
final Rect bounds = getBounds();
|
||||
final int textSize = bounds.height() * 2 / 3;
|
||||
myPaint.setTextSize(textSize);
|
||||
myOutlinePaint.setTextSize(textSize);
|
||||
|
||||
final Rect textBounds = new Rect();
|
||||
myPaint.getTextBounds("a", 0, 1, textBounds);
|
||||
final float y = bounds.height() / 2 + textBounds.height();
|
||||
|
||||
final int progress = mySlider.getProgress();
|
||||
final int max = mySlider.getMax();
|
||||
if (progress >= max / 3) {
|
||||
final String text = myResource.getResource("slow").getValue();
|
||||
final float textWidth = myOutlinePaint.measureText(text);
|
||||
final float x = 6;
|
||||
canvas.drawText(text, x, y, myOutlinePaint);
|
||||
canvas.drawText(text, x, y, myPaint);
|
||||
}
|
||||
if (progress <= 2 * max / 3) {
|
||||
final String text = myResource.getResource("fast").getValue();
|
||||
final float textWidth = myOutlinePaint.measureText(text);
|
||||
final float x = bounds.width() - textWidth - 6;
|
||||
canvas.drawText(text, x, y, myOutlinePaint);
|
||||
canvas.drawText(text, x, y, myPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -361,6 +361,12 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
volumeKeysPreferences.setEnabled(scrollingPreferences.VolumeKeysOption.getValue());
|
||||
|
||||
scrollingScreen.addOption(scrollingPreferences.AnimationOption, "animation");
|
||||
scrollingScreen.addPreference(new AnimationSpeedPreference(
|
||||
this,
|
||||
scrollingScreen.Resource,
|
||||
"animationSpeed",
|
||||
scrollingPreferences.AnimationSpeedOption
|
||||
));
|
||||
scrollingScreen.addOption(scrollingPreferences.HorizontalOption, "horizontal");
|
||||
|
||||
final Screen dictionaryScreen = createPreferenceScreen("dictionary");
|
||||
|
|
|
@ -244,7 +244,7 @@ public final class FBView extends ZLTextView {
|
|||
? PageIndex.current
|
||||
: (diff < 0 ? PageIndex.next : PageIndex.previous);
|
||||
if (getAnimationType() != Animation.none) {
|
||||
startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up);
|
||||
startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
|
||||
} else {
|
||||
myReader.scrollViewToCenter();
|
||||
onScrollingFinished(pageIndex);
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.geometerplus.fbreader.fbreader;
|
|||
|
||||
import org.geometerplus.zlibrary.core.options.ZLBooleanOption;
|
||||
import org.geometerplus.zlibrary.core.options.ZLEnumOption;
|
||||
import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
||||
import org.geometerplus.zlibrary.core.view.ZLView;
|
||||
|
||||
public class ScrollingPreferences {
|
||||
|
@ -43,6 +44,8 @@ public class ScrollingPreferences {
|
|||
|
||||
public final ZLEnumOption<ZLView.Animation> AnimationOption =
|
||||
new ZLEnumOption<ZLView.Animation>("Scrolling", "Animation", ZLView.Animation.slide);
|
||||
public final ZLIntegerRangeOption AnimationSpeedOption =
|
||||
new ZLIntegerRangeOption("Scrolling", "AnimationSpeed", 1, 10, 4);
|
||||
|
||||
public final ZLBooleanOption HorizontalOption =
|
||||
new ZLBooleanOption("Scrolling", "Horizontal", true);
|
||||
|
|
|
@ -61,7 +61,8 @@ class TurnPageAction extends FBAction {
|
|||
view.startAutoScrolling(
|
||||
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||
preferences.HorizontalOption.getValue()
|
||||
? FBView.Direction.rightToLeft : FBView.Direction.up
|
||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||
preferences.AnimationSpeedOption.getValue()
|
||||
);
|
||||
} else {
|
||||
view.scrollPage(myForward, FBView.ScrollingMode.NO_OVERLAPPING, 0);
|
||||
|
@ -77,7 +78,8 @@ class TurnPageAction extends FBAction {
|
|||
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||
preferences.HorizontalOption.getValue()
|
||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||
x, y
|
||||
x, y,
|
||||
preferences.AnimationSpeedOption.getValue()
|
||||
);
|
||||
} else {
|
||||
view.scrollPage(myForward, FBView.ScrollingMode.NO_OVERLAPPING, 0);
|
||||
|
|
|
@ -59,7 +59,8 @@ class VolumeKeyTurnPageAction extends FBAction {
|
|||
view.startAutoScrolling(
|
||||
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||
preferences.HorizontalOption.getValue()
|
||||
? FBView.Direction.rightToLeft : FBView.Direction.up
|
||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||
preferences.AnimationSpeedOption.getValue()
|
||||
);
|
||||
} else {
|
||||
view.scrollPage(forward, FBView.ScrollingMode.NO_OVERLAPPING, 0);
|
||||
|
|
|
@ -80,15 +80,15 @@ public abstract class ZLApplication {
|
|||
}
|
||||
}
|
||||
|
||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction) {
|
||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
||||
if (myWindow != null) {
|
||||
myWindow.startViewAutoScrolling(pageIndex, direction);
|
||||
myWindow.startViewAutoScrolling(pageIndex, direction, speed);
|
||||
}
|
||||
}
|
||||
|
||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y) {
|
||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed) {
|
||||
if (myWindow != null) {
|
||||
myWindow.startViewAutoScrolling(pageIndex, direction, x, y);
|
||||
myWindow.startViewAutoScrolling(pageIndex, direction, x, y, speed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ abstract public class ZLApplicationWindow {
|
|||
abstract protected void repaintView();
|
||||
abstract protected void scrollViewManually(int startX, int startY, int endX, int endY, ZLView.Direction direction);
|
||||
abstract protected void scrollViewToCenter();
|
||||
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction);
|
||||
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y);
|
||||
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed);
|
||||
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed);
|
||||
|
||||
abstract protected void rotate();
|
||||
abstract protected boolean canRotate();
|
||||
|
|
|
@ -199,22 +199,22 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
myScrollingIsActive = active;
|
||||
}
|
||||
|
||||
public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction) {
|
||||
public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int speed) {
|
||||
if (isScrollingActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setScrollingActive(true);
|
||||
ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction);
|
||||
ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, speed);
|
||||
}
|
||||
|
||||
public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int x, int y) {
|
||||
public final synchronized void startAutoScrolling(PageIndex pageIndex, Direction direction, int x, int y, int speed) {
|
||||
if (isScrollingActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setScrollingActive(true);
|
||||
ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, x, y);
|
||||
ZLApplication.Instance().startViewAutoScrolling(pageIndex, direction, x, y, speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,17 +89,17 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction) {
|
||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
||||
final ZLAndroidWidget widget =
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||
widget.startAutoScrolling(pageIndex, direction, null, null);
|
||||
widget.startAutoScrolling(pageIndex, direction, null, null, speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y) {
|
||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed) {
|
||||
final ZLAndroidWidget widget =
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||
widget.startAutoScrolling(pageIndex, direction, x, y);
|
||||
widget.startAutoScrolling(pageIndex, direction, x, y, speed);
|
||||
}
|
||||
|
||||
public void rotate() {
|
||||
|
|
|
@ -67,7 +67,8 @@ abstract class AnimationProvider {
|
|||
setup(startX, startY, endX, endY, direction, w, h);
|
||||
}
|
||||
|
||||
void startAutoScrolling(boolean forward, float speed, ZLView.Direction direction, int w, int h, Integer x, Integer y) {
|
||||
void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
System.err.println("starting: " + forward + " " + startSpeed + " " + direction + " " + w + " " + h + " " + x + " " + y + " " + speed);
|
||||
if (!inProgress()) {
|
||||
if (x == null || y == null) {
|
||||
if (direction.IsHorizontal) {
|
||||
|
@ -84,7 +85,7 @@ abstract class AnimationProvider {
|
|||
myMode = forward
|
||||
? Mode.AutoScrollingForward
|
||||
: Mode.AutoScrollingBackward;
|
||||
mySpeed = speed;
|
||||
mySpeed = startSpeed;
|
||||
}
|
||||
|
||||
boolean inProgress() {
|
||||
|
|
|
@ -31,6 +31,8 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
final Path myFgPath = new Path();
|
||||
final Path myEdgePath = new Path();
|
||||
|
||||
private float mySpeedFactor;
|
||||
|
||||
CurlAnimationProvider(Paint paint) {
|
||||
super(paint);
|
||||
|
||||
|
@ -195,18 +197,18 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
void startAutoScrolling(boolean forward, float speed, ZLView.Direction direction, int w, int h, Integer x, Integer y) {
|
||||
void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
if (x == null || y == null) {
|
||||
if (direction.IsHorizontal) {
|
||||
x = speed < 0 ? w - 3 : 3;
|
||||
x = startSpeed < 0 ? w - 3 : 3;
|
||||
y = 1;
|
||||
} else {
|
||||
x = 1;
|
||||
y = speed < 0 ? h - 3 : 3;
|
||||
y = startSpeed < 0 ? h - 3 : 3;
|
||||
}
|
||||
} else {
|
||||
final int cornerX = x > myWidth / 2 ? myWidth : 0;
|
||||
final int cornerY = y > myHeight / 2 ? myHeight : 0;
|
||||
final int cornerX = x > w / 2 ? w : 0;
|
||||
final int cornerY = y > h / 2 ? h : 0;
|
||||
int deltaX = Math.min(Math.abs(x - cornerX), w / 5);
|
||||
int deltaY = Math.min(Math.abs(y - cornerY), h / 5);
|
||||
if (direction.IsHorizontal) {
|
||||
|
@ -217,7 +219,8 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
x = Math.abs(cornerX - deltaX);
|
||||
y = Math.abs(cornerY - deltaY);
|
||||
}
|
||||
super.startAutoScrolling(forward, speed, direction, w, h, x, y);
|
||||
super.startAutoScrolling(forward, startSpeed, direction, w, h, x, y, speed);
|
||||
mySpeedFactor = (float)Math.pow(2.0, 0.25 * speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -227,7 +230,7 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
}
|
||||
|
||||
final int speed = (int)Math.abs(mySpeed);
|
||||
mySpeed *= 2;
|
||||
mySpeed *= mySpeedFactor;
|
||||
|
||||
final int cornerX = myStartX > myWidth / 2 ? myWidth : 0;
|
||||
final int cornerY = myStartY > myHeight / 2 ? myHeight : 0;
|
||||
|
|
|
@ -24,6 +24,8 @@ import android.graphics.Paint;
|
|||
import org.geometerplus.zlibrary.core.view.ZLView;
|
||||
|
||||
abstract class SimpleAnimationProvider extends AnimationProvider {
|
||||
private float mySpeedFactor;
|
||||
|
||||
SimpleAnimationProvider(Paint paint) {
|
||||
super(paint);
|
||||
}
|
||||
|
@ -43,6 +45,12 @@ abstract class SimpleAnimationProvider extends AnimationProvider {
|
|||
return ZLView.PageIndex.current;
|
||||
}
|
||||
|
||||
@Override
|
||||
void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
super.startAutoScrolling(forward, startSpeed, direction, w, h, x, y, speed);
|
||||
mySpeedFactor = (float)Math.pow(1.5, 0.25 * speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
void doStep() {
|
||||
if (!getMode().Auto) {
|
||||
|
@ -69,6 +77,7 @@ abstract class SimpleAnimationProvider extends AnimationProvider {
|
|||
} else {
|
||||
bound = 0;
|
||||
}
|
||||
System.err.println("before check: " + mySpeed + " " + getScrollingShift() + " " + bound);
|
||||
if (mySpeed > 0) {
|
||||
if (getScrollingShift() >= bound) {
|
||||
if (myDirection.IsHorizontal) {
|
||||
|
@ -90,6 +99,6 @@ abstract class SimpleAnimationProvider extends AnimationProvider {
|
|||
return;
|
||||
}
|
||||
}
|
||||
mySpeed *= 1.5;
|
||||
mySpeed *= mySpeedFactor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
|||
postInvalidate();
|
||||
}
|
||||
|
||||
public void startAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, Integer x, Integer y) {
|
||||
public void startAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, Integer x, Integer y, int speed) {
|
||||
if (myMainBitmap == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -216,19 +216,19 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
|||
animator.terminate();
|
||||
break;
|
||||
case previous:
|
||||
animator.startAutoScrolling(false, -3, direction, w, h, x, y);
|
||||
animator.startAutoScrolling(false, -3, direction, w, h, x, y, speed);
|
||||
break;
|
||||
case next:
|
||||
animator.startAutoScrolling(false, 3, direction, w, h, x, y);
|
||||
animator.startAutoScrolling(false, 3, direction, w, h, x, y, speed);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case previous:
|
||||
animator.startAutoScrolling(true, 3, direction, w, h, x, y);
|
||||
animator.startAutoScrolling(true, 3, direction, w, h, x, y, speed);
|
||||
setPageToScrollTo(pageIndex);
|
||||
break;
|
||||
case next:
|
||||
animator.startAutoScrolling(true, -3, direction, w, h, x, y);
|
||||
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
|
||||
setPageToScrollTo(pageIndex);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue