Our Recent Work – Test environment refactoring and UI compatibility issues

It’s been some time now since the last release. During this period, one of the most meaningful thing we did was the refactoring of test environment for EPUB books. Before, we had written unit tests for each API. Along with the more and more types that were supported, and the increase in books that were tested, the maintenance of test code was causing trouble for us. So we stopped to improve testing tools. Now, just put the book to be tested on the internal test site, then the test program automatically runs the testcases. We run these tests each time we commit the code internally. We are very grateful to those members of the epub samples team, whose website is: http://code.google.com/p/epub-samples/.

Another thing, however, turned out to be very frustrating: for UI, supporting the basic flip operation is a matter of course. Since considerable difference exists between different Android versions – simply too many inconsistencies –  providing compatible code becomes very complex. If we consider only the iOS platform, the flipping effect can be made flamboyant. No programmer wants to maintain a very complex codes, which will bring us a lot of pressure in maintenance. Maybe we should introduce a modest version and leave a better UI to the next version, or maybe we give up support for some low Android versions.

Recently, we received quite a lot emails which gave us some valuable suggestions, thank you very much. We will attach great importance to your proposals, I believe that our team will do better, our goal is that our users do the most with the least code.

AnFengDe EPUB UI Component 20120824 is released

A new version of AnFengDe EPUB UI Component is released. A significant improvement of this version is the support to EPUB 2.0.x, in which most of the ebooks on the net are published. The SDK API interface is unchanged for compatibility with previous applications. Also we’ve added Google’s AdMob feature. Ebook readers developed by this dev kit will cast advertisements. Please contact us if you want to remove it or replace it with your own ads. Paying a very small amount of fee will suffice.

We are still working to the development, please keep attention.

AnFengDe EPUB UI Component 20120810 is released

EPub 3.0 applications can be developed easily with EPUB UI Component. Referencing the component is very simple, here is the link :Getting started with EPUB UI Component.
This component can display books and play the video and audio in books. All you have to do is just referencing the component and simply adding some codes to your project.
You can develop your iOS project with the iOS EPUB UI Component, and develop your Android project with the Android EPUB UI Component. They are both full free, you can use them anywhere.
The next version will be released soon, it will be more rich.

If you have any idea and suggestions, please let us know:support@anfengde.com.

Getting Started with EPUB SDK

See in google document: Get Started With EPUB SDK

Getting Started with EPUB SDK

Introduction

EPUB SDK is a development kit written in pure ANSI C, realizing EPUB 3.0 parsing and achieving excellent performance on mobile devices.
This development kit provides native development interfaces for both Android and iOS. It contains a framework for the iOS platform, a jar file and a shared library for the Android platform.
All you need to do is simple copying and importing, then you can directly reference in your own project.

Installation
The EPUB SDK is distributed as a .zip archive. The file name has the following naming convention: AnFengde-EPUB_SDK-<version>.zip, where

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

The distribution
After you have downloaded and extracted 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 SDK in Your Application Project
Android Platform
In order to use our EPUB SDK in your application project, your project will need to reference both the jar file (anfengde-epub.jar ) and the shared library (libepubjni.so). You can copy the files under android/lib/EPUB_UI/libs (containing anfengde-epub.jar and armeabi/libepubjni.so) to your own project. Please put these files under project/libs folder. If no libs folder exists in your own project, you can create one manually.
Referencing the EPUB SDK implementation jar library
To add a reference to the jar library, follow these steps:

  • Method One
    • In Package Explorer, right-click on libs/anfengde-epub.jar and select Build Path->Add to Build Path.
  • Method Two
    • In Package Explorer, right-click on your project and select Properties.
    • In the Properties window, select Java Build Path, and then click on Libraries tab, then click on the Add External Jar button, and browse your jar file and click OK (Java Build Path->Libraries->Add External Jar->pick the jar file->OK).

Figure 1 – android EPUB SDK add jar-method one

Figure 2 – android EPUB SDK add jar-method two

After the above operations, you have succeeded in adding EPUB SDK to your own project, and your can use it for development.

