20131217: New Release with Support for KitKat 4.4

Thanks to our Indian user who sent us the issue of our SDK failure after updating to KitKat 4.4, the latest Android version.
The new release resolves the specific problems proposed by him. We appreciate any suggestions and issues from our clients, who may encounter other issues due to different devices and/or diffenrent platforms.

Screen Shot 1

AnFengDe EPUB UI Component 20131021 is Released

After the last release in June, we kept receiving suggestions from developers, for which we felt the need to publish a new version. In this one the following features are enforced:

1, Support for MIPS, X86, ARMEBI, ARMEBI-V7A chip architectures;
2, Support for Android 4.3;
3, Updated and tested for iOS7 environment.

We’ve been developing UI for the new release. Indeed it has taken us quite a long time. But we think it’s worthy. Due to time and energy limitations, there’s been no optimization for the iOS7 interface. Most of the job with significance has been at the EPUB parsing layer.

A Success Case Using our EPUB SDK

We had yesterday an encouraging feedback from one of our SDK users who has been developing an app for Brazil’s Ministry of Education. The ministry equips public school teachers with tablets that are preinstalled of the app to introduce new technologies to these teachers. The app contains eight books. From the screenshots forwarded to us by Mr.Joao Filipe Dalla Rosa(joaofilipedallarosa@gmail.com), thanks be to him, we can see that the rendering of illustrations is quite nice, though we are Portuguese illiterate.

Screen shot 3

Screen shot of Bookshelf

Screen Shot 1

Screen Shot 1

Screen Shots

Screen Shot 2



Screen Shot s

Screen Shot 8

Screen Shot s

Screen Shot 8

AnFengDe EPUB UI Component 20130521 is released

In this release we’ve modified our project because some people want to load the inbuilt books and don’t want users to delete them. We deleted the add book function and delete book function. So if you want to add books to you project, you can put them in the books folder(in android is the assets/books), and the app will load them when it starts.

Introducing EPUB CFI

CFI, or Canonical Fragment Identifier, is a device designed by IDPF to refer any location of an element or context in an EPUB publication. CFI has a structure similar to that of an HTTP address and has been the result of inspiration by the power of the Web’s hyperlinks.
We at Anfengde was applying the % percentage to indicate reading progress when developing our AnReader. Though we had spent a lot of time on the EPUB3 Specifications, even making a rather formal translation to contribute to IDPF, we ignored the chapters about CFI. Then Ric Wright’s mentioning of it caught our attention when he pulled our code and ran our SDK. Ric Wright is serving part time as technical director of the Readium SDK project and is the president of Geo F/X. So we researched this part again and discussed within our team about the rules IDPF has made. It’s yet a tentative measure as we understand it since IDPF only labels it as recommended.
Below is a brief introduction, for full documentation please check at IDPF’s site.

