anfengde--epub ui

来源:互联网 发布:java中的接口定义 编辑:程序博客网 时间:2024/06/03 20:35

Getting Started with EPUB UI Component


class:calss:http://epub.anfengde.com/epub_ui_android_doc/
Here is the last Doc:Getting Started with EPUB UI Component.

Getting Started with  EPUB UI Component

Introduction

EPUB UI Component is a development kit with which EPub 3.0 applications can be developed easily. Referenced in your project, the component helps your parsing and displays the book.

Installation

The EPUB UI Component is distributed as a .zip archive. The file has the following naming convention: AnFengde-EPUB_UI_Component-<version>.zip, where

  • <version> is the version number, e.g. 20120704
  • for example: AnFengde-EPUB_UI_Component-20120704.zip

The distribution

After downloading and extracting the archive to the desired location, you will find the following contents:

  • android    directory containing the EPUB SDK resources for the Android platform
    • EPUB_SDK_Example    directory containing the EPub SDK example for android
    • UI_Example    directory containing the UI component project for android
    • lib    directory containing the EPUB_UI library project
  • ios     directory containing the EPUB_SDK resources for the iOS platform
    • EPUB_SDK_Example    directory containing the EPub SDK example for iOS
    • UI_Example    directory containing the UI component project for iOS
    • lib     directory containing the framework AnFengDe_EPUB_SDK.framework and AnFengDe_EPUB_UI.embeddedframework
  • README.md
  • GettingStartedwithEPUBSDK.pdf
  • GettingStartedWithEPUBUIComponent.pdf

Setting Up Development Environment

For the Android platform, this guide assumes that you are using Eclipse as your Android IDE, and that you have installed and configured the Android SDK and ADT plug-in for Eclipse.
For iOS platform, this guide assumes that you are using Xcode as your IDE.
If you are using other IDEs, please consult the documentation of your IDE.

Using EPUB UI Component in Your Application Project

Android Platform
Epub UI Component is a Library Project in android platform, and getting started with it is very simple. You just add the library to your project. Now look at the sample and it will tell you how to reference the Epub UI Component in your android project.
Importing EPUB_UI Project
To import EPUB_UI library project in you Eclipse(Version: Juno Release).

  • File-> Import->Existing Android Code Into Workspace->Browse our EPUB_UI project

Figure 1-import the EPUB_UI project

Referencing EPUB_UI Project
To create an android project:

  • File->New->Android Project, name the project as CallEPubUI
  • Right click on the CallEPubUI project->Properties->Android->Add->EPUB_UI->OK->OK

Figure 2-CallEPubUI project

Figure 3-reference the EPUB_UI project(1)

Figure 3-reference the EPUB_UI project(2)

Opening the EPub Book

If everything is OK, now add the code in the main.xml of the CallEPubUI project.

<com.anfengde.epub.ui.BookView
android:id=”@+id/bookView1”
android:layout_width=”match_parent”
android:layout_height=”fill_parent” >
</com.anfengde.epub.ui.BookView>

Add the code in the AndroidManifest.xml of the CallEPubUI project.

in the manifest tag add the code:
<uses-permission android:name=”android.permission.INTERNET”/>
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />    <uses-permission android:name=”android.permission.WRITE_SETTINGS”/>
<uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE”/> <uses-permission android:name=”android.permission.ACCESS_LOCATION_EXTRA_COMMANDS”/>

in the application tag add the code:

<activity android:name=”com.google.ads.AdActivity”     android:configChanges=”keyboard|keyboardHidden|orientation|
screenLayout|uiMode|screenSize|smallestScreenSize”/>

Pay attention to space symbol. If some problems occur, please set project target in project.properties to android-13 or above and then clean the project.

As a last step, add some codes in the onCreate method of the CallEPubUIActivity.

BookView bookView = (BookView) findViewById(R.id.bookView1);
bookView.setPath(Constants.CACHE_PAHT);
bookView.initBook();
bookView.openShelf();

bookView1” is the EPUB UI Component ID, you can change it.
Constants.CACHE_PAHT
is the cache path.        

Note:
If you want to associate your project with ePub file type. You can add this code below to your <activity> tag in the AndroidManifest.xml.

<intent-­filter>
<action android:name=”android.intent.action.VIEW” />
<category android:name=”android.intent.category.DEFAULT” />
<category android:name=”android.intent.category.BROWSABLE” />

 
<data
android:host=”*” android:scheme=”file” />
<data
android:mimeType=”*/*” android:pathPattern=”.*\\.epub” />
</intent-­filter>

And then you can invoke openBookFromFileExplorer(Intent intent) to get the book path from the intent to open the book. Refer to our project.


Run the CallEPubUI project. Now you can add books to the bookshelf.

Figure 4-the book showing up

0 0
原创粉丝点击