iOS Platform
In order to use our EPUB SDK in your application project, your project will need to reference the framework of AnfengdeEpub.framework. All you need to do is to copy the framework ro your own iOS project and add it to the project.
Referencing the EPUB SDK framework
To add a reference to the framework, follow these steps:

  • In Project navigator, right-click Framework, then select Add File to “<projec name>”, and browse the framework and Add it. Then you will see as follow:

Figure 3 – Framework

Using The Sample Project
The EPUB SDK distribution package includes the sample projects to show you how you can use some of the main features of the EPUB SDK in your application.
Android platform
To open and build the sample project, follow these steps:

  • File->New->project->Android->Android Project->Next.
  • Select Creating project from existing source, and browse the sample project. And modify Project Name = Example, then click Next. Check Build Target = Android 2.2, and Next. Modify Application Name =  Example, then Finish.

Figure 4 – import the sample project

Figure 5 – load the sample project

Figure 6 – import the sample project-2

After you have setup the sample project correctly, you can then build and run the application to see the sample work.

Figure 7 – running the sample project (left is Android, right is iOS)

iOS
For the iOS sample project, you can double-click example.xcodeproj. Then you can build and run the application to see the sample work.

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


IOS Platform
Epub UI Component is the framework in iOS platform, and getting started with it is very simple. You just add the framework to your project. Now look at the sample and you know how to reference it in your iOS project.
Creating a Project
To create a new project and name it as CallEPubUI with Xcode(Version 4.2.1)

  • Create a new Xcode project -> Application->Single View Application

Figure 5-create a single view application

Figure 6-CallEPubUI project

Adding the Frameworks and Resources
To add the frameworks and resources to CallEPubUI project in Xcode:

  • Right click on the Frameworks in the CallEPubUI project
  • select “Add Files to “CallEPubUI””
  • select  AnFengDe_EPUB_SDK.framework and AnFengDe_EPUB_UI.embeddedframework, and then add them to CallEPubUI project.
  • In Build Phases option drag .js files from Compile Sources to CopyBundle Resources

Figure 7-add framework to CallEPubUI project

Add iOS framework
Add the following frameworks to your project:

  • MediaPlayer.framework
  • MessageUI.framework
  • SystemConfiguration.framework
  • AudioToolbox.framework
  • CoreGraphics.framework
  • libsqlite3.dylib

Figure 8-add iOS framework


Add -all_load under Other Linker Flags in the project build info: CallEPubUI target ->Build Settings ->Linking ->Other Linker Flags->Add “-all_load”.

Opening the EPUB Book

If everything is OK, the CallEPubUI project looks like this:


Figure 9-the resources list of CallEPubUI project


Now add some codes in the AppDelegate.h (not ViewController.h).

#import <UIKit/UIKit.h>
#import <AnFengDe_EPUB_UI/EPubUIHeader.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) EPubRootViewController *rootEpubView;

@end

And in the AppDelegate.m (not ViewController.m), some codes are added to the method:

@implementation AppDelegate

@synthesize window = _window;
@synthesize rootEpubView;

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.rootEpubView = [[EPubRootViewController alloc] initWithNibName:@”EPubRootViewController” bundle:nil];
self.window.rootViewController = self.rootEpubView;
[self.window makeKeyAndVisible];
   return YES;
}

Note:
If you want to associate your project with ePub file type. You need to add the option in your project info.plist file like this:

It is different in the different version Xcode, so maybe you need to find the right way to do that.

And then you can invoke openBookFromSafari(NSURL *url) to get the book path from the url to open the book. Refer to our project.

 

Run the CallEPubUI project.

Figure 10-the book showing up

AnFengDe EPUB SDK Android development enviroment setting

Please copy our library files under lib folder to your android project’s libs folder. If no libs folder exists in your project, you can create one manually.

android epub sdk dev path for copy

android epub sdk dev path for copy

And now you have succeeded adding epub sdk library.

android epub sdk build setting

Example

We supplied an example for your reference under example folder. The project can run on both the device and the simulator.

More

For more information, please contact us.