/*
* Copyright (C) 2011 Alex Kuiper
*
* This file is part of PageTurner
*
* PageTurner 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 3 of the License, or
* (at your option) any later version.
*
* PageTurner 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 PageTurner. If not, see <http://www.gnu.org/licenses/>.*
*/
package net.nightwhistler.pageturner.activity;
import java.net.URLEncoder;
import java.util.List;
import net.nightwhistler.htmlspanner.HtmlSpanner;
import net.nightwhistler.pageturner.Configuration;
import net.nightwhistler.pageturner.Configuration.AnimationStyle;
import net.nightwhistler.pageturner.Configuration.ColourProfile;
import net.nightwhistler.pageturner.Configuration.ScrollStyle;
import net.nightwhistler.pageturner.R;
import net.nightwhistler.pageturner.animation.Animations;
import net.nightwhistler.pageturner.animation.Animator;
import net.nightwhistler.pageturner.animation.PageCurlAnimator;
import net.nightwhistler.pageturner.animation.PageTimer;
import net.nightwhistler.pageturner.animation.RollingBlindAnimator;
import net.nightwhistler.pageturner.library.LibraryService;
import net.nightwhistler.pageturner.sync.AccessException;
import net.nightwhistler.pageturner.sync.BookProgress;
import net.nightwhistler.pageturner.sync.ProgressService;
import net.nightwhistler.pageturner.view.AnimatedImageView;
import net.nightwhistler.pageturner.view.BookView;
import net.nightwhistler.pageturner.view.BookViewListener;
import net.nightwhistler.pageturner.view.NavGestureDetector;
import net.nightwhistler.pageturner.view.ProgressListAdapter;
import nl.siegmann.epublib.domain.Book;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import roboguice.activity.RoboActivity;
import roboguice.inject.InjectView;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.SpannedString;
import android.util.DisplayMetrics;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewSwitcher;
import com.google.inject.Inject;
public class ReadingActivity extends RoboActivity implements BookViewListener {
private static final String POS_KEY = "offset:";
private static final String IDX_KEY = "index:";
protected static final int REQUEST_CODE_GET_CONTENT = 2;
public static final String PICK_RESULT_ACTION = "colordict.intent.action.PICK_RESULT";
public static final String SEARCH_ACTION = "colordict.intent.action.SEARCH";
public static final String EXTRA_QUERY = "EXTRA_QUERY";
public static final String EXTRA_FULLSCREEN = "EXTRA_FULLSCREEN";
public static final String EXTRA_HEIGHT = "EXTRA_HEIGHT";
public static final String EXTRA_WIDTH = "EXTRA_WIDTH";
public static final String EXTRA_GRAVITY = "EXTRA_GRAVITY";
public static final String EXTRA_MARGIN_LEFT = "EXTRA_MARGIN_LEFT";
public static final String EXTRA_MARGIN_TOP = "EXTRA_MARGIN_TOP";
public static final String EXTRA_MARGIN_BOTTOM = "EXTRA_MARGIN_BOTTOM";
public static final String EXTRA_MARGIN_RIGHT = "EXTRA_MARGIN_RIGHT";
private static final Logger LOG = LoggerFactory.getLogger(ReadingActivity.class);
@Inject
private ProgressService progressService;
@Inject
private LibraryService libraryService;
@Inject
private Configuration config;
@InjectView(R.id.mainContainer)
private ViewSwitcher viewSwitcher;
@InjectView(R.id.bookView)
private BookView bookView;
@InjectView(R.id.myTitleBarTextView)
private TextView titleBar;
@InjectView(R.id.myTitleBarLayout)
private LinearLayout titleBarLayout;
@InjectView(R.id.dummyView)
private AnimatedImageView dummyView;
private ProgressDialog waitDialog;
private AlertDialog tocDialog;
private GestureDetector gestureDetector;
private View.OnTouchListener gestureListener;
private String bookTitle;
private String titleBase;
private String fileName;
private int progressPercentage;
private boolean oldBrightness = false;
private boolean oldStripWhiteSpace = false;
private enum Orientation { HORIZONTAL, VERTICAL }
private CharSequence selectedWord = null;
private Handler uiHandler;
private Handler backgroundHandler;
private Toast brightnessToast;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Restore preferences
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.read_book);
this.uiHandler = new Handler();
HandlerThread bgThread = new HandlerThread("background");
bgThread.start();
this.backgroundHandler = new Handler(bgThread.getLooper());
this.waitDialog = new ProgressDialog(this);
this.waitDialog.setOwnerActivity(this);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
this.gestureDetector = new GestureDetector(new NavGestureDetector(
bookView, this, metrics));
/*
final PinchZoomListener pinch = new PinchZoomListener( this,
new PinchZoomListener.FloatAdapter() {
@Override public void setValue(float value) { updateTextSize(value); }
@Override public float getValue() { return bookView.getTextSize(); }
});
*/
this.gestureListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
//pinch.onTouch(v, event);
return gestureDetector.onTouchEvent(event);
}
};
this.viewSwitcher.setOnTouchListener(gestureListener);
this.bookView.setOnTouchListener(gestureListener);
this.bookView.addListener(this);
this.bookView.setSpanner(getInjector().getInstance(HtmlSpanner.class));
this.oldBrightness = config.isBrightnessControlEnabled();
this.oldStripWhiteSpace = config.isStripWhiteSpaceEnabled();
registerForContextMenu(bookView);
String file = getIntent().getStringExtra("file_name");
if ( file == null && getIntent().getData() != null ) {
file = getIntent().getData().getPath();
}
if ( file == null ) {
file = config.getLastOpenedFile();
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
EPUB 解析 (java) (469个子文件)
resources.ap_ 419KB
ReadingActivity.apk 911KB
pageturner.bks 820B
proguard.cfg 1KB
ReadingActivity.class 33KB
LibraryActivity.class 22KB
BookView.class 20KB
Configuration.class 12KB
PageCurlAnimator.class 10KB
HtmlSpanner.class 9KB
SqlLiteLibraryService.class 9KB
CatalogActivity.class 8KB
LibraryDatabaseHelper.class 8KB
PageTurnerWebProgressService.class 7KB
PageTurnerSpine.class 6KB
ImportTask.class 6KB
AmbilWarnaDialog.class 6KB
TableHandler.class 6KB
CatalogActivity$LoadOPDSTask.class 6KB
ScrollingStrategy.class 5KB
CatalogActivity$DownloadFileTask.class 5KB
SinglePageStrategy.class 5KB
LibraryActivity$LoadBooksTask.class 5KB
CatalogActivity$DownloadingCatalogAdapter.class 5KB
BookView$LoadTextTask.class 4KB
SeekBarPreference.class 4KB
LibraryActivity$BookListAdapter.class 4KB
ReadingActivity$ManualProgressSync.class 4KB
BookView$ImageCallback.class 4KB
ResourceLoader.class 4KB
ProgressListAdapter.class 3KB
Nucular.class 3KB
LibraryActivity$BookCaseAdapter.class 3KB
NavGestureDetector.class 3KB
LibraryActivity$5.class 3KB
ReadingActivity$DownloadProgressTask.class 3KB
TableHandler$TableRowDrawable.class 3KB
BookCaseView.class 3KB
PageTurnerWebProgressService$SSLHttpClient.class 3KB
LibraryActivity$MenuSelectionListener.class 3KB
Entry.class 3KB
LibraryDatabaseHelper$LibraryBookResult.class 3KB
R$id.class 3KB
PageCurlAnimator$Vector2D.class 2KB
CatalogActivity$DownloadingCatalogAdapter$1.class 2KB
R$string.class 2KB
Dialogs.class 2KB
RollingBlindAnimator.class 2KB
BookView$LinkTagHandler.class 2KB
AmbilWarnaKotak.class 2KB
ContentParser.class 2KB
ListItemHandler.class 2KB
LibraryActivity$4.class 2KB
PageTimer.class 2KB
LibraryBook.class 2KB
QueryResultAdapter.class 2KB
ColourChooserPref.class 2KB
PreHandler.class 2KB
BookView$ImageTagHandler.class 2KB
LibraryActivity$QueryMenuAdapter.class 2KB
LibraryDatabaseHelper$Field.class 2KB
AtomElement.class 2KB
PinchZoomListener.class 2KB
ImageHandler.class 2KB
FeedParser.class 2KB
ReadingActivity$AutoScrollRunnable.class 2KB
PageTurnerSpine$SpineEntry.class 2KB
ColourChooserPref$Square.class 2KB
ReadingActivity$PageCurlRunnable.class 2KB
Animations.class 2KB
ElementParser.class 2KB
LibraryActivity$11.class 2KB
TableHandler$Table.class 2KB
AmbilWarnaDialog$1.class 2KB
AmbilWarnaDialog$2.class 2KB
ReadingActivity$3.class 2KB
Feed.class 2KB
EntryParser.class 2KB
AuthorParser.class 2KB
TitleParser.class 2KB
TagNodeHandler.class 2KB
LibraryActivity$BookCaseAdapter$1.class 2KB
ReadingActivity$7.class 2KB
BookView$AnchorHandler.class 2KB
Configuration$LibrarySelection.class 1KB
BookView$1.class 1KB
ReadingActivity$6.class 1KB
R$drawable.class 1KB
LibraryActivity$2.class 1KB
HeaderHandler.class 1KB
PageTurnerPrefsActivity.class 1KB
QueryResult.class 1KB
LibraryActivity$13.class 1KB
ReadingActivity$BrowserSearchMenuItem.class 1KB
MarginHandler.class 1KB
ReadingActivity$Orientation.class 1KB
CatalogListAdapter.class 1KB
Configuration$OrientationLock.class 1KB
LinkParser.class 1KB
LibraryDatabaseHelper$Order.class 1KB
共 469 条
- 1
- 2
- 3
- 4
- 5
「已注销」
- 粉丝: 150
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页