The characters employed by IDPF to construct identifiers are “/”, ”[“, “~”, “!”, “@” and “^”, among which “^” escapes characters to avoid confliction. Identifiers are a sequence of steps placed in brackets and prefixed with “epubcfi”. They are then appended to the end of IRI with #, e.g.,
book.epub#epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/3:10).

In the above example, even numbers like 6 and 4 after “/” indicate that the step is an element of a DOM object. Odd numbers after “/” are texts to be rendered. Contents inside square brackets ([…]) are assertions for verification. Each special character is defined with specific usages in the link about, so we only cite an example from there to demonstrate the clues.
Given the following Package Document:

<?xml version="1.0"?>

<package version="2.0" 
         unique-identifier="bookid" 
         xmlns="http://www.idpf.org/2007/opf"
         xmlns:dc="http://purl.org/dc/elements/1.1/" 
         xmlns:opf="http://www.idpf.org/2007/opf">

 <metadata>
        <dc:title>...</dc:title>
        <dc:identifier id="bookid">...</dc:identifier>
        <dc:creator>...</dc:creator>
        <dc:language>en</dc:language>
 </metadata>
 <manifest>
        <item id="toc"
              properties="nav"
              href="toc.xhtml" 
              media-type="application/xhtml+xml"/>
        <item id="titlepage" 
              href="titlepage.xhtml" 
              media-type="application/xhtml+xml"/>
        <item id="chapter01" 
              href="chapter01.xhtml" 
              media-type="application/xhtml+xml"/>
        <item id="chapter02" 
              href="chapter02.xhtml" 
              media-type="application/xhtml+xml"/>
        <item id="chapter03" 
              href="chapter03.xhtml" 
              media-type="application/xhtml+xml"/>
        <item id="chapter04" 
              href="chapter04.xhtml" 
              media-type="application/xhtml+xml"/>
    </manifest>
    
    <spine>
        <itemref id="titleref"  idref="titlepage"/>
        <itemref id="chap01ref" idref="chapter01"/>
        <itemref id="chap02ref" idref="chapter02"/>
        <itemref id="chap03ref" idref="chapter03"/>
        <itemref id="chap04ref" idref="chapter04"/>
    </spine>
    
</package>

and the XHTML Content Document chapter01.xhtml:

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>...</title>
    </head>
    
    <body id="body01">
        <p>...</p>
        <p>...</p>
        <p>...</p>
        <p>...</p>
        <p id="para05">xxx<em>yyy</em>0123456789</p>
        <p>...</p>
        <p>...</p>
        <img id="svgimg" src="foo.svg" alt="..."/>
        <p>...</p>
        <p>...</p>
    </body>
</html>

Then epubcfi(/6) is the step of “spine”, the 3rd element in the package, epubcfi(/6/4) the 2nd spine element which is chap01ref, for which [chap01ref] is asserted for checking. Thus the EPUB CFI of epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/3:2) refers to the location of “1” in the text string 0123456789.

Running Unit Tests Automatically on the Emulator for Multiple Android Versions

It’s natural to write unit tests when developing Android applications, and it’s really convenient to do so in Eclipse by selecting “Run as Android Test”. Faced with testing for multiple Android versions, however, it’s troublesome because we will have to make manual selection of versions. Moreover, on the integrated test server only the command line is used. Obviously, we’ll benefit a lot if we have a script to control the versions automatically.

We first need to define an array loop:

all=(android2.2 android2.3 android3.2 android4.1 android4.2)
for i in "${all[@]}"
do
 .... run testcase and collect result....
done

There is the other issue: after starting the emulator from the command line, sometimes the command “adb” cannot detect it, causing the “adb wait-for-device” command to wait forever.   We wrote a small function to detect it, after starting the simulator, “adb devices” is called every second to scan if the word “offline” exists. If nothing is detected within one minute, then the current simulator is killed for restart.

# wait android emulator boot normally, sometime it looks booted,
# but adb cmd can not detected
function wait_emulator_boot(){
 bootok=0
 wait_time=1
 while [ $bootok -le 0 ]; do
   sleep 1
   # if detected offline status, it is boot ok
   bootok=`adb devices|grep offline|wc -l`
   (( wait_time++ ))
   # wait one minute, because more slower when version higher
   if [[ $wait_time -ge 60 ]]; then
     return
   fi
 done
 return
}

Next comes, without doubt, the emulator control by adb command and collecting test data. But there are some problems with the command adb, which, in particular, does not have return values. For example,

 adb install nobody.nobody.nobody

always returns 0. In other words, the script can’t detect if the installation succeeds or fails, an issue heaped with grumbles in Android forums.

The case with us is that the emulator already starts normally, by appearance at least, immediate executing of package installation would report:“Could not access the package manager, is the system running?”

Such error messages indicate that modules for software management are not ready yet inside the emulator. The higher the emulator version, the more serious the issue.

access_done=0
while [ $access_done -le 0 ]; do
  sleep 1
  access_done=`adb uninstall com.anfengde.epub.test|grep -v "Is the system running?"|wc -l`
done

Similarly, we keep scanning the output of error messages to see if it’s executable.

Full code is listed below so that it may be of use to you. Video clip of the running can be found at: Video Clip

#!/bin/bash
# Wirte by AFD Team, 2013.4.10
# define android version array for loop test
all=(android2.2 android2.3 android3.2 android4.1 android4.2)

# clean and build new version
ant clean
ant release

