Skip to content

Commit

Permalink
Merge pull request #256 from codetoart/master
Browse files Browse the repository at this point in the history
Search implementation - v0.4.1
  • Loading branch information
Mahavir Jain committed Aug 20, 2018
2 parents 69c8298 + 01415fe commit a81b7a6
Show file tree
Hide file tree
Showing 85 changed files with 5,167 additions and 2,714 deletions.
51 changes: 29 additions & 22 deletions README.md
Expand Up @@ -40,7 +40,7 @@ FolioReader-Android is an ePub reader written in Java.
Add following dependency to your app build.gradle:

``` java
compile 'com.folioreader:folioreader:0.4.0'
compile 'com.folioreader:folioreader:0.4.1'
```

Add maven repository to your top level build.gradle:
Expand All @@ -55,39 +55,40 @@ allprojects {
}
```

### Usage
### AndroidManifest

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

First add permissions and activity tag for `FolioActivity` in your `AndroidManifest.xml`:
{your-app-module}/res/xml/network_security_config.xml

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.folioreader.android.sample">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application>
...
<activity
android:name="com.folioreader.ui.folio.activity.FolioActivity"
android:theme="@style/AppTheme.NoActionBar" />
...
<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>
```

Then add network_security_config.xml in your app module's AndroidManifest.xml

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
...
<application android:networkSecurityConfig="@xml/network_security_config">
...
</application>

</manifest>
```

**Note: In case if you are upgrading to 0.4.0 and above don't forget to remove `android:configChanges="orientation|screenSize"` from `<activity>` tag of `FolioActivity`.**
### Usage

Get singleton object of `FolioReader`:

```java
FolioReader folioReader = FolioReader.getInstance(getApplicationContext());
FolioReader folioReader = FolioReader.get();
```

Call the function `openBook()`:
Expand All @@ -103,6 +104,12 @@ folioReader.openBook("file:///android_asset/TheSilverChair.epub");
folioReader.openBook(R.raw.adventures);
```

<br />

**Note: From v0.4.1 you don't need to specify permissions and `FolioActivity` tag in AndroidManifest.xml**

<br />

## WIKI

