The Start Guide Of SkyEpub SDK For Android In Java.

2y ago
31 Views
2 Downloads
1,011.01 KB
16 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Aliana Wahl
Transcription

T he Start Guide of SkyEpub SDK for Android in JavaThe Start Guide of SkyEpub SDK for Android in Java.SkyEpub SDK is the most advanced and widely used epub sdk, which provides almost everyfeature to create a high level epub reader/viewer with minimum efforts.This document is designed to show the easy way how to start and set your Android applicationwith SkyEpub sdk for Android. and this start guide focuses on only making the basic skelecton ofan epub reader for the very first time.The source code (SkyTJ) of this document is also available at http://www.skyepub.net/downloads .You’d better refer to SkyEpub Advanced Demo for Java or SkyEpub Advanced Demo for Kotlinto find the fully implemented epub reader demo using SkyEpub sdk.Prerequisite SoftwareAndroid Studio 4.0.x or aboveSkyEpub SDK 8.5.x or aboveDocument History1.123 Feb 20211

T he Start Guide of SkyEpub SDK for Android in JavaCreate ProjectNew New Project Empty Projectand set project name as SkyTJ2.2

T he Start Guide of SkyEpub SDK for Android in JavaAndroidManifest Setting for Permissionsa. Add permissions like below to AndroidManifest.xml. uses-permission android:name "android.permission.INTERNET" / uses-permission android:name "android.permission.ACCESS NETWORK STATE" / uses-permission android:name "android.permission.VIBRATE" / uses-permission android:name "android.permission.ACCESS WIFI STATE" / uses-permission android:name "android.permission.CHANGE WIFI STATE" / uses-permission android:name "android.permission.READ EXTERNAL STORAGE" / uses-permission android:name "android.permission.WRITE EXTERNAL STORAGE" / uses-permission android:name "android.permission.RECEIVE BOOT COMPLETED" / uses-permission android:name "android.permission.WAKE LOCK" / b. android :requestLegacyExternalStorage “true”is needed to be added to application . application.android :requestLegacyExternalStorage "true"3

T he Start Guide of SkyEpub SDK for Android in JavaAllow the Access to ‘localhost’Select “Android” in Project Pane by dropdown the menu.Make xml folder under app res ( click right button on res folder and select New Directory )make app res xml network security.xml file.The content of this file is like the following. ?xml version "1.0" encoding "utf-8"? network-security-config domain-config cleartextTrafficPermitted "true" domain includeSubdomains "true" 127.0.0.1 /domain domain includeSubdomains "true" localhost /domain /domain-config /network-security-config Add networkSecurityConfig property to Application element in AndroidManifest.xml applicationandroid :requestLegacyExternalStorage "true"android:networkSecurityConfig " @xml/network security"4

T he Start Guide of SkyEpub SDK for Android in JavaImport skyepub.jar and other jar into this project.a.skyepub.jar: the latest version is always available from gacy.jar: http://hc.apache.org/downloads.cgiDrag these two files into P roject Project SkyTJ app libs .b. click the right button on skyepub.jar and choose ‘Add As Library’ .c. Add org.apache.http.legacy to AndroidManifest.xml /activity uses-libraryandroid:name "org.apache.http.legacy"android:required "false" / /application 5

T he Start Guide of SkyEpub SDK for Android in JavaCreate BookActivityCreate new Activity by New Activity Empty ActivitySet the name of the new activity as ‘BookActivity’.6

T he Start Guide of SkyEpub SDK for Android in JavaMake one button to open book in MainActivityAdd a button by modifying r es layout activity main.xml .set id to ‘openBookButton’and set text to ‘Open Book’and set onClick to ‘onOpenBookPressed’the modified xml looks like the below. ?xml version "1.0" encoding "utf-8"? mlns:android app ls "http://schemas.android.com/tools"android:layout width "match parent"android:layout height "match parent"tools:context ".MainActivity" Buttonandroid:id "@ id/ openBookButton "android:layout width "wrap content"android:layout height "wrap content" android:layout marginStart "60dp"android:layout marginTop "40dp"android:onClick " onOpenBookPressed "android:text " Open Book "app:layout constraintStart toStartOf "parent"app:layout constraintTop toTopOf "parent" / /androidx.constraintlayout.widget.ConstraintLayout 7