# wait android emulator boot normally, sometime it looks booted,
# but adb cmd can not detected
function wait_emulator_boot(){
  bootok=0
  wait_time=1
  while [ $bootok -le 0 ]; do
    sleep 1
    # if detected offline status, it is boot ok
    bootok=`adb devices|grep offline|wc -l`
    (( wait_time++ ))
    # wait one minute, because more slower when version higher
    if [[ $wait_time -ge 60 ]]; then
        return
    fi
  done
  return
}

# loop android version array
for i in "${all[@]}"
do
    retry=1
    running=0
    while [ $running -le 0 ]; do
        adb -s emulator-5554 emu kill
        echo "startup emulator:" $i "times:" $retry
        # run emulator in background
        emulator -avd $i &amp;
        wait_emulator_boot

        # recheck emulator status
        running=`adb devices|grep line|wc -l`
        echo "check status:" $running "time:" `date`
    done

    # boot normally, just wait online
    adb wait-for-device

    # check software manager work not
    access_done=0
    while [ $access_done -le 0 ]; do
        sleep 1
        access_done=`adb uninstall com.anfengde.epub.test|grep -v "Is the system running?"|wc -l`
    done

    adb uninstall com.anfengde.epub.test &gt; /dev/null
    adb install ./bin/EPUB_SDKTest.apk

    # run testcase
    adb shell am instrument -w com.anfengde.epub.test/android.test.InstrumentationTestRunner
    adb -s emulator-5554 emu kill
done

AnFengDe EPUB SDK vs Adobe RMSDK

Public Google Document is here!

AnFengDe EPUB SDK

Introduction

EPUB SDK is a development kit written in ANSI C and Java, 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.

App:

AnReader

Test books:

Creative Commons – A shared culture.epub, Around the world in 28 languages.epub. For more epub 3.0 test books you can click this link,
http://code.google.com/p/epub-samples/downloads/list.

Supported functions

Both our android app and ios app shared the same UI and features.

  • Changing text size        We provided multiple, more than RMSDK’s, text sizes for you to choose from.  To zoom in or out, just tap the button pair on the top menu bar marked as “A”.
  • Flipping pages        Swipe left and right on the screen. Our SDK also supports previous/next chapter jumping by tapping buttons at the bottom setting bar.
  • Bookmark            It’s easy to add a bookmark anywhere you please in the book.
  • Table of contents        Table of contents for epub 3.0 and epub 2.0 books will display correctly. That’s what neither RMSDK nor Stanza can do.
  • Skipping pages        It’s easy to jump to anywhere of the book by moving the slider on the sliding bar.
  • Page percentage        Our SDK chooses to use percentage in marking the reading progress.
  • Playing audio and video    Our SDK supports the playing of audio and video files embedded in the book.
  • TTS(Text To Speech)    our SDK support speaking the selected content of the book.
  • Friendly reading interface    For several books (such as this book), if you open them using RMSDK, you can find that the reading interface is unfriendly. For the same book, our SDK performs excellent rendering.
  • Changing the style of UI    If you are not satisfied with the original UI style, our SDK provides several interfaces for customizing and replacement.
  • Supporting both EPUB 2.0 and EPUB 3.0 specification    Our SDK exhibits excellent performance in rendering EPUB 2.0 and EPUB 3.0 books.
  • Free of charge    AnReader SDK with advertisement bar is free of charge. To the best of our knowledge, the price for licensing RMSDK on ios is $30,000.

More functions    Our team is working on AnFengDe EPUB SDK for adding more features.

RMSDK

______________________________________________

Introduction

The Adobe Reader Mobile SDK (RMSDK) is Adobe’s toolkit for rendering EPUB and PDF content for eReading apps and devices.
______________________________________________

App:

DLReader

Test books:

Creative Commons – A shared culture.epub, Around the world in 28 languages.epub.
______________________________________________

Supported functions

  • Changing text size        The app provided five text sizes.
  • Flipping pages        Swipe the finger left and right on the screen.
  • Changing orientation    You can choose the reading orientation. Our AnFengDe team thought that this function was useless and had abandoned it.
  • Searching            RMSDK supports searching. The function will be available in the future release.
  • Hightlight            RMSDK supports highlighting. The function is in our plan and will be available in the future release.
  • Bookmark This is a basic function of the reader software.
  • Skipping pages This is a basic function of the reader software.

Function Table List

AnFengDe EPUB SDK vs Adobe RMSDK