* [Home](https://github.com/FolioReader/FolioReader-Android/wiki)
Expand Down
13 changes: 6 additions & 7 deletions build.gradle
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.KOTLIN_VERSION = '1.2.50'
ext.KOTLIN_VERSION = '1.2.60'

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.1.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -31,17 +31,16 @@ allprojects {
}

ext {
LIBRARY_VERSION = "0.4.0"
LIBRARY_VERSION = '0.4.1'
R2_STREAMER_VERSION = '0.1.8'

VERSION_NAME = "1.0"
VERSION_CODE = 1

ANDROID_MIN_SDK = 14
ANDROID_MIN_SDK = 15
ANDROID_COMPILE_SDK_VERSION = 28
ANDROID_TARGET_SDK_VERSION = 28
ANDROID_LIB_VERSION = '28.0.0-alpha3'

R2_STREAMER_VERSION = '0.1.7'
ANDROID_LIB_VERSION = '28.0.0-rc01'
}

task clean(type: Delete) {
Expand Down
26 changes: 26 additions & 0 deletions folioreader/AndroidManifest.xml
Expand Up @@ -2,10 +2,36 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.folioreader">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />

<application>

<provider
android:name=".AppContext"
android:authorities="${applicationId}.com.folioreader"
android:exported="false" />

<activity
android:name=".ui.folio.activity.FolioActivity"
android:label="@string/app_name"
android:theme="@style/FolioAppDayTheme" />

<activity
android:name=".ui.folio.activity.ContentHighlightActivity"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".ui.folio.activity.SearchActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>

</application>

</manifest>
2 changes: 2 additions & 0 deletions folioreader/build.gradle
Expand Up @@ -95,12 +95,14 @@ dependencies {

//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
implementation "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"

// r2-streamer
api "org.readium:r2-fetcher:$R2_STREAMER_VERSION"
api "org.readium:r2-parser:$R2_STREAMER_VERSION"
api "org.readium:r2-server:$R2_STREAMER_VERSION"

implementation 'org.greenrobot:eventbus:3.1.1'
implementation "org.apache.commons:commons-text:1.4"
}
apply from: '../folioreader/bintray/bintrayv1.gradle'
Binary file removed folioreader/res/drawable-hdpi/icon_font.png
Binary file not shown.
Binary file removed folioreader/res/drawable-mdpi/icon_font.png
Binary file not shown.
Binary file removed folioreader/res/drawable-xhdpi/ic_drawer.png
Binary file not shown.
Binary file removed folioreader/res/drawable-xhdpi/icon_font.png
Binary file not shown.
Binary file removed folioreader/res/drawable-xhdpi/man_speech_icon.png
Binary file not shown.
Binary file removed folioreader/res/drawable-xxhdpi/icon_font.png
Binary file not shown.
Binary file removed folioreader/res/drawable-xxxhdpi/icon_font.png
Binary file not shown.
9 changes: 9 additions & 0 deletions folioreader/res/drawable/ic_drawer.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#71C951"
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z" />
</vector>
10 changes: 0 additions & 10 deletions folioreader/res/drawable/ic_drawer_green_24dp.xml

This file was deleted.

10 changes: 10 additions & 0 deletions folioreader/res/drawable/ic_search.xml
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF71C951"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" />
</vector>
9 changes: 9 additions & 0 deletions folioreader/res/drawable/icon_font.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#71C951"
android:pathData="M17,8H20V20H21V21H17V20H18V17H14L12.5,20H14V21H10V20H11L17,8M18,9L14.5,16H18V9M5,3H10C11.11,3 12,3.89 12,5V16H9V11H6V16H3V5C3,3.89 3.89,3 5,3M6,5V9H9V5H6Z" />
</vector>
12 changes: 12 additions & 0 deletions folioreader/res/drawable/man_speech_icon.xml
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF71C951"
android:pathData="M9,9m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
<path
android:fillColor="#FF71C951"
android:pathData="M9,15c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4zM16.76,5.36l-1.68,1.69c0.84,1.18 0.84,2.71 0,3.89l1.68,1.69c2.02,-2.02 2.02,-5.07 0,-7.27zM20.07,2l-1.63,1.63c2.77,3.02 2.77,7.56 0,10.74L20.07,16c3.9,-3.89 3.91,-9.95 0,-14z" />
</vector>
38 changes: 38 additions & 0 deletions folioreader/res/layout/activity_search.xml
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.folio.activity.SearchActivity"
tools:menu="menu_search">

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="?android:attr/actionBarSize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp" />

</android.support.design.widget.AppBarLayout>

</android.support.constraint.ConstraintLayout>
42 changes: 28 additions & 14 deletions folioreader/res/layout/folio_activity.xml
@@ -1,25 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
tools:context=".ui.folio.activity.FolioActivity"
tools:menu="menu_main">

<com.folioreader.view.DirectionalViewpager
android:id="@+id/folioPageViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:direction="vertical" />
android:layout_width="0dp"
android:layout_height="0dp"
app:direction="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.folioreader.view.FolioToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize" />
<com.folioreader.view.FolioAppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<com.folioreader.view.MediaControllerView
android:id="@+id/media_controller_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp" />

</RelativeLayout>
</com.folioreader.view.FolioAppBarLayout>

</android.support.constraint.ConstraintLayout>
2 changes: 2 additions & 0 deletions folioreader/res/layout/folio_page_fragment.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/folioPageFragment"
android:layout_width="match_parent"
Expand Down Expand Up @@ -28,6 +29,7 @@
android:id="@+id/loadingView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:maxVisibleDuration="10000"
tools:visibility="invisible" />

<com.folioreader.view.VerticalSeekbar
Expand Down

0 comments on commit a81b7a6

Please sign in to comment.