T he Start Guide of SkyEpub SDK for Android in JavaInclude sample epub in this project.Make folder in Project Android app assets booksand drag ‘Alice.epub’ into this folder.8

T he Start Guide of SkyEpub SDK for Android in JavaMake some code in MainActivityWhen MainActitivy starts,it will create folder ‘books’ under the document folder of the app.and it will copy Alice.epub from a ssets books Alice.epub to the folder above.These codes are just to copy one sample file to use.and these have nothing to do with SkyEpub sdk itself.MainActivity.java is now like the below.package com.skyepub.skytj;import androidx.appcompat.app.AppCompatActivity;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.os.Bundle;import android.util.Log;import android.view.View;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;public class MainActivity extends AppCompatActivity { final String TAG "SKYEPUB" ; @Override protected void onCreate(Bundle savedInstanceState) { super out. activity main );check();setup();} void check() {String path this .getStorageDirectory() "/books/" "Alice.epub" ;File file new File(path); if (file.exists()) {Log. w( TAG , "File installed" );} else {Log. w( TAG , "File not installed" );}} void setup() { try { if (isSetup()) return ; this .makeDirectory( "books" ); this .copyBookFromAssetsToDevice( "Alice.epub" );SharedPreferences pref getSharedPreferences( "SkyMiniJ" , 0 );SharedPreferences.Editor edit pref.edit();edit.putBoolean( "isSetup" , t rue );edit.commit();9

T he Start Guide of SkyEpub SDK for Android in Java} catch (Exception e) {}} private boolean isSetup() {SharedPreferences pref getSharedPreferences( "SkyMiniJ" , 0 ); return pref.getBoolean( "isSetup" , false );} public void copyBookFromAssetsToDevice(String fileName) { try {String path this .getStorageDirectory() "/books/" fileName;File file new File(path); if (file.exists()) return ;Context context;InputStream localInputStream getAssets().open( "books/" fileName);FileOutputStream localFileOutputStream newFileOutputStream( this .getStorageDirectory() "/books/" fileName); byte [] arrayOfByte new byte [ 1024 ]; int offset; while ((offset localInputStream.read(arrayOfByte)) 0 ){localFileOutputStream.write(arrayOfByte, 0 , tream.close();Log. d ( TAG , fileName " copied to phone" );} catch (IOException ();Log. d ( TAG , "failed to copy" ); return ;}} public boolean makeDirectory(String dirName) { boolean res;String filePath new String( this .getStorageDirectory() "/" dirName);File file new File(filePath); if (!file.exists()) {res file.mkdirs();} else {res false ;} return res;} public String getStorageDirectory() {String res "" ;res getFilesDir().getAbsolutePath() "/" getString( this .getApplicationInfo(). labelRes ); return res;}10

T he Start Guide of SkyEpub SDK for Android in Java public void onOpenBookPressed(View view) {Intent intent;intent new Intent( this , BookActivity. class );intent.putExtra( "BOOKCODE" , 0 );intent.putExtra( "BOOKNAME" , "Alice.epub" );startActivity(intent);}}onOpenBookPressed passes over bookCode, bookName to BookActivity whenopenButton is clicked.11

T he Start Guide of SkyEpub SDK for Android in JavaAdd a ConstraintLayout named ‘skyepubView’ toBookActivityand add the properties to cover the entire screen.skyepub sdk will be inserted into this ‘skyepubView’.the activity book.xml to which new constraintLayout is added is like the following. ?xml version "1.0" encoding "utf-8"? mlns:android app ls "http://schemas.android.com/tools"android:layout width "match parent"android:layout height "match parent"tools:context ".BookActivity" androidx.constraintlayout.widget. ConstraintLayoutandroid:id "@ id/ skyepubView "android:layout width "0dp"android:layout height "0dp"android:background "#871F1F"app:layout constraintBottom toBottomOf "parent"app:layout constraintEnd toEndOf "parent"app:layout constraintStart toStartOf "parent"app:layout constraintTop toTopOf "parent" /androidx.constraintlayout.widget.ConstraintLayout /androidx.constraintlayout.widget.ConstraintLayout 12

T he Start Guide of SkyEpub SDK for Android in JavaComplete the code to open epub in BookActivitypackage com.skyepub.skytj;import androidx.appcompat.app.AppCompatActivity;import import android.Manifest;import android.annotation. SuppressLint ;import android.app.Activity;import android.content.pm.PackageManager;import android.graphics.Color;import android.os.Build;import android.os.Bundle;import android.speech.tts.TextToSpeech;import android.util.Log;import android.view.HapticFeedbackConstants;import android.view.View;import android.view.WindowManager;import android.widget.ImageButton;import android.widget.SeekBar;import android.widget.TextView;import com.skytree.epub.Book;import com.skytree.epub.KeyListener;import com.skytree.epub.PageTransition;import com.skytree.epub.PagingMode;import com.skytree.epub.ReflowableControl;import com.skytree.epub.SkyProvider;import java.io.File;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLConnection;public class BookActivity extends AppCompatActivity {ConstraintLayout skyepubView ;ReflowableControl rv ;String fileName ; int bookCode ; double pagePositionInBook ; final String TAG "SKYEPUB" ; public String getStorageDirectory() {String res "" ;//All book related data will be stored /data/data/com./files/appName/ res getFilesDir().getAbsolutePath() "/" getString( this .getApplicationInfo(). labelRes ); return res;} @Override protected void onCreate(Bundle savedInstanceState) { super out. activity book );13

T he Start Guide of SkyEpub SDK for Android in Java} this . makeFullscreen ( this ); skyepubView (ConstraintLayout) this .findViewById(R.id. skyepubView ); this .makeBookViewer(); public void makeBookViewer() {Bundle bundle getIntent().getExtras(); fileName bundle.getString( "BOOKNAME" ); bookCode bundle.getInt( "BOOKCODE" ); pagePositionInBook 0 ;r v new ReflowableControl( this );/ / in case that device supportstransparent webkit, the background image under the content can be shown. in some devices,content may be overlapped. rv .setId( 7777 ); // set the bookCode to identify the book file. rv . bookCode this . bookCode ;// // Be sure that the file exists before setting. String bookPath this .getStorageDirectory() "/books/" fileName ; rv .setBookPath(bookPath); // if true, double pages will be displayed on landscape mode. rv .setDoublePagedForLandscape( true ); // set the initial font style for book. rv .setFont( "Book Fonts" , this .getRealFontSize( 3 )); // set the initial line space for book. rv .setLineSpacing( this .getRealLineSpace( 2 )); // the value is supposed to be percent(%).// set the horizontal gap(margin) on both left and right side of each page. rv .setHorizontalGapRatio( 0.30 ); // set the vertical gap(margin) on both top and bottom side of each page. rv .setVerticalGapRatio( 0.20 );rv.setMarginTopRatio(0.7);// SkyProvider is the default ContentProvider which is presented with SDK.// SkyProvider can read the content of epub file without unzipping.// SkyProvider is also fully integrated with SkyDRM solution. SkyProvider skyProvider new SkyProvider(); rv .setContentProvider(skyProvider); // set the start positon to open the book. rv .setStartPositionInBook( pagePositionInBook ); // if true, globalPagination will be activated.// this enables the calculation of page number based on entire book ,not on each chapter.// this globalPagination consumes huge computing power.// AVOID GLOBAL PAGINATION FOR LOW SPEC DEVICES. rv .setGlobalPagination( false ); // set the navigation area on both left and right side to go to the previous or next page whenthe area is clicked. rv .setNavigationAreaWidthRatio( 0.2f ); // both left and right side.// set the navigation area enabled rv .setNavigationAreaEnabled( true ); // set the device locked to prevent Rotation. rv .setRotationLocked( true );14

T he Start Guide of SkyEpub SDK for Android in Java // If you want to get the license key for commercial use, please email us(skytree21@gmail.com).// Without the license key, watermark message will be shown in background. rv .setLicenseKey( "0000-0000-0000-0000" ); // set PageTransition Effect int transitionType bundle.getInt( "transitionType" ); if (transitionType 0) { rv .setPageTransition(PageTransition. None );} else if (transitionType 1) { rv .setPageTransition(PageTransition. Slide );} else if (transitionType 2) { rv .setPageTransition(PageTransition. Curl );} rv .setSystemSelectionEnabled( true ); rv .setForegroundColor(Color. BLACK ); rv .keepBackgroundColor( true ); rv .setLayoutParams( LayoutParams. MATCH PARENT ,ConstraintLayout.LayoutParams. MATCH PARENT) ); skyepubView .addView( rv );} int getRealFontSize( int fontSizeIndex) { int rs 0 ; switch (fontSizeIndex) { case 0 :rs 24 ; break ; case 1 :rs 27 ; break ; case 2 :rs 30 ; break ; case 3 :rs 34 ; break ; case 4 :rs 37 ; break ; default :rs 27 ;}rs ( int ) (( double ) rs * 0.75f );} return rs; public int getRealLineSpace( int lineSpaceIndex) { int rs - 1 ; if (lineSpaceIndex 0 ) {rs 125 ;} else if (lineSpaceIndex 1 ) {15

T he Start Guide of SkyEpub SDK for Android in Java}rs 150 ;} else if (lineSpaceIndex 2 ) {rs 165 ;} else if (lineSpaceIndex 3 ) {rs 180 ;} else if (lineSpaceIndex 4 ) {rs 200 ;} else {rs 150 ;} return rs; @SuppressLint ( "InlinedApi" ) public static void makeFullscreen(Activity activity) tParams. FLAG FULLSCREEN, WindowManager.LayoutParams. FLAG FULLSCREEN) ; if (Build.VERSION. SDK INT 19 ) sibility(View. SYSTEM UI FLAG IMMERSIVE View. SYSTEM UI FLAG HIDE NAVIGATION View. SYSTEM UI FLAG FULLSCREEN View. SYSTEM UI FLAG IMMERSIVE STICKY View. SYSTEM UI FLAG LAYOUT FULLSCREEN View. SYSTEM UI FLAG LAYOUT HIDE NAVIGATION View. SYSTEM UI FLAG LAYOUT STABLE) ;} else if (Build.VERSION. SDK INT 11 ) sibility(View. SYSTEM UI FLAG LOW PROFILE );}}}16

T h e S t a rt G ui de of S kyE pub S D K for A ndroi d i n J a va The Start Guide of SkyEpub SDK for Android in Java. SkyEpub SDK is the most advanced and widely used epub sdk, which provides almost every feature to create a high level epub reader/viewer with minimum efforts.

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. Crawford M., Marsh D. The driving force : food in human evolution and the future.

Massachusetts Curriculum Framework for English Language Arts and Literacy 3 Grade 5 Language Standards [L]. 71 Resources for Implementing the Pre-K–5 Standards. 74 Range, Quality, and Complexity of Student Reading Pre-K–5 . 79 Qualitative Analysis of Literary Texts for Pre-K–5: A Continuum of Complexity. 80 Qualitative Analysis of Informational Texts for Pre-K–